Merge remote-tracking branch 'origin/master-checkBom-lhj1012'

This commit is contained in:
10001392 2024-10-14 17:56:01 +08:00
commit 7a22dbb141
6 changed files with 75 additions and 10 deletions

View File

@ -432,11 +432,17 @@ public class PBomApi extends BaseApi {
@GetMapping("checkBomExist")
@ApiOperation("BOM完整性检查")
public ResultVO<List<String>> checkBomExist(@Valid @RequestParam("bomRowId") @NotNull Long bomRowId,
public ResultVO<List<CheckBomVO>> checkBomExist(@Valid @RequestParam("bomRowId") @NotNull Long bomRowId,
@Valid @RequestParam("type") @NotNull Integer type){
return ResultVO.success(bomNewPbomParentService.checkBomExist(bomRowId,type));
}
@PostMapping("checkBomExport")
@ApiOperation("BOM完整性检查结果导出")
public void checkBomExport(@Valid @RequestBody @NotNull List<CheckBomVO> messages
, HttpServletResponse response) throws IOException {
EecExcelUtil.export(response, messages, CheckBomVO.class, "缺BOM信息");
}
@PostMapping("checkException")
@ApiOperation("PBOM-数据异常检查")

View File

@ -13,4 +13,7 @@ public class OriginalConstant {
public static final String NO_BOM_VERSION="A-1";
public static final String DEFAULT_BOM_VERSION="A00";
//不需要有BOM的版本号 1040506070大类以及200201小类这些不需要BOM的物料版本号显示B00
public static final String NO_NEED_BOM = "B00";
}

View File

@ -0,0 +1,32 @@
package com.nflg.product.bomnew.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.ttzero.excel.annotation.ExcelColumn;
import java.io.Serializable;
/**
* packageName com.nflg.product.bomnew.pojo.vo
*
* @author luohj
* @className CheckBomVO
* @date 2024/10/12 0012
* @description BOM完整性检查
*/
@Data
@Accessors(chain = true)
public class CheckBomVO implements Serializable {
@ApiModelProperty(value = "路径")
@ExcelColumn("路径")
private String path;
@ApiModelProperty(value = "路径中最后一个BOM")
private String lastBom;
@ApiModelProperty(value = "图号")
@ExcelColumn("图号")
private String drawingNo;
}

View File

@ -443,7 +443,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setEditStatus(parent.getEditStatus());
child.setVirtualPackageIs(parent.getVirtualPackageIs());
child.setSuperMaterialStatus(parent.getSuperMaterialStatus());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
// 1040506070大类以及200201小类这些不需要BOM的物料版本号显示B00 by 10002327 241012
if(MaterialshouldBomExistUtil.checkNoNeedBom(child)){
child.setCurrentVersion(OriginalConstant.NO_NEED_BOM);
}else if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);

View File

@ -393,7 +393,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
child.setVirtualPackageIs(parent.getVirtualPackageIs());
child.setTechnologyUserCode(parent.getTechnologyUserCode());
child.setTechnologyUserName(parent.getTechnologyUserName());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
// 1040506070大类以及200201小类这些不需要BOM的物料版本号显示B00 by 10002327 241012
if(MaterialshouldBomExistUtil.checkNoNeedBom(child)){
child.setCurrentVersion(OriginalConstant.NO_NEED_BOM);
}else if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
@ -2025,17 +2028,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
* @param bomRowId
* @return
*/
public List<String> checkBomExist(Long bomRowId, Integer type){
List<String> rList = Lists.newArrayList();
public List<CheckBomVO> checkBomExist(Long bomRowId, Integer type){
List<CheckBomVO> checkBomList = Lists.newArrayList();
BomNewPbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(parent == null).throwMessage("该BOM不存在" + bomRowId);
checkChild(rList,parent,type,1,parent.getMaterialNo());
return rList;
checkChild(checkBomList,parent,type,1,parent.getMaterialNo());
return checkBomList;
}
private void checkChild(List<String> rList,BomNewPbomParentEntity parent, Integer type,int currLevel,String currNos){
private void checkChild(List<CheckBomVO> checkBomList ,BomNewPbomParentEntity parent, Integer type,int currLevel,String currNos){
List<BomNewPbomParentVO> cList = getChild(parent,type);
List<Long> bomRowIdList = cList.stream().filter(c -> c.getBomRowId() > 0).map(BomNewPbomParentVO::getBomRowId).distinct().collect(Collectors.toList());
List<BomNewPbomParentEntity> pList = Lists.newArrayList();
@ -2049,12 +2052,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
AtomicInteger finalCurrLevel = new AtomicInteger(currLevel);
cList.forEach(c -> {
if(StrUtil.equalsIgnoreCase(OriginalConstant.NO_BOM_VERSION,c.getCurrentVersion())){
rList.add(currNos + " > " + c.getMaterialNo());
//rList.add(currNos + " > " + c.getMaterialNo());
CheckBomVO checkBomVO = new CheckBomVO();
checkBomVO.setPath(currNos + " > " + c.getMaterialNo());
checkBomVO.setLastBom(c.getMaterialNo());
checkBomVO.setDrawingNo(c.getDrawingNo());
checkBomList.add(checkBomVO);
}
//不为空则进行递归 currLevel < 200 不再递归判断为死循环
if(finalPMap.get(c.getBomRowId()) != null && currLevel < 200){
finalCurrLevel.getAndIncrement();
checkChild(rList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo());
checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo());
}
});

View File

@ -7,6 +7,7 @@ import com.nflg.product.bomnew.constant.OriginalConstant;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import java.util.List;
import java.util.Objects;
/**
* 判断物料是否应该有BOM
@ -36,4 +37,16 @@ public class MaterialshouldBomExistUtil {
(materialCategoryCode.startsWith("20") && MaterialGetEnum.developing.equalsValue(materialGetType)));
}
public static boolean checkNoNeedBom(BaseMaterialVO material){
//1040506070大类以及200201小类这些不需要BOM的物料版本号显示B00 by 10002327 241012
return material != null && StrUtil.isNotBlank(material.getMaterialCategoryCode())
&& (material.getMaterialCategoryCode().startsWith("10") ||
material.getMaterialCategoryCode().startsWith("40") ||
material.getMaterialCategoryCode().startsWith("50") ||
material.getMaterialCategoryCode().startsWith("60") ||
material.getMaterialCategoryCode().startsWith("70") ||
Objects.equals("200201",material.getMaterialCategoryCode())
);
}
}