diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java index ae9d429..a5295bf 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java @@ -245,25 +245,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService } //零件检测详情为空,则代表本次校验为合格。 if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) { - MesPartInspection partInspection; + MesPartInspection partInspection = null; //返工单返修完成,需可疑品移正常库 - if (model.isTransferFlg() && model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { - //电子化检验 - String target = configService.getCfgValue(org, "LGORT"); - - DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); - DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); - - MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); - if (version != null) { - target = version.getReceiveInventoryPoint(); - } - - MesMove move = createMove(model, getDestLocateNo(model, org), target, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); - moveRepository.save(move); - - } //判断首次合格还是 多次检验最终为合格品 //若返修单返修完成,则会生成一个新的检验单并合格 @@ -274,7 +258,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (model.getOptType() != null && model.getOptType() == 2) { partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); } - partInspectionRepository.save(partInspection); + partInspection = partInspectionRepository.save(partInspection); if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { checkProduceSn(produceSn, model.getSn()); @@ -294,7 +278,6 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService } else { - //原单据不合格 现合格 if (model.getPartInspection().getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()) { model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()); @@ -367,7 +350,25 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService } } } + if (model.isTransferFlg() && model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { + //电子化检验 + String target = configService.getCfgValue(org, "LGORT"); + + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); + MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); + if (version != null) { + target = version.getReceiveInventoryPoint(); + } + log.info("partInspection={}",partInspection); + if (partInspection != null) { + model.setPartInspection(partInspection); + } + MesMove move = createMove(model, getDestLocateNo(model, org), target, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); + moveRepository.save(move); + + } } else { //零件检测详情不为空,则代表本次校验为不合格。 @@ -375,6 +376,17 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService MesPartInspection partInspection; if (StringUtils.isEmpty(model.getPartInspection())) { + //已创建返修单 + DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean); + + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, reworkPackBean); + int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean); + if (count > 0) { + throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); + } + partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org); if (model.getOptType() != null && model.getOptType() == 2) { @@ -434,7 +446,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (Objects.isNull(srcLocateNo)) { srcLocateNo = configService.getCfgValue(org, "LGORT"); - DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); @@ -444,12 +456,29 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService } if (model.getOptType() != 2) { //移库 - MesMove move = createMove(model, srcLocateNo, configService.getCfgValue(org, "UMLGO"), org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); + //移库 + String destLocateNo = getDestLocateNo(model, org); + String dest = configService.getCfgValue(org, "UMLGO"); + if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) { + return; + } + MesMove move = createMove(model, srcLocateNo, dest, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); moveRepository.save(move); } } else { + //已创建返修单 + DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean); + + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, reworkPackBean); + int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean); + if (count > 0) { + throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); + } + model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()); ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); if (model.getOptType() != null && model.getOptType() == 2) { @@ -509,15 +538,20 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService if (model.getOptType() != 2) { String srcLocateNo = configService.getCfgValue(org, "LGORT"); - DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); if (version != null) { srcLocateNo = version.getReceiveInventoryPoint(); } - - MesMove move = createMove(model, srcLocateNo, configService.getCfgValue(org, "UMLGO"), org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); + //移库 + String destLocateNo = getDestLocateNo(model, org); + String dest = configService.getCfgValue(org, "UMLGO"); + if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) { + return; + } + MesMove move = createMove(model, srcLocateNo, dest, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); moveRepository.save(move); } @@ -877,7 +911,6 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService private List queryDefectAlarmConfigByLocationCodeList(MesPart part, Integer frontBack, List locationCodeList, List partTypeDefectCodeList, String org) { - DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); DdlPreparedPack.getStringEqualPack(part.getPartNo(), "partNo", packBean); DdlPreparedPack.getStringEqualPack(part.getPartTypeCode(), "partTypeCode", packBean); @@ -1027,7 +1060,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService String productVersion = model.getProductVersion(); if (!StringUtils.isEmpty(productVersion)) { - DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(); + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPreparedPack.getStringEqualPack(partNo, "partNo", ddlPackBean); DdlPreparedPack.getStringEqualPack(workCenterCode, "workCenterCode", ddlPackBean); DdlPreparedPack.getStringEqualPack(productVersion, "productVersion", ddlPackBean);