feat: 如果导入的单位跟物料主数据单位不一致,则提示数据不一致异常

This commit is contained in:
曹鹏飞 2024-04-25 14:26:01 +08:00
parent b34beca4f2
commit 36e0e5c293
4 changed files with 33 additions and 22 deletions

View File

@ -626,14 +626,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public void checkBomException(List<BomNewEbomParentVO> list, List<Integer> unCheckList) {
CheckEBomException checkEBomException = new CheckEBomException(list);
checkEBomException.setUnCheckExcept(unCheckList);
checkEBomException.checkException();
//保存异常
saveException(checkEBomException);
}
// public void checkBomException(List<BomNewEbomParentVO> list, List<Integer> unCheckList) {
// CheckEBomException checkEBomException = new CheckEBomException(list);
// checkEBomException.setUnCheckExcept(unCheckList);
// checkEBomException.checkException();
//
// //保存异常
// saveException(checkEBomException);
// }
/**

View File

@ -19,6 +19,7 @@ import com.nflg.product.bomnew.util.VUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
@ -108,12 +109,14 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
}
}
public <T extends BaseMaterialVO> void intiMaterialInfo(List<T> data , String ... ignorePropertyList) {
public <T extends BaseMaterialVO> List<BaseMaterialVO> intiMaterialInfo(List<T> data, String... ignorePropertyList) {
List<String> materialNos = data.stream().map(BaseMaterialVO::getMaterialNo).filter(StrUtil::isNotBlank).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BaseMaterialVO> materialBaseInfos = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
intiMaterialInfo(data, materialBaseInfos, ignorePropertyList);
return materialBaseInfos;
}
return Collections.emptyList();
}
public <T extends BaseMaterialVO> void intiMaterialInfo(List<T> data ,List<BaseMaterialVO> materialBaseInfos, String ... ignorePropertyList) {

View File

@ -14,10 +14,7 @@ import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
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.BomLevelUtil;
import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.TreeUtils;
import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.*;
import lombok.Getter;
import lombok.Setter;
import nflg.product.common.constant.STATE;
@ -88,28 +85,27 @@ public class CheckEBomException {
*/
public void initException() {
//初始化物料信息
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
checkException();
checkException(materialBaseInfo);
}
public void initException(List<Integer> unCheckException) {
//初始化物料信息
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
this.unCheckExcept=unCheckException;
checkException();
checkException(materialBaseInfo);
}
public void initException(String... ignorePropertyList) {
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, ignorePropertyList);
checkException();
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, ignorePropertyList);
checkException(materialBaseInfo);
}
public void checkException() {
public void checkException(List<BaseMaterialVO> materialBaseInfo) {
for (BomNewEbomParentVO vo : allBomDetail) {
// if(Objects.isNull(vo.getExceptionStatus())) {
//忽略不检查的如14
@ -118,7 +114,10 @@ public class CheckEBomException {
&& unCheckExcept.contains(vo.getExceptionStatus())) {
continue;
}
BaseMaterialVO mainVO = materialBaseInfo.stream()
.filter(u -> StrUtil.equals(u.getMaterialNo(), vo.getMaterialNo()))
.findFirst()
.orElse(null);
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
// }
if (StrUtil.isNotBlank(vo.getMaterialNo())
@ -132,6 +131,9 @@ public class CheckEBomException {
} else if (StrUtil.isBlank(vo.getProjectType()) && !Objects.equals(vo.getRootIs(), 1)
&& !Objects.equals(vo.getUserRootIs(), 1) && !Objects.equals(vo.getRootIsForWaitReview(), 1)) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
} else if ((StrUtil.equals("KG", StringUtil.toUpperCase(vo.getMaterialUnit())) && !StrUtil.equals(StringUtil.toUpperCase(vo.getMaterialUnit()), "PC"))
|| (!Objects.isNull(mainVO) && !StrUtil.equals(vo.getMaterialUnit(), mainVO.getMaterialUnit()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_12.getValue());
} else if (StrUtil.isNotBlank(vo.getNoticeNums()) && EBomExceptionStatusEnum.EXCEPT_NO_11.equalsValue(vo.getExceptionStatus())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
}

View File

@ -1,5 +1,6 @@
package com.nflg.product.bomnew.util;
import cn.hutool.core.util.StrUtil;
import org.apache.commons.lang3.StringUtils;
/**
@ -134,4 +135,9 @@ public class StringUtil {
}
return count;
}
public static String toUpperCase(String str) {
if (StrUtil.isBlank(str)) return str;
return str.toUpperCase();
}
}