From 580655a0a86c2f1b32bf925717ced214504a6eee Mon Sep 17 00:00:00 2001 From: jing's Date: Sun, 24 Dec 2023 15:09:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=B0=83=E6=95=B4=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 16 +- .../constant/EBomExceptionStatusEnum.java | 16 ++ .../constant/ProjectTypeInputTypeEnum.java | 4 +- .../bomnew/pojo/dto/BomNewEBomRevertDTO.java | 5 +- .../service/BomNewEbomParentService.java | 270 +++++++++--------- .../domain/EBom/CheckEBomException.java | 66 ++++- .../bomnew/service/domain/EBom/EBomEdit.java | 9 +- 7 files changed, 220 insertions(+), 166 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 83beb01d..f67e90a2 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 @@ -190,11 +190,12 @@ public class EbomApi extends BaseApi { @PostMapping("revertDesign") @ApiOperation("退回到设计") - public ResultVO revertDesign(@RequestBody BomNewEBomRevertDTO dto) { + public ResultVO revertDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException { if (CollectionUtil.isEmpty(dto.getRowIdList())) { return ResultVO.error(STATE.ParamErr, "请选择要退回的数据"); } dto.setRevertUserName(SessionUtil.getUserName()); + dto.setUserCode(SessionUtil.getUserCode()); bomNewEbomParentService.revertDesign(dto); return ResultVO.success(true); @@ -203,14 +204,15 @@ public class EbomApi extends BaseApi { @PostMapping("reviewDesign") @ApiOperation("设计复核") - public ResultVO reviewDesign(@RequestBody BomNewEBomRevertDTO dto) { + public ResultVO reviewDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException { if (CollectionUtil.isEmpty(dto.getRowIdList())) { return ResultVO.error(STATE.ParamErr, "请选择要复核的数据"); } dto.setRevertUserName(SessionUtil.getUserName()); - return bomNewEbomParentService.designReview(dto); - + dto.setUserCode(SessionUtil.getUserCode()); + bomNewEbomParentService.designReview(dto); + return ResultVO.success(true); } @@ -252,8 +254,8 @@ public class EbomApi extends BaseApi { @GetMapping("delete") @ApiOperation("删除物料") - public ResultVO deleteMaterial(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{ - bomNewEbomParentService.deleteMaterial(bomRowId); + public ResultVO deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{ + bomNewEbomParentService.deleteBom(bomRowId); bomNewEbomParentService.computeLevelNumAndRootState(); return ResultVO.success(true); } @@ -273,7 +275,7 @@ public class EbomApi extends BaseApi { @PostMapping("submit") @ApiOperation("提交") - public ResultVO submit(@RequestBody BomNewEBomParentEditDTO dto) { + public ResultVO submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { return ResultVO.success(bomNewEbomParentService.submit(dto)); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomExceptionStatusEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomExceptionStatusEnum.java index 9efac418..fafab8cf 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomExceptionStatusEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomExceptionStatusEnum.java @@ -39,4 +39,20 @@ public enum EBomExceptionStatusEnum implements ValueEnum { private final Integer value; private final String description; + + public static EBomExceptionStatusEnum findEnumByCode(Integer code) { + for (EBomExceptionStatusEnum statusEnum : EBomExceptionStatusEnum.values()) { + if (statusEnum.getValue().equals(code)) { + + return statusEnum; + } + } + throw new IllegalArgumentException("code is invalid"); + } + + public static String code2description(Integer code) { + return findEnumByCode(code).getDescription(); + } + + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java index 9e0e5654..aeee5e2f 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java @@ -32,7 +32,9 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum { @AllArgsConstructor public enum ProjectTypeEnum implements ValueEnum { TYPE_Q("Q", "Q"), - TYPE_F("F", "F"); + TYPE_F("F", "F"), + TYPE_Z("Z", "Z"), + TYPE_L("L", "L"); private final String value; private final String description; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomRevertDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomRevertDTO.java index c3946094..9a415165 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomRevertDTO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomRevertDTO.java @@ -15,9 +15,12 @@ public class BomNewEBomRevertDTO { //退回人 + @ApiModelProperty("忽略不是必填") private String revertUserName; + @ApiModelProperty("忽略不是必填") + private String userCode; - @ApiModelProperty("行id列表") + @ApiModelProperty("必填,行id列表") private List rowIdList; } 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 44fd4826..3466278e 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 @@ -279,8 +279,16 @@ public class BomNewEbomParentService extends ServiceImpl buildBomTree(Long rowId) throws Exception { - return getBomTree(rowId); + public List buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException { + + 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; } @@ -559,7 +567,6 @@ public class BomNewEbomParentService extends ServiceImpl result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class); @@ -573,7 +580,13 @@ 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 waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList()); - List revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList()); - List pbomList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(waitList)) { - List materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); + List revertList=new ArrayList<>(); + for (Long bomRowId: + rowIds) { - throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList))); - } - if (CollUtil.isNotEmpty(revertList)) { - List materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); + List bomTreeList= buildBomTreeContainSelf(bomRowId); +// +// +// +// List waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList()); +// List revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList()); - throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList))); - } - if (pbomList.size() > 0) { - List materialNoList = pbomList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); + List pbomList = bomTreeList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList()); +// if (CollUtil.isNotEmpty(waitList)) { +// List materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); +// +// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList))); +// } +// if (CollUtil.isNotEmpty(revertList)) { +// List materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); +// +// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList))); +// } + if (pbomList.size() > 0) { + List materialNoList = pbomList.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList()); + throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM,无法退回设计", StrUtil.join(",", materialNoList))); - throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM,无法退回设计", StrUtil.join(",", materialNoList))); + } + + //忽略叶子节点 + revertList.addAll(bomTreeList.stream() + .filter(u->u.getBomRowId()>0) + .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); } //重新创建保存list 避免污染 List updateList = new ArrayList<>(); - bomNewEbomParentEntityList.forEach(item -> { + for (Long rowId : revertList) { BomNewEbomParentEntity entity = new BomNewEbomParentEntity(); - entity.setRowId(item.getRowId()); - entity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); + entity.setRowId(rowId); + entity.setEditStatus(EBomStatusEnum.RETURNED.getValue()); entity.setRevertTime(LocalDateTime.now()); entity.setRevertUserName(dto.getRevertUserName()); updateList.add(entity); - }); - + } if (!this.updateBatchById(updateList)) { throw new NflgBusinessException(STATE.Error, "退回设计失败"); @@ -707,144 +744,63 @@ public class BomNewEbomParentService extends ServiceImpl designReview(BomNewEBomRevertDTO dto) { + public Boolean designReview(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException { List rowIds = dto.getRowIdList(); - List bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds); + List bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list(); + if (CollUtil.isEmpty(bomNewEbomParentEntityList)) { - return ResultVO.error("下级BOM无法进行复核"); + // return ResultVO.error("下级BOM无法进行复核"); + VUtils.isTure(true).throwMessage("下级BOM无法进行复核"); } if (rowIds.size() != bomNewEbomParentEntityList.size()) { - - return ResultVO.error("选择数据中包含有下级BOM无法进行复核"); - } - - for (BomNewEbomParentEntity item : - bomNewEbomParentEntityList) { - - - if (item.getStatus().equals(EBomStatusEnum.CHECKED.getValue())) { - return ResultVO.error(StrUtil.format("{} 已复核过,不需重复复核", item.getMaterialNo())); - } - - if (item.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) { - return ResultVO.error("请调整数据后进行复核"); - } - - if (item.getNum().equals(EbomEditStatusEnum.HANDLER_CREATED.getValue())) { - return ResultVO.error("请先提交确认后进行复核"); - } - - - if (StrUtil.isEmpty(item.getMaterialNo()) || (item.getNum() == null || item.getNum().floatValue() == 0)) { - return ResultVO.error(EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription()); - } - - MaterialMainEntity entity = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, item.getMaterialNo()).one(); - - if (entity == null) { - return ResultVO.error("物料编码[" + item.getMaterialNo() + "]物料不存在"); - } - - if (Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_4) - || Objects.equals(entity.getMaterialState(), MaterialGetEnum.MaterialStateEnum.STATE_NO_5)) { - return ResultVO.error("物料编码[" + item.getMaterialNo() + "]冻结/完全弃用异常"); - } - - + VUtils.isTure(true).throwMessage("数据中包含有下级BOM无法进行复核"); + // return ResultVO.error("数据中包含有下级BOM无法进行复核"); } + List checkStatus=CollectionUtil.toList(new Integer[]{ + EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_6.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_7.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_8.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_9.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_10.getValue() + }); List updateReviewIdList = new ArrayList<>(); - //子bom检查 - for (BomNewEbomParentEntity item : - bomNewEbomParentEntityList) { - - List childBomList; - try { - childBomList = buildBomTree(item.getRowId()); - } catch (Exception e) { - return ResultVO.error("获取Bom数据失败"); - } - - - if (CollUtil.isNotEmpty(childBomList)) { - - for (BomNewEbomParentVO childBomItem : - childBomList) { - - - if (childBomItem.getNum().equals(EBomExceptionStatusEnum.INIT.getValue())) { - return ResultVO.error("请调整数据后进行复核"); - } - - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_2.getDescription())); - } - - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_3.getDescription())); - } - - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_4.getDescription())); - } - - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_6.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_6.getDescription())); - } - - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription())); - } - - - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_7.getDescription())); - } - - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_8.getDescription())); - } - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_9.getDescription())); - - } - if (childBomItem.getExceptionStatus().equals(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue())) { - return ResultVO.error(StrUtil.format("物料{} {}", childBomItem.getMaterialNo(), EBomExceptionStatusEnum.EXCEPT_NO_10.getDescription())); - - } - - - } - - - } - - updateReviewIdList.addAll(childBomList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); - + 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())) + .map(BomNewEbomParentVO::getRowId).collect(Collectors.toList())); } - //改变复核状态 - List updateReviewList = new ArrayList<>(); for (Long id : updateReviewIdList) { BomNewEbomParentEntity entity = new BomNewEbomParentEntity(); entity.setRowId(id); entity.setAuditTime(LocalDateTime.now()); entity.setAuditUserName(dto.getRevertUserName()); + entity.setStatus(EBomStatusEnum.CHECKED.getValue()); updateReviewList.add(entity); } + if (!this.updateBatchById(updateReviewList)) { throw new NflgBusinessException(STATE.Error, "复核失败"); } - - return ResultVO.success(true); - + return true; } @@ -878,6 +834,7 @@ public class BomNewEbomParentService extends ServiceImpl parentList = new ArrayList<>(); // parentList.add(parentVO); // materialMainService.intiMaterialInfo(parentList); @@ -926,12 +883,13 @@ public class BomNewEbomParentService extends ServiceImpl checkStatus=CollectionUtil.toList(new Integer[]{ + EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_4.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_6.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_7.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_8.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_9.getValue(), + EBomExceptionStatusEnum.EXCEPT_NO_10.getValue() + }); + + + List allBom =Convert.convert(new TypeReference>() { + },eBomEdit.childEntities); + + 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 (CollUtil.isNotEmpty(eBomEdit.childEntities)) { + if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) { ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); } + if (dto.getParent() != null) { if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java index 43a54c8b..969f6e75 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java @@ -1,18 +1,25 @@ package com.nflg.product.bomnew.service.domain.EBom; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; +import com.google.common.collect.ImmutableList; +import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum; import com.nflg.product.bomnew.constant.MaterialGetEnum; +import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; import com.nflg.product.bomnew.service.BomNewEbomParentService; import com.nflg.product.bomnew.service.MaterialMainService; import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.TreeUtils; +import com.nflg.product.bomnew.util.VUtils; import lombok.Getter; +import nflg.product.common.constant.STATE; import java.math.BigDecimal; import java.util.ArrayList; @@ -31,12 +38,14 @@ public class CheckEBomException { List allBomDetail ; public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException { - allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId); - BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId); - BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent); - convert.setBomRowId(convert.getRowId()); - convert.setParentRowId(0L); - allBomDetail.add(convert); +// allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId); +// BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId); +// BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent); +// convert.setBomRowId(convert.getRowId()); +// convert.setParentRowId(0L); +// allBomDetail.add(convert); + + allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId); } /** @@ -58,9 +67,14 @@ public class CheckEBomException { if(Objects.isNull(vo.getExceptionStatus())) { vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); } - if (StrUtil.isNotBlank(vo.getMaterialNo()) && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState()) || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) { + if (StrUtil.isNotBlank(vo.getMaterialNo()) + && (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState()) + || MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) { vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue()); - } else if (StrUtil.isBlank(vo.getMaterialNo()) || Objects.isNull(vo.getNum()) || (Objects.nonNull(vo.getNum()) && BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) { + } else if (StrUtil.isBlank(vo.getMaterialNo()) + || Objects.isNull(vo.getNum()) + || (Objects.nonNull(vo.getNum()) + && BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) { vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue()); } else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) { vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue()); @@ -106,15 +120,15 @@ public class CheckEBomException { } } - if ("Q".equals(parent.getProjectType())) { - List qList = child.stream().filter(u -> "Q".equals(u.getProjectType())).collect(Collectors.toList()); + if (ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.equals(parent.getProjectType())) { + List qList = child.stream().filter(u -> ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.equals(u.getProjectType())).collect(Collectors.toList()); if (CollUtil.isNotEmpty(qList)) { parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue()); qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue())); } } - if ("F".equals(parent.getProjectType())) { - List qList = child.stream().filter(u -> "F".equals(u.getProjectType())).collect(Collectors.toList()); + if (ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.equals(parent.getProjectType())) { + List qList = child.stream().filter(u -> ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.equals(u.getProjectType())).collect(Collectors.toList()); if (CollUtil.isNotEmpty(qList)) { parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue()); qList.forEach(u -> u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue())); @@ -138,4 +152,32 @@ public class CheckEBomException { } } + + + public void checkContainExcept(List codeList) throws NflgBusinessException { + + if(CollUtil.isEmpty(codeList))return; + + for (BomNewEbomParentVO item: + allBomDetail) { + //并集 寻找相同 + List list=CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList());; + + if(CollUtil.isNotEmpty(list)){ + + throw new NflgBusinessException(STATE.BusinessError, EBomExceptionStatusEnum.code2description(list.get(0))); + + } + + } + + + + } + + + + + + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java index f071d22a..ed40aacc 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java @@ -45,8 +45,6 @@ public class EBomEdit { BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) { - - BomNewEbomParentEntity parent = new BomNewEbomParentEntity(); BeanUtil.copyProperties(parent, vo); @@ -73,6 +71,7 @@ public class EBomEdit { parent.setBomExist(1); parent.setLastVersionIs(1); parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); + parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); if(StrUtil.isEmpty(parent.getProjectType())){ parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); } @@ -96,7 +95,6 @@ public class EBomEdit { List materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); - //检查物料编码是否在主数据中存在 List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); List effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); @@ -143,7 +141,10 @@ public class EBomEdit { child.setCreatedTime(LocalDateTime.now()); child.setCreatedBy(SessionUtil.getUserCode()); child.setSourceRowId(0l); - } + parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); + parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue()); + + } parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));