From f70b94e327773e0d40b409f2a1ac9d86f33f1924 Mon Sep 17 00:00:00 2001 From: "xiangwei.zhang" <752558143@qq.com> Date: Mon, 31 Mar 2025 17:11:36 +0800 Subject: [PATCH] =?UTF-8?q?45843=201=20=E6=97=A0=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E8=A1=A5=E6=8A=A5=E5=B7=A5JOB=E9=92=88=E5=AF=B9=E5=A4=9A?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=89=88=E6=9C=AC=E5=9C=BA=E6=99=AF=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8SAP=20=E4=B8=BB=E6=95=B0?= =?UTF-8?q?=E6=8D=AE0001=E8=BF=9B=E8=A1=8C=E8=A1=A5=E6=8A=A5=E5=B7=A5=202?= =?UTF-8?q?=20=E6=97=A0=E5=B7=A5=E5=8D=95=E6=8A=A5=E5=B7=A5=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=BA=A7=E7=BA=BF=E7=89=A9=E6=96=99=E5=8F=B7?= =?UTF-8?q?=E4=B8=BA=E4=B8=80=E4=B8=AA=E4=BA=8B=E5=8A=A1=E5=8E=BB=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E7=94=9F=E4=BA=A7=E7=89=88=E6=9C=AC=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesWorkOrderService.java | 46 ++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java index a60409a..d00ec76 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java @@ -818,19 +818,36 @@ public class MesWorkOrderService implements IMesWorkOrderService { throw new ImppBusiException(String.format("班次信息未维护,产线=%s",workCenterCode)); } List shifts = shiftList.stream().filter(mesShift -> Objects.equals(mesShift.getWorkCenterCode(), workCenterCode)).collect(Collectors.toList()); + // 获取产品加工记录对应时间的班次 + + Integer hours = transfer(productionRecord.getCompleteDateTime()).getHours(); + + Date currentDate = TimeTool.stringParseToDate(productionRecord.getCompleteDateTime()); + String lotNo = productionRecord.getLotNo(); + // 基于加工时间判断具体的班次 + MesShift currentShift = shiftList.stream().filter(shift -> { + String startTime = lotNo + " " + shift.getStartTime(); + String endTime = lotNo + " " + shift.getEndTime(); + if (Objects.equals(shift.getShiftCode(), "20")) { + endTime = getDateTime(lotNo, 2) + " " + shift.getEndTime(); + } + Date startDate = DateUtil.parse(startTime); + Date endDate = DateUtil.parse(endTime); + return currentDate.getTime() > startDate.getTime() && currentDate.getTime() < endDate.getTime(); + }).findFirst().orElse(null); + - MesShift currentShift = shifts.stream().filter(mesShift -> Objects.equals(mesShift.getShiftCode(), shiftCode)).findFirst().orElse(null); String orderDate = productionRecord.getLotNo(); if (currentShift.getStartTime().compareTo(currentShift.getEndTime()) > 0) { // 如果比0点大,需要找日期前一天的班次的工单号,如果是0点前,date =lotNO 如果是0点后,则找lot的前一天 - int hours = transfer(productionRecord.getCompleteDateTime()).getHours(); if (hours < 12) { orderDate = getDate(productionRecord.getLotNo(), 1); } else { orderDate = getDate(productionRecord.getLotNo(), 0); } + } List list = new ArrayList<>(); @@ -856,7 +873,6 @@ public class MesWorkOrderService implements IMesWorkOrderService { // 如果开始时间大于结束时间,说明跨天了,跨天说明是晚班,需要找, 如果是晚班, 则找早中班的工单 if (currentShift.getStartTime().compareTo(currentShift.getEndTime()) > 0) { // 如果比0点大,需要找日期前一天的班次的工单号,如果是0点前,date =lotNO 如果是0点后,则找lot的前一天 - int hours = transfer(productionRecord.getCompleteDateTime()).getHours(); if (hours < 12) { date = getDate(productionRecord.getLotNo(), 1); } else { @@ -1754,4 +1770,28 @@ public class MesWorkOrderService implements IMesWorkOrderService { move.setWorkCenter(workCenterCode); return move; } + /** + * flag = 1 减少 1天, = 2 加一天 + * + * @param lotNo + * @param flag + * @return + */ + public String getDateTime(String lotNo, int flag) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + Date d = null; + try { + d = df.parse(lotNo); + } catch (ParseException e) { + e.printStackTrace(); + } + Calendar cal = Calendar.getInstance(); + cal.setTime(d); + if (flag == 1) { + cal.add(Calendar.DATE, -1); //减1天 + } else if (flag == 2) { + cal.add(Calendar.DATE, 1); //加1天 + } + return df.format(cal.getTime()).substring(0, 10); + } }