forked from I3-YF/i3plus-mes-yfai
jx mes 看板
parent
de3fac5a34
commit
7d2477e8bb
@ -0,0 +1,87 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxCenterWorkingBoardService;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.bean.MesOutPutStatistics;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.bean.MesShiftProdCenterRecord;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtEnumUtil;
|
||||
import cn.estsh.i3plus.platform.common.tool.MathOperation;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author : wangjie
|
||||
* @CreateDate : 2022-02-15
|
||||
* @Modify:
|
||||
**/
|
||||
@Slf4j
|
||||
public class JxCenterWorkingBoardProxyEnergyRateService implements IJxCenterWorkingBoardService {
|
||||
|
||||
private IJxCenterWorkingBoardService proxyService;
|
||||
|
||||
public JxCenterWorkingBoardProxyEnergyRateService() {}
|
||||
|
||||
public JxCenterWorkingBoardProxyEnergyRateService(IJxCenterWorkingBoardService proxyService) {
|
||||
this.proxyService = proxyService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap) {
|
||||
|
||||
if (null != proxyService) proxyService.queryCenterWorkingBoardData(dataMap);
|
||||
|
||||
String workCenterCode = (String) dataMap.get(MesExtConstWords.WORK_CENTER_CODE);
|
||||
String workTime = (String) dataMap.get(MesExtConstWords.WORK_TIME);
|
||||
String shiftCode = (String) dataMap.get(MesExtConstWords.SHIFT_CODE);
|
||||
String curTime = (String) dataMap.get("curTime");
|
||||
List<MesShiftProdCenterRecord> shiftProdCenterRecordList = (List<MesShiftProdCenterRecord>) dataMap.get(MesShiftProdCenterRecord.class.getSimpleName());
|
||||
List<MesOutPutStatistics> outPutStatisticsList = (List<MesOutPutStatistics>) dataMap.get(MesOutPutStatistics.class.getSimpleName());
|
||||
Map<String, String> partStandardWorkMap = (Map<String, String>) dataMap.get(MesExtConstWords.STANDARD_WORK);
|
||||
|
||||
List<MesOutPutStatistics> filterList2OutPut = CollectionUtils.isEmpty(outPutStatisticsList) ? null :
|
||||
outPutStatisticsList.stream().filter(o -> (null != o && o.getWorkCenterCode().equals(workCenterCode) && o.getWorkTime().equals(workTime) && o.getShiftCode().equals(shiftCode))).collect(Collectors.toList());
|
||||
List<MesShiftProdCenterRecord> filterList2ShiftProd = CollectionUtils.isEmpty(shiftProdCenterRecordList) ? null :
|
||||
shiftProdCenterRecordList.stream().filter(o -> (null != o && o.getWorkCenterCode().equals(workCenterCode) && o.getWorkTime().equals(workTime) && o.getShiftCode().equals(shiftCode) && o.getStartTime().compareTo(curTime) <= 0)).collect(Collectors.toList());
|
||||
|
||||
List<MesShiftProdCenterRecord> stopList = getShiftProdDataListByFlag(filterList2ShiftProd, false);
|
||||
List<MesShiftProdCenterRecord> prodList = getShiftProdDataListByFlag(filterList2ShiftProd, true);
|
||||
|
||||
Double serviceTime = CollectionUtils.isEmpty(prodList) ? new Double(0) : prodList.stream().filter(o -> null != o).mapToDouble(o -> getStatisticsTime(o, curTime)).sum();
|
||||
Double nonWorkingTime = CollectionUtils.isEmpty(stopList) ? new Double(0) : stopList.stream().filter(o -> null != o).mapToDouble(o -> getStatisticsTime(o, curTime)).sum();
|
||||
Double standardTime = CollectionUtils.isEmpty(filterList2OutPut) ? new Double(0) : filterList2OutPut.stream().filter(o -> null != o).mapToDouble(o -> getStatisticsTime(o, partStandardWorkMap)).sum();
|
||||
Double workingTime = MathOperation.sub(serviceTime, nonWorkingTime);
|
||||
|
||||
dataMap.put("serviceTime", serviceTime);
|
||||
dataMap.put("nonWorkingTime", nonWorkingTime);
|
||||
dataMap.put("standardTime", standardTime);
|
||||
dataMap.put("workingTime", workingTime);
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private List<MesShiftProdCenterRecord> getShiftProdDataListByFlag(List<MesShiftProdCenterRecord> shiftProdCenterRecordList, Boolean flag) {
|
||||
if (CollectionUtils.isEmpty(shiftProdCenterRecordList)) return null;
|
||||
if (!flag) return shiftProdCenterRecordList.stream().filter(o -> (null != o && (MesExtEnumUtil.SHIFT_PROD_TYPE.NORMAL_STOP_CENTER.getValue() == o.getProdType() || MesExtEnumUtil.SHIFT_PROD_TYPE.UNNORMAL_STOP_CENTER.getValue() == o.getProdType()))).collect(Collectors.toList());
|
||||
else return shiftProdCenterRecordList.stream().filter(o -> (null != o && (MesExtEnumUtil.SHIFT_PROD_TYPE.NORMAL_PROD.getValue() == o.getProdType() || MesExtEnumUtil.SHIFT_PROD_TYPE.UNNORMAL_PROD.getValue() == o.getProdType()))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Double getStatisticsTime(MesShiftProdCenterRecord shiftProdCenterRecord, String curTime) {
|
||||
try {
|
||||
String endTime = shiftProdCenterRecord.getEndTime().compareTo(curTime) <= 0 ? shiftProdCenterRecord.getEndTime() : curTime;
|
||||
return MathOperation.mul(new Double(TimeTool.getSecoundsBetweenTime(1, shiftProdCenterRecord.getStartTime(), endTime)), shiftProdCenterRecord.getWorkerQty());
|
||||
} catch (ParseException e) {
|
||||
return new Double(0);
|
||||
}
|
||||
}
|
||||
|
||||
private Double getStatisticsTime(MesOutPutStatistics outPutStatistics, Map<String, String> partStandardWorkMap) {
|
||||
return MathOperation.mul(outPutStatistics.getQty(), ((!CollectionUtils.isEmpty(partStandardWorkMap) && partStandardWorkMap.containsKey(outPutStatistics.getPartNo())) ? Double.parseDouble(partStandardWorkMap.get(outPutStatistics.getPartNo())) : new Double(0)));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxCenterWorkingBoardService;
|
||||
import cn.estsh.i3plus.ext.mes.apiservice.dao.IPartExtDao;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author : wangjie
|
||||
* @CreateDate : 2022-02-15
|
||||
* @Modify:
|
||||
**/
|
||||
@Slf4j
|
||||
public class JxCenterWorkingBoardProxyStandardWorkService extends JxCenterWorkingBoardCommonService implements IJxCenterWorkingBoardService {
|
||||
|
||||
private IPartExtDao partExtDao;
|
||||
|
||||
public JxCenterWorkingBoardProxyStandardWorkService() {
|
||||
this.partExtDao = (IPartExtDao) SpringContextsUtil.getBean("partExtDao");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap) {
|
||||
String organizeCode = (String) dataMap.get(MesExtConstWords.ORGANIZE_CODE);
|
||||
String partStandardWorkMap4Cached = (String) execCachedCenterWorkingBoardData(organizeCode, MesExtConstWords.ZERO_STR, MesExtConstWords.STANDARD_WORK, null);
|
||||
Map<String, String> partStandardWorkMap = !StringUtils.isEmpty(partStandardWorkMap4Cached) ? JSONObject.parseObject(partStandardWorkMap4Cached, Map.class) : execPartExtStandardWorkMap(organizeCode);
|
||||
dataMap.put(MesExtConstWords.STANDARD_WORK, partStandardWorkMap);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
private Map<String, String> execPartExtStandardWorkMap(String organizeCode) {
|
||||
Map<String, String> partStandardWorkMap = partExtDao.queryPartExtStandardWorkStrMap(organizeCode);
|
||||
if (CollectionUtils.isEmpty(partStandardWorkMap)) partStandardWorkMap = new HashMap<>();
|
||||
execCachedCenterWorkingBoardData(organizeCode, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr(), MesExtConstWords.STANDARD_WORK, JSONObject.toJSONString(partStandardWorkMap));
|
||||
return partStandardWorkMap;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxCenterWorkingBoardService;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.bean.MesOutPutStatisticsTimeSegment;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.repository.MesOutPutStatisticsTimeSegmentRepository;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author : wangjie
|
||||
* @CreateDate : 2022-02-15
|
||||
* @Modify:
|
||||
**/
|
||||
@Slf4j
|
||||
public class JxCenterWorkingBoardProxyTimeSegmentService implements IJxCenterWorkingBoardService {
|
||||
|
||||
private MesOutPutStatisticsTimeSegmentRepository outPutStatisticsTimeSegmentRepository;
|
||||
|
||||
public JxCenterWorkingBoardProxyTimeSegmentService() {
|
||||
this.outPutStatisticsTimeSegmentRepository = (MesOutPutStatisticsTimeSegmentRepository) SpringContextsUtil.getBean("mesOutPutStatisticsTimeSegmentRepository");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap) {
|
||||
|
||||
String orgainzeCode = (String) dataMap.get(MesExtConstWords.ORGANIZE_CODE);
|
||||
String workCenterCode = (String) dataMap.get(MesExtConstWords.WORK_CENTER_CODE);
|
||||
String workTime = (String) dataMap.get(MesExtConstWords.WORK_TIME);
|
||||
String shiftCode = (String) dataMap.get(MesExtConstWords.SHIFT_CODE);
|
||||
|
||||
if (StringUtils.isEmpty(workTime) || StringUtils.isEmpty(shiftCode)) return dataMap;
|
||||
|
||||
List<MesOutPutStatisticsTimeSegment> outPutStatisticsTimeSegmentList = outPutStatisticsTimeSegmentRepository.findByProperty(
|
||||
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE, MesExtConstWords.WORK_TIME, MesExtConstWords.SHIFT_CODE, MesExtConstWords.WORK_ORDER_TYPE},
|
||||
new Object[]{orgainzeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCenterCode, workTime, shiftCode, MesExtEnumUtil.WORK_ORDER_TYPE.STANDARD_ORDER.getValue()});
|
||||
|
||||
if (CollectionUtils.isEmpty(outPutStatisticsTimeSegmentList)) return dataMap;
|
||||
|
||||
dataMap.put(MesOutPutStatisticsTimeSegment.class.getSimpleName(), outPutStatisticsTimeSegmentList);
|
||||
|
||||
return dataMap;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue