pbom-异常检查

This commit is contained in:
大米 2024-09-24 17:18:24 +08:00
parent 271015fcc2
commit 841c20dff8
4 changed files with 165 additions and 0 deletions

View File

@ -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<Boolean> checkException(@RequestParam("bomRowId") Long bomRowId, @ApiParam("pBomType:pbom类型 0- pBom工作表 1-pBOM正式表")@RequestParam("pBomType") Integer pBomType) {
bomNewPbomParentService.checkException(bomRowId,pBomType);
return ResultVO.success(true);
}
}

View File

@ -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

View File

@ -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<BomNewPbomParentMapper,
}
/**
* 获取正式版-bom
* @param rowId
* @param countLevelNum
* @return
*/
public List<BomNewPbomParentVO> getFormalAllBom(Long rowId, Integer countLevelNum) {
List<BomNewPbomParentVO> 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<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewPbomParentVO> result = submit.join();
return result.stream().distinct().collect(Collectors.toList());
}
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum, Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
AtomicInteger levelNum = new AtomicInteger(1);
@ -2004,5 +2023,27 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
/**
* PBOM-数据异常检查
* @param rowId
*/
public void checkException(Long rowId,Integer bomType){
BomNewPbomParentEntity parent = this.getById(rowId);
VUtils.isTure(parent==null).throwMessage("PBom不存在");
List<BomNewPbomParentVO> 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();
}
}

View File

@ -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<BomNewPbomParentVO> allBomDetail;
/**
* @param allBom 整颗BOM树包含跟节点
*/
public CheckPBomException(List<BomNewPbomParentVO> 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<BomNewPbomParentVO> 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<BomNewPbomParentVO> parentEnts = initExceptionParentDo(ImmutableList.of(vo));
while (CollUtil.isNotEmpty(parentEnts) ) {
parentEnts = initExceptionParentDo(parentEnts);
}
}
private List<BomNewPbomParentVO> initExceptionParentDo(List<BomNewPbomParentVO> vos) {
Set<Long> parentRowIds = vos.stream().filter(u->u.getParentRowId()>0).map(u -> u.getParentRowId()).collect(Collectors.toSet());
List<BomNewPbomParentVO> parents = allBomDetail.stream().filter(u ->parentRowIds.contains(u.getBomRowId())).collect(Collectors.toList());
parents.forEach(u->u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()));
return parents;
}
}