diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java index 23e022c..f180d3c 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java @@ -7,6 +7,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.aspect.MonitorLog; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.IMesShippingScanStrategyService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingCheckModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; @@ -117,6 +118,9 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService @Autowired private IMesProduceSnExtService mesProduceSnExtService; + @Autowired + private MesMoveRepository moveRepository; + @Override public MesSortShippingCheckModel doShippingOrderNoQuery(MesShippingOrderManagement shippingOrderManagement) { //校验发运单 @@ -155,6 +159,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService //零件发运组 MesPartShippingGroup shippingGroup = Objects.isNull(model.getMesPartShippingGroup()) ? getMesPartShippingGroup(orderManagement.getOrganizeCode(), orderManagement.getShippingGroupCode()) : model.getMesPartShippingGroup(); //扫描跳过码 + model.setMesPartShippingGroup(shippingGroup); if (!Objects.isNull(model.getIsPass()) && Objects.equals(MesPcnExtConstWords.ONE, model.getIsPass())) { skipShippingDetails(model, model.getUserInfo(), orderManagement); //扫描条码 @@ -578,7 +583,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService } } //客供品移库 - customerSupplyMove(orderManagement, userInfo, sortShippingModel, shippingList, detail); + customerSupplyMove(orderManagement, userInfo, sortShippingModel, shippingList, detail, model.getMesPartShippingGroup()); detail.setSystemSyncStatus(CommonEnumUtil.FALSE); detail.setActualQty(MesPcnExtConstWords.ONE); @@ -728,9 +733,10 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService sortShippingModel.setMesWorkOrderList(mesWorkOrderExtService.getWorkOrderList(organizeCode, orderNoList)); sortShippingModel.setMesWorkOrderPartList(mesWorkOrderService.findMesWorkOrderPartByOrderNo(organizeCode, orderNoList)); sortShippingModel.setMesProductionRecordList(mesProductionRecordService.findProductionRecordList(organizeCode, orderNoList, MesExtEnumUtil.MES_REPORT_TYPE.CUSTOMER_SUPPLY_MOVE.getValue())); - sortShippingModel.setMesMoveRuleList(mesMoveRuleService.findMesMoveRuleByPartProdGroupCode(shippingGroupCode, organizeCode,MesExtEnumUtil.MOVE_RULE_GROUP_TYPE.MOVE_RULE_GROUP_TYPE_10.getValue())); - sortShippingModel.setMesPartList(mesPartService.findMesPartByPartNo(sortShippingModel.getPartNoAllList(), organizeCode)); } + sortShippingModel.setMesPartList(mesPartService.findMesPartByPartNo(sortShippingModel.getPartNoAllList(), organizeCode)); + sortShippingModel.setMesMoveRuleList(mesMoveRuleService.findMesMoveRuleByPartProdGroupCode(shippingGroupCode, organizeCode,MesExtEnumUtil.MOVE_RULE_GROUP_TYPE.MOVE_RULE_GROUP_TYPE_10.getValue())); + return sortShippingModel; } @@ -742,7 +748,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService return produceSnByCustSnMap; } - private void customerSupplyMove(MesShippingOrderManagement orderManagement, String userInfo, MesSortShippingModel sortShippingModel, List shippingList, MesShippingOrderManagementDetail detail) { + private void customerSupplyMove(MesShippingOrderManagement orderManagement, String userInfo, MesSortShippingModel sortShippingModel, List shippingList, MesShippingOrderManagementDetail detail, MesPartShippingGroup mesPartShippingGroup) { if (!StringUtils.isEmpty(detail.getVisualOrderNo()) && !Objects.isNull(sortShippingModel.getMesWorkOrderMap()) && sortShippingModel.getMesWorkOrderMap().containsKey(detail.getVisualOrderNo())) { MesWorkOrder workOrder = sortShippingModel.getMesWorkOrderMap().get(detail.getVisualOrderNo()); //散件发运 @@ -765,6 +771,52 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService } } } + } else if (Objects.equals(MesExtEnumUtil.PART_GROUP_MOVE_TYPE.PART_GROUP_MOVE_TYPE_10.getValue(), mesPartShippingGroup.getMoveType())) { + + //散件发运 + if (!Objects.isNull(sortShippingModel.getMesMoveRuleMap())) { + //标记为总成不记录回传表 + detail.setSaveFlag(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); + MesMoveRule moveRule = null; + MesPart itemPart = mesPartService.getMesPartByPartNo(detail.getPartNo(), detail.getOrganizeCode()); + if (Objects.isNull(itemPart) || StringUtil.isEmpty(itemPart.getEsd()) || Objects.isNull(sortShippingModel.getMesMoveRuleMap()) || !sortShippingModel.getMesMoveRuleMap().containsKey(itemPart.getEsd())) { + detail.setSaveFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); + log.info("客供品移库零件【{}】维护的ESD属性未匹配到零件发运组【{}】中的移库规则", detail.getPartNo(), orderManagement.getShippingGroupCode()); + return; + } + moveRule = sortShippingModel.getMesMoveRuleMap().get(itemPart.getEsd()); + if (moveRule == null) { + detail.setSaveFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); + log.info("客供品移库零件【{}】维护的移库规则不做处理", detail.getPartNo(), orderManagement.getShippingGroupCode()); + return; + } + if (MesExtEnumUtil.MOVE_TYPE_REPORT_TYPE.MOVE.getValue() == moveRule.getReportType()) { + doCreateReworkMove(orderManagement.getOrganizeCode(),userInfo,moveRule.getErpSrcLocateNo(),moveRule.getErpDestLocateNo(), "", detail.getPartNo(), detail.getActualQty(),detail.getBarcode()); + } else if (MesExtEnumUtil.MOVE_TYPE_REPORT_TYPE.NOT_HANDLER.getValue() == moveRule.getReportType()) { + log.info("客供品移库零件【{}】维护的移库规则不做处理", detail.getPartNo(), orderManagement.getShippingGroupCode()); + return; + } + } } } + + private void doCreateReworkMove(String organizeCode,String userName, String srcLocate, String destLocate, String workCenterCode, String partNo, double qty, String sn) { + MesPartSap mesPartSap = mesPartService.getMesPartSapByPartNo(partNo, organizeCode); + MesMove move = new MesMove(); + move.setMatnr(mesPartSap.getPartNo()); + move.setOrganizeCode(organizeCode); + move.setFactoryCode(organizeCode); + move.setLgort(srcLocate); + move.setUmlgo(destLocate); + move.setPartInspectionId(0L); + move.setMenge(qty); + move.setMeins(mesPartSap.getUnit()); + move.setPostDate(TimeTool.getToday()); + move.setPostTime(TimeTool.getTimeShortWithColon()); + move.setMoveType(MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE.getValue()); + move.setProductSn(sn); + move.setWorkCenter(workCenterCode); + ConvertBean.serviceModelInitialize(move, userName); + moveRepository.insert(move); + } }