From 463a36566066115779a5f1bd1305614574cdac71 Mon Sep 17 00:00:00 2001 From: jun Date: Wed, 4 Sep 2024 10:30:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=E6=8E=92=E5=BA=8F=20=E8=BF=94?= =?UTF-8?q?=E5=B7=A5=E6=8B=86=E8=A7=A3=E6=B5=81=E7=A8=8B=E5=BC=80=E5=8F=91?= 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, 101 insertions(+), 14 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 2163477..fed45ea 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,6 +4,7 @@ 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; @@ -111,6 +112,12 @@ 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(); @@ -208,9 +215,30 @@ 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) { @@ -321,10 +349,9 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { // 需要新增一条替换条码的记录 MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly(); - BeanUtils.copyProperties(assembly, mesProductionRepeatAssembly); + BeanUtils.copyProperties(assembly, mesProductionRepeatAssembly,MesPcnExtConstWords.ID); 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()); @@ -334,17 +361,14 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { ConvertBean.serviceModelUpdate(assembly,requestModel.getUserName()); mesProductionAssemblyRepository.update(assembly); // 新装配件记录为已装配 - mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); + MesProductionAssembly productionAssembly = mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); + //唯一性校验数据更新 + if (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_30.getValue() == assembly.getMatchType()) { + saveProductionAssemblyUnique(requestModel, assembly.getAssemblySn(), productionAssembly); + } //自制件更新条码状态 if(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_10.getValue() == assembly.getMatchType()){ - 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); + updateProductSn(requestModel, assembly, (MesProductionAssemblyContext) context); } checkResult = false; break; @@ -359,6 +383,43 @@ 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; @@ -492,10 +553,9 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { // 需要新增一条替换条码的记录 MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly(); - BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly); + BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly,MesPcnExtConstWords.ID); 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()); @@ -509,7 +569,11 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService { mesProductionAssemblyRepository.update(mesProductionAssembly); // 新装配件记录为已装配 ConvertBean.serviceModelInitialize(mesProductionRepeatAssembly,requestModel.getUserName()); - mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); + MesProductionAssembly productionAssembly = mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly); + //唯一性校验数据更新 + if (MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_30.getValue() == mesProductionAssembly.getMatchType()) { + saveProductionAssemblyUnique(requestModel, mesProductionAssembly.getAssemblySn(), productionAssembly); + } } /** * 需要更新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 ae5e574..7c7cad7 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,6 +8,7 @@ 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; @@ -37,6 +38,7 @@ 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; /** @@ -384,6 +386,7 @@ 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()); @@ -476,6 +479,26 @@ 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);