BUG修复

This commit is contained in:
大米 2024-01-18 10:53:22 +08:00
parent 67824540e3
commit 36d810252f
3 changed files with 32 additions and 28 deletions

View File

@ -197,7 +197,7 @@ public class PBomApi extends BaseApi {
public ResultVO<Boolean> convertToMBom(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException { public ResultVO<Boolean> convertToMBom(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException {
BomNewPbomParentEntity parent = bomNewPbomParentService.getById(bomRowId); BomNewPbomParentEntity parent = bomNewPbomParentService.getById(bomRowId);
VUtils.isTure(!parent.getMaterialNo().startsWith("31")).throwMessage("只有31开头的物料才可以发布"); VUtils.isTure(!parent.getMaterialNo().startsWith("31")).throwMessage("只有31开头的物料才可以发布");
VUtils.isTure(parent.getStatus()> PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM才能生成MBom"); VUtils.isTure(parent.getStatus()< PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM才能生成MBom");
// //
VUtils.isTure(!parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)).throwMessage("只有1010工厂BOM才能进行分工厂"); VUtils.isTure(!parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)).throwMessage("只有1010工厂BOM才能进行分工厂");
return ResultVO.success(bomNewPbomParentService.convertToMBom(bomRowId)); return ResultVO.success(bomNewPbomParentService.convertToMBom(bomRowId));

View File

@ -681,12 +681,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, paramDTO.getBomRowIds()).list(); List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, paramDTO.getBomRowIds()).list();
List<String> notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList()); List<String> notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更"); VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更");
List<BomNewEbomParentEntity> parentResult = new ArrayList<>(); List<BomNewEbomParentEntity> parentResult = new ArrayList<>();
List<BomNewEbomChildEntity> childResult = new ArrayList<>(); List<BomNewEbomChildEntity> childResult = new ArrayList<>();
for (Long bomRowId : paramDTO.getBomRowIds()) { for (Long bomRowId : paramDTO.getBomRowIds()) {
BomNewEbomParentEntity parent = this.getById(bomRowId); BomNewEbomParentEntity parent = this.getById(bomRowId);
List<BomNewEbomParentEntity> existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
//含发布前版本则无需升级
if(CollUtil.isEmpty(existEnt)) {
List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list(); List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list();
BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); BomNewEbomParentEntity newParent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent, newParent); BeanUtil.copyProperties(parent, newParent);
newParent.setRowId(IdWorker.getId()); newParent.setRowId(IdWorker.getId());
@ -698,8 +701,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parent.setLastVersionIs(0); parent.setLastVersionIs(0);
parentResult.add(newParent); parentResult.add(newParent);
parentResult.add(parent); parentResult.add(parent);
for (BomNewEbomChildEntity childEnt : child) { for (BomNewEbomChildEntity childEnt : child) {
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
BeanUtil.copyProperties(childEnt, newChild); BeanUtil.copyProperties(childEnt, newChild);
@ -708,6 +709,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
childResult.add(newChild); childResult.add(newChild);
} }
} }
}
if (CollUtil.isNotEmpty(parentResult)) { if (CollUtil.isNotEmpty(parentResult)) {
this.saveOrUpdateBatch(parentResult); this.saveOrUpdateBatch(parentResult);

View File

@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.enums.BooleanEnum;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -556,16 +557,16 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空"); VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 0); List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 0,true);
materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list(); List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
StringBuilder relPattern = new StringBuilder(); StringBuilder relPattern = new StringBuilder();
List<BomNewPbomChildEntity> result = new ArrayList<>(); List<BomNewPbomChildEntity> result = new ArrayList<>();
for (BomNewPbomParentVO child : childrenVO) { for (BomNewPbomParentVO child : childrenVO) {
if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) { // if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) {
continue; // continue;
} // }
for (BomFactorySplitRuleEntity role : relList) { for (BomFactorySplitRuleEntity role : relList) {
Boolean match = true; Boolean match = true;
if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) { if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) {
@ -655,8 +656,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} }
private void setSubNodeFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child , String facCode){ private void setSubNodeFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child , String facCode){
String zero ="1"+ StrUtil.padAfter("0", parentVO.getLevelNum().toString().split(".")[1].length(), "0"); String[] numSplit = parentVO.getLevelNumber().toString().split(".");
BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), new BigDecimal(1).divide(NumberUtil.div ( new BigDecimal(1) , new BigDecimal(zero))) ); String zero ="1"+ StrUtil.padAfter("0", (numSplit.length>1? numSplit[1].length():0), "0");
BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(),(NumberUtil.div ( new BigDecimal(1) , new BigDecimal(zero))) );
List<BomNewPbomParentVO> subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList()); List<BomNewPbomParentVO> subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList());
for (BomNewPbomParentVO node : subNodes) { for (BomNewPbomParentVO node : subNodes) {
node.setProductionFactoryCode(facCode); node.setProductionFactoryCode(facCode);