From 0f795e71fd70841bb9aaac3321b5bedea2594ded Mon Sep 17 00:00:00 2001 From: jing's Date: Sun, 24 Dec 2023 19:42:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E7=89=A9=E6=96=99=E7=B1=BB=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 2 +- .../bomnew/pojo/vo/BaseMaterialVO.java | 5 + .../service/BomNewEbomParentService.java | 213 ++++++++++-------- .../mapper/master/MaterialMainMapper.xml | 2 +- 4 files changed, 120 insertions(+), 102 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 567dde20..7bc40ffd 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -274,7 +274,7 @@ public class EbomApi extends BaseApi { @ApiOperation("删除物料") public ResultVO deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{ bomNewEbomParentService.deleteBom(bomRowId); - bomNewEbomParentService.computeLevelNumAndRootState(); + return ResultVO.success(true); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java index dc6eb24e..4ddd503e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BaseMaterialVO.java @@ -55,4 +55,9 @@ public class BaseMaterialVO { @ApiModelProperty("物料大类别") private String relCategoryCode; + @ApiModelProperty("物料分类编码名称") + private String categoryName; + + + } 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 0bde840f..14407c31 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 @@ -203,6 +203,7 @@ public class BomNewEbomParentService extends ServiceImpl buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException { - List list= getBomTree(rowId); - BomNewEbomParentVO parentVO=Convert.convert(BomNewEbomParentVO.class,this.getById(rowId)); - if(parentVO!=null) { + List list = getBomTree(rowId); + BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, this.getById(rowId)); + if (parentVO != null) { parentVO.setBomRowId(rowId); parentVO.setParentRowId(0L); list.add(parentVO); } - return list; + return list; } @@ -466,7 +472,7 @@ public class BomNewEbomParentService extends ServiceImpl { try { this.getBaseMapper().updateRootState(); + ebomChildService.getBaseMapper().updateEBomMaterialUse(); this.compucteLevelNum(); } catch (Exception e) { @@ -600,7 +608,7 @@ public class BomNewEbomParentService extends ServiceImpl rowIds = dto.getRowIdList(); - // List bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds); + // List bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds); List bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list(); if (CollUtil.isEmpty(bomNewEbomParentEntityList)) { - // throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回"); + // throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回"); VUtils.isTure(true).throwMessage("下级BOM无法进行退回"); } if (rowIds.size() != bomNewEbomParentEntityList.size()) { - // throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回"); + // throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回"); VUtils.isTure(true).throwMessage("选择数据中包含有下级BOM无法进行退回"); } - List revertList=new ArrayList<>(); - for (Long bomRowId: - rowIds) { + List revertList = new ArrayList<>(); + for (Long bomRowId : + rowIds) { - List bomTreeList= buildBomTreeContainSelf(bomRowId); + List bomTreeList = buildBomTreeContainSelf(bomRowId); // // // @@ -734,9 +742,9 @@ public class BomNewEbomParentService extends ServiceImplu.getBomRowId()>0) - .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); + revertList.addAll(bomTreeList.stream() + .filter(u -> u.getBomRowId() > 0) + .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); } @@ -776,16 +784,16 @@ public class BomNewEbomParentService extends ServiceImpl checkStatus=CollectionUtil.toList(new Integer[]{ + List checkStatus = CollectionUtil.toList(new Integer[]{ EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(), @@ -797,16 +805,16 @@ public class BomNewEbomParentService extends ServiceImpl updateReviewIdList = new ArrayList<>(); - for (Long bomRowId: - rowIds) { - CheckEBomException checkEBomException=new CheckEBomException(bomRowId); + for (Long bomRowId : + rowIds) { + CheckEBomException checkEBomException = new CheckEBomException(bomRowId); //错误状态包含在checkStatus内有异常抛出 checkEBomException.checkContainExcept(checkStatus); //筛选bomRowId()>0 说明有bom,更新只到parent这层,无bom不需要更新 //设计人员只可以复核自己的物料,如果存在引用其他用户创建的物料时,不可以改变被引用物料的审核状态。 - updateReviewIdList.addAll( checkEBomException.getAllBomDetail().stream() - .filter(u->u.getBomRowId()>0 - && u.getCreatedBy().equals(dto.getUserCode())) + updateReviewIdList.addAll(checkEBomException.getAllBomDetail().stream() + .filter(u -> u.getBomRowId() > 0 + && u.getCreatedBy().equals(dto.getUserCode())) .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); } @@ -824,20 +832,21 @@ public class BomNewEbomParentService extends ServiceImpl childEntity=new ArrayList<>(); - dto.getRowIdList().forEach(rowid->{ - BomNewEbomChildEntity entity=new BomNewEbomChildEntity(); + List childEntity = new ArrayList<>(); + dto.getRowIdList().forEach(rowid -> { + BomNewEbomChildEntity entity = new BomNewEbomChildEntity(); entity.setRowId(rowid); entity.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue()); entity.setProjectType(dto.getProjectType()); @@ -850,15 +859,14 @@ public class BomNewEbomParentService extends ServiceImpl parentList = new ArrayList<>(); // parentList.add(parentVO); // materialMainService.intiMaterialInfo(parentList); @@ -898,7 +906,6 @@ public class BomNewEbomParentService extends ServiceImpl delBom = null; //设计 工艺,删录入 excel导入 - delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 - && (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) - || EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))) - .collect(Collectors.toList()); + delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 + && (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) + || EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))) + .collect(Collectors.toList()); - - - - //借用件不能删除,原始bom转换只能自己 - List obomList=null; + //借用件不能删除,原始bom转换只能自己 + List obomList = null; if (userRoleService.designer()) { - obomList=bomTree.stream().filter(u -> u.getBomRowId() > 0 + obomList = bomTree.stream().filter(u -> u.getBomRowId() > 0 && (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue()) - &&u.getCreatedBy().equals(SessionUtil.getUserCode()) - )) + && u.getCreatedBy().equals(SessionUtil.getUserCode()) + )) .collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(obomList)){ + if (CollectionUtil.isNotEmpty(obomList)) { delBom.addAll(obomList); } } @@ -969,16 +974,20 @@ public class BomNewEbomParentService extends ServiceImpl rowIds=obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(obomList)) { + List rowIds = obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList()); SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds); } - return true; } @@ -994,25 +1003,25 @@ public class BomNewEbomParentService extends ServiceImpl * 1. */ public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { @@ -1020,7 +1029,7 @@ public class BomNewEbomParentService extends ServiceImpl checkStatus=CollectionUtil.toList(new Integer[]{ + List checkStatus = CollectionUtil.toList(new Integer[]{ EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(), EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(), @@ -1032,67 +1041,71 @@ public class BomNewEbomParentService extends ServiceImpl allBom =Convert.convert(new TypeReference>() { - },eBomEdit.childEntities); + List allBom = Convert.convert(new TypeReference>() { + }, eBomEdit.childEntities); - if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){ - allBom.add(Convert.convert(BomNewEbomParentVO.class,eBomEdit.parentEntities.get(0))); + if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { + allBom.add(Convert.convert(BomNewEbomParentVO.class, eBomEdit.parentEntities.get(0))); } CheckEBomException checkEBomException = new CheckEBomException(allBom); checkEBomException.checkContainExcept(checkStatus); - if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { this.saveOrUpdateBatch(eBomEdit.parentEntities); + } if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) { ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); + } if (dto.getParent() != null) { deleteBomChild(dto.getDelDatas()); } - + ebomChildService.getBaseMapper().updateEBomMaterialUse(); return true; } /** - * 1. 编辑页面的删除只是删除BOM的关联关系; - * 2. 删除规则: - * 1. 从原始Bom导入的数据,数据没有异常的情况下,用户不可以删除 - * 2. 用户可以直接删除,用户单击暂存或是提交时才会保存至数据库。 + * 1. 编辑页面的删除只是删除BOM的关联关系; + * 2. 删除规则: + * 1. 从原始Bom导入的数据,数据没有异常的情况下,用户不可以删除 + * 2. 用户可以直接删除,用户单击暂存或是提交时才会保存至数据库。 */ - private void deleteBomChild(List delList){ + private void deleteBomChild(List delList) { - List delTagList=new ArrayList<>(); + List delTagList = new ArrayList<>(); //原始bom不正常 - List s1List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_BOM.getValue(),u.getSource()) - &&!Objects.equals(u.getExceptionStatus(),EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(s1List)){ + List s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) + && !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(s1List)) { delTagList.addAll(s1List); } //手动创建 - List s2List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(),u.getSource() ) - || Objects.equals(EBomSourceEnum.FROM_MDM.getValue(),u.getSource())).collect(Collectors.toList()); + List s2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource()) + || Objects.equals(EBomSourceEnum.FROM_MDM.getValue(), u.getSource())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(s2List)){ + if (CollectionUtil.isNotEmpty(s2List)) { delTagList.addAll(s2List); } - if(CollectionUtil.isNotEmpty(delTagList)){ - List rowIdList = delTagList.stream().filter(u -> u.getRowId()!=null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); - ebomChildService.removeByIds(rowIdList); + if (CollectionUtil.isNotEmpty(delTagList)) { + List rowIdList = delTagList.stream().filter(u -> u.getRowId() != null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(rowIdList)) { + ebomChildService.removeByIds(rowIdList); + + + } } } - } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml index ab14af09..069af6ca 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/MaterialMainMapper.xml @@ -71,7 +71,7 @@