jx mes 看板

tags/yfai-mes-ext-v1.0
王杰 1 year ago
parent de3fac5a34
commit 7d2477e8bb

@ -70,4 +70,9 @@ public interface IJxTimeSegmentStatisticsService {
*/
String getTimeSegmentCode(MesTimeSegmentStatistics timeSegmentStatistics);
/**
* 线
*/
List<MesTimeSegmentStatistics> getTimeSegmentStatisticsList(String organizeCode, String workCenterCode, String shiftCode);
}

@ -17,7 +17,7 @@ public interface IJxCenterWorkingBoardService {
* @return 线
*/
@ApiOperation(value = "嘉兴产线运行看板", notes = "嘉兴产线运行看板")
Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap);
default Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap) { return dataMap; };
/**
* 线
@ -27,4 +27,10 @@ public interface IJxCenterWorkingBoardService {
@ApiOperation(value = "清除产线运行看板数据无用数据", notes = "清除产线运行看板数据无用数据")
default Map<String, Object> clearUselessData(Map<String, Object> dataMap) { return dataMap; }
/**
* 线
*/
@ApiOperation(value = "嘉兴产线运行看板缓存数据清除", notes = "嘉兴产线运行看板缓存数据清除")
default Object execCachedCenterWorkingBoardData(String organizeCode, String flag, String item, Object data) { return null; }
}

@ -3,7 +3,6 @@ package cn.estsh.i3plus.ext.mes.apiservice.controller.busi.jx;
import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxCenterWorkingBoardService;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
@ -56,4 +55,18 @@ public class JxCenterWorkingBoardController extends MesBaseController {
}
}
@PostMapping(value = "/ext/jx/center-working-board/delete-cached-data")
@ApiOperation(value = "嘉兴产线运行看板缓存数据清除")
public ResultBean deleteCachedCenterWorkingBoardData(@RequestBody Map<String, Object> dataMap) {
try {
String organizeCode = (null != dataMap && dataMap.containsKey(MesExtConstWords.ORGANIZE_CODE)) ? (String) dataMap.get(MesExtConstWords.ORGANIZE_CODE) : AuthUtil.getOrganize().getOrganizeCode();
centerWorkingBoardService.execCachedCenterWorkingBoardData(organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValueStr(), null, null);
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -40,6 +40,13 @@ public interface IPartExtDao {
Map<String, Double> queryPartExtStandardWorkMap(String organizeCode);
/**
*
* @param organizeCode
* @return
*/
Map<String, String> queryPartExtStandardWorkStrMap(String organizeCode);
/**
*
* @param organizeCode
* @param categoryCode3

@ -153,6 +153,26 @@ public class PartExtDao implements IPartExtDao {
}
@Override
public Map<String, String> queryPartExtStandardWorkStrMap(String organizeCode) {
Map<String, String> resultMap = new HashMap<>();
StringBuffer hql = new StringBuffer();
hql.append(" select pe.part_no_ext, pe.standard_work ");
hql.append(" from mes_part_ext pe where pe.organize_code_ext = :organizeCode ");
Query query = entityManager.createNativeQuery(hql.toString());
query.setParameter(MesExtConstWords.ORGANIZE_CODE, organizeCode);
List list = query.getResultList();
if (!CollectionUtils.isEmpty(list)) {
list.stream().forEach(o -> {
Object[] cellArr = (Object[]) o;
if (null != cellArr && cellArr.length == 2 && !StringUtils.isEmpty(cellArr[0]) && !StringUtils.isEmpty(cellArr[1])) {
resultMap.put(cellArr[0].toString(), cellArr[1].toString());
}
});
}
return resultMap;
}
@Override
public Map<String, String> queryPartCategoryCode3Map(String organizeCode, String categoryCode3) {
Map<String, String> resultMap = new HashMap<>();
StringBuffer hql = new StringBuffer();

@ -49,9 +49,7 @@ public class JxTimeSegmentStatisticsService implements IJxTimeSegmentStatisticsS
@Override
public void insertTimeSegmentStatistics(MesTimeSegmentStatistics timeSegmentStatistics){
List<MesTimeSegmentStatistics> timeSegmentStatisticsList = timeSegmentStatisticsRepository.findByProperty(
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE, MesExtConstWords.SHIFT_CODE},
new Object[]{timeSegmentStatistics.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), timeSegmentStatistics.getWorkCenterCode(), timeSegmentStatistics.getShiftCode()});
List<MesTimeSegmentStatistics> timeSegmentStatisticsList = getTimeSegmentStatisticsList(timeSegmentStatistics.getOrganizeCode(), timeSegmentStatistics.getWorkCenterCode(), timeSegmentStatistics.getShiftCode());
checkTimeIsValid(timeSegmentStatisticsList, timeSegmentStatistics);
timeSegmentStatistics.setTimeLength(getTimeLength(timeSegmentStatistics.getStartTime(), timeSegmentStatistics.getEndTime(), TimeTool.getToday()));
timeSegmentStatistics.setTimeSegmentCode(getTimeSegmentCode(timeSegmentStatistics));
@ -62,9 +60,7 @@ public class JxTimeSegmentStatisticsService implements IJxTimeSegmentStatisticsS
@Override
public void updateTimeSegmentStatistics(MesTimeSegmentStatistics timeSegmentStatistics) {
List<MesTimeSegmentStatistics> timeSegmentStatisticsList = timeSegmentStatisticsRepository.findByProperty(
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE, MesExtConstWords.SHIFT_CODE},
new Object[]{timeSegmentStatistics.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), timeSegmentStatistics.getWorkCenterCode(), timeSegmentStatistics.getShiftCode()});
List<MesTimeSegmentStatistics> timeSegmentStatisticsList = getTimeSegmentStatisticsList(timeSegmentStatistics.getOrganizeCode(), timeSegmentStatistics.getWorkCenterCode(), timeSegmentStatistics.getShiftCode());
Optional<MesTimeSegmentStatistics> timeSegmentStatisticsDbOp = CollectionUtils.isEmpty(timeSegmentStatisticsList) ? null : timeSegmentStatisticsList.stream().filter(o -> (null != o && o.getId().compareTo(timeSegmentStatistics.getId()) == 0)).findFirst();
if (null == timeSegmentStatisticsDbOp || !timeSegmentStatisticsDbOp.isPresent())
throw ImppExceptionBuilder.newInstance()
@ -177,4 +173,11 @@ public class JxTimeSegmentStatisticsService implements IJxTimeSegmentStatisticsS
}
}
@Override
public List<MesTimeSegmentStatistics> getTimeSegmentStatisticsList(String organizeCode, String workCenterCode, String shiftCode) {
return timeSegmentStatisticsRepository.findByProperty(
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE, MesExtConstWords.SHIFT_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCenterCode, shiftCode});
}
}

@ -64,6 +64,8 @@ public class JxCenterWorkingBoardCenterOneService implements IJxCenterWorkingBoa
dataMap.put("BOARD_BOTTOM", "PKATJX·松下厨电科技嘉兴有限公司");
dataMap.put("生产状态", dataMap.get(MesExtConstWords.STATUS));
dataMap.put("异常停工时间", getUnnormalStopCenterData(shiftProdCenterRecordList, curTime));
dataMap.put("4M变更信息", getFourMChangeData(workCenterExtDb, curTime));
@ -80,6 +82,7 @@ public class JxCenterWorkingBoardCenterOneService implements IJxCenterWorkingBoa
dataMap.remove(MesExtConstWords.WORK_TIME);
dataMap.remove(MesExtConstWords.SHIFT_CODE);
dataMap.remove(MesExtConstWords.WORK_CENTER_CODE);
dataMap.remove(MesExtConstWords.STATUS);
dataMap.remove("curTime");
return dataMap;
}

@ -1,20 +1,25 @@
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;
import cn.estsh.i3plus.ext.mes.api.base.jx.IJxTimeSegmentStatisticsService;
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.MesOutPutStatisticsTimeSegment;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesTimeSegmentStatistics;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesWorkCenterExt;
import cn.estsh.i3plus.ext.mes.pojo.model.jx.JxCenterWorkingBoardBusiModel;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.tool.MathOperation;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
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.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -29,9 +34,12 @@ public class JxCenterWorkingBoardCenterThreeService extends JxCenterWorkingBoard
private IJxCenterWorkingBoardService proxyService;
private IJxTimeSegmentStatisticsService timeSegmentStatisticsService;
public JxCenterWorkingBoardCenterThreeService(IJxCenterWorkingBoardService proxyService0, IJxCenterWorkingBoardService proxyService) {
this.proxyService0 = proxyService0;
this.proxyService = proxyService;
this.timeSegmentStatisticsService = (IJxTimeSegmentStatisticsService) SpringContextsUtil.getBean("jxTimeSegmentStatisticsService");
}
@Override
@ -49,6 +57,8 @@ public class JxCenterWorkingBoardCenterThreeService extends JxCenterWorkingBoard
List<MesOutPutStatistics> outPutStatisticsList = (List<MesOutPutStatistics>) dataMap.get(MesOutPutStatistics.class.getSimpleName());
List<MesOutPutStatisticsTimeSegment> outPutStatisticsTimeSegmentList = (List<MesOutPutStatisticsTimeSegment>) dataMap.get(MesOutPutStatisticsTimeSegment.class.getSimpleName());
Optional<MesWorkOrder> curWorkOrder = getFirstWorkOrder(workOrderList, outPutStatisticsList, workCenterExtDb);
List<MesOutPutStatistics> curOutPutStatisticsList = getFirstOutPutStatisticsList(outPutStatisticsList, curWorkOrder);
@ -59,6 +69,8 @@ public class JxCenterWorkingBoardCenterThreeService extends JxCenterWorkingBoard
dataMap.put("当前实绩台数", getQtyStr(dataMap.containsKey(MesExtConstWords.COMPLET_QTY) ? (Double) dataMap.get(MesExtConstWords.COMPLET_QTY) : getOutPutStatisticsList2AmountQty(curOutPutStatisticsList)));
dataMap.put("小时产量", getTimeSegmentStatistics(outPutStatisticsTimeSegmentList, workCenterExtDb));
return clearUselessData(dataMap);
}
@ -116,4 +128,56 @@ public class JxCenterWorkingBoardCenterThreeService extends JxCenterWorkingBoard
return qty;
}
private Object getTimeSegmentStatistics(List<MesOutPutStatisticsTimeSegment> outPutStatisticsTimeSegmentList, MesWorkCenterExt workCenterExtDb) {
JxCenterWorkingBoardBusiModel psData = new JxCenterWorkingBoardBusiModel().title("小时产量");
if (StringUtils.isEmpty(workCenterExtDb.getWorkTime()) || StringUtils.isEmpty(workCenterExtDb.getShiftCode())) return psData;
String item = new StringJoiner(MesExtConstWords.AND).add("TIME_SEGMENT").add(workCenterExtDb.getWorkCenterCode()).add(workCenterExtDb.getShiftCode()).toString();
String timeSegmentStatisticsList4Cached = (String) execCachedCenterWorkingBoardData(workCenterExtDb.getOrganizeCode(), MesExtConstWords.ZERO_STR, item, null);
List<MesTimeSegmentStatistics> timeSegmentStatisticsList = !StringUtils.isEmpty(timeSegmentStatisticsList4Cached) ? JSONObject.parseArray(timeSegmentStatisticsList4Cached, MesTimeSegmentStatistics.class) : execTimeSegmentStatistics(workCenterExtDb, item);
timeSegmentStatisticsList = CollectionUtils.isEmpty(timeSegmentStatisticsList) ? null :
timeSegmentStatisticsList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getStartTime()) && !StringUtils.isEmpty(o.getEndTime()))).collect(Collectors.toList());
if (CollectionUtils.isEmpty(timeSegmentStatisticsList)) return psData;
timeSegmentStatisticsList = timeSegmentStatisticsList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesTimeSegmentStatistics::getStartTime)).collect(Collectors.toList());
Map<String, List<MesOutPutStatisticsTimeSegment>> statisticsMap = CollectionUtils.isEmpty(outPutStatisticsTimeSegmentList) ? null :
outPutStatisticsTimeSegmentList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesOutPutStatisticsTimeSegment::getTimeSegmentCode));
for (MesTimeSegmentStatistics timeSegmentStatistics : timeSegmentStatisticsList) {
if (null == timeSegmentStatistics) continue;
List<MesOutPutStatisticsTimeSegment> statisticsList = CollectionUtils.isEmpty(statisticsMap) ? null : statisticsMap.get(timeSegmentStatistics.getTimeSegmentCode());
psData.addChartData(timeSegmentStatistics.getStartTime().substring(0, 5), getAmountPlanQty(timeSegmentStatistics, workCenterExtDb), getOutPutStatisticsTimeSegmentList2AmountQty(statisticsList));
}
return psData;
}
private List<MesTimeSegmentStatistics> execTimeSegmentStatistics(MesWorkCenterExt workCenterExtDb, String item) {
List<MesTimeSegmentStatistics> timeSegmentStatisticsList = timeSegmentStatisticsService.getTimeSegmentStatisticsList(workCenterExtDb.getOrganizeCode(), workCenterExtDb.getWorkCenterCode(), workCenterExtDb.getShiftCode());
if (!CollectionUtils.isEmpty(timeSegmentStatisticsList)) execCachedCenterWorkingBoardData(workCenterExtDb.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr(), item, JSONObject.toJSONString(timeSegmentStatisticsList));
return timeSegmentStatisticsList;
}
private Double getAmountPlanQty(MesTimeSegmentStatistics timeSegmentStatistics, MesWorkCenterExt workCenterExtDb) {
try {
if (StringUtils.isEmpty(workCenterExtDb.getWorkTakt()) || MathOperation.compareTo(workCenterExtDb.getWorkTakt(), new Double(0)) == 0) return new Double(0);
return MathOperation.mul(new Double(TimeTool.getSecoundsBetweenTime(1, appendWorkTime(timeSegmentStatistics.getStartTime(), workCenterExtDb.getWorkTime()), appendWorkTime(timeSegmentStatistics.getEndTime(), workCenterExtDb.getWorkTime()))), workCenterExtDb.getWorkTakt());
} catch (ParseException e) {
return new Double(0);
}
}
private String appendWorkTime(String hms, String workTime) {
return new StringJoiner(MesExtConstWords.ONE_SPACE).add(workTime).add(hms).toString();
}
public Double getOutPutStatisticsTimeSegmentList2AmountQty(List<MesOutPutStatisticsTimeSegment> outPutStatisticsTimeSegmentList) {
return CollectionUtils.isEmpty(outPutStatisticsTimeSegmentList) ? new Double(0) : outPutStatisticsTimeSegmentList.stream().filter(o -> null != o).mapToDouble(MesOutPutStatisticsTimeSegment::getQty).sum();
}
}

@ -1,7 +1,6 @@
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.bean.*;
import cn.estsh.i3plus.ext.mes.pojo.model.jx.JxCenterWorkingBoardBusiModel;
import cn.estsh.i3plus.ext.mes.pojo.repository.MesOrderJobRepository;
@ -10,15 +9,16 @@ 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 cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesShift;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.repository.MesShiftRepository;
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.math.BigDecimal;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@ -32,20 +32,20 @@ public class JxCenterWorkingBoardCenterTwoService extends JxCenterWorkingBoardCo
private IJxCenterWorkingBoardService proxyService0;
private IJxCenterWorkingBoardService proxyService1;
private IJxCenterWorkingBoardService proxyService;
private MesShiftRepository shiftRepository;
private MesOrderJobRepository orderJobRepository;
private IPartExtDao partExtDao;
public JxCenterWorkingBoardCenterTwoService(IJxCenterWorkingBoardService proxyService0, IJxCenterWorkingBoardService proxyService) {
public JxCenterWorkingBoardCenterTwoService(IJxCenterWorkingBoardService proxyService0, IJxCenterWorkingBoardService proxyService1, IJxCenterWorkingBoardService proxyService) {
this.proxyService0 = proxyService0;
this.proxyService1 = proxyService1;
this.proxyService = proxyService;
this.shiftRepository = (MesShiftRepository) SpringContextsUtil.getBean("mesShiftRepository");
this.orderJobRepository = (MesOrderJobRepository) SpringContextsUtil.getBean("mesOrderJobRepository");
this.partExtDao = (IPartExtDao) SpringContextsUtil.getBean("partExtDao");
}
@Override
@ -53,26 +53,20 @@ public class JxCenterWorkingBoardCenterTwoService extends JxCenterWorkingBoardCo
dataMap = proxyService0.queryCenterWorkingBoardData(dataMap);
dataMap = proxyService1.queryCenterWorkingBoardData(dataMap);
MesWorkCenterExt workCenterExtDb = (MesWorkCenterExt) dataMap.get(MesWorkCenterExt.class.getSimpleName());
packProxyCondition(dataMap, workCenterExtDb);
dataMap = proxyService.queryCenterWorkingBoardData(dataMap);
String curTime = TimeTool.getNowTime(true);
List<MesShiftProdCenterRecord> shiftProdCenterRecordList = (List<MesShiftProdCenterRecord>) dataMap.get(MesShiftProdCenterRecord.class.getSimpleName());
List<MesWorkOrder> workOrderList = (List<MesWorkOrder>) dataMap.get(MesWorkOrder.class.getSimpleName());
List<MesOutPutStatistics> outPutStatisticsList = (List<MesOutPutStatistics>) dataMap.get(MesOutPutStatistics.class.getSimpleName());
List<MesRepairTask> repairTaskList = (List<MesRepairTask>) dataMap.get(MesRepairTask.class.getSimpleName());
Map<String, Double> partStandardWorkMap = partExtDao.queryPartExtStandardWorkMap(workCenterExtDb.getOrganizeCode());
statisticsData(shiftProdCenterRecordList, outPutStatisticsList, partStandardWorkMap, workCenterExtDb, curTime, dataMap);
dataMap.put("当前班次", getShiftName(workCenterExtDb));
dataMap.put("出勤人数", workCenterExtDb.getWorkerQty());
@ -113,10 +107,12 @@ public class JxCenterWorkingBoardCenterTwoService extends JxCenterWorkingBoardCo
dataMap.remove(MesExtConstWords.WORK_TIME);
dataMap.remove(MesExtConstWords.SHIFT_CODE);
dataMap.remove(MesExtConstWords.WORK_CENTER_CODE);
dataMap.remove(MesExtConstWords.STANDARD_WORK);
dataMap.remove("serviceTime");
dataMap.remove("nonWorkingTime");
dataMap.remove("standardTime");
dataMap.remove("workingTime");
dataMap.remove("curTime");
return dataMap;
}
@ -127,54 +123,23 @@ public class JxCenterWorkingBoardCenterTwoService extends JxCenterWorkingBoardCo
dataMap.put(MesExtConstWords.WORK_TIME, workCenterExtDb.getWorkTime());
dataMap.put(MesExtConstWords.SHIFT_CODE, workCenterExtDb.getShiftCode());
dataMap.put(MesExtConstWords.WORK_CENTER_CODE, workCenterExtDb.getWorkCenterCode());
dataMap.put("curTime", TimeTool.getNowTime(true));
}
private void statisticsData(List<MesShiftProdCenterRecord> shiftProdCenterRecordList, List<MesOutPutStatistics> outPutStatisticsList,
Map<String, Double> partStandardWorkMap, MesWorkCenterExt workCenterExtDb, String curTime, Map<String, Object> dataMap) {
List<MesOutPutStatistics> filterList2OutPut = CollectionUtils.isEmpty(outPutStatisticsList) ? null :
outPutStatisticsList.stream().filter(o -> (null != o && o.getShiftCode().equals(workCenterExtDb.getShiftCode()))).collect(Collectors.toList());
List<MesShiftProdCenterRecord> filterList2ShiftProd = CollectionUtils.isEmpty(shiftProdCenterRecordList) ? null :
shiftProdCenterRecordList.stream().filter(o -> (null != o && o.getShiftCode().equals(workCenterExtDb.getShiftCode()) && 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);
}
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(2, shiftProdCenterRecord.getStartTime(), endTime)), shiftProdCenterRecord.getWorkerQty());
} catch (ParseException e) {
return new Double(0);
}
}
private Double getStatisticsTime(MesOutPutStatistics outPutStatistics, Map<String, Double> partStandardWorkMap) {
return MathOperation.mul(outPutStatistics.getQty(), ((!CollectionUtils.isEmpty(partStandardWorkMap) && partStandardWorkMap.containsKey(outPutStatistics.getPartNo())) ? partStandardWorkMap.get(outPutStatistics.getPartNo()) : new Double(0)));
}
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 String getShiftName(MesWorkCenterExt workCenterExtDb) {
if (StringUtils.isEmpty(workCenterExtDb.getShiftCode())) return MesExtConstWords.EMPTY;
String item = new StringJoiner(MesExtConstWords.AND).add("SHIFT").add(workCenterExtDb.getWorkCenterCode()).add(workCenterExtDb.getShiftCode()).toString();
String shift4Cached = (String) execCachedCenterWorkingBoardData(workCenterExtDb.getOrganizeCode(), MesExtConstWords.ZERO_STR, item, null);
MesShift shift = !StringUtils.isEmpty(shift4Cached) ? JSONObject.parseObject(shift4Cached, MesShift.class) : execShift(workCenterExtDb, item);
return null == shift ? MesExtConstWords.EMPTY : shift.getShiftName();
}
private String getShiftName(MesWorkCenterExt workCenterExtDb) {
return StringUtils.isEmpty(workCenterExtDb.getShiftCode()) ? MesExtConstWords.EMPTY :
shiftRepository.getByProperty(
private MesShift execShift(MesWorkCenterExt workCenterExtDb, String item) {
MesShift shiftDb = shiftRepository.getByProperty(
new String[]{MesExtConstWords.ORGANIZE_CODE, MesExtConstWords.IS_DELETED, MesExtConstWords.IS_VALID, MesExtConstWords.WORK_CENTER_CODE, MesExtConstWords.SHIFT_CODE},
new Object[]{workCenterExtDb.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCenterExtDb.getWorkCenterCode(), workCenterExtDb.getShiftCode()}).getShiftName();
new Object[]{workCenterExtDb.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCenterExtDb.getWorkCenterCode(), workCenterExtDb.getShiftCode()});
if (null != shiftDb) execCachedCenterWorkingBoardData(workCenterExtDb.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr(), item, JSONObject.toJSONString(shiftDb));
return shiftDb;
}
private String getOrderJobStatistics(MesWorkCenterExt workCenterExtDb) {

@ -1,10 +1,12 @@
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.MesWorkCenterExt;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.tool.MathOperation;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -21,7 +23,13 @@ import java.util.stream.Collectors;
* @Modify:
**/
@Slf4j
public class JxCenterWorkingBoardCommonService {
public class JxCenterWorkingBoardCommonService implements IJxCenterWorkingBoardService {
private IJxCenterWorkingBoardService proxyService;
public JxCenterWorkingBoardCommonService() {
this.proxyService = (IJxCenterWorkingBoardService) SpringContextsUtil.getBean("jxCenterWorkingBoardDispatchService");
}
public List<MesWorkOrder> getWorkOrderList2Sort(List<MesWorkOrder> workOrderList, List<MesOutPutStatistics> outPutStatisticsList, MesWorkCenterExt workCenterExtDb) {
List<String> hasOutPutOrder = CollectionUtils.isEmpty(outPutStatisticsList) ? null : outPutStatisticsList.stream().filter(o -> null != o).map(MesOutPutStatistics::getWorkOrderNo).collect(Collectors.toList());
@ -78,4 +86,8 @@ public class JxCenterWorkingBoardCommonService {
return bd;
}
@Override
public Object execCachedCenterWorkingBoardData(String organizeCode, String flag, String item, Object data) {
return proxyService.execCachedCenterWorkingBoardData(organizeCode, flag, item, data);
}
}

@ -2,10 +2,14 @@ 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.util.MesExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.MesEnumUtil;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Map;
import java.util.StringJoiner;
/**
* @Author : wangjie
@ -16,6 +20,9 @@ import java.util.Map;
@Service
public class JxCenterWorkingBoardDispatchService implements IJxCenterWorkingBoardService {
@Resource(name = MesExtConstWords.REDIS_MES)
private ImppRedis redisMes;
@Override
public Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap) {
@ -25,20 +32,38 @@ public class JxCenterWorkingBoardDispatchService implements IJxCenterWorkingBoar
return new JxCenterWorkingBoardCenterOneService(new JxCenterWorkingBoardProxyCenterService(), new JxCenterWorkingBoardProxyWorkingStatusService(new JxCenterWorkingBoardProxySpcrService())).queryCenterWorkingBoardData(dataMap);
case "center02":
return new JxCenterWorkingBoardCenterTwoService(new JxCenterWorkingBoardProxyCenterService(),
new JxCenterWorkingBoardProxyOrderService(new JxCenterWorkingBoardProxyOutPutService(new JxCenterWorkingBoardProxyRepairService(new JxCenterWorkingBoardProxySpcrService())))).queryCenterWorkingBoardData(dataMap);
return new JxCenterWorkingBoardCenterTwoService(new JxCenterWorkingBoardProxyCenterService(), new JxCenterWorkingBoardProxyStandardWorkService(),
new JxCenterWorkingBoardProxyEnergyRateService(new JxCenterWorkingBoardProxyOrderService(new JxCenterWorkingBoardProxyOutPutService(new JxCenterWorkingBoardProxyRepairService(new JxCenterWorkingBoardProxySpcrService()))))).queryCenterWorkingBoardData(dataMap);
case "center03":
return new JxCenterWorkingBoardCenterThreeService(new JxCenterWorkingBoardProxyCenterService(), new JxCenterWorkingBoardProxyOrderService(new JxCenterWorkingBoardProxyOutPutService())).queryCenterWorkingBoardData(dataMap);
return new JxCenterWorkingBoardCenterThreeService(new JxCenterWorkingBoardProxyCenterService(), new JxCenterWorkingBoardProxyOrderService(new JxCenterWorkingBoardProxyOutPutService(new JxCenterWorkingBoardProxyTimeSegmentService()))).queryCenterWorkingBoardData(dataMap);
case "monitor01":
return new JxCenterWorkingBoardMonitorOneService(new JxCenterWorkingBoardProxyAllCenterService(), new JxCenterWorkingBoardProxyWorkingStatusService(),
return new JxCenterWorkingBoardMonitorOneService(
new JxCenterWorkingBoardProxyAllCenterService(), new JxCenterWorkingBoardProxyStandardWorkService(), new JxCenterWorkingBoardProxyWorkingStatusService(), new JxCenterWorkingBoardProxyEnergyRateService(),
new JxCenterWorkingBoardProxyOrderService(new JxCenterWorkingBoardProxyOutPutService(new JxCenterWorkingBoardProxyRepairService(new JxCenterWorkingBoardProxySpcrService())))).queryCenterWorkingBoardData(dataMap);
default:
return dataMap;
}
}
@Override
public Object execCachedCenterWorkingBoardData(String organizeCode, String flag, String item, Object data) {
String key = new StringJoiner(MesExtConstWords.COLON).add(organizeCode).add("JX_BOARD_DATA").toString();
switch (flag) {
case "0" :
return redisMes.getHash(key, item);
case "1" :
return redisMes.putHash(key, item, data, MesEnumUtil.EXPIRE_TIME.NEVER.getValue());
case "2" :
default:
redisMes.deleteKey(key);
return true;
}
}
}

@ -6,17 +6,20 @@ import cn.estsh.i3plus.ext.mes.api.base.bu.IBusiConfigService;
import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxCenterWorkingBoardService;
import cn.estsh.i3plus.ext.mes.pojo.bean.*;
import cn.estsh.i3plus.ext.mes.pojo.model.MesAccidentDateModel;
import cn.estsh.i3plus.ext.mes.pojo.model.bu.MesNumberOfSafeOperationDaysModel;
import cn.estsh.i3plus.ext.mes.pojo.model.jx.JxCenterWorkingBoardBusiModel;
import cn.estsh.i3plus.ext.mes.pojo.repository.MesOutPutStatisticsRepository;
import cn.estsh.i3plus.ext.mes.pojo.repository.MesPlantInfoRepository;
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 cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
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;
@ -36,6 +39,10 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
private IJxCenterWorkingBoardService proxyService1;
private IJxCenterWorkingBoardService proxyService2;
private IJxCenterWorkingBoardService proxyService3;
private IJxCenterWorkingBoardService proxyService;
private MesPlantInfoRepository plantInfoRepository;
@ -48,9 +55,11 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
private MesOutPutStatisticsRepository outPutStatisticsRepository;
public JxCenterWorkingBoardMonitorOneService(IJxCenterWorkingBoardService proxyService0, IJxCenterWorkingBoardService proxyService1, IJxCenterWorkingBoardService proxyService) {
public JxCenterWorkingBoardMonitorOneService(IJxCenterWorkingBoardService proxyService0, IJxCenterWorkingBoardService proxyService1, IJxCenterWorkingBoardService proxyService2, IJxCenterWorkingBoardService proxyService3, IJxCenterWorkingBoardService proxyService) {
this.proxyService0 = proxyService0;
this.proxyService1 = proxyService1;
this.proxyService2 = proxyService2;
this.proxyService3 = proxyService3;
this.proxyService = proxyService;
this.plantInfoRepository = (MesPlantInfoRepository) SpringContextsUtil.getBean("mesPlantInfoRepository");
this.numberOfSafeOperationDaysService = (IMesNumberOfSafeOperationDaysService) SpringContextsUtil.getBean("mesNumberOfSafeOperationDaysService");
@ -64,6 +73,8 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
dataMap = proxyService0.queryCenterWorkingBoardData(dataMap);
dataMap = proxyService1.queryCenterWorkingBoardData(dataMap);
List<MesWorkCenterExt> workCenterExtDbList = (List<MesWorkCenterExt>) dataMap.get(MesWorkCenterExt.class.getSimpleName());
packProxyCondition(dataMap, workCenterExtDbList);
@ -84,9 +95,7 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
dataMap.put("生产进度", getProductionSchedule(organizeCode, workCenterExtDbList, dataMap));
dataMap.put("本体产线状态", getOntologyLineWorkingStatus(organizeCode, workCenterExtDbList, dataMap));
dataMap.put("本体能率", "");
calcOntologyLineData(organizeCode, workCenterExtDbList, dataMap);
return clearUselessData(dataMap);
}
@ -101,6 +110,13 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
dataMap.remove(MesExtConstWords.WORK_TIME);
dataMap.remove(MesExtConstWords.SHIFT_CODE);
dataMap.remove(MesExtConstWords.WORK_CENTER_CODE);
dataMap.remove(MesExtConstWords.STANDARD_WORK);
dataMap.remove(MesExtConstWords.STATUS);
dataMap.remove("serviceTime");
dataMap.remove("nonWorkingTime");
dataMap.remove("standardTime");
dataMap.remove("workingTime");
dataMap.remove("curTime");
return dataMap;
}
@ -110,6 +126,7 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
Collections.sort(workTimeList);
dataMap.put(MesExtConstWords.START_TIME, workTimeList.get(0));
dataMap.put(MesExtConstWords.END_TIME, workTimeList.get(workTimeList.size() - 1));
dataMap.put("curTime", TimeTool.getNowTime(true));
}
private MesPlantInfo getOrganizeInfo(String organizeCode) {
@ -118,12 +135,12 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue()});
}
private MesNumberOfSafeOperationDays getAmountSafeRunningDays(String organizeCode) {
return numberOfSafeOperationDaysService.queryNumberOfSafeOperationDays(organizeCode);
private MesNumberOfSafeOperationDaysModel getAmountSafeRunningDays(String organizeCode) {
return numberOfSafeOperationDaysService.queryBuNumberOfSafeOperationDaysBoard(organizeCode);
}
private MesAccidentDateModel getCurYearAmountAccident(String organizeCode) {
return accidentDateService.queryAccidentDaysBoard(organizeCode);
return accidentDateService.queryBuAccidentDaysBoard(organizeCode);
}
private Map<String, List<MesWorkOrder>> getCenterMap4Order(List<MesWorkOrder> workOrderList) {
@ -142,14 +159,14 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
List<MesOutPutStatistics> outPutStatisticsList = (List<MesOutPutStatistics>) dataMap.get(MesOutPutStatistics.class.getSimpleName());
if (CollectionUtils.isEmpty(workOrderList) && CollectionUtils.isEmpty(outPutStatisticsList)) return psData;
MesBusiConfig catagoryCodeCfg = busiConfigService.getBusiConfigByCfgCode(organizeCode, MesExtConstWords.SX_CATEGORY_CFG);
String catagoryCodeCfg4Cached = (String) execCachedCenterWorkingBoardData(organizeCode, MesExtConstWords.ZERO_STR, MesExtConstWords.SX_CATEGORY_CFG, null);
MesBusiConfig catagoryCodeCfg = !StringUtils.isEmpty(catagoryCodeCfg4Cached) ? JSONObject.parseObject(catagoryCodeCfg4Cached, MesBusiConfig.class) : execCatagoryCodeCfg(organizeCode);
if (null == catagoryCodeCfg || StringUtils.isEmpty(catagoryCodeCfg.getCfgValue()) || StringUtils.isEmpty(catagoryCodeCfg.getCfgValueSeq())) return psData;
String[] categoryCodeArr = catagoryCodeCfg.getCfgValueSeq().split(MesExtConstWords.COMMA);
String[] categoryNameArr = catagoryCodeCfg.getCfgValue().split(MesExtConstWords.COMMA);
if (categoryCodeArr.length != categoryNameArr.length) return psData;
Map<String, List<MesWorkOrder>> centerMap4OrderFilter = new HashMap<>();
Map<String, List<MesOutPutStatistics>> centerMap4OutPutFilter = new HashMap<>();
Map<String, List<MesWorkOrder>> centerMap4Order = getCenterMap4Order(workOrderList);
@ -173,7 +190,6 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
categoryCodeMap4Order.put(workCenterExtDb.getCategoryCode(), categoryCodeList4Order);
categoryCodeMap4OutPut.put(workCenterExtDb.getCategoryCode(), categoryCodeList4OutPut);
if (!CollectionUtils.isEmpty(workOrderList4Center)) centerMap4OrderFilter.put(workCenterExtDb.getWorkCenterCode(), workOrderList4Center);
if (!CollectionUtils.isEmpty(outPutStatisticsList4Center)) centerMap4OutPutFilter.put(workCenterExtDb.getWorkCenterCode(), sortOutPutStatisticsList(outPutStatisticsList4Center));
}
@ -187,18 +203,19 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
psData.addChartData(categoryNameArr[i], completeQtyAmount, planQtyAmount, getBigDecimalPercent(divThenMul100Format1RoundHalfUp(completeQtyAmount, planQtyAmount)));
}
dataMap.put(MesWorkOrder.class.getSimpleName(), centerMap4OrderFilter);
dataMap.put(MesOutPutStatistics.class.getSimpleName(), centerMap4OutPutFilter);
return psData;
}
private JxCenterWorkingBoardBusiModel getOntologyLineWorkingStatus(String organizeCode, List<MesWorkCenterExt> workCenterExtDbList, Map<String, Object> dataMap) {
private Map<String, Object> calcOntologyLineData(String organizeCode, List<MesWorkCenterExt> workCenterExtDbList, Map<String, Object> dataMap) {
JxCenterWorkingBoardBusiModel psData = new JxCenterWorkingBoardBusiModel().title("本体产线状态");
JxCenterWorkingBoardBusiModel psData1 = new JxCenterWorkingBoardBusiModel().title("本体产线状态");
JxCenterWorkingBoardBusiModel psData2 = new JxCenterWorkingBoardBusiModel().title("本体能率");
List<MesBusiConfig> busiConfigList = busiConfigService.getConfigListSortSeq(organizeCode, MesExtConstWords.BOARD_WORK_SHOW_FLAG);
if (CollectionUtils.isEmpty(busiConfigList)) return psData;
String busiConfigList4Cached = (String) execCachedCenterWorkingBoardData(organizeCode, MesExtConstWords.ZERO_STR, MesExtConstWords.BOARD_WORK_SHOW_FLAG, null);
List<MesBusiConfig> busiConfigList = !StringUtils.isEmpty(busiConfigList4Cached) ? JSONObject.parseArray(busiConfigList4Cached, MesBusiConfig.class) : execConfigListSortSeq(organizeCode);
if (CollectionUtils.isEmpty(busiConfigList)) return packOntologyLineWorkingStatusAndEnergyRate(dataMap, psData1, psData2);
Map<String, MesWorkCenterExt> workCenterExtDbMap = workCenterExtDbList.stream().filter(o -> null != o).collect(Collectors.toMap(MesWorkCenterExt::getWorkCenterCode, o -> o));
@ -212,13 +229,43 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
dataMap.put(MesExtConstWords.WORK_TIME, workCenterExtDb.getWorkTime());
dataMap.put(MesExtConstWords.SHIFT_CODE, workCenterExtDb.getShiftCode());
dataMap.put(MesExtConstWords.WORK_CENTER_CODE, workCenterExtDb.getWorkCenterCode());
MesOutPutStatistics outPutStatistics = (!CollectionUtils.isEmpty(centerMap4OutPutFilter) && centerMap4OutPutFilter.containsKey(workCenterExtDb.getWorkCenterCode())) ? centerMap4OutPutFilter.get(workCenterExtDb.getWorkCenterCode()).get(0) : getOutPutStatisticsByCenter(organizeCode, workCenterExtDb.getWorkCenterCode());
List<MesOutPutStatistics> outPutStatisticsListFilter = (null == outPutStatistics || CollectionUtils.isEmpty(centerMap4OutPutFilter)) ? null : centerMap4OutPutFilter.get(workCenterExtDb.getWorkCenterCode());
outPutStatisticsListFilter = CollectionUtils.isEmpty(outPutStatisticsListFilter) ? null : outPutStatisticsListFilter.stream().filter(o -> (null != o && o.getWorkOrderNo().equals(outPutStatistics.getWorkOrderNo()))).collect(Collectors.toList());
psData.addChartData(workCenterExtDb.getWorkCenterCode(), null == outPutStatistics ? null : outPutStatistics.getPartNo(), getRepairRate(outPutStatisticsListFilter, repairTaskList, workCenterExtDb), proxyService1.queryCenterWorkingBoardData(dataMap).get("生产状态"));
List<MesOutPutStatistics> outPutStatisticsListFilter = CollectionUtils.isEmpty(centerMap4OutPutFilter) ? null : centerMap4OutPutFilter.get(workCenterExtDb.getWorkCenterCode());
dataMap.put(MesOutPutStatistics.class.getSimpleName(), outPutStatisticsListFilter);
MesOutPutStatistics outPutStatistics = !CollectionUtils.isEmpty(outPutStatisticsListFilter) ? outPutStatisticsListFilter.get(0) : getOutPutStatisticsByCenter(organizeCode, workCenterExtDb.getWorkCenterCode());
List<MesOutPutStatistics> outPutStatisticsList2Order = (null == outPutStatistics || CollectionUtils.isEmpty(outPutStatisticsListFilter)) ? null : outPutStatisticsListFilter.stream().filter(o -> (null != o && o.getWorkOrderNo().equals(outPutStatistics.getWorkOrderNo()))).collect(Collectors.toList());
psData1.addChartData(workCenterExtDb.getWorkCenterCode(), null == outPutStatistics ? null : outPutStatistics.getPartNo(), getRepairRate(outPutStatisticsList2Order, repairTaskList, workCenterExtDb), proxyService2.queryCenterWorkingBoardData(dataMap).get(MesExtConstWords.STATUS));
proxyService3.queryCenterWorkingBoardData(dataMap);
psData2.addChartData(workCenterExtDb.getWorkCenterCode(),
getBigDecimalPercent(divThenMul100Format1RoundHalfUp((Double) dataMap.get("standardTime"), (Double) dataMap.get("workingTime"))),
getBigDecimalPercent(divThenMul100Format1RoundHalfUp((Double) dataMap.get("workingTime"), (Double) dataMap.get("serviceTime"))),
getBigDecimalPercent(divThenMul100Format1RoundHalfUp((Double) dataMap.get("standardTime"), (Double) dataMap.get("serviceTime"))));
}
return psData;
return packOntologyLineWorkingStatusAndEnergyRate(dataMap, psData1, psData2);
}
private MesBusiConfig execCatagoryCodeCfg(String organizeCode) {
MesBusiConfig catagoryCodeCfg = busiConfigService.getBusiConfigByCfgCode(organizeCode, MesExtConstWords.SX_CATEGORY_CFG);
if (null != catagoryCodeCfg) execCachedCenterWorkingBoardData(organizeCode, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr(), MesExtConstWords.SX_CATEGORY_CFG, JSONObject.toJSONString(catagoryCodeCfg));
return catagoryCodeCfg;
}
private List<MesBusiConfig> execConfigListSortSeq(String organizeCode) {
List<MesBusiConfig> busiConfigList = busiConfigService.getConfigListSortSeq(organizeCode, MesExtConstWords.BOARD_WORK_SHOW_FLAG);
if (!CollectionUtils.isEmpty(busiConfigList)) execCachedCenterWorkingBoardData(organizeCode, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr(), MesExtConstWords.BOARD_WORK_SHOW_FLAG, JSONObject.toJSONString(busiConfigList));
return busiConfigList;
}
private Map<String, Object> packOntologyLineWorkingStatusAndEnergyRate(Map<String, Object> dataMap, JxCenterWorkingBoardBusiModel psData1, JxCenterWorkingBoardBusiModel psData2) {
dataMap.put("本体产线状态", psData1);
dataMap.put("本体能率", psData2);
return dataMap;
}
private String getRepairRate(List<MesOutPutStatistics> outPutStatisticsList, List<MesRepairTask> repairTaskList, MesWorkCenterExt workCenterExtDb) {
@ -233,9 +280,10 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC
private MesOutPutStatistics getOutPutStatisticsByCenter(String organizeCode, String workCenterCode) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getNumEqualPack(workCenterCode, MesExtConstWords.WORK_CENTER_CODE, packBean);
DdlPreparedPack.getStringEqualPack(workCenterCode, MesExtConstWords.WORK_CENTER_CODE, packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.WORK_ORDER_TYPE.STANDARD_ORDER.getValue(), MesExtConstWords.WORK_ORDER_TYPE, packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{MesExtConstWords.MODIFY_DATE_TIME}, packBean);
return outPutStatisticsRepository.getByProperty(packBean);
}
}

@ -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)));
}
}

@ -28,10 +28,6 @@ public class JxCenterWorkingBoardProxyOutPutService implements IJxCenterWorkingB
private MesOutPutStatisticsRepository outPutStatisticsRepository;
public JxCenterWorkingBoardProxyOutPutService() {
this.outPutStatisticsRepository = (MesOutPutStatisticsRepository) SpringContextsUtil.getBean("mesOutPutStatisticsRepository");
}
public JxCenterWorkingBoardProxyOutPutService(IJxCenterWorkingBoardService proxyService) {
this.proxyService = proxyService;
this.outPutStatisticsRepository = (MesOutPutStatisticsRepository) SpringContextsUtil.getBean("mesOutPutStatisticsRepository");

@ -35,6 +35,8 @@ public class JxCenterWorkingBoardProxyRepairService implements IJxCenterWorkingB
@Override
public Map<String, Object> queryCenterWorkingBoardData(Map<String, Object> dataMap) {
if (null != proxyService) proxyService.queryCenterWorkingBoardData(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);

@ -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;
}
}

@ -51,7 +51,7 @@ public class JxCenterWorkingBoardProxyWorkingStatusService implements IJxCenterW
if (null == filterData) enumItem = SHIFT_PROD_TYPE_COLOR.NO_WORKING;
else enumItem = SHIFT_PROD_TYPE_COLOR.getByValue(filterData.getProdType());
dataMap.put("生产状态", new StringJoiner(MesExtConstWords.COMMA).add(enumItem.workingStatusName).add(enumItem.color).toString());
dataMap.put(MesExtConstWords.STATUS, new StringJoiner(MesExtConstWords.COMMA).add(enumItem.workingStatusName).add(enumItem.color).toString());
return dataMap;
}

@ -111,5 +111,10 @@ public class MesWorkCenterExt extends MesWorkCenter implements Serializable {
@ApiParam("事业别")
private String careerCode;
@Column(name = "WORK_TAKT", columnDefinition = "decimal(18,8)")
@ColumnDefault("0")
@ApiParam("生产节拍")
private Double workTakt;
}

@ -48,4 +48,10 @@ public class JxCenterWorkingBoardBusiModel extends JxEChartsReportCommonDataMode
return this;
}
public JxCenterWorkingBoardBusiModel addChartData(String key, Object value, Object value2) {
if (CollectionUtils.isEmpty(this.chartDataList)) this.chartDataList = new LinkedList<>();
this.chartDataList.add(new JxEChartsReportCommonDataModel.SxDataModel(key, value, value2));
return this;
}
}

Loading…
Cancel
Save