From 7d2477e8bbc4ec759f8f59b83e17f6b9b4a9849b Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Wed, 22 Nov 2023 17:33:07 +0800 Subject: [PATCH] =?UTF-8?q?jx=20mes=20=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/jx/IJxTimeSegmentStatisticsService.java | 5 ++ .../api/busi/jx/IJxCenterWorkingBoardService.java | 8 +- .../busi/jx/JxCenterWorkingBoardController.java | 15 +++- .../i3plus/ext/mes/apiservice/dao/IPartExtDao.java | 7 ++ .../ext/mes/apiservice/daoimpl/PartExtDao.java | 20 +++++ .../base/jx/JxTimeSegmentStatisticsService.java | 15 ++-- .../jx/JxCenterWorkingBoardCenterOneService.java | 3 + .../jx/JxCenterWorkingBoardCenterThreeService.java | 72 ++++++++++++++++- .../jx/JxCenterWorkingBoardCenterTwoService.java | 83 ++++++-------------- .../busi/jx/JxCenterWorkingBoardCommonService.java | 14 +++- .../jx/JxCenterWorkingBoardDispatchService.java | 33 +++++++- .../jx/JxCenterWorkingBoardMonitorOneService.java | 90 +++++++++++++++++----- ...JxCenterWorkingBoardProxyEnergyRateService.java | 87 +++++++++++++++++++++ .../jx/JxCenterWorkingBoardProxyOutPutService.java | 4 - .../jx/JxCenterWorkingBoardProxyRepairService.java | 2 + ...CenterWorkingBoardProxyStandardWorkService.java | 46 +++++++++++ ...xCenterWorkingBoardProxyTimeSegmentService.java | 53 +++++++++++++ ...enterWorkingBoardProxyWorkingStatusService.java | 2 +- .../i3plus/ext/mes/pojo/bean/MesWorkCenterExt.java | 5 ++ .../model/jx/JxCenterWorkingBoardBusiModel.java | 6 ++ 20 files changed, 468 insertions(+), 102 deletions(-) create mode 100644 modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyEnergyRateService.java create mode 100644 modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyStandardWorkService.java create mode 100644 modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyTimeSegmentService.java diff --git a/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/base/jx/IJxTimeSegmentStatisticsService.java b/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/base/jx/IJxTimeSegmentStatisticsService.java index af8032a..7fc8601 100644 --- a/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/base/jx/IJxTimeSegmentStatisticsService.java +++ b/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/base/jx/IJxTimeSegmentStatisticsService.java @@ -70,4 +70,9 @@ public interface IJxTimeSegmentStatisticsService { */ String getTimeSegmentCode(MesTimeSegmentStatistics timeSegmentStatistics); + /** + * 获取生产线班次分时配置信息 + */ + List getTimeSegmentStatisticsList(String organizeCode, String workCenterCode, String shiftCode); + } diff --git a/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/busi/jx/IJxCenterWorkingBoardService.java b/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/busi/jx/IJxCenterWorkingBoardService.java index 8d66b0d..eb26031 100644 --- a/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/busi/jx/IJxCenterWorkingBoardService.java +++ b/modules/i3plus-ext-mes-api/src/main/java/cn/estsh/i3plus/ext/mes/api/busi/jx/IJxCenterWorkingBoardService.java @@ -17,7 +17,7 @@ public interface IJxCenterWorkingBoardService { * @return 产线运行看板数据 */ @ApiOperation(value = "嘉兴产线运行看板", notes = "嘉兴产线运行看板") - Map queryCenterWorkingBoardData(Map dataMap); + default Map queryCenterWorkingBoardData(Map dataMap) { return dataMap; }; /** * 清除产线运行看板数据无用数据 @@ -27,4 +27,10 @@ public interface IJxCenterWorkingBoardService { @ApiOperation(value = "清除产线运行看板数据无用数据", notes = "清除产线运行看板数据无用数据") default Map clearUselessData(Map dataMap) { return dataMap; } + /** + * 嘉兴产线运行看板缓存数据清除 + */ + @ApiOperation(value = "嘉兴产线运行看板缓存数据清除", notes = "嘉兴产线运行看板缓存数据清除") + default Object execCachedCenterWorkingBoardData(String organizeCode, String flag, String item, Object data) { return null; } + } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/controller/busi/jx/JxCenterWorkingBoardController.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/controller/busi/jx/JxCenterWorkingBoardController.java index 2aa2399..8438cf6 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/controller/busi/jx/JxCenterWorkingBoardController.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/controller/busi/jx/JxCenterWorkingBoardController.java @@ -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 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); + } + } + } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dao/IPartExtDao.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dao/IPartExtDao.java index 3dc3882..d196e41 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dao/IPartExtDao.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dao/IPartExtDao.java @@ -40,6 +40,13 @@ public interface IPartExtDao { Map queryPartExtStandardWorkMap(String organizeCode); /** + * 查询物料标准工数集合 + * @param organizeCode 组织代码 + * @return 物料标准工数集合 + */ + Map queryPartExtStandardWorkStrMap(String organizeCode); + + /** * 查询物料产品类别集合 * @param organizeCode 组织代码 * @param categoryCode3 产品类别 diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/daoimpl/PartExtDao.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/daoimpl/PartExtDao.java index 0fd7de6..b923c9b 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/daoimpl/PartExtDao.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/daoimpl/PartExtDao.java @@ -153,6 +153,26 @@ public class PartExtDao implements IPartExtDao { } @Override + public Map queryPartExtStandardWorkStrMap(String organizeCode) { + Map 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 queryPartCategoryCode3Map(String organizeCode, String categoryCode3) { Map resultMap = new HashMap<>(); StringBuffer hql = new StringBuffer(); diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/jx/JxTimeSegmentStatisticsService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/jx/JxTimeSegmentStatisticsService.java index 2658053..76e73c5 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/jx/JxTimeSegmentStatisticsService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/base/jx/JxTimeSegmentStatisticsService.java @@ -49,9 +49,7 @@ public class JxTimeSegmentStatisticsService implements IJxTimeSegmentStatisticsS @Override public void insertTimeSegmentStatistics(MesTimeSegmentStatistics timeSegmentStatistics){ - List 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 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 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 timeSegmentStatisticsList = getTimeSegmentStatisticsList(timeSegmentStatistics.getOrganizeCode(), timeSegmentStatistics.getWorkCenterCode(), timeSegmentStatistics.getShiftCode()); Optional 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 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}); + } + } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterOneService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterOneService.java index d259b80..6f4f14f 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterOneService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterOneService.java @@ -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; } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterThreeService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterThreeService.java index ed55dab..5336786 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterThreeService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterThreeService.java @@ -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 outPutStatisticsList = (List) dataMap.get(MesOutPutStatistics.class.getSimpleName()); + List outPutStatisticsTimeSegmentList = (List) dataMap.get(MesOutPutStatisticsTimeSegment.class.getSimpleName()); + Optional curWorkOrder = getFirstWorkOrder(workOrderList, outPutStatisticsList, workCenterExtDb); List 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 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 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> 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 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 execTimeSegmentStatistics(MesWorkCenterExt workCenterExtDb, String item) { + List 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 outPutStatisticsTimeSegmentList) { + return CollectionUtils.isEmpty(outPutStatisticsTimeSegmentList) ? new Double(0) : outPutStatisticsTimeSegmentList.stream().filter(o -> null != o).mapToDouble(MesOutPutStatisticsTimeSegment::getQty).sum(); + } + } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterTwoService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterTwoService.java index 0ddf5ad..8823414 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterTwoService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCenterTwoService.java @@ -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 shiftProdCenterRecordList = (List) dataMap.get(MesShiftProdCenterRecord.class.getSimpleName()); - List workOrderList = (List) dataMap.get(MesWorkOrder.class.getSimpleName()); List outPutStatisticsList = (List) dataMap.get(MesOutPutStatistics.class.getSimpleName()); List repairTaskList = (List) dataMap.get(MesRepairTask.class.getSimpleName()); - Map 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()); - } - - private void statisticsData(List shiftProdCenterRecordList, List outPutStatisticsList, - Map partStandardWorkMap, MesWorkCenterExt workCenterExtDb, String curTime, Map dataMap) { - - List filterList2OutPut = CollectionUtils.isEmpty(outPutStatisticsList) ? null : - outPutStatisticsList.stream().filter(o -> (null != o && o.getShiftCode().equals(workCenterExtDb.getShiftCode()))).collect(Collectors.toList()); - List 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 stopList = getShiftProdDataListByFlag(filterList2ShiftProd, false); - List 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 partStandardWorkMap) { - return MathOperation.mul(outPutStatistics.getQty(), ((!CollectionUtils.isEmpty(partStandardWorkMap) && partStandardWorkMap.containsKey(outPutStatistics.getPartNo())) ? partStandardWorkMap.get(outPutStatistics.getPartNo()) : new Double(0))); - } - - private List getShiftProdDataListByFlag(List 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()); + dataMap.put("curTime", TimeTool.getNowTime(true)); } private String getShiftName(MesWorkCenterExt workCenterExtDb) { - return StringUtils.isEmpty(workCenterExtDb.getShiftCode()) ? MesExtConstWords.EMPTY : - 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(); + 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 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()}); + if (null != shiftDb) execCachedCenterWorkingBoardData(workCenterExtDb.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr(), item, JSONObject.toJSONString(shiftDb)); + return shiftDb; } private String getOrderJobStatistics(MesWorkCenterExt workCenterExtDb) { diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCommonService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCommonService.java index b1d96e3..2a87cda 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCommonService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardCommonService.java @@ -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 getWorkOrderList2Sort(List workOrderList, List outPutStatisticsList, MesWorkCenterExt workCenterExtDb) { List 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); + } } \ No newline at end of file diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardDispatchService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardDispatchService.java index 32cfd86..c39248d 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardDispatchService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardDispatchService.java @@ -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 queryCenterWorkingBoardData(Map 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; } + } } \ No newline at end of file diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardMonitorOneService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardMonitorOneService.java index 0901cb4..7eaa90c 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardMonitorOneService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardMonitorOneService.java @@ -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 workCenterExtDbList = (List) 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> getCenterMap4Order(List workOrderList) { @@ -142,14 +159,14 @@ public class JxCenterWorkingBoardMonitorOneService extends JxCenterWorkingBoardC List outPutStatisticsList = (List) 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> centerMap4OrderFilter = new HashMap<>(); Map> centerMap4OutPutFilter = new HashMap<>(); Map> 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 workCenterExtDbList, Map dataMap) { + private Map calcOntologyLineData(String organizeCode, List workCenterExtDbList, Map dataMap) { - JxCenterWorkingBoardBusiModel psData = new JxCenterWorkingBoardBusiModel().title("本体产线状态"); + JxCenterWorkingBoardBusiModel psData1 = new JxCenterWorkingBoardBusiModel().title("本体产线状态"); + JxCenterWorkingBoardBusiModel psData2 = new JxCenterWorkingBoardBusiModel().title("本体能率"); - List 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 busiConfigList = !StringUtils.isEmpty(busiConfigList4Cached) ? JSONObject.parseArray(busiConfigList4Cached, MesBusiConfig.class) : execConfigListSortSeq(organizeCode); + if (CollectionUtils.isEmpty(busiConfigList)) return packOntologyLineWorkingStatusAndEnergyRate(dataMap, psData1, psData2); Map 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 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 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 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 execConfigListSortSeq(String organizeCode) { + List 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 packOntologyLineWorkingStatusAndEnergyRate(Map dataMap, JxCenterWorkingBoardBusiModel psData1, JxCenterWorkingBoardBusiModel psData2) { + dataMap.put("本体产线状态", psData1); + dataMap.put("本体能率", psData2); + return dataMap; } private String getRepairRate(List outPutStatisticsList, List 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); } + } diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyEnergyRateService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyEnergyRateService.java new file mode 100644 index 0000000..8064d8a --- /dev/null +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyEnergyRateService.java @@ -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 queryCenterWorkingBoardData(Map 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 shiftProdCenterRecordList = (List) dataMap.get(MesShiftProdCenterRecord.class.getSimpleName()); + List outPutStatisticsList = (List) dataMap.get(MesOutPutStatistics.class.getSimpleName()); + Map partStandardWorkMap = (Map) dataMap.get(MesExtConstWords.STANDARD_WORK); + + List 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 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 stopList = getShiftProdDataListByFlag(filterList2ShiftProd, false); + List 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 getShiftProdDataListByFlag(List 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 partStandardWorkMap) { + return MathOperation.mul(outPutStatistics.getQty(), ((!CollectionUtils.isEmpty(partStandardWorkMap) && partStandardWorkMap.containsKey(outPutStatistics.getPartNo())) ? Double.parseDouble(partStandardWorkMap.get(outPutStatistics.getPartNo())) : new Double(0))); + } + +} diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyOutPutService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyOutPutService.java index 4906923..de8734b 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyOutPutService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyOutPutService.java @@ -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"); diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyRepairService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyRepairService.java index f38d772..21207e1 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyRepairService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyRepairService.java @@ -35,6 +35,8 @@ public class JxCenterWorkingBoardProxyRepairService implements IJxCenterWorkingB @Override public Map queryCenterWorkingBoardData(Map 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); diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyStandardWorkService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyStandardWorkService.java new file mode 100644 index 0000000..0cf6342 --- /dev/null +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyStandardWorkService.java @@ -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 queryCenterWorkingBoardData(Map dataMap) { + String organizeCode = (String) dataMap.get(MesExtConstWords.ORGANIZE_CODE); + String partStandardWorkMap4Cached = (String) execCachedCenterWorkingBoardData(organizeCode, MesExtConstWords.ZERO_STR, MesExtConstWords.STANDARD_WORK, null); + Map partStandardWorkMap = !StringUtils.isEmpty(partStandardWorkMap4Cached) ? JSONObject.parseObject(partStandardWorkMap4Cached, Map.class) : execPartExtStandardWorkMap(organizeCode); + dataMap.put(MesExtConstWords.STANDARD_WORK, partStandardWorkMap); + return dataMap; + } + + private Map execPartExtStandardWorkMap(String organizeCode) { + Map 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; + } + +} \ No newline at end of file diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyTimeSegmentService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyTimeSegmentService.java new file mode 100644 index 0000000..906ec60 --- /dev/null +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyTimeSegmentService.java @@ -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 queryCenterWorkingBoardData(Map 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 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; + + } + +} diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyWorkingStatusService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyWorkingStatusService.java index b38f0a7..3d1ee61 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyWorkingStatusService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardProxyWorkingStatusService.java @@ -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; } diff --git a/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/bean/MesWorkCenterExt.java b/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/bean/MesWorkCenterExt.java index b4f50f0..6b920d0 100644 --- a/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/bean/MesWorkCenterExt.java +++ b/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/bean/MesWorkCenterExt.java @@ -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; + } diff --git a/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/model/jx/JxCenterWorkingBoardBusiModel.java b/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/model/jx/JxCenterWorkingBoardBusiModel.java index 70b80fe..3313c18 100644 --- a/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/model/jx/JxCenterWorkingBoardBusiModel.java +++ b/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/model/jx/JxCenterWorkingBoardBusiModel.java @@ -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; + } + }