From e2d4d5bbe46bb73931c4e1a9a4b937cd973e9812 Mon Sep 17 00:00:00 2001 From: jing's Date: Tue, 10 Sep 2024 16:44:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=BD=E7=95=A5T=E9=A1=B9=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewEbomParentService.java | 22 ++- .../bomnew/service/domain/EBom/EBomEdit.java | 131 +++++++++--------- 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index ffd09ea5..6e96509c 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -2140,10 +2140,7 @@ public class BomNewEbomParentService extends ServiceImpl computeLevelNumAndRootState()); + if (eBomEdit.isRootForWaitReview()) { updateRootForWaitReview(); @@ -2197,10 +2196,7 @@ public class BomNewEbomParentService extends ServiceImpl childEntities; @@ -84,22 +84,22 @@ public class EBomEdit { parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); - boolean isTechnician= SpringUtil.getBean(UserRoleService.class).technician(); - parent.setStatus(isTechnician? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue()); - parent.setCreatedJob(isTechnician? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); + boolean isTechnician = SpringUtil.getBean(UserRoleService.class).technician(); + parent.setStatus(isTechnician ? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue()); + parent.setCreatedJob(isTechnician ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); //工艺人不用更新 - if(isTechnician){ - isRootForWaitReview=false; - }else{ - isRootForWaitReview=true; + if (isTechnician) { + isRootForWaitReview = false; + } else { + isRootForWaitReview = true; } - isNewBom=true; + isNewBom = true; parent.setCreatedTime(LocalDateTime.now()); parent.setModifyTime(LocalDateTime.now()); - parent.setExpireEndTime( LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") )); + parent.setExpireEndTime(LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); parent.setRootIs(0); parent.setUserRootIs(0); parent.setMaterialOriginalUnit(parent.getMaterialUnit()); @@ -113,24 +113,22 @@ public class EBomEdit { /** * 如果有定版后才能新建bom + * * @param materialNo */ - void checkHadBom(String materialNo){ + void checkHadBom(String materialNo) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(BomNewEbomParentEntity::getMaterialNo, materialNo) - .ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()); + .ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()); List existBomlist = SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper); - VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage(materialNo+"该物料已存在BOM"); + VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage(materialNo + "该物料已存在BOM"); } - - - void createRootBom(BomNewEBomParentEditDTO createDTO) { - checkHadBom(createDTO.getParent().getMaterialNo()); + checkHadBom(createDTO.getParent().getMaterialNo()); parentEntity = createParentBomInfo(createDTO.getParent()); parentEntity.setEditStatus(createDTO.getOpType()); @@ -155,7 +153,7 @@ public class EBomEdit { } - public static void checkVirtualPackage(BomNewEbomChildEntity child){ + public static void checkVirtualPackage(BomNewEbomChildEntity child) { if (StrUtil.equals(child.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY)) { child.setVirtualPartType(VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()); } else { @@ -190,7 +188,7 @@ public class EBomEdit { // child.setVirtualPartIs(1); // } - EBomEdit.checkVirtualPackage(child); + EBomEdit.checkVirtualPackage(child); //新增数据 if (child.getRowId() == null || child.getRowId() == 0) { @@ -200,7 +198,7 @@ public class EBomEdit { child.setCreatedBy(SessionUtil.getUserCode()); child.setSourceRowId(""); child.setParentRowId(parentEntity.getRowId()); - if(StrUtil.isEmpty(child.getOrderNumber())){ + if (StrUtil.isEmpty(child.getOrderNumber())) { child.setOrderNumber("001"); } if (dto.getOpType() == EbomEditStatusEnum.HANDLER_FINISHED.getValue()) { @@ -262,20 +260,22 @@ public class EBomEdit { throw new NflgBusinessException(STATE.Error, "parent 数据不能为空"); } - // if (CollUtil.isEmpty(dto.getDatas())) { - // throw new NflgBusinessException(STATE.Error, "datas 数据不能为空"); - // } List materialNos = dto.getDatas().stream() .filter(f -> !StrUtil.equals(f.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY, true)) .map(BaseMaterialVO::getMaterialNo) .collect(Collectors.toList()); - if(materialNos.contains(dto.getParent().getMaterialNo())){ - VUtils.isTure(true).throwMessage(StrUtil.format("上下级存在相同物料{}",dto.getParent().getMaterialNo())); + if (materialNos.contains(dto.getParent().getMaterialNo())) { + VUtils.isTure(true).throwMessage(StrUtil.format("上下级存在相同物料{}", dto.getParent().getMaterialNo())); } //检查物料编码是否在主数据中存在 //暂存不需检查,提交时检查 - if(ObjectUtil.equal(EbomEditStatusEnum.HANDLER_FINISHED.getValue(),dto.getOpType())) { + if (ObjectUtil.equal(EbomEditStatusEnum.HANDLER_FINISHED.getValue(), dto.getOpType())) { + List checkMaterialInNull = materialNos.stream().filter(item -> StrUtil.isEmpty(item)).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(checkMaterialInNull)) { + VUtils.isTure(true).throwMessage("提交数据包含空物料编码"); + } + materialNos.add(dto.getParent().getMaterialNo()); List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); List effectiveMaterialNos = materialBaseInfo.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList()); @@ -284,43 +284,44 @@ public class EBomEdit { } //检查数据是否可修改 - List notNullRowIdList= dto.getDatas().stream().filter(u->u.getRowId()!=null && u.getRowId()>0).collect(Collectors.toList()); - Map mapList= ListCommonUtil.listToMap(notNullRowIdList,BomNewEbomParentVO::getRowId); + List notNullRowIdList = dto.getDatas().stream().filter(u -> u.getRowId() != null && u.getRowId() > 0).collect(Collectors.toList()); + Map mapList = ListCommonUtil.listToMap(notNullRowIdList, BomNewEbomParentVO::getRowId); - QueryWrapper queryChildWrapper=new QueryWrapper<>(); - List rowIds=notNullRowIdList.stream().filter(u->ObjectUtil.isNotNull(u.getRowId()) && u.getRowId()>0 ).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); - if(CollUtil.isEmpty(rowIds)){ - return; - } - queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId,rowIds); - List childList=SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper); + QueryWrapper queryChildWrapper = new QueryWrapper<>(); + List rowIds = notNullRowIdList.stream().filter(u -> ObjectUtil.isNotNull(u.getRowId()) && u.getRowId() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); + if (CollUtil.isEmpty(rowIds)) { + return; + } + queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId, rowIds); + List childList = SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper); // 数据不存在异常的情况下,数据是不能被修改 List check1List = childList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) && Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); - for (BomNewEbomChildEntity childEntity: - check1List ) { - if(mapList.get(childEntity.getRowId()) ==null){ - continue; + if (CollUtil.isEmpty(check1List)) { + return; } - //忽略物料编码空的 - if(ObjectUtil.isNull(childEntity.getMaterialNo())){ + for (BomNewEbomChildEntity childEntity : + check1List) { + if (mapList.get(childEntity.getRowId()) == null) { + continue; + } + //忽略物料编码空的 + if (ObjectUtil.isNull(childEntity.getMaterialNo())) { continue; } - //检查物料id是否被修改,根据情况还可加入其他条件 - if(!mapList.get(childEntity.getRowId()).getMaterialNo().equals(childEntity.getMaterialNo())){ - throw new NflgBusinessException(STATE.Error,StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以修改 ", childEntity.getMaterialNo())); - } + //检查物料id是否被修改,根据情况还可加入其他条件 + if (!mapList.get(childEntity.getRowId()).getMaterialNo().equals(childEntity.getMaterialNo())) { + throw new NflgBusinessException(STATE.Error, StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以修改 ", childEntity.getMaterialNo())); + } } } - - public void handleBom(BomNewEBomParentEditDTO dto) { checkDataRule(dto); //添加根节点数据 @@ -334,17 +335,17 @@ public class EBomEdit { //缺bom if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) { - checkHadBom(dto.getParent().getMaterialNo()); + checkHadBom(dto.getParent().getMaterialNo()); parentEntity = createParentBomInfo(dto.getParent()); - // dto.getParent().setBomRowId(dto.getParent().getRowId()); + // dto.getParent().setBomRowId(dto.getParent().getRowId()); dto.getDatas().forEach(k -> { k.setParentRowId(parentEntity.getRowId()); }); - // parentEntity.setEditStatus(dto.getOpType()); + // parentEntity.setEditStatus(dto.getOpType()); - }else{ + } else { parentEntity = Convert.convert(BomNewEbomParentEntity.class, dto.getParent()); parentEntity.setModifyTime(LocalDateTime.now()); } @@ -363,31 +364,31 @@ public class EBomEdit { } - public void nextVersion(){ + public void nextVersion() { - if(!isNewBom){ + if (!isNewBom) { return; } //缺bom,新建的bom 版本增加 //同一物料且存在一个 lastVersionIs=1 - if(ObjectUtil.isNotNull(getParentEntity().getLastVersionIs()) - && ObjectUtil.equal(getParentEntity().getLastVersionIs(),1)) { - QueryWrapper queryWrapper=new QueryWrapper<>(); + if (ObjectUtil.isNotNull(getParentEntity().getLastVersionIs()) + && ObjectUtil.equal(getParentEntity().getLastVersionIs(), 1)) { + QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda() + queryWrapper.lambda() .eq(BomNewEbomParentEntity::getMaterialNo, getParentEntity().getMaterialNo()) - .eq(BomNewEbomParentEntity::getLastVersionIs,1) - // .eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) + .eq(BomNewEbomParentEntity::getLastVersionIs, 1) + // .eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) .orderByDesc(BomNewEbomParentEntity::getCurrentVersion); - List oldParent=SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper); + List oldParent = SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper); - if(CollUtil.isNotEmpty(oldParent)){ + if (CollUtil.isNotEmpty(oldParent)) { // oldParent.setLastVersionIs(0); - BomNewEbomParentEntity lastParent=oldParent.get(0); - for (BomNewEbomParentEntity u: + BomNewEbomParentEntity lastParent = oldParent.get(0); + for (BomNewEbomParentEntity u : oldParent) { u.setLastVersionIs(0); - lastParent=u; + lastParent = u; } getParentEntity().setCurrentVersion(VersionUtil.getNextVersion(lastParent.getCurrentVersion())); SpringUtil.getBean(BomNewEbomParentService.class).updateBatchById(oldParent);