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 08bd0e7..7edf508 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 @@ -570,19 +570,18 @@ public class MesWorkOrderService implements IMesWorkOrderService { bom.setItemPartNo(mesBom.getItemPartNo()); return bom; })); - if(MesExtEnumUtil.NOSORT_REPORT_TYPE.REPORT.getValue() == productionRecord.getReportType()){ + if (MesExtEnumUtil.NOSORT_REPORT_TYPE.REPORT.getValue() == productionRecord.getReportType()) { for (Map.Entry> entry : map.entrySet()) { - mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, oldMesWorkOrder, mesProductVersion, entry.getValue().get(0),productionRecord.getProductSn(),false)); + mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, oldMesWorkOrder, mesProductVersion, entry.getValue().get(0), productionRecord.getProductSn(), false, map.size())); } } else if (MesExtEnumUtil.NOSORT_REPORT_TYPE.CUSTOMER_SUPPLY_MOVE.getValue() == productionRecord.getReportType()) { - customerSupplyMove(productionRecord,oldMesWorkOrder, mesProductVersion, mesBoms, productionRecord.getProductSn(), mesProductOffLineList, mesMoveList,userName); + customerSupplyMove(productionRecord, oldMesWorkOrder, mesProductVersion, mesBoms, mesProductOffLineList, mesMoveList, userName); } else { LOGGER.info("汇报类型不存在"); return; } if(!CollectionUtils.isEmpty(mesProductOffLineList)){ - mesProductOffLineList.forEach(item -> item.setBomTotalSize(mesProductOffLineList.size())); mesProductOffLineRDao.saveAll(mesProductOffLineList); } @@ -606,7 +605,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { } - private MesProductOffLine getMesProductOffLine(MesProductionRecord productionRecord, String userName, MesWorkOrder oldMesWorkOrder, MesProductVersion mesProductVersion, MesBom mesBom,String reportSn,boolean isItemReport) { + private MesProductOffLine getMesProductOffLine(MesProductionRecord productionRecord, String userName, MesWorkOrder oldMesWorkOrder, MesProductVersion mesProductVersion, MesBom mesBom,String reportSn,boolean isItemReport,Integer bomSize) { MesProductOffLine newMesProductOffLine = new MesProductOffLine(); BeanUtils.copyProperties(mesBom, newMesProductOffLine, MesPcnExtConstWords.BASE_BEAN_FIELDS); @@ -656,6 +655,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { newMesProductOffLine.setOrganizeCode(oldMesWorkOrder.getOrganizeCode()); newMesProductOffLine.setDescription(productionRecord.getCompleteDateTime()); newMesProductOffLine.setProductionRecordId(productionRecord.getId().toString()); + newMesProductOffLine.setBomTotalSize(bomSize); ConvertBean.serviceModelInitialize(newMesProductOffLine, userName); return newMesProductOffLine; } @@ -1024,12 +1024,15 @@ public class MesWorkOrderService implements IMesWorkOrderService { return; } //排序汇报 - List mesProductOffLineList = new ArrayList<>(); - List mesMoveList = new ArrayList<>(); - List shippingList = new ArrayList<>(); + List mesProductOffLineList = null; + List mesMoveList = null; + List shippingList = null; boolean isReport = false; boolean isMove = false; for (String orderNo : model.getMesProductionRecordMap().keySet()) { + mesProductOffLineList = new ArrayList<>(); + mesMoveList = new ArrayList<>(); + shippingList = new ArrayList<>(); try { //加工记录 MesProductionRecord record = model.getMesProductionRecordMap().get(orderNo).iterator().next(); @@ -1067,7 +1070,8 @@ public class MesWorkOrderService implements IMesWorkOrderService { } //保存报工记录 试制单不报工 if (CollectionUtils.isNotEmpty(mesProductOffLineList)) { - mesProductOffLineList.forEach(item -> item.setBomTotalSize(mesProductOffLineList.size())); + List finalMesProductOffLineList = mesProductOffLineList; + mesProductOffLineList.forEach(item -> item.setBomTotalSize(finalMesProductOffLineList.size())); mesProductOffLineRDao.saveAll(mesProductOffLineList); } //保存移库记录 @@ -1091,7 +1095,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { if (e instanceof ImppBusiException) { msg = ((ImppBusiException) e).getErrorDetail(); } - log.error("工单:{}报工失败{}", orderNo, ExceptionUtils.getStackTrace(e)); + log.error("工单:{}报工失败{}", orderNo, msg); productionRecordService.updateProductionRecord(model.getMesProductionRecordMap().get(orderNo), userName, MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_40.getValue(), msg); } } @@ -1413,13 +1417,16 @@ public class MesWorkOrderService implements IMesWorkOrderService { } } - private void customerSupplyMove(MesProductionRecord productionRecord,MesWorkOrder mesWorkOrder, MesProductVersion mesProductVersion, List mesBoms, String sn, List mesProductOffLineList, List mesMoveList,String userName) { + private void customerSupplyMove(MesProductionRecord productionRecord,MesWorkOrder mesWorkOrder, MesProductVersion mesProductVersion, List mesBoms, List mesProductOffLineList, List mesMoveList,String userName) { boolean isItemMove; boolean isItemReport; MesMoveRule moveRule; //查询零件生产组的移库规则 List moveRules = mesMoveRuleService.findMesMoveRuleByPartProdGroupCode(mesWorkOrder.getPartProdGroupCode(), mesWorkOrder.getOrganizeCode()); - if(CollectionUtils.isEmpty(moveRules)) return; + if(CollectionUtils.isEmpty(moveRules)) { + LOGGER.info("工单:{} 生产组:{}移库规则信息不存在",mesWorkOrder.getWorkOrderNo(),mesWorkOrder.getPartProdGroupCode()); + return; + } Map> mesMoveRuleMap = moveRules.stream().filter(t -> Objects.nonNull(t.getSrcType())).collect(Collectors.groupingBy(MesMoveRule::getSrcType)); List itemPartNoList = mesBoms.stream().map(MesBom::getItemPartNo).collect(Collectors.toList()); //子物料SAP下发信息 @@ -1457,10 +1464,10 @@ public class MesWorkOrderService implements IMesWorkOrderService { //bom下的子节汇报 if (!CollectionUtils.isEmpty(bomList)) { for (MesBom bom : bomList) { - mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, mesWorkOrder, itemVersion, bom, reportSn, true)); + mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, mesWorkOrder, itemVersion, bom, reportSn, true, bomList.size())); } } else { - mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, mesWorkOrder, itemVersion, mesBom, reportSn, true)); + mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, mesWorkOrder, itemVersion, mesBom, reportSn, true, MesPcnExtConstWords.ONE)); } } //移库 @@ -1478,7 +1485,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { //bom下的子节汇报,总成也需要汇报 if (!CollectionUtils.isEmpty(mesProductOffLineList)) { for (MesBom mesBom : mesBoms) { - mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, mesWorkOrder, mesProductVersion, mesBom, productionRecord.getProductSn(), false)); + mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, mesWorkOrder, mesProductVersion, mesBom, productionRecord.getProductSn(), false,mesBoms.size())); } } }