From 9174710dcf5d025ac641d9d976d95946c97ee9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E7=AC=91=E7=9D=80=E9=9D=A2=E5=AF=B9=E6=98=8E?= =?UTF-8?q?=E5=A4=A9?= <752558143@qq.com> Date: Fri, 21 Jun 2024 16:09:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=B1=95=E7=A4=BA=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/apiservice/serviceimpl/rulematch/WriteVariableService.java | 7 +++++++ .../apiservice/serviceimpl/step/MesAssemblyScanStepService.java | 2 +- .../serviceimpl/step/MesAssemblyShowNosortStepService.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/WriteVariableService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/WriteVariableService.java index 1705085..9e8a382 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/WriteVariableService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/WriteVariableService.java @@ -53,6 +53,10 @@ public class WriteVariableService implements IWriteVariableService { public MesEquipVariableRwResult writeVariable(StationRequestBean reqBean, String value, MesEquipmentVariable equipmentVariable, String kepwareFlag, Integer foreignKey, Integer index, Integer maxTimes) { // 需要不同的策略不同的转换方式 String newValue = transferValue(reqBean, value, foreignKey, index); + if (StringUtils.isEmpty(newValue)) { + LOGGER.info("发送的值为空,不予发送"); + return null; + } MesEquipVariableRwResult mesEquipVariableRwResult = equipVariableRwExtService.writeVariable(newValue, equipmentVariable, kepwareFlag); if (!mesEquipVariableRwResult.getIsSuccessed() && mesEquipVariableRwResult.getIsNoCfg()) { for (int i = 0;i < maxTimes; i++) { @@ -90,6 +94,9 @@ public class WriteVariableService implements IWriteVariableService { if (StringUtils.isEmpty(value)) { return null; } + if (mesProductionPartContext == null) { + mesProductionPartContext = new MesProductionPartContext(); + } switch (value.toUpperCase()) { case "%RESULT%" : newValue = mesProductionPartContext.getPartNo(); break; case "%PARAM%": newValue = mesProductionPartContext.getWorkOrderNo(); break; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java index 013dca5..85668de 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyScanStepService.java @@ -95,8 +95,8 @@ public class MesAssemblyScanStepService extends BaseStepService { if (CollectionUtils.isEmpty(prodRuleContextList)) { //获取上下文生产扫/读信息:装配件条码 - List cachedEquipVariableCollectContextList = productionDispatchContextStepService.getScanAssemblySnContext(reqBean); + List cachedEquipVariableCollectContextList = productionDispatchContextStepService.getScanAssemblySnContext(reqBean); //删除上下文扫/读信息:装配件条码 productionDispatchContextStepService.deleteScanAssemblySnContext(reqBean); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java index 5cc332a..ef1e260 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyShowNosortStepService.java @@ -294,7 +294,7 @@ public class MesAssemblyShowNosortStepService extends BaseStepService { //显示装配件信息 public Boolean showProductionAssembly(StationRequestBean reqBean, StationResultBean resultBean, MesWorkCenter workCenter, MesCellEquipContext cellEquipContext, List prodRuleContextList, List productionPartContextList) { - Map productionPartMap = productionPartContextList.stream().filter(o -> null != o && o.getForeignKey() != null).collect(Collectors.toMap(MesProductionPartContext::getForeignKey, o -> o)); + Map productionPartMap = productionPartContextList == null ? null : productionPartContextList.stream().filter(o -> null != o && o.getForeignKey() != null).collect(Collectors.toMap(MesProductionPartContext::getForeignKey, o -> o)); for (MesProdRuleContext prodRuleContext : prodRuleContextList) { From 43f74b6ce30d7e10269df17bfd6da64535d53004 Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Fri, 21 Jun 2024 16:24:06 +0800 Subject: [PATCH 2/4] step --- .../IMesProductionCustomContextStepService.java | 2 +- .../MesFunctionChooseCavityOrderService.java | 5 +++- .../step/MesAssemblyGeneratePartNoStepService.java | 3 +++ .../step/MesMouldNoReadStepService.java | 5 ++-- .../step/MesWorkOrderCheckNosortStepService.java | 27 ++++++++++++++-------- .../step/MesWorkOrderCheckSortStepService.java | 14 ++++------- .../step/MesWorkOrderCheckStepService.java | 24 +++++++++++++++++-- .../step/MesWorkOrderSaveStepService.java | 14 ----------- .../step/MesWorkOrderScanStepService.java | 15 ++++++++---- .../MesProductionCustomContextStepService.java | 2 +- .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 2 ++ 11 files changed, 67 insertions(+), 46 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java index dc5fc1f..d32498e 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesProductionCustomContextStepService.java @@ -44,7 +44,7 @@ public interface IMesProductionCustomContextStepService { @ApiOperation(value = "获取手动选择的腔数及工单信息上下文") List getFunctionChooseCavityOrderContext(StationRequestBean reqBean); - @ApiOperation(value = "保存手动选择的腔数及工单信息上下文", notes = "[StationKvBean(key=cavity, name=腔数, value=3, seq=0), StationKvBean(key=workOrderNo, name=加工单, value=工单1;工单2;工单3, seq=1)]") + @ApiOperation(value = "保存选择/扫描/读取的腔数及工单信息上下文", notes = "[StationKvBean(key=cavity, name=腔数, value=3, seq=0), StationKvBean(key=cellMessageSource, name=工位信息来源, value=10, seq=1), StationKvBean(key=workOrderNo, name=加工单, value=工单1;工单2;工单3, seq=2)]") Boolean saveFunctionChooseCavityOrderContext(StationRequestBean reqBean, List resultList); @ApiOperation(value = "删除手动选择的腔数及工单信息上下文") diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionChooseCavityOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionChooseCavityOrderService.java index bb658d1..73570cb 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionChooseCavityOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/station/function/MesFunctionChooseCavityOrderService.java @@ -16,6 +16,7 @@ import cn.estsh.i3plus.pojo.mes.model.ButtonDynamicModel; import cn.estsh.i3plus.pojo.mes.model.StationKvBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationResultBean; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -96,7 +97,9 @@ public class MesFunctionChooseCavityOrderService extends BaseSwsService implemen if (cavity != list.size() - 1) return null; - return StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(MesPcnExtConstWords.CAVITY, "腔数", list.remove(0)), + return StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), + new StationKvBean(MesPcnExtConstWords.CAVITY, "腔数", list.remove(0)), + new StationKvBean(MesPcnExtConstWords.CELL_MESSAGE_SOURCE, "工位信息来源", MesExtEnumUtil.CELL_MESSAGE_SOURCE.PICK.getValueStr()), new StationKvBean(MesPcnExtConstWords.WORK_ORDER_NO, "加工单", list.stream().filter(o -> null != o).collect(Collectors.joining(MesPcnExtConstWords.SEMICOLON)))); } catch (NumberFormatException e) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyGeneratePartNoStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyGeneratePartNoStepService.java index fd8b568..78481e9 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyGeneratePartNoStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyGeneratePartNoStepService.java @@ -109,6 +109,9 @@ public class MesAssemblyGeneratePartNoStepService extends BaseStepService { //保存上下文产品加工规则信息集合 productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList); + //显示装配件信息 + assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList, null); + return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult.nextTriggerEvent(null), String.format("上下文中的装配件条码%s匹配成功!", assemblySn)); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldNoReadStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldNoReadStepService.java index e71d2d4..c34e2c8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldNoReadStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesMouldNoReadStepService.java @@ -8,7 +8,6 @@ import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariableCfg; -import cn.estsh.i3plus.pojo.mes.bean.MesPart; import cn.estsh.i3plus.pojo.mes.bean.MesProdRouteOptParam; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationResultBean; @@ -77,8 +76,8 @@ public class MesMouldNoReadStepService extends BaseStepService { //获取上下文信息 MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getCurCellEquipment(reqBean, stepParamMap); - //当前工序已存在模具号 并且 存在产出零件数据信息 - if (productionDispatchContextStepService.checkMouldNoIsExistContext(reqBean) && (productionDispatchContextStepService.checkProductionPartIsExistContext(reqBean))) return stepResult; + //当前工序已存在模具号 + if (productionDispatchContextStepService.checkMouldNoIsExistContext(reqBean)) return stepResult; //获取生产过程上下文对象有异常信息 抛出异常 if (!productionProcessContextStepService.getEquipmentVariableCfgList(productionProcessContext).getSuccess()) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage()); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckNosortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckNosortStepService.java index 4aa7733..60671f8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckNosortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckNosortStepService.java @@ -1,5 +1,6 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService; @@ -9,8 +10,10 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmCommonService; +import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; +import cn.estsh.i3plus.pojo.mes.model.StationKvBean; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StepResult; @@ -39,6 +42,9 @@ public class MesWorkOrderCheckNosortStepService extends MesWorkOrderCheckStepSer private IMesProductionDispatchContextStepService productionDispatchContextStepService; @Autowired + private IMesProductionCustomContextStepService productionCustomContextStepService; + + @Autowired private IMesWorkOrderExtService workOrderExtService; @Autowired @@ -103,19 +109,20 @@ public class MesWorkOrderCheckNosortStepService extends MesWorkOrderCheckStepSer equipVariableCollectContextList.get(0).getEquipVariableValue(), cellEquipmentContext.getCavity(), cellEquipmentContext.getCavity() - productionPartContextList.size())); //验证是否全部为空腔 - if (!checkIsAllFinishCode(productionPartContextList)) - return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前%s加工单%s验证工单状态成功%s!", - MesExtEnumUtil.CELL_MESSAGE_SOURCE.valueOfDescription(equipVariableCollectContextList.get(0).getMessageSource()), - equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.toList()).toString(), - MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue() == equipVariableCollectContextList.get(0).getMessageSource() ? String.format(",上下文中的加工单个数[%s]已满足腔数", productionPartContextList.size()) : MesPcnExtConstWords.EMPTY)); + if (doCheckIsAllFinishCode(reqBean, productionPartContextList)) + return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前上下文中的加工单信息全部为空腔,已清除当前的空腔数据!"); - //删除上下文产出零件信息 - productionDispatchContextStepService.deleteProductionPartContext(reqBean); + //保存选择/扫描/读取的腔数及工单信息上下文 + productionCustomContextStepService.saveFunctionChooseCavityOrderContext(reqBean, StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), + new StationKvBean(MesPcnExtConstWords.CAVITY, "腔数", String.valueOf(productionPartContextList.size())), + new StationKvBean(MesPcnExtConstWords.CELL_MESSAGE_SOURCE, "工位信息来源", MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValueStr()), + new StationKvBean(MesPcnExtConstWords.WORK_ORDER_NO, "加工单", equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.joining(MesPcnExtConstWords.SEMICOLON))))); - return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前上下文中的加工单信息全部为空腔,已清除当前的空腔数据!"); + return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前%s加工单%s验证工单状态成功%s!", + MesExtEnumUtil.CELL_MESSAGE_SOURCE.valueOfDescription(equipVariableCollectContextList.get(0).getMessageSource()), + equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.toList()).toString(), + MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue() == equipVariableCollectContextList.get(0).getMessageSource() ? String.format(",上下文中的加工单个数[%s]已满足腔数", productionPartContextList.size()) : MesPcnExtConstWords.EMPTY)); } - - } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckSortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckSortStepService.java index aac432d..56b1791 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckSortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckSortStepService.java @@ -108,16 +108,12 @@ public class MesWorkOrderCheckSortStepService extends MesWorkOrderCheckStepServi equipVariableCollectContextList.get(0).getEquipVariableValue(), cellEquipmentContext.getCavity(), cellEquipmentContext.getCavity() - productionPartContextList.size())); //验证是否全部为空腔 - if (!checkIsAllFinishCode(productionPartContextList)) - return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前%s加工单%s验证工单状态成功%s!", - MesExtEnumUtil.CELL_MESSAGE_SOURCE.valueOfDescription(equipVariableCollectContextList.get(0).getMessageSource()), - equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.toList()).toString(), - MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue() == equipVariableCollectContextList.get(0).getMessageSource() ? String.format(",上下文中的加工单个数[%s]已满足腔数", productionPartContextList.size()) : MesPcnExtConstWords.EMPTY)); + if (doCheckIsAllFinishCode(reqBean, productionPartContextList)) return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前上下文中的加工单信息全部为空腔,已清除当前的空腔数据!"); - //删除上下文产出零件信息 - productionDispatchContextStepService.deleteProductionPartContext(reqBean); - - return execNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前上下文中的加工单信息全部为空腔,已清除当前的空腔数据!"); + return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前%s加工单%s验证工单状态成功%s!", + MesExtEnumUtil.CELL_MESSAGE_SOURCE.valueOfDescription(equipVariableCollectContextList.get(0).getMessageSource()), + equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.toList()).toString(), + MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue() == equipVariableCollectContextList.get(0).getMessageSource() ? String.format(",上下文中的加工单个数[%s]已满足腔数", productionPartContextList.size()) : MesPcnExtConstWords.EMPTY)); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java index e16c73e..1f9bc2d 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java @@ -11,6 +11,7 @@ import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmCommonService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService; import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil; +import cn.estsh.i3plus.platform.common.tool.MathOperation; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter; import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder; @@ -102,9 +103,12 @@ public class MesWorkOrderCheckStepService extends BaseStepService { } //验证是否全部为空腔 - public Boolean checkIsAllFinishCode(List productionPartContextList) { + public Boolean doCheckIsAllFinishCode(StationRequestBean reqBean, List productionPartContextList) { Optional optional = productionPartContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).findFirst(); - return (null != optional && optional.isPresent()) ? false : true; + if (null != optional && optional.isPresent()) return false; + //删除上下文产出零件信息 + productionDispatchContextStepService.deleteProductionPartContext(reqBean); + return true; } //验证工单的有效性 @@ -119,6 +123,9 @@ public class MesWorkOrderCheckStepService extends BaseStepService { List workOrderList = workOrderExtService.getWorkOrderList(reqBean.getOrganizeCode(), workOrderNoList); Map> workOrderMap = CollectionUtils.isEmpty(workOrderList) ? null : workOrderList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesWorkOrder::getWorkOrderNo)); + //根据值分组数据 + Map> amountMap = equipVariableCollectContextList.stream().filter(o -> (null != o)).collect(Collectors.groupingBy(MesEquipVariableCollectContext::getEquipVariableValue)); + if (!CollectionUtils.isEmpty(workOrderNoList)) { for (String workOrderNo : workOrderNoList) { @@ -138,6 +145,19 @@ public class MesWorkOrderCheckStepService extends BaseStepService { if (!workOrderDbList.get(0).getWorkCenterCode().equals(reqBean.getWorkCenterCode())) return stepResult.isCompleted(false).msg(String.format("请检查工单信息,加工单[%s]信息所属生产线[%s]与当前生产线[%s]不一致!", workOrderNo, workOrderDbList.get(0).getWorkCenterCode(), reqBean.getWorkCenterCode())); + if ((StringUtils.isEmpty(workCenter.getIsCheckOrderQty()) || workCenter.getIsCheckOrderQty().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0 || + workCenter.getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue()) == 0) && + MathOperation.compareTo(MathOperation.add(workOrderDbList.get(0).getCompleteQty(), new Double(workOrderMap.get(workOrderDbList.get(0).getWorkOrderNo()).size())), workOrderList.get(0).getQty()) > 0) + return stepResult.isCompleted(false).msg(String.format("请检查工单信息,加工单[%s]信息完成数量[%s]累加当前腔数量[%s]已超过计划数量[%s]!", + workOrderNo, workOrderDbList.get(0).getCompleteQty(), workOrderMap.get(workOrderDbList.get(0).getWorkOrderNo()).size(), workOrderList.get(0).getQty())); + + if (!StringUtils.isEmpty(workCenter.getIsCheckOrderQty()) && workCenter.getIsCheckOrderQty().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0 && + workCenter.getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue()) == 0 && + MathOperation.compareTo(MathOperation.add(workOrderDbList.get(0).getReportedQty(), new Double(workOrderMap.get(workOrderDbList.get(0).getWorkOrderNo()).size())), + (MathOperation.mul(workOrderDbList.get(0).getQty(), MathOperation.div(MathOperation.add(workCenter.getOrderRate(), new Double(100)), new Double(100))))) >= 0) + return stepResult.isCompleted(false).msg(String.format("请检查工单信息,加工单[%s]信息汇报数量[%s]累加当前腔数量[%s]已超过计划数量[%s]超工单比例[%s]!", + workOrderNo, workOrderDbList.get(0).getReportedQty(), workOrderMap.get(workOrderDbList.get(0).getWorkOrderNo()).size(), workOrderList.get(0).getQty(), workCenter.getOrderRate() + MesPcnExtConstWords.PERCENT)); + } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveStepService.java index 6334b02..2248c87 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderSaveStepService.java @@ -114,12 +114,9 @@ public class MesWorkOrderSaveStepService extends BaseStepService { Integer reportQty = 0; for (MesProductionPsOutContext productionPsOutContext : produceSnContextList) { - if (null == productionPsOutContext) continue; - if (productionPsOutContext.getIsCalcCompleteQty() == CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) calcCompleteQty += 1; if (prMap.get(productionPsOutContext.getForeignKey()).getReportType().compareTo(MesExtEnumUtil.NOSORT_REPORT_TYPE.NO_REPORT.getValue()) != 0) reportQty += 1; - } if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) == 0 && reportQty.compareTo(MesPcnExtConstWords.ZERO) == 0) continue; @@ -133,15 +130,6 @@ public class MesWorkOrderSaveStepService extends BaseStepService { if (!workOrder.getWorkCenterCode().equals(reqBean.getWorkCenterCode())) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息所属生产线[%s]与当前生产线[%s]不一致!", entry.getKey(), workOrder.getWorkCenterCode(), reqBean.getWorkCenterCode())); - //TODO 超工单数量验证 - /*if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0 && (StringUtils.isEmpty(workCenter.getIsCheckOrderQty()) || workCenter.getIsCheckOrderQty().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0) && workOrder.getCompleteQty().compareTo(workOrder.getQty()) >= 0) - execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息及生产线信息,生产线[%s]不允许超工单生产,且加工单[%s]信息已完成数量[%s]累加当前完成数量[%s]将超过计划数量[%s]!", entry.getKey(), reqBean.getWorkCenterCode(), workOrder.getCompleteQty(), calcCompleteQty, workOrder.getQty())); - - if (reportQty.compareTo(MesPcnExtConstWords.ZERO) > 0 && (!StringUtils.isEmpty(workCenter.getIsCheckOrderQty()) && workCenter.getIsCheckOrderQty().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) && - workOrder.getReportedQty().compareTo(MathOperation.mul(workOrder.getQty(), MathOperation.div(MathOperation.add(workCenter.getOrderRate(), new Double(100)), new Double(100)))) >= 0) - execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息及生产线信息,生产线[%s]允许超工单生产,且加工单[%s]信息已汇报数量[%s]已满足计划数量[%s]超出比例[%s]!", - reqBean.getWorkCenterCode(), entry.getKey(), workOrder.getReportedQty(), workOrder.getQty(), workCenter.getOrderRate() + MesPcnExtConstWords.PERCENT));*/ - if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0) workOrder.setCompleteQty(MathOperation.add(workOrder.getCompleteQty(), calcCompleteQty)); if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0 && workOrder.getUnCompleteQty().compareTo(new Double(0)) > 0 && MathOperation.compareTo(MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty)), new Double(0)) >= 0) workOrder.setUnCompleteQty(MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty))); @@ -158,8 +146,6 @@ public class MesWorkOrderSaveStepService extends BaseStepService { } - - } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderScanStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderScanStepService.java index 6cdf732..3cd491f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderScanStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderScanStepService.java @@ -104,20 +104,25 @@ public class MesWorkOrderScanStepService extends BaseStepService { //封装扫/读信息:加工单信息 (选择) private List doHandleScanWorkOrderNoContext(StationRequestBean reqBean, StepResult stepResult) { + //获取手动选择的腔数及工单信息上下文, 扫描的加工单也会存入其中 List chooseCavityOrder = productionCustomContextStepService.getFunctionChooseCavityOrderContext(reqBean); + //删除手动选择的腔数及工单信息上下文 + if (!CollectionUtils.isEmpty(chooseCavityOrder)) productionCustomContextStepService.deleteFunctionChooseCavityOrderContext(reqBean); + if (CollectionUtils.isEmpty(chooseCavityOrder)) return null; - List pickList = new ArrayList<>(Arrays.asList(chooseCavityOrder.stream().filter(o -> (null != o && o.getKey().equals(MesPcnExtConstWords.WORK_ORDER_NO))).findFirst().get().getValue().split(MesPcnExtConstWords.SEMICOLON))); + String cellMessageSorce = chooseCavityOrder.stream().filter(o -> (null != o && o.getKey().equals(MesPcnExtConstWords.CELL_MESSAGE_SOURCE))).findFirst().get().getValue(); + List chooseList = new ArrayList<>(Arrays.asList(chooseCavityOrder.stream().filter(o -> (null != o && o.getKey().equals(MesPcnExtConstWords.WORK_ORDER_NO))).findFirst().get().getValue().split(MesPcnExtConstWords.SEMICOLON))); List equipVariableCollectContextList = new ArrayList<>(); - pickList.stream().filter(o -> !StringUtils.isEmpty(o)).forEach(o -> equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), o, TimeTool.getNowTime(true), MesExtEnumUtil.CELL_MESSAGE_SOURCE.PICK.getValue()))); + chooseList.stream().filter(o -> !StringUtils.isEmpty(o)).forEach(o -> equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), o, TimeTool.getNowTime(true), Integer.valueOf(cellMessageSorce)))); //发送工步内容 - String scanInfo = chooseCavityOrder.stream().filter(o -> null != o).map(o -> o.getName() + "[" + o.getValue() + "]").collect(Collectors.joining(MesPcnExtConstWords.SEMICOLON)); - productionCustomContextStepService.doSendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.PICK); + String scanInfo = chooseCavityOrder.stream().filter(o -> (null != o && !o.getKey().equals(MesPcnExtConstWords.CELL_MESSAGE_SOURCE))).map(o -> o.getName() + "[" + o.getValue() + "]").collect(Collectors.joining(MesPcnExtConstWords.SEMICOLON)); + productionCustomContextStepService.doSendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.getByValue(Integer.valueOf(cellMessageSorce))); - stepResult.msg(String.format("当前选择信息%s!", scanInfo)); + stepResult.msg(String.format("当前%s%s!", MesExtEnumUtil.CELL_MESSAGE_SOURCE.valueOfDescription(Integer.valueOf(cellMessageSorce)), scanInfo)); return equipVariableCollectContextList; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java index 7cc1ffb..d9d6f6e 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/context/MesProductionCustomContextStepService.java @@ -119,7 +119,7 @@ public class MesProductionCustomContextStepService extends BaseStepService imple return !StringUtils.isEmpty(chooseCavityOrderJson) ? JSONObject.parseArray(chooseCavityOrderJson, StationKvBean.class) : null; } - //保存手动选择的腔数及工单信息上下文 腔数=工单个数 数据格式: [StationKvBean(key=cavity, name=腔数, value=3, seq=0), StationKvBean(key=workOrderNo, name=加工单, value=工单1;工单2;工单3, seq=1)] + //保存选择/扫描/读取的腔数及工单信息上下文 腔数=工单个数 数据格式: [StationKvBean(key=cavity, name=腔数, value=3, seq=0), StationKvBean(key=cellMessageSource, name=工位信息来源, value=10, seq=1), StationKvBean(key=workOrderNo, name=加工单, value=工单1;工单2;工单3, seq=2)] @Override public Boolean saveFunctionChooseCavityOrderContext(StationRequestBean reqBean, List resultList) { if (CollectionUtils.isEmpty(resultList)) return false; diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index b9d80e3..fc5a11f 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -125,6 +125,8 @@ public class MesPcnExtConstWords { public static final String CAVITY = "cavity"; // 数量 public static final String QTY = "qty"; + // 工位信息来源 + public static final String CELL_MESSAGE_SOURCE = "cellMessageSource"; //设备数据变量读写访问配置 From 7af7279c3cc015c908af3a22f509c35abbc90b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E7=AC=91=E7=9D=80=E9=9D=A2=E5=AF=B9=E6=98=8E?= =?UTF-8?q?=E5=A4=A9?= <752558143@qq.com> Date: Fri, 21 Jun 2024 17:48:36 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=B1=95=E7=A4=BA=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java index 1f9bc2d..04271d8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesWorkOrderCheckStepService.java @@ -77,10 +77,10 @@ public class MesWorkOrderCheckStepService extends BaseStepService { MesWorkCenter workCenter = productionProcessContext.getWorkCenter(); //排序线 加工单验证工步 - if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == workCenter.getCenterType()) return ((IStepService) SpringContextsUtil.getBean("mesProductSnCheckSortStepService")).execute(reqBean); + if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == workCenter.getCenterType()) return ((IStepService) SpringContextsUtil.getBean("mesWorkOrderCheckSortStepService")).execute(reqBean); //非排序线 加工单验证工步 - return ((IStepService) SpringContextsUtil.getBean("mesProductSnCheckNosortStepService")).execute(reqBean); + return ((IStepService) SpringContextsUtil.getBean("mesWorkOrderCheckNosortStepService")).execute(reqBean); } From e6fe1a6ddf9c31119080b9a8997aeda5a4c1c569 Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Fri, 21 Jun 2024 18:06:01 +0800 Subject: [PATCH 4/4] step --- .../step/MesAssemblyMatchNosortStepService.java | 9 + .../step/MesProductSnGenerateStepServiceBak.java | 200 --------------------- 2 files changed, 9 insertions(+), 200 deletions(-) delete mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepServiceBak.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchNosortStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchNosortStepService.java index 6e5eadb..fc202cd 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchNosortStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesAssemblyMatchNosortStepService.java @@ -6,12 +6,14 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepServ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; +import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StationResultBean; import cn.estsh.i3plus.pojo.mes.model.StepResult; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import cn.estsh.impp.framework.boot.util.SpringContextsUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -79,6 +81,10 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService { //根据产出零件或者腔数拿到需要的加工规则数量, 优先使用产出零件数量 Integer needQty = !CollectionUtils.isEmpty(productionPartContextList) ? productionPartContextList.size() : cellEquipContext.getCavity(); + //全部匹配完毕,存在进料的时候直接调用 并且不存在产出零件的时候 生成零件条码工步 【收尾都调用是因为 生成零件条码工步 调用执行过程中可能会出现配置报错】 + if (!hasUnBindAssembly && !CollectionUtils.isEmpty(productionPsInContextList) && productionPsInContextList.size() >= needQty && !productionDispatchContextStepService.checkProductionPsOutIsExistContext(reqBean)) + ((IStepService) SpringContextsUtil.getBean("mesProductSnGenerateStepService")).execute(reqBean); + //没有待绑定数据, 验证当前是否满足腔数 没有进料主条码代码当前加工规则已经全部加载, 有的话需要判断是否全部扫完 没有扫完需要返回false继续扫描主条码 if (!IsNeedScanAssembly || !hasUnBindAssembly) return execDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, @@ -104,6 +110,9 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService { if (result || !hasUnBindAssembly) productionDispatchContextStepService.saveProdRuleDataContext(reqBean, prodRuleContextList); if (result || !hasUnBindAssembly) assemblyShowNosortStepService.showProductionAssembly(reqBean, resultBean, productionProcessContext.getWorkCenter(), cellEquipContext, prodRuleContextList, productionPartContextList); + //全部匹配完毕,存在进料的时候直接调用 生成零件条码工步 + if (!hasUnBindAssembly && !CollectionUtils.isEmpty(productionPsInContextList) && productionPsInContextList.size() >= needQty) ((IStepService) SpringContextsUtil.getBean("mesProductSnGenerateStepService")).execute(reqBean); + //没有待绑定数据, 验证当前是否满足腔数 没有进料主条码代码当前加工规则已经全部加载, 有的话需要判断是否全部扫完 没有扫完需要返回false继续扫描主条码 if (!hasUnBindAssembly) return execDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepServiceBak.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepServiceBak.java deleted file mode 100644 index 53932bd..0000000 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductSnGenerateStepServiceBak.java +++ /dev/null @@ -1,200 +0,0 @@ -package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step; - -import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPojoVersionService; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; -import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; -import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext; -import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext; -import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext; -import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; -import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; -import cn.estsh.i3plus.platform.common.convert.ConvertBean; -import cn.estsh.i3plus.platform.common.tool.JsonUtilTool; -import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; -import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; -import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; -import cn.estsh.i3plus.pojo.mes.bean.MesPart; -import cn.estsh.i3plus.pojo.mes.bean.MesPojoVersion; -import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; -import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell; -import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; -import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; -import cn.estsh.i3plus.pojo.mes.model.StationResultBean; -import cn.estsh.i3plus.pojo.mes.model.StepResult; -import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository; -import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository; -import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; -import cn.hutool.core.date.DateUtil; -import com.google.common.base.Objects; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Description : 生成零件条码 - * @Author : wangjie - **/ -@Slf4j -@Service -public class MesProductSnGenerateStepServiceBak extends BaseStepService { - @Autowired - private SnowflakeIdMaker snowflakeIdMaker; - - @Autowired - private IMesProductionProcessContextStepService productionProcessContextStepService; - - @Autowired - private MesPartRepository mesPartRepository; - - @Autowired - private MesProduceSnRepository mesProduceSnRepository; - - @Autowired - private ISyncFuncService syncFuncService; - - public static final String ORDER_NO_JIS_SORT = "ORDER_NO_JIS_SORT"; - - @Autowired - private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService; - - @Autowired - private IMesPojoVersionService mesPojoVersionService; - - /**todo 有产成无进料场景 - * todo 根据装配件条码没有找到加工规则,如果需要跳过装配件绑定,直接生成条码,就需要不看加工规则,直接根据产成零件生成条码,当前设计方式就需要变更。 - * @param reqBean - * @return - */ - @Override - public StepResult execute(StationRequestBean reqBean) { - - StationResultBean resultBean = new StationResultBean(); - - StepResult stepResult = StepResult.getSuccessComplete(); - String result = mesProductionDispatchContextStepService.getProductResultContext(reqBean); - // 获取上下文信息 - MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue()); - MesWorkCell mesWorkCell = productionProcessContext.getWorkCell(); - // 获取产出零件信息 - List productionPartContextList = mesProductionDispatchContextStepService.getProductionPartContext(reqBean); - if (CollectionUtils.isEmpty(productionPartContextList)) { - foundExThrow(reqBean, "必过工步不允许跳过"); - } - // 获取零件号,可能存在多个 - List partNoList = productionPartContextList.stream().map(MesProductionPartContext::getPartNo).collect(Collectors.toList()); - // 根据零件号组装产品条码信息 - List mesProduceSns = generateSn(reqBean, productionProcessContext, mesWorkCell, partNoList, result); - // 保存条码信息 - mesProduceSnRepository.saveAll(mesProduceSns); - - savePojoVersion(mesProduceSns); - - List mesProductionPsOutContexts = new ArrayList<>(); - for (MesProduceSn mesProduceSn : mesProduceSns) { - MesProductionPsOutContext mesProductionPsOutContext = new MesProductionPsOutContext(); - BeanUtils.copyProperties(mesProduceSn, mesProductionPsOutContext); - mesProductionPsOutContexts.add(mesProductionPsOutContext); - } - // 放到上下文 - mesProductionDispatchContextStepService.saveProductionPsOutContext(reqBean, mesProductionPsOutContexts); - - return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "生成零件条码成功"); - } - - private void savePojoVersion(List mesProduceSns) { - mesProduceSns.forEach(mesProduceSn -> { - MesPojoVersion version = new MesPojoVersion(); - version.setRefId(mesProduceSn.getId()); - version.setRefClass(mesProduceSn.getClass().getName()); - version.setBean(JsonUtilTool.encode(mesProduceSn)); - version.setCreateUser(version.getCreateUser()); - version.setModifyUser(version.getModifyUser()); - version.setVersionMethodName("insert"); - version.setOrganizeCode(mesProduceSn.getOrganizeCode()); - mesPojoVersionService.recordPojoVersion(version); - }); - } - - /** - * 根据零件号组装产品条码信息 - * @param reqBean - * @param productionProcessContext - * @param mesWorkCell - * @param partNoList - * @return - */ - private List generateSn(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesWorkCell mesWorkCell, List partNoList, String result) { - List mesProduceSns = new ArrayList<>(); - for (String partNo : partNoList) { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode()); - DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean); - MesPart mesPart = mesPartRepository.getByProperty(packBean); - if (mesPart == null) { - MesPcnException.throwFlowException("零件号不存在"); - } - // 根据条码规则生成条码 - String sn = generateByRule(mesPart); - // 组装条码信息 - MesProduceSn mesProduceSn = generateMesProduceSn(mesPart, sn, mesWorkCell, productionProcessContext, reqBean, result); - ConvertBean.serviceModelInitialize(mesProduceSn, reqBean.getUserInfo()); - mesProduceSns.add(mesProduceSn); - } - return mesProduceSns; - } - - /** - * 生成条码 - * @param mesPart - * @return - */ - private String generateByRule(MesPart mesPart) { - //生成工单号 - GenSerialNoModel genSerialNoModel = new GenSerialNoModel(ORDER_NO_JIS_SORT); - genSerialNoModel.setPartNo(mesPart.getPartNo()); - List resultList = syncFuncService.syncSerialNo(genSerialNoModel, mesPart.getCreateUser(), mesPart.getOrganizeCode(), 1).getResultList(); - return resultList.get(0); - } - - private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, MesWorkCell mesWorkCell,MesProductionProcessContext productionProcessContext, StationRequestBean reqBean, String result) { - long serialNum = snowflakeIdMaker.nextId(); - - MesProduceSn mesProduceSn = new MesProduceSn(); - mesProduceSn.setSerialNumber(serialNum + ""); - mesProduceSn.setProductSn(sn); - mesProduceSn.setCustSn(sn); - mesProduceSn.setPartNo(mesPart.getPartNo()); - mesProduceSn.setPartName(mesPart.getPartName()); - mesProduceSn.setAreaCode(mesWorkCell.getAreaCode()); - mesProduceSn.setWorkCenterCode(mesWorkCell.getWorkCenterCode()); - mesProduceSn.setWorkCellCode(mesWorkCell.getWorkCellCode()); - mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate()); - mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate()); - mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate()); - mesProduceSn.setQty(1d); - mesProduceSn.setSnStatus(10); - Integer qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue(); - if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SCRAP.getValue(), result)) { - qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue(); - } else if (Objects.equal(MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_SUSPICIOUS.getValue(), result)) { - qcStatus = MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue(); - } - mesProduceSn.setQcStatus(qcStatus); - mesProduceSn.setLotNo(DateUtil.format(new Date(), "YYYYMMDD")); - mesProduceSn.setRouteCode(reqBean.getRouteCode()); - mesProduceSn.setProcessCode(productionProcessContext.getProcessCode()); - mesProduceSn.setCraftCode(productionProcessContext.getCraftCode()); - mesProduceSn.setPrintCount(0); - mesProduceSn.setPrintStatus(10); - mesProduceSn.setOrganizeCode(reqBean.getOrganizeCode()); - - return mesProduceSn; - } -}