From acb67d09b7b9cf334626b7e87e2c72b502b3dc90 Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Fri, 15 Dec 2023 13:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jx/JxCenterWorkingBoardCenterTwoService.java | 2 - .../busi/jx/JxCenterWorkingBoardCommonService.java | 20 +++ .../jx/JxCenterWorkingBoardDispatchService.java | 2 +- ...JxCenterWorkingBoardProxyEnergyRateService.java | 20 +-- .../jx/JxCenterWorkingBoardWorkDailyService.java | 142 +++++++++++++++++++-- .../i3plus/ext/mes/pojo/util/MesExtEnumUtil.java | 23 ++++ 6 files changed, 177 insertions(+), 32 deletions(-) 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 0ca7610..596d16c 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 @@ -130,8 +130,6 @@ public class JxCenterWorkingBoardCenterTwoService extends JxCenterWorkingBoardCo dataMap.put("curTime", TimeTool.getNowTime(true)); } - - private String getOrderJobStatistics(MesWorkCenterExt workCenterExtDb) { List orderJobList = (StringUtils.isEmpty(workCenterExtDb.getWorkTime()) || StringUtils.isEmpty(workCenterExtDb.getShiftCode())) ? null : orderJobRepository.findByProperty( 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 58bb249..0bd5357 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 @@ -5,6 +5,7 @@ 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.bean.MesWorkCenterExt; 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.mes.bean.MesWorkOrder; @@ -58,6 +59,14 @@ public class JxCenterWorkingBoardCommonService implements IJxCenterWorkingBoardS return CollectionUtils.isEmpty(outPutStatisticsList) ? new Double(0) : outPutStatisticsList.stream().filter(o -> null != o).mapToDouble(MesOutPutStatistics::getQty).sum(); } + public Double getStandardTime(List outPutStatisticsList, Map partStandardWorkMap) { + return CollectionUtils.isEmpty(outPutStatisticsList) ? new Double(0) : outPutStatisticsList.stream().filter(o -> null != o).mapToDouble(o -> getStatisticsTime(o, partStandardWorkMap)).sum(); + } + + 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))); + } + public Map> getOutPutStatisticsMapByOrderNo(List outPutStatisticsList) { return CollectionUtils.isEmpty(outPutStatisticsList) ? null : outPutStatisticsList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesOutPutStatistics::getWorkOrderNo)); } @@ -66,6 +75,12 @@ public class JxCenterWorkingBoardCommonService implements IJxCenterWorkingBoardS return CollectionUtils.isEmpty(outPutStatisticsList) ? null : outPutStatisticsList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesOutPutStatistics::getModifyDatetime).reversed()).collect(Collectors.toList()); } + public List getShiftProdCenterRecordListByFlag(List shiftProdCenterRecordList, Boolean flag) { + if (CollectionUtils.isEmpty(shiftProdCenterRecordList)) return null; + if (flag) 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()); + 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()); + } + public Double statisticsOrderPlanQty(List workOrderList, String workTime) { return CollectionUtils.isEmpty(workOrderList) ? new Double(0) : workOrderList.stream().filter(o -> (null != o && o.getStartTime().contains(workTime))).mapToDouble(MesWorkOrder::getQty).sum(); } @@ -95,6 +110,11 @@ public class JxCenterWorkingBoardCommonService implements IJxCenterWorkingBoardS return format1RounHalfUp(d); } + public BigDecimal divFormat1RoundHalfUp(Double d1, Double d2) { + Double d = (MathOperation.compareTo(d1, new Double(0)) == 0 || MathOperation.compareTo(d2, new Double(0)) == 0) ? null : MathOperation.div(d1, d2); + return format1RounHalfUp(d); + } + public BigDecimal format1RounHalfUp(Double d) { if (StringUtils.isEmpty(d)) d = new Double(0); BigDecimal bd = new BigDecimal(d); 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 3b8106f..8458df0 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 @@ -60,7 +60,7 @@ public class JxCenterWorkingBoardDispatchService implements IJxCenterWorkingBoar case "workDaily": return new JxCenterWorkingBoardWatchService(new JxCenterWorkingBoardWorkDailyService( - new JxCenterWorkingBoardProxyCenterService(), new JxCenterWorkingBoardProxyShiftService(), + new JxCenterWorkingBoardProxyCenterService(), new JxCenterWorkingBoardProxyStandardWorkService(), new JxCenterWorkingBoardProxyShiftService(), new JxCenterWorkingBoardProxyOutPutService(new JxCenterWorkingBoardProxySpcrService(new JxCenterWorkingBoardProxySpcPmService(new JxCenterWorkingBoardProxyAssistService()))) )).queryCenterWorkingBoardData(dataMap); 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 index 8c7e601..666711a 100644 --- 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 @@ -4,14 +4,11 @@ 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 org.springframework.util.StringUtils; -import java.text.ParseException; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -50,15 +47,14 @@ public class JxCenterWorkingBoardProxyEnergyRateService extends JxCenterWorkingB List filterList2ShiftProd = CollectionUtils.isEmpty(shiftProdCenterRecordList) ? null : shiftProdCenterRecordList.stream().filter(o -> (null != o && o.getWorkCenterCode().equals(workCenterCode) && o.getWorkTime().equals(workTime) && (StringUtils.isEmpty(shiftCode) || o.getShiftCode().equals(shiftCode)) && o.getStartTime().compareTo(curTime) <= 0)).collect(Collectors.toList()); - List prodList = getShiftProdDataListByFlag(filterList2ShiftProd, true); + List prodList = getShiftProdCenterRecordListByFlag(filterList2ShiftProd, true); Double serviceTime = CollectionUtils.isEmpty(prodList) ? new Double(0) : prodList.stream().filter(o -> null != o).mapToDouble(o -> getStatisticsTime(o, curTime)).sum(); dataMap.put("serviceTime", serviceTime); - Double standardTime = CollectionUtils.isEmpty(filterList2OutPut) ? new Double(0) : filterList2OutPut.stream().filter(o -> null != o).mapToDouble(o -> getStatisticsTime(o, partStandardWorkMap)).sum(); - dataMap.put("standardTime", standardTime); + dataMap.put("standardTime", getStandardTime(filterList2OutPut, partStandardWorkMap)); if (!dataMap.containsKey("onlyCalcRate")) { - List stopList = getShiftProdDataListByFlag(filterList2ShiftProd, false); + List stopList = getShiftProdCenterRecordListByFlag(filterList2ShiftProd, false); Double nonWorkingTime = CollectionUtils.isEmpty(stopList) ? new Double(0) : stopList.stream().filter(o -> null != o).mapToDouble(o -> getStatisticsTime(o, curTime)).sum(); dataMap.put("nonWorkingTime", nonWorkingTime); @@ -69,14 +65,4 @@ public class JxCenterWorkingBoardProxyEnergyRateService extends JxCenterWorkingB 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(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/JxCenterWorkingBoardWorkDailyService.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardWorkDailyService.java index dcf89ec..16b6d19 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardWorkDailyService.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/serviceimpl/busi/jx/JxCenterWorkingBoardWorkDailyService.java @@ -1,19 +1,24 @@ 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.MesShiftProdCenterPm; -import cn.estsh.i3plus.ext.mes.pojo.bean.MesShiftProdCenterRecord; -import cn.estsh.i3plus.ext.mes.pojo.bean.MesWorkCenterExt; +import cn.estsh.i3plus.ext.mes.pojo.bean.*; 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.mes.bean.MesShift; -import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder; 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.Calendar; +import java.util.List; import java.util.Map; +import java.util.StringJoiner; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; /** * @Author : wangjie @@ -27,11 +32,14 @@ public class JxCenterWorkingBoardWorkDailyService extends JxCenterWorkingBoardCo private IJxCenterWorkingBoardService proxyService1; + private IJxCenterWorkingBoardService proxyService2; + private IJxCenterWorkingBoardService proxyService; - public JxCenterWorkingBoardWorkDailyService(IJxCenterWorkingBoardService proxyService0, IJxCenterWorkingBoardService proxyService1, IJxCenterWorkingBoardService proxyService) { + public JxCenterWorkingBoardWorkDailyService(IJxCenterWorkingBoardService proxyService0, IJxCenterWorkingBoardService proxyService1, IJxCenterWorkingBoardService proxyService2, IJxCenterWorkingBoardService proxyService) { this.proxyService0 = proxyService0; this.proxyService1 = proxyService1; + this.proxyService2 = proxyService2; this.proxyService = proxyService; } @@ -40,21 +48,67 @@ public class JxCenterWorkingBoardWorkDailyService extends JxCenterWorkingBoardCo proxyService0.queryCenterWorkingBoardData(dataMap); - proxyService1.queryCenterWorkingBoardData(dataMap); + Map partStandardWorkMap = (Map) proxyService1.queryCenterWorkingBoardData(dataMap).get(MesExtConstWords.STANDARD_WORK); + MesShift shift = (MesShift) proxyService2.queryCenterWorkingBoardData(dataMap).get(MesShift.class.getSimpleName()); proxyService.queryCenterWorkingBoardData(packProxyCondition(dataMap)); MesWorkCenterExt workCenterExtDb = (MesWorkCenterExt) dataMap.get(MesWorkCenterExt.class.getSimpleName()); - MesShift shift = (MesShift) dataMap.get(MesShift.class.getSimpleName()); MesShiftProdCenterPm shiftProdCenterPm = (MesShiftProdCenterPm) dataMap.get(MesShiftProdCenterPm.class.getSimpleName()); + List outPutStatisticsList = (List) dataMap.get(MesOutPutStatistics.class.getSimpleName()); + List assistOutAndEnterList = (List) dataMap.get(MesAssistOutAndEnter.class.getSimpleName()); + List shiftProdCenterRecordList = (List) dataMap.get(MesShiftProdCenterRecord.class.getSimpleName()); + + List dinnerTimeRecordList = getShiftProdCenterRecordList2Dinner(shiftProdCenterRecordList); + Map> dinnerTimeRecordMap = getShiftProdCenterRecordMap2Dinner(dinnerTimeRecordList); + + String workTime = (String) dataMap.get(MesExtConstWords.WORK_TIME); + String shift2StartTime = null == shift ? MesExtConstWords.EMPTY : appendTime(workTime, shift.getStartTime()); + String shift2EndTime = getEndTimeByShift(workTime, shift); + String record2EndTime = null == shiftProdCenterPm ? MesExtConstWords.EMPTY : shiftProdCenterPm.getWorkEndTime(); + + Integer time2TotalShangban = calcTimeSubDinnerTime(shift2StartTime, shift2EndTime, dinnerTimeRecordList); + Integer time2NonWorking = calcTime2ShiftProdList(getShiftProdCenterRecordListByFlag(shiftProdCenterRecordList, false)); + Integer time2Jiaban = calcTime2JiaBan(shift2EndTime, record2EndTime, dinnerTimeRecordMap); + Integer time2Working = time2TotalShangban - time2NonWorking; + Integer atHomeNum = null == shiftProdCenterPm ? MesExtConstWords.ZERO : shiftProdCenterPm.getAtHomeNum(); + + Double workQty = null == shiftProdCenterPm ? new Double(0) : shiftProdCenterPm.getWorkerQty(); + Double time2StandardTime = getStandardTime(outPutStatisticsList, partStandardWorkMap); + + BigDecimal energyRate = divThenMul100Format1RoundHalfUp(time2StandardTime, new Double(time2Working)); + BigDecimal utilizationRate = divThenMul100Format1RoundHalfUp(new Double(time2Working), new Double(calcTime2ShiftProdList(getShiftProdCenterRecordListByFlag(shiftProdCenterRecordList, true)))); + dataMap.put("生产线名称", workCenterExtDb.getWorkCenterName()); dataMap.put("班次名称", null == shift ? MesExtConstWords.EMPTY : shift.getShiftName()); dataMap.put("日期", dataMap.get(MesExtConstWords.WORK_TIME)); - dataMap.put("上班时间", null == shiftProdCenterPm ? MesExtConstWords.EMPTY : shiftProdCenterPm.getWorkStartTime()); - dataMap.put("下班时间", null == shiftProdCenterPm ? MesExtConstWords.EMPTY : shiftProdCenterPm.getWorkEndTime()); - dataMap.put("定时", ""); + dataMap.put("上班时间", shift2StartTime); + dataMap.put("下班时间", shift2EndTime); + dataMap.put("定时", calcTimeSubDinnerTime(shift2StartTime, shift2EndTime, getShiftProdCenterRecordList2Dinner(dinnerTimeRecordMap, MesExtEnumUtil.SX_DINNER_TYPE.DINNER.getValue()))); + + dataMap.put("在籍人数", atHomeNum); + dataMap.put("出勤人数", workQty.intValue()); + dataMap.put("缺勤人数", null == shiftProdCenterPm ? MesExtConstWords.ZERO : shiftProdCenterPm.getAbsenteeismNum()); + dataMap.put("加班人数", null == shiftProdCenterPm ? MesExtConstWords.ZERO : shiftProdCenterPm.getOvertimeNum()); + + dataMap.put("新上班", null == shiftProdCenterPm ? MesExtConstWords.ZERO : shiftProdCenterPm.getNewWorkNum()); + dataMap.put("退职", null == shiftProdCenterPm ? MesExtConstWords.ZERO : shiftProdCenterPm.getQuitWorkNum()); + dataMap.put("借入人数", getAssistWorkQty(assistOutAndEnterList, true).intValue()); + dataMap.put("借出人数", getAssistWorkQty(assistOutAndEnterList, false).intValue()); + + dataMap.put("能率", getBigDecimalPercent(energyRate)); + dataMap.put("稼动率", getBigDecimalPercent(utilizationRate)); + dataMap.put("效率", getBigDecimalPercent(format1RounHalfUp(MathOperation.mul(energyRate.doubleValue(), utilizationRate.doubleValue())))); + dataMap.put("出勤率", getBigDecimalPercent(divThenMul100Format1RoundHalfUp(workQty, new Double(atHomeNum)))); + dataMap.put("人均台数", divFormat1RoundHalfUp(getOutPutStatisticsList2AmountQty(outPutStatisticsList), workQty)); + + dataMap.put("标准时间", format1RounHalfUp(time2StandardTime)); + dataMap.put("总上班时间", time2TotalShangban); + dataMap.put("作业时间", time2Working); + dataMap.put("非作业时间", time2NonWorking); + dataMap.put("加班时间", time2Jiaban); return clearUselessData(dataMap); } @@ -65,7 +119,9 @@ public class JxCenterWorkingBoardWorkDailyService extends JxCenterWorkingBoardCo dataMap.remove(MesOutPutStatistics.class.getSimpleName()); dataMap.remove(MesShiftProdCenterRecord.class.getSimpleName()); dataMap.remove(MesShiftProdCenterPm.class.getSimpleName()); - dataMap.remove(MesExtConstWords.SHIFT_NAME); + dataMap.remove(MesAssistOutAndEnter.class.getSimpleName()); + dataMap.remove(MesShift.class.getSimpleName()); + dataMap.remove(MesExtConstWords.STANDARD_WORK); dataMap.remove("hasShiftCode"); return dataMap; } @@ -75,4 +131,66 @@ public class JxCenterWorkingBoardWorkDailyService extends JxCenterWorkingBoardCo return dataMap; } + private Double getAssistWorkQty(List assistOutAndEnterList, Boolean flag) { + if (CollectionUtils.isEmpty(assistOutAndEnterList)) return new Double(0); + if (flag) return assistOutAndEnterList.stream().filter(o -> (null != o && MesExtEnumUtil.BU_ASSIST_OUT_AND_ENTER_DETAIL.ASSIST_ENTER.getValue() == o.getAssistOutAndEnterDetail())).mapToDouble(MesAssistOutAndEnter::getInfluenceNumber).sum(); + else return assistOutAndEnterList.stream().filter(o -> (null != o && MesExtEnumUtil.BU_ASSIST_OUT_AND_ENTER_DETAIL.ASSIST_ENTER.getValue() != o.getAssistOutAndEnterDetail())).mapToDouble(MesAssistOutAndEnter::getInfluenceNumber).sum(); + } + + private List getShiftProdCenterRecordList2Dinner(List shiftProdCenterRecordList) { + return CollectionUtils.isEmpty(shiftProdCenterRecordList) ? null : shiftProdCenterRecordList.stream().filter(o -> (null != o && o.getProdCode().contains(MesExtEnumUtil.SX_DINNER_TYPE.DINNER.name()))).collect(Collectors.toList()); + } + + private List getShiftProdCenterRecordList2Dinner(Map> shiftProdCenterRecordMap, String prodCode) { + return CollectionUtils.isEmpty(shiftProdCenterRecordMap) ? null : shiftProdCenterRecordMap.get(prodCode); + } + + private Map> getShiftProdCenterRecordMap2Dinner(List shiftProdCenterRecordList) { + return CollectionUtils.isEmpty(shiftProdCenterRecordList) ? null : shiftProdCenterRecordList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesShiftProdCenterRecord::getProdCode)); + } + + private Integer calcTime2ShiftProdList(List shiftProdCenterRecordList) { + return CollectionUtils.isEmpty(shiftProdCenterRecordList) ? MesExtConstWords.ZERO : + shiftProdCenterRecordList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getStartTime()) && !StringUtils.isEmpty(o.getEndTime()))).mapToInt(o -> getSecoundsBetweenTime(o.getStartTime(), o.getEndTime())).sum(); + } + + private Integer calcTime2JiaBan(String shift2EndTime, String record2EndTime, Map> dinnerTimeRecordMap) { + if (record2EndTime.compareTo(shift2EndTime) <= 0) return MesExtConstWords.ZERO; + return calcTimeSubDinnerTime(shift2EndTime, record2EndTime, getShiftProdCenterRecordList2Dinner(dinnerTimeRecordMap, MesExtEnumUtil.SX_DINNER_TYPE.DINNER_OT.getValue())); + } + + private String getEndTimeByShift(String workTime, MesShift shift) { + if (null == shift) return MesExtConstWords.EMPTY; + String ymd = shift.getStartTime().compareTo(shift.getEndTime()) <= 0 ? workTime : TimeTool.timeCalc(TimeTool.stringParseToDate(workTime, MesExtConstWords.DATE_FORMAT), Calendar.DATE, 1, MesExtConstWords.DATE_FORMAT); + return appendTime(ymd, shift.getEndTime()); + } + + private String appendTime(String ymd, String time) { + return new StringJoiner(MesExtConstWords.ONE_SPACE).add(ymd).add(time).toString(); + } + + private Integer calcTimeSubDinnerTime(String startTime, String endTime, List dinnerTimeRecordList) { + if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) return MesExtConstWords.ZERO; + AtomicReference dinnerTime = new AtomicReference<>(0); + if (!CollectionUtils.isEmpty(dinnerTimeRecordList)) + dinnerTimeRecordList.forEach(o -> dinnerTime.updateAndGet(v -> v + calcDinnerTime(startTime, endTime, o))); + return getSecoundsBetweenTime(startTime, endTime) - dinnerTime.get(); + } + + private Integer calcDinnerTime(String startTime, String endTime, MesShiftProdCenterRecord dinnerTimeRecord) { + Boolean flag; + if (dinnerTimeRecord.getStartTime().compareTo(startTime) >= 0 && dinnerTimeRecord.getStartTime().compareTo(endTime) < 0) flag = true; + else if (dinnerTimeRecord.getEndTime().compareTo(startTime) > 0 && dinnerTimeRecord.getStartTime().compareTo(endTime) <= 0) flag = true; + else flag = false; + return !flag ? MesExtConstWords.ZERO : getSecoundsBetweenTime(dinnerTimeRecord.getStartTime(), dinnerTimeRecord.getEndTime()); + } + + private Integer getSecoundsBetweenTime(String startTime, String endTime) { + try { + return TimeTool.getSecoundsBetweenTime(2, startTime, endTime); + } catch (ParseException e) { + return MesExtConstWords.ZERO; + } + } + } diff --git a/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/util/MesExtEnumUtil.java b/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/util/MesExtEnumUtil.java index 13eca4d..fc6e39d 100644 --- a/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/util/MesExtEnumUtil.java +++ b/modules/i3plus-ext-mes-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pojo/util/MesExtEnumUtil.java @@ -5412,4 +5412,27 @@ public class MesExtEnumUtil { return tmp; } } + + @JsonFormat(shape = JsonFormat.Shape.OBJECT) + public enum SX_DINNER_TYPE { + DINNER("DINNER", "正餐"), + DINNER_OT("DINNER_OT", "加班餐"); + + private String value; + private String description; + + SX_DINNER_TYPE(String value, String description) { + this.value = value; + this.description = description; + } + + public String getValue() { + return value; + } + + public String getDescription() { + return description; + } + } + }