pbom-发布,只变化T项时,直接更新T项

This commit is contained in:
大米 2024-09-04 11:08:52 +08:00
parent 6ec9c55415
commit 195fff751f
1 changed files with 28 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package com.nflg.product.bomnew.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
@ -1216,6 +1217,33 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
if(oldChildSet0.equals(newChildSet0)){
newPBom.setStatus(PBomStatusEnum.PUBLISH.getValue());
newPBom.setDelIs(1);
//当T项外都一致时直接更新T项
List<BomNewPbomParentVO> oldBomT = oldBomDetail.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
//新T项
List<BomNewPbomParentVO> newBomT = newChildren.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
Set<String> oldTSet = oldBomT.stream().map(BomNewPbomParentVO::getMaterialNoAndNumAndProjectType).collect(Collectors.toSet());
Set<String> newTSet = newBomT.stream().map(BomNewPbomParentVO::getMaterialNoAndNumAndProjectType).collect(Collectors.toSet());
if(CollUtil.isNotEmpty(newBomT) && !newTSet.equals(oldTSet)){
if (CollUtil.isNotEmpty(oldBomT)) {
List<Long> bomRowIdsForT = oldBomT.stream().map(u -> u.getRowId()).collect(Collectors.toList());
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteBatchIds(bomRowIdsForT);
}
List<BomNewPbomChildEntity> tNewChildren=new ArrayList<>();
for (BomNewPbomParentVO netT : newBomT) {
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
BeanUtil.copyProperties(netT, childEnt);
childEnt.setRowId(IdWorker.getId());
childEnt.setParentRowId(oldParent.getRowId());
childEnt.setFacCode(oldParent.getFacCode());
childEnt.setIdentityNo(StrUtil.join("-", oldParent.getMaterialNo(), netT.getMaterialNo()));
tNewChildren.add(childEnt);
}
if (CollUtil.isNotEmpty(tNewChildren)) {
pbomChildService.saveBatch(tNewChildren);
}
}
}
else if(oldChildSet.equals(newChildSet)){
newPBom.setCurrentVersion( VersionUtil.getNextVersionForSmallVersion(oldParent.getCurrentVersion()));