From 3b391c1019f737bd0db66bea89bf04c1f6bf9a6a Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Sat, 8 Feb 2025 15:29:23 +0800 Subject: [PATCH] =?UTF-8?q?=2044424=20PCN=EF=BC=9A=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=88=A4=E5=8F=AF=E7=96=91=E7=9A=84=E7=A0=81=EF=BC=8C=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E5=B7=A5=E5=8D=95=E6=A3=80=E9=AA=8C=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=9C=A8=E6=89=AB=E6=8F=8F=E8=A3=85=E9=85=8D?= =?UTF-8?q?=E4=BB=B6=E5=B7=A5=E6=AD=A5=E6=97=B6=E6=89=AB=E6=8F=8F=E5=88=A4?= =?UTF-8?q?=E5=8F=AF=E7=96=91=E7=A0=81=EF=BC=8C=E5=B7=A5=E5=8D=95=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=E4=B8=BA=E5=8F=AF=E7=96=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../step/MesWorkOrderSaveSortStepService.java | 85 +++++++++++++++------- 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java index 763fdd0..b38176f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveSortStepService.java @@ -17,6 +17,7 @@ import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StepResult; import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,7 +27,9 @@ import org.springframework.util.StringUtils; import javax.persistence.EntityManager; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @Description : 保存加工单信息工步 【排序】 @@ -89,42 +92,68 @@ public class MesWorkOrderSaveSortStepService extends BaseStepService { private void doHandleWorkOrderData(StationRequestBean reqBean, StationResultBean resultBean, List productionPartContextList, MesWorkCell workCell) { + //获取上下文加工结果 + String productResult = productionDispatchContextStepService.getProductResultContext(reqBean); + + Map propertyMap; + for (MesProductionPartContext productionPartContext : productionPartContextList) { if (null == productionPartContext || StringUtils.isEmpty(productionPartContext.getForeignKey())) continue; + //判断是否末道工位 Boolean isEndWorkCell = (!StringUtils.isEmpty(workCell.getIsEndWorkCell()) && workCell.getIsEndWorkCell().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) ? true : false; - if (!isEndWorkCell && productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) == 0) continue; - - if (!isEndWorkCell) { - workOrderRepository.updateByPropertiesNoSync( - new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, - new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, - new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, - MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, - MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME}, - new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()), - CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY, - MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue(), productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime()}); - } else { - productionPartContext.setOfflineTime(TimeTool.getNowTime(true)); - workOrderRepository.updateByPropertiesNoSync( - new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, - new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, - new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, - MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, - MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.COMPLETE_QTY, MesPcnExtConstWords.UN_COMPLETE_QTY, - MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME, MesPcnExtConstWords.END_TIME, MesPcnExtConstWords.OFFLINE_TIME}, - new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()), - CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY, - MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue(), new Double(1), new Double(0), - productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime(), productionPartContext.getOfflineTime(), productionPartContext.getOfflineTime()}); + propertyMap = new HashMap<>(); + + //质量非合格 + if (!StringUtils.isEmpty(productResult) && !productResult.equals(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue() + MesPcnExtConstWords.EMPTY)) { + propertyMap.put(MesPcnExtConstWords.QC_STATUS, Integer.valueOf(productResult)); } - log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:[{}:{}]", - reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), - StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), MesPcnExtConstWords.WORK_ORDER_STATUS, !isEndWorkCell ? MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue() : MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); + //末工位 或者 非加工中 + if (isEndWorkCell || productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) != 0) { + if (!isEndWorkCell) { + propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()); + propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime()); + propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime()); + } else { + productionPartContext.setOfflineTime(TimeTool.getNowTime(true)); + propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); + propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime()); + propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime()); + propertyMap.put(MesPcnExtConstWords.END_TIME, productionPartContext.getOfflineTime()); + propertyMap.put(MesPcnExtConstWords.OFFLINE_TIME, productionPartContext.getOfflineTime()); + propertyMap.put(MesPcnExtConstWords.COMPLETE_QTY, new Double(1)); + propertyMap.put(MesPcnExtConstWords.UN_COMPLETE_QTY, new Double(0)); + } + } + + //当存在修改字段的情况下进行修改工单信息 + if (!CollectionUtils.isEmpty(propertyMap) && propertyMap.size() > 0) { + propertyMap.put(MesPcnExtConstWords.MODIFY_USER, reqBean.getUserInfo()); + propertyMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date())); + propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_STATUS, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); + propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.EMPTY); + + String[] propertyName = new String[propertyMap.size()]; + Object[] propertyValue = new Object[propertyMap.size()]; + + Integer index = 0; + for (Map.Entry innerEntry : propertyMap.entrySet()) { + if (null == innerEntry) continue; + propertyName[index] = innerEntry.getKey(); + propertyValue[index] = innerEntry.getValue(); + index ++; + } + + workOrderRepository.updateByPropertiesNoSync(new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, propertyName, propertyValue); + + log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:{}", + reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), + StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), JSONObject.toJSONString(propertyMap)); + + } } }