From 2d7e14e91606889088035727a96d7ae01ed694ff Mon Sep 17 00:00:00 2001 From: jun Date: Wed, 4 Sep 2024 10:32:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=9F=E6=9D=90=E6=96=99=E9=98=B2=E9=94=99?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E4=BA=A4=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= =?UTF-8?q?(=E4=BB=A3=E7=A0=81=E5=9B=9E=E9=80=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/base/MesReworkTaskServiceImpl.java | 92 ++++------------------ .../serviceimpl/busi/MesNcProcessingService.java | 23 ------ 2 files changed, 14 insertions(+), 101 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java index fed45ea..2163477 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/base/MesReworkTaskServiceImpl.java @@ -4,7 +4,6 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService; import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService; import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesReworkTaskService; import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService; -import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesAssemblyExtService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; @@ -112,12 +111,6 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { @Autowired private IMesProduceSnExtService produceSnExtService; - @Autowired - private IMesAssemblyExtService mesAssemblyExtService; - - @Autowired - private MesProductionAssemblyUniqueRepository mesProductionAssemblyUniqueRepository; - @Override public ListPager queryReworkTask(MesReworkTask mesReworkTask, Pager pager) { String organizeCode = !StringUtils.isEmpty(mesReworkTask.getOrganizeCode())?mesReworkTask.getOrganizeCode():AuthUtil.getOrganizeCode(); @@ -215,30 +208,9 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { if (CollectionUtils.isEmpty(mesProductionAssemblies)) { MesPcnException.throwFlowException("装配件信息不存在"); } - //装配件是自制件,查询自制件经过的装配件记录 - recursionAssemblySn(mesProductionAssemblies,requestModel); - return mesProductionAssemblies; } - - public void recursionAssemblySn(List mesProductionAssemblyList,MesReworkTaskRequestModel requestModel){ - DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode()); - DdlPreparedPack.getInPackList(mesProductionAssemblyList.stream().map(MesProductionAssembly::getAssemblySn).distinct().collect(Collectors.toList()), "productSn", packBean); - DdlPreparedPack.getNumEqualPack(requestModel.getIsOrigSn(), "isOrigSn", packBean); - if (!StringUtils.isEmpty(requestModel.getAssemblyPartNo())) { - DdlPreparedPack.getStringEqualPack(requestModel.getAssemblyPartNo(), "assemblyPartNo", packBean); - } - if (!Objects.isNull(requestModel.getAssemblyPartStatus())) { - DdlPreparedPack.getNumEqualPack(requestModel.getAssemblyPartStatus(), "assemblyStatus", packBean); - } - List mesProductionAssemblies = mesProductionAssemblyRepository.findByHqlWhere(packBean); - if(!CollectionUtils.isEmpty(mesProductionAssemblies)){ - recursionAssemblySn(mesProductionAssemblies,requestModel); - mesProductionAssemblyList.addAll(mesProductionAssemblies); - } - } - @Override public void reworkSuccess(MesReworkTaskRequestModel requestModel) { @@ -349,9 +321,10 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { // 需要新增一条替换条码的记录 MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly(); - BeanUtils.copyProperties(assembly, mesProductionRepeatAssembly,MesPcnExtConstWords.ID); + BeanUtils.copyProperties(assembly, mesProductionRepeatAssembly); mesProductionRepeatAssembly.setAssemblySn(requestModel.getSn()); mesProductionRepeatAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue()); + mesProductionRepeatAssembly.setId(null); mesProductionRepeatAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); mesProductionRepeatAssembly.setFid(UUID .randomUUID().toString()); ConvertBean.serviceModelInitialize(mesProductionRepeatAssembly,requestModel.getUserName()); @@ -361,14 +334,17 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { ConvertBean.serviceModelUpdate(assembly,requestModel.getUserName()); mesProductionAssemblyRepository.update(assembly); // 新装配件记录为已装配 - MesProductionAssembly productionAssembly = mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); - //唯一性校验数据更新 - if (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_30.getValue() == assembly.getMatchType()) { - saveProductionAssemblyUnique(requestModel, assembly.getAssemblySn(), productionAssembly); - } + mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); //自制件更新条码状态 if(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_10.getValue() == assembly.getMatchType()){ - updateProductSn(requestModel, assembly, (MesProductionAssemblyContext) context); + List produceSnList = produceSnExtService.getProduceSnList(requestModel.getOrganizeCode(), requestModel.getSn()); + if (CollectionUtils.isEmpty(produceSnList)) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn()); + Optional optional = produceSnList.stream().filter(sn->sn.getId().equals(((MesProductionAssemblyContext)context).getProductSnId())).findFirst(); + if (!optional.isPresent()) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn()); + // 更新新替换得条码为已装配 + updateNewSn(optional.get(),requestModel.getUserName()); + //更新原条码状态为已拆解 + updateOldSn(assembly); } checkResult = false; break; @@ -383,43 +359,6 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { } } - private void updateProductSn(MesReworkTaskRequestModel requestModel, MesProductionAssembly assembly, MesProductionAssemblyContext context) { - List produceSnList = produceSnExtService.getProduceSnList(requestModel.getOrganizeCode(), requestModel.getSn()); - if (CollectionUtils.isEmpty(produceSnList)) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn()); - Optional optional = produceSnList.stream().filter(sn->sn.getId().equals(context.getProductSnId())).findFirst(); - if (!optional.isPresent()) MesPcnException.throwFlowException("零件条码[%s]信息不存在!", requestModel.getSn()); - // 更新新替换得条码为已装配 - updateNewSn(optional.get(), requestModel.getUserName()); - //更新原条码状态为已拆解 - updateOldSn(assembly); - } - - private void saveProductionAssemblyUnique(MesReworkTaskRequestModel requestModel, String assemblySN, MesProductionAssembly productionAssembly) { - //绑定数据解绑 - saveProductionAssemblyUnique(requestModel, assemblySN); - //唯一性校验数据保存 - saveProductionAssemblyUnique(productionAssembly); - } - - private void saveProductionAssemblyUnique(MesReworkTaskRequestModel requestModel, String assemblySN) { - List assemblyUniqueList = mesAssemblyExtService.getProductionAssemblyUniqueList(requestModel.getOrganizeCode(), assemblySN); - if(!CollectionUtils.isEmpty(assemblyUniqueList)){ - assemblyUniqueList.forEach(t->{ - t.setSystemSyncStatus(CommonEnumUtil.FALSE); - t.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_20.getValue()); - ConvertBean.serviceModelUpdate(t, requestModel.getUserName()); - }); - mesProductionAssemblyUniqueRepository.saveAll(assemblyUniqueList); - } - } - - private void saveProductionAssemblyUnique(MesProductionAssembly productionAssembly) { - MesProductionAssemblyUnique productionAssemblyUnique = new MesProductionAssemblyUnique(); - BeanUtils.copyProperties(productionAssembly, productionAssemblyUnique, MesPcnExtConstWords.ID); - productionAssemblyUnique.setPid(productionAssembly.getId()); - mesProductionAssemblyUniqueRepository.insert(productionAssemblyUnique); - } - private Object getContext(MesReworkTaskRequestModel requestModel, MesProductionAssembly mesProductionAssembly,Map mesWorkCenterMap) { if(StringUtils.isEmpty(mesProductionAssembly.getWorkCenterCode())) MesPcnException.throwFlowException("产线代码不存在"); Object context = null; @@ -553,9 +492,10 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { // 需要新增一条替换条码的记录 MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly(); - BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly,MesPcnExtConstWords.ID); + BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly); mesProductionRepeatAssembly.setAssemblySn(sn); mesProductionRepeatAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue()); + mesProductionRepeatAssembly.setId(null); mesProductionRepeatAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); mesProductionRepeatAssembly.setFid(UUID .randomUUID().toString()); @@ -569,11 +509,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { mesProductionAssemblyRepository.update(mesProductionAssembly); // 新装配件记录为已装配 ConvertBean.serviceModelInitialize(mesProductionRepeatAssembly,requestModel.getUserName()); - MesProductionAssembly productionAssembly = mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); - //唯一性校验数据更新 - if (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_30.getValue() == mesProductionAssembly.getMatchType()) { - saveProductionAssemblyUnique(requestModel, mesProductionAssembly.getAssemblySn(), productionAssembly); - } + mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); } /** * 需要更新NC标记后进入的表明细状态为已处理 diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 7c7cad7..ae5e574 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -8,7 +8,6 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesNcProcessingDao; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel; -import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.tool.TimeTool; @@ -38,7 +37,6 @@ import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.stream.Collectors; /** @@ -386,7 +384,6 @@ public class MesNcProcessingService implements IMesNcProcessingService { reworkTask.setPartInspectionId(model.getPartInspection().getId()); reworkTask.setOrganizeCode(org); reworkTask.setResponsibleParty(model.getOnlyPerson()); - reworkTask.setDisassembleType(disassembleType(model, org, sn)); reworkTask.setLotNo(model.getPartInspection().getLotNo()); reworkTask.setType(model.getPartInspection().getSourceType()); ConvertBean.serviceModelInitialize(reworkTask, model.getUserName()); @@ -479,26 +476,6 @@ public class MesNcProcessingService implements IMesNcProcessingService { } - private int disassembleType(MesNcProcessingInputModel model, String org, MesProduceSn sn) { - if (MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue() == model.getPartInspection().getSourceType()) { - if (Objects.isNull(sn)) { - throw new ImppBusiException(String.format("【%s】此条码不存在,请检查数据", model.getSn())); - } - //产线信息 - MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(org, sn.getWorkCenterCode()); - if (Objects.isNull(centerDb)) { - throw new ImppBusiException(String.format("产线【%s】信息不存在,请检查数据", sn.getWorkCenterCode())); - } - //拆解类型 - if (MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == centerDb.getCenterType()) { - return MesExtEnumUtil.REWORK_TASK_DISASSEMBLE_TYPE.SORT_DISASSEMBLE.getValue(); - } else if (MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue() == centerDb.getCenterType()) { - return MesExtEnumUtil.REWORK_TASK_DISASSEMBLE_TYPE.NOSORT_DISASSEMBLE.getValue(); - } - } - return MesPcnExtConstWords.ZERO; - } - private MesProduceSn checkProduceSn(String serialNumber, String org) { //根据扫描的条码查询条码是否存在 DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);