diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index 89ed62e8..568c4ed8 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -25,6 +25,7 @@ import com.nflg.product.bomnew.util.EecExcelUtil; import com.nflg.product.bomnew.util.VUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import nflg.product.common.vo.ResultVO; import org.apache.commons.compress.utils.Lists; import org.springframework.transaction.annotation.Transactional; @@ -439,4 +440,14 @@ public class PBomApi extends BaseApi { } + @GetMapping("checkException") + @ApiOperation("PBOM-数据异常检查") + @LogRecord(success = "PBom-BOM数据异常检查,操作结果:{{#_ret}}", bizNo = "{{#bomRowId.toString()}}", type = "PBom-数据异常检查") + public ResultVO checkException(@RequestParam("bomRowId") Long bomRowId, @ApiParam("pBomType:pbom类型: 0- pBom工作表 1-pBOM正式表")@RequestParam("pBomType") Integer pBomType) { + + bomNewPbomParentService.checkException(bomRowId,pBomType); + return ResultVO.success(true); + } + + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java index 8362e825..aa3dd655 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java @@ -338,6 +338,10 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable { //发布PBOM 时 ,对比Pbom已发布版是否一致,一致则不转PBOM正式,直接删除PBOM 草稿数据 private Integer delIs=0; + + @ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常 7=物料主数据不存在 8=项目类别为空 9=项目赋值异常(父级物料的项目类型为Q时,子级中不能存在项目类别为Q的物料) 10=项目赋值异常(当父级物料的项目类型为F时,子级中不能存在项目类型为F的物料) 11=未填写变更原因和技术通知单 12=数量需要用户确认 13=项目类型需要用户确认") + private Integer exceptionStatus; + private static final long serialVersionUID = 1L; @Override diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 2705b726..4fc69ac2 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -28,6 +28,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery; import com.nflg.product.bomnew.pojo.query.CopyPBomV2Query; import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery; import com.nflg.product.bomnew.pojo.vo.*; +import com.nflg.product.bomnew.service.domain.EBom.CheckPBomException; import com.nflg.product.bomnew.service.domain.PBom.*; import com.nflg.product.bomnew.service.domain.Sap; import com.nflg.product.bomnew.util.*; @@ -769,6 +770,24 @@ public class BomNewPbomParentService extends ServiceImpl getFormalAllBom(Long rowId, Integer countLevelNum) { + List bomDetail = this.getBaseMapper().getParentChild(rowId); + AtomicInteger levelNum = new AtomicInteger(1); + BomNewPbomParentEntity parent = this.getBaseMapper().selectById(rowId); + PBomFormalTreeTask detailTask = new PBomFormalTreeTask(bomDetail, countLevelNum, levelNum,parent.getFacCode()); + ForkJoinTask> submit = bomDetailPool.submit(detailTask); + + List result = submit.join(); + return result.stream().distinct().collect(Collectors.toList()); + + } + public List getAllBom(Long rowId, Integer countLevelNum, Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException { List bomDetail = this.getBaseMapper().getParentChild(rowId); AtomicInteger levelNum = new AtomicInteger(1); @@ -2004,5 +2023,27 @@ public class BomNewPbomParentService extends ServiceImpl allBom =new ArrayList<>(); + if(bomType==0){ + allBom= this.getAllBom(rowId, 0); + }else { + this.getFormalAllBom(rowId,0); + } + BomNewPbomParentVO convert = Convert.convert(BomNewPbomParentVO.class, parent); + convert.setBomRowId(convert.getRowId()); + convert.setParentRowId(0L); + allBom.add(convert); + CheckPBomException checkException=new CheckPBomException(allBom); + checkException.initException(); + + } + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckPBomException.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckPBomException.java new file mode 100644 index 00000000..dd76664d --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckPBomException.java @@ -0,0 +1,109 @@ +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.StrUtil; +import cn.hutool.extra.spring.SpringUtil; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Sets; +import com.nflg.product.base.core.exception.NflgBusinessException; +import com.nflg.product.bomnew.constant.*; +import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; +import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; +import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; +import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO; +import com.nflg.product.bomnew.service.BomNewEbomChildService; +import com.nflg.product.bomnew.service.BomNewEbomParentService; +import com.nflg.product.bomnew.service.MaterialMainService; +import com.nflg.product.bomnew.util.*; +import lombok.Getter; +import lombok.Setter; +import nflg.product.common.constant.STATE; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 检查BOM 异常 + */ +public class CheckPBomException { + + @Getter + List allBomDetail; + + + + + + /** + * @param allBom 整颗BOM树(包含跟节点) + */ + public CheckPBomException(List allBom) { + allBomDetail = allBom; + } + + /** + * 初始化异常 + */ + public void initException() { + //初始化物料信息 + SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); + + checkException(); + } + public void checkException() { + for (BomNewPbomParentVO vo : allBomDetail) { + 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()))) { + vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue()); + } + } + } + /** + * 黄色警号异常 + * + * @param + */ + public void initExceptionYellowWarn() { + Set exceptionItems = allBomDetail.stream().filter(u -> EBomExceptionStatusEnum.EXCEPT_NO_2.equals(u.getExceptionStatus())).collect(Collectors.toSet()); + for (BomNewPbomParentVO vo : exceptionItems) { + initExceptionParent(vo); + } + + } + + + /** + * 初始化上级警告 + * @param vo + * @return + */ + protected void initExceptionParent(BomNewPbomParentVO vo) { + + List parentEnts = initExceptionParentDo(ImmutableList.of(vo)); + + while (CollUtil.isNotEmpty(parentEnts) ) { + parentEnts = initExceptionParentDo(parentEnts); + } + + } + + private List initExceptionParentDo(List vos) { + Set parentRowIds = vos.stream().filter(u->u.getParentRowId()>0).map(u -> u.getParentRowId()).collect(Collectors.toSet()); + List parents = allBomDetail.stream().filter(u ->parentRowIds.contains(u.getBomRowId())).collect(Collectors.toList()); + parents.forEach(u->u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue())); + return parents; + } + + + + + + +}