Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

This commit is contained in:
jing's 2024-01-03 17:48:30 +08:00
commit 5bed408ca7
6 changed files with 62 additions and 28 deletions

View File

@ -162,4 +162,6 @@ public class PBomApi extends BaseApi {
}

View File

@ -10,4 +10,7 @@ public class EBomConstant {
public static final String DESIGNER = "设计人员";
//工艺人员
public static final String TECHNICIAN = "工艺人员";
//EBOM 获取时初始化物料主数据信息是忽略的字段
public static final String[] EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT = {"material", "materialTexture", "projectType", "materialUnit"};
}

View File

@ -122,13 +122,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> data = new ArrayList<>();
data.addAll(parents);
data.addAll(childs);
materialMainService.intiMaterialInfo(data, "material", "materialTexture", "projectType");
materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
returnResult = handSeachToTree(parents, childs);
}
}
} else {
Page<BomNewEbomParentVO> result = this.getBaseMapper().getEBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserJob(), SessionUtil.getUserCode());
materialMainService.intiMaterialInfo(result.getRecords(), "material", "materialTexture", "projectType");
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
returnResult = result;
}
//动态判断异常
@ -267,7 +267,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(rowId);
List<BomNewEbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
//排除项目类别的赋值
materialMainService.intiMaterialInfo(parentChild, "material", "materialTexture", "projectType");
materialMainService.intiMaterialInfo(parentChild, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
if (CollUtil.isNotEmpty(parentChild)) {
List<String> materialNos = parentChild.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.nflg.product.bomnew.pojo.vo.MaterialMateVO;
import com.nflg.product.bomnew.service.MaterialMainService;
import org.apache.commons.lang.StringUtils;
import java.util.List;
import java.util.regex.Pattern;
@ -21,17 +22,31 @@ public class MaterialMateCache {
public MaterialMateVO findMaterialByNameOrmaterialTexture(String materialName, String materialTexture){
for (MaterialMateVO mate : materialMateList) {
StringBuilder namePatternRel= new StringBuilder();
String texturePatternRel= "";
String namePattern=mate.getMaterialName();
String texturePattern=StrUtil.replace(mate.getMaterialTexture(),"/","|") ;
List<String> namePatternItems = StrUtil.split(namePattern,'/');
for (String namePatternItem:namePatternItems) {
if(namePatternItem.startsWith("#")){
namePattern+= StrUtil.replace(namePattern,1,'#','$')+"|";
if(StrUtil.isNotBlank(namePatternItem)) {
if (namePatternItem.startsWith("#")) {
namePatternRel.append((StrUtil.isBlank(namePatternRel.toString())?"": "|" )+ namePatternItem.replace("#", "^"));
} else if (namePatternItem.endsWith("#")) {
namePatternRel.append((StrUtil.isBlank(namePatternRel.toString())?"": "|" )+ namePatternItem.replace("#", "$"));
} else {
namePatternRel.append((StrUtil.isBlank(namePatternRel.toString())?"": "|" )+ ".*" + namePatternItem + ".*");
}
}
namePattern+= StrUtil.replace(namePattern,0,'#','$')+"|";
}
Pattern p = Pattern.compile(namePattern);
Pattern p2 = Pattern.compile(texturePattern);
if(StrUtil.isNotBlank(mate.getMaterialTexture())) {
texturePatternRel = mate.getMaterialTexture().replace('/', '|');
}
Pattern p = Pattern.compile(namePatternRel.toString());
Pattern p2 = Pattern.compile(texturePatternRel);
if(p.matcher(materialName).find() && p2.matcher(StrUtil.isBlank(materialTexture)?"":materialTexture ).find()){
return mate;
}

View File

@ -80,7 +80,7 @@ public class CheckEBomException {
*/
public void initException() {
//初始化物料信息
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail);
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail,"projectType");
checkException();
@ -130,19 +130,19 @@ public class CheckEBomException {
* @param
*/
private void checkOther() {
List<CheckEBomExceptionDTO> checkEBomExceptionDTOS=new ArrayList<>();
// List<CheckEBomExceptionDTO> checkEBomExceptionDTOS=new ArrayList<>();
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
for (BomNewEbomParentVO parent : parents) {
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList());
if(CollUtil.isNotEmpty(child)){
child.forEach(u->{
CheckEBomExceptionDTO ent=new CheckEBomExceptionDTO();
ent.setRowId(u.getRowId());
ent.setParentMaterialNo(parent.getMaterialNo());
ent.setChildMaterialNo(u.getMaterialNo());
checkEBomExceptionDTOS.add(ent);
});
}
// if(CollUtil.isNotEmpty(child)){
// child.forEach(u->{
// CheckEBomExceptionDTO ent=new CheckEBomExceptionDTO();
// ent.setRowId(u.getRowId());
// ent.setParentMaterialNo(parent.getMaterialNo());
// ent.setChildMaterialNo(u.getMaterialNo());
// checkEBomExceptionDTOS.add(ent);
// });
// }
//是否存在重复物料
Map<String, List<BomNewEbomParentVO>> childMaterialMap = ListCommonUtil.listGroupMap(child, BomNewEbomParentVO::getMaterialNo);
for (String key : childMaterialMap.keySet()) {

View File

@ -79,8 +79,8 @@ public class OriginalBomToEBomConvert extends BaseConvert {
List<BomOriginalListVO> noMaterialNo = data.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
SpringUtil.getBean(MaterialMainService.class).initMaterialForDrawdingNo(noMaterialNo, BomOriginalListVO::getDrawingNo, BomOriginalListVO::setMaterialNo, BomOriginalListVO::setMaterialName);
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(ImmutableList.of(parent));
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(bomDetail);
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(ImmutableList.of(parent),"material", "materialTexture","materialName");
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(bomDetail, "material", "materialTexture","materialName");
SpringUtil.getBean(MaterialMainService.class).initShouldBomExist(bomDetail, BomOriginalListVO::getMaterialCategoryCode, BomOriginalListVO::setShouldBomExist, BomOriginalListVO::getMaterialGetType);
//处理父级
@ -111,12 +111,12 @@ public class OriginalBomToEBomConvert extends BaseConvert {
handlerCommonMaterialForReplace(parentEnt);
if (CollUtil.isNotEmpty(parentChild)) {
//合并相同编码的物料
// List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
Long parentRowId = buildEBomParent(parentEnt);
// buildEBomChild(parentChild, parentRowId);
handlerChild(parentEnt, parentChild);
// buildEBomChild(parentChild, parentRowId);
parentEnt.setEBomRowId(parentRowId);
handlerChild(parentEnt, mergeResult);
} else { //无子级
MaterialMateVO materialByRel = getMaterialByRel(parent.getMaterialName(), parent.getMaterialTexture());
@ -207,7 +207,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
//找到对应物料
BaseMaterialVO materialBaseInfo = getCommonMaterialByRel(childVo);
if (Objects.nonNull(materialBaseInfo)) {
if (Objects.nonNull(materialBaseInfo) && hasParent(childVo.getMaterialNo())) {
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
//存在旧版本
@ -233,6 +233,12 @@ public class OriginalBomToEBomConvert extends BaseConvert {
}
}
private boolean hasParent(String materialNo){
Map<String, BomNewEbomParentEntity> parentMap = ListCommonUtil.listToMap(this.eBomParentResult, BomNewEbomParentEntity::getMaterialNo);
return parentMap.containsKey(materialNo);
}
private void handlerCommonMaterialForReplace(BomOriginalListVO parentEntity) {
@ -280,8 +286,10 @@ public class OriginalBomToEBomConvert extends BaseConvert {
childEntity.setMaterialDesc(material.getMaterialDesc());
childEntity.setMaterialTexture(material.getMaterial());
childEntity.setUnitWeight(parent.getUnitWeight());
childEntity.setNum(new BigDecimal(parent.getNum()) );
childEntity.setNum(parent.getUnitWeight()) ;
childEntity.setCreatedBy(SessionUtil.getUserCode());
childEntity.setMaterialUnit("KG");
// this.eBomChildResult.add(childEntity);
return childEntity;
@ -353,6 +361,12 @@ public class OriginalBomToEBomConvert extends BaseConvert {
childEntity.setParentRowId(parentRowId);
childEntity.setIdentityNo(StrUtil.join("_", parentRowId.toString(), childEntity.getRowId()));
childEntity.setModifyTime(LocalDateTime.now());
//当为原材料时数量=总重 单位改为KG 图号=编码
if(StrUtil.isNotBlank(childEntity.getMaterialCategoryCode())&& childEntity.getMaterialCategoryCode().startsWith("10")){
childEntity.setNum(childEntity.getTotalWeight());
childEntity.setMaterialUnit("KG");
childEntity.setDrawingNo(childEntity.getMaterialNo());
}
this.eBomChildResult.add(childEntity);