1、变更影响

This commit is contained in:
大米 2024-06-27 18:11:44 +08:00
parent 80bf577fb6
commit a2cc8ee7ca
7 changed files with 48 additions and 76 deletions

View File

@ -116,6 +116,10 @@ public class BomNewEbomUpgradeChangeEntity implements Serializable {
@ApiModelProperty(value = "虚拟包父级物料编码") @ApiModelProperty(value = "虚拟包父级物料编码")
private String virtualMaterialParentMaterialNo; private String virtualMaterialParentMaterialNo;
@TableField(value = "virtual_material_parent_material_no")
@ApiModelProperty("工厂编码")
private String facCode;
private static final long serialVersionUID = 862599074345253800L; private static final long serialVersionUID = 862599074345253800L;
} }

View File

@ -123,6 +123,13 @@ public class BomNewEbomVirtualPackageCompositionEntity implements Serializable {
@ApiModelProperty(value = "虚拟包父级物料编码") @ApiModelProperty(value = "虚拟包父级物料编码")
private String virtualMaterialParentMaterialNo; private String virtualMaterialParentMaterialNo;
/**
* 版本号
*/
@TableField(value = "fac_code")
@ApiModelProperty(value = "工厂编码--虚拟包工厂编码")
private String facCode;
private static final long serialVersionUID = -50661114691989818L; private static final long serialVersionUID = -50661114691989818L;
} }

View File

@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.nflg.product.bomnew.constant.ConvertToPBomModelEnum; import com.nflg.product.bomnew.constant.ConvertToPBomModelEnum;
import com.nflg.product.bomnew.constant.EBomStatusEnum;
import com.nflg.product.bomnew.constant.PBomStatusEnum; import com.nflg.product.bomnew.constant.PBomStatusEnum;
import com.nflg.product.bomnew.mapper.master.BomNewEbomUpdateDetailMapper; import com.nflg.product.bomnew.mapper.master.BomNewEbomUpdateDetailMapper;
import com.nflg.product.bomnew.mapper.master.BomNewEbomUpgradeChangeMapper; import com.nflg.product.bomnew.mapper.master.BomNewEbomUpgradeChangeMapper;
@ -77,7 +78,7 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
for ( BomNewEbomUpgradeChangeEntity ent:upList) { for ( BomNewEbomUpgradeChangeEntity ent:upList) {
BomNewEbomParentEntity ebom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, ent.getVirtualMaterialParentMaterialNo()) BomNewEbomParentEntity ebom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, ent.getVirtualMaterialParentMaterialNo())
.eq(BomNewEbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()).last(" order by current_version desc limit 1").one(); .eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).last(" order by current_version desc limit 1").one();
if(Objects.isNull(ebom)){ if(Objects.isNull(ebom)){
List<BomNewEbomParentVO> bomTree =ebomParentService.getFormalBomTree(ebom.getRowId()); List<BomNewEbomParentVO> bomTree =ebomParentService.getFormalBomTree(ebom.getRowId());
@ -86,8 +87,8 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
parentBom.setChildBomRowId(ebom.getRowId()); parentBom.setChildBomRowId(ebom.getRowId());
parentBom.setParentRowId(0L); parentBom.setParentRowId(0L);
bomTree.add(parentBom); bomTree.add(parentBom);
ChangeImpactUpgrade updateImpact=new ChangeImpactUpgrade(parentBom, bomTree, ImmutableList.of("1001","1020"),ent.getMaterialNo()); ChangeImpactUpgrade updateImpact=new ChangeImpactUpgrade(parentBom, bomTree, ImmutableList.of(ent.getFacCode()),ent.getMaterialNo());
updateImpact.buildVMaterialPBom(); updateImpact.convert();
if(CollUtil.isNotEmpty(updateImpact.getPBomParentResult())){ if(CollUtil.isNotEmpty(updateImpact.getPBomParentResult())){
pbomParentService.saveOrUpdateBatch(updateImpact.getPBomParentResult()); pbomParentService.saveOrUpdateBatch(updateImpact.getPBomParentResult());

View File

@ -6,6 +6,7 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.conmon.util.SessionUtil;
@ -25,41 +26,18 @@ import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ChangeImpactUpgrade { public class ChangeImpactUpgrade extends EBomToPbomBase {
protected BomNewEbomParentVO parent;
@ApiModelProperty("转换模式0-常规 1-覆盖")
protected ConvertToPBomModelEnum convertMode;
//工厂编码列表
private List<String> facCodes;
private List<BomNewEbomParentVO> allBomDetail;
private List<BomNewEbomParentVO> result = new ArrayList<>();
@Getter
private List<BomNewPbomParentEntity> pBomParentResult = new ArrayList<>();
@Getter
private List<BomNewPbomChildEntity> pBomChildResult = new ArrayList<>();
//需升级虚拟包编码 //需升级虚拟包编码
private String vMaterialNo; private String vMaterialNo;
protected Set<String> hasBuildVNo = Sets.newHashSet();
public ChangeImpactUpgrade(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, String vMaterialNo) { public ChangeImpactUpgrade(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, String vMaterialNo) {
this.parent = inParent; this.parent = inParent;
this.allBomDetail = inAllBomDetail; this.allBomDetail = inAllBomDetail;
this.facCodes = inFacCodes; this.facCodes = inFacCodes;
this.vMaterialNo = vMaterialNo; this.vMaterialNo = vMaterialNo;
generateDrawingNo(allBomDetail, 0L, ""); // generateDrawingNo(allBomDetail, 0L, "");
} }
@ -67,13 +45,13 @@ public class ChangeImpactUpgrade {
/** /**
* 构建虚拟包新版本-PBOM * 构建虚拟包新版本-PBOM
*/ */
public void buildVMaterialPBom() { @Override
public void convert() {
liftingLayer(); liftingLayer();
//找虚拟包-构建PBOM //找虚拟包-构建PBOM
List<BomNewEbomParentVO> vMaterial = result.stream().filter(u -> u.getMaterialNo().equals(vMaterialNo)).collect(Collectors.toList()); List<BomNewEbomParentVO> vMaterial = result.stream().filter(u -> u.getMaterialNo().equals(vMaterialNo)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(vMaterial)) { if (CollUtil.isNotEmpty(vMaterial)) {
for (String facCode : facCodes) { for (String facCode : facCodes) {
//虚拟包-子级 //虚拟包-子级
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vMaterial.get(0).getBomRowId())).collect(Collectors.toList()); List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vMaterial.get(0).getBomRowId())).collect(Collectors.toList());
@ -103,6 +81,8 @@ public class ChangeImpactUpgrade {
} }
/** /**
* 合并子级 * 合并子级
* *
@ -182,6 +162,7 @@ public class ChangeImpactUpgrade {
if (Objects.nonNull(oldParent)) { if (Objects.nonNull(oldParent)) {
oldParent.setExpireEndTime(LocalDateTime.now()); oldParent.setExpireEndTime(LocalDateTime.now());
oldParent.setLastVersionIs(0); oldParent.setLastVersionIs(0);
this.pBomParentResult.add(oldParent);
} }
this.pBomParentResult.add(pBomParent); this.pBomParentResult.add(pBomParent);
return pBomParent; return pBomParent;
@ -194,33 +175,7 @@ public class ChangeImpactUpgrade {
* @param * @param
* @param * @param
*/ */
protected void liftingLayer() {
for (BomNewEbomParentVO vo : allBomDetail) {
if (StrUtil.isNotBlank(vo.getProjectType()) && vo.getProjectType().equals(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey())) {
BomNewEbomParentVO lastVirtualPackage = getLastVirtualPackage(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
if (Objects.nonNull(lastVirtualPackage) && lastVirtualPackage.getMaterialNo().equals(vMaterialNo)) {
liftingLayerSummary(lastVirtualPackage, vo);
vo.setSourceRowId(String.valueOf(vo.getParentRowId()));
vo.setSourceParentMaterialNo(getParentMaterialNo(vo.getBomRowId()));
vo.setParentRowId(lastVirtualPackage.getBomRowId());
result.add(vo);
}
continue;
}
if (StrUtil.isNotBlank(vo.getProjectType()) && vo.getProjectType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey())) {
BomNewEbomParentVO lastVirtualPackage = getLastVirtualPackage(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
if (Objects.nonNull(lastVirtualPackage) && lastVirtualPackage.getMaterialNo().equals(vMaterialNo)) {
liftingLayerSummary(lastVirtualPackage, vo);
vo.setSourceRowId(String.valueOf(vo.getParentRowId()));
vo.setSourceParentMaterialNo(getParentMaterialNo(vo.getBomRowId()));
vo.setParentRowId(lastVirtualPackage.getBomRowId());
result.add(vo);
}
continue;
}
result.add(vo);
}
}
/** /**
* 提层汇总数量 * 提层汇总数量

View File

@ -234,6 +234,7 @@ public abstract class EBomToPbomBase {
} }
private List<Long> hasCupmVo = new ArrayList<>(); private List<Long> hasCupmVo = new ArrayList<>();
/** /**
* @param parentVO 父项 * @param parentVO 父项
* @param directDeliveryVo 直发包 * @param directDeliveryVo 直发包
@ -362,6 +363,7 @@ public abstract class EBomToPbomBase {
packageCompositionEntity.setDeviseName(lastVirtualPackage.getDeviseName()); packageCompositionEntity.setDeviseName(lastVirtualPackage.getDeviseName());
packageCompositionEntity.setDeptName(lastVirtualPackage.getDeptName()); packageCompositionEntity.setDeptName(lastVirtualPackage.getDeptName());
packageCompositionEntity.setFromLiftingLayerState(0); packageCompositionEntity.setFromLiftingLayerState(0);
packageCompositionEntity.setFacCode(lastVirtualPackage.getMaterialName().contains(EBomConstant.XIAN_TAO_FACTORY_Name_1020) ? "1020" : "1010");
if (!lastVirtualPackage.getBomRowId().equals(vo.getParentRowId())) { if (!lastVirtualPackage.getBomRowId().equals(vo.getParentRowId())) {
packageCompositionEntity.setFromLiftingLayerState(1); packageCompositionEntity.setFromLiftingLayerState(1);
} }
@ -373,28 +375,28 @@ public abstract class EBomToPbomBase {
this.virtualPackageCompositionResult.add(packageCompositionEntity); this.virtualPackageCompositionResult.add(packageCompositionEntity);
} }
/**
* 变更影响
*/
protected void changeImpact() { protected void changeImpact() {
// Set<String> vmaterialNo = allBomDetail.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(u.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(u.getVirtualPartType())).map(u -> u.getMaterialNo()).collect(Collectors.toSet()); if(parent.getVirtualPartType()<=0 && compareVirtualPackage(parent)){
List<BomNewEbomParentVO> firstParent = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList()); return;
for (BomNewEbomParentVO vo : firstParent) { }
changeImpactDo(vo); changeImpactDo(parent);
} }
//
protected void changeImpactDo(BomNewEbomParentVO parentVO) {
} List<BomNewEbomParentVO> firstLevelBoms = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parentVO.getBomRowId())).collect(Collectors.toList());
for (BomNewEbomParentVO firstLevelBom : firstLevelBoms) {
private void changeImpactDo(BomNewEbomParentVO parentVO) { if(firstLevelBom.getBomRowId()>0) {
List<BomNewEbomParentVO> subVos = getAllSubInListIncludeSelf(parentVO, allBomDetail); if(firstLevelBom.getVirtualPartType()<=0 && compareVirtualPackage(firstLevelBom)){
List<BomNewEbomParentVO> subVosParent = subVos.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
for (BomNewEbomParentVO vo : subVosParent) {
if (compareVirtualPackage(vo)) {
break; break;
} }
changeImpactDo(firstLevelBom);
} }
}
} }
private Boolean compareVirtualPackage(BomNewEbomParentVO vo) { private Boolean compareVirtualPackage(BomNewEbomParentVO vo) {
@ -476,6 +478,7 @@ public abstract class EBomToPbomBase {
changeEntity.setRelMaterialDesc(vo.getMaterialDesc()); changeEntity.setRelMaterialDesc(vo.getMaterialDesc());
changeEntity.setStatus(0); changeEntity.setStatus(0);
changeEntity.setUpdatedTime(LocalDateTime.now()); changeEntity.setUpdatedTime(LocalDateTime.now());
changeEntity.setFacCode(v.getFacCode());
changeEntity.setVirtualMaterialParentMaterialNo(v.getVirtualMaterialParentMaterialNo()); changeEntity.setVirtualMaterialParentMaterialNo(v.getVirtualMaterialParentMaterialNo());
upgradeChangeResult.add(changeEntity); upgradeChangeResult.add(changeEntity);

View File

@ -17,12 +17,13 @@
<result column="status" property="status" jdbcType="INTEGER"/> <result column="status" property="status" jdbcType="INTEGER"/>
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/> <result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
<result column="virtual_material_parent_material_no" property="virtualMaterialParentMaterialNo" jdbcType="VARCHAR"/> <result column="virtual_material_parent_material_no" property="virtualMaterialParentMaterialNo" jdbcType="VARCHAR"/>
<result column="fac_code" property="facCode" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
row_id, material_no, version_old, version_new, material_name, drawing_no, devise_name, dept_name, row_id, material_no, version_old, version_new, material_name, drawing_no, devise_name, dept_name,
rel_material_no, rel_material_desc, status, updated_time,virtual_material_parent_material_no rel_material_no, rel_material_desc, status, updated_time,virtual_material_parent_material_no,fac_code
</sql> </sql>
<delete id="delByVNo"> <delete id="delByVNo">

View File

@ -19,12 +19,13 @@
<result column="from_lifting_layer_state" property="fromLiftingLayerState" jdbcType="INTEGER"/> <result column="from_lifting_layer_state" property="fromLiftingLayerState" jdbcType="INTEGER"/>
<result column="current_version" property="currentVersion" jdbcType="VARCHAR" /> <result column="current_version" property="currentVersion" jdbcType="VARCHAR" />
<result column="virtual_material_parent_material_no" property="virtualMaterialParentMaterialNo" jdbcType="VARCHAR" /> <result column="virtual_material_parent_material_no" property="virtualMaterialParentMaterialNo" jdbcType="VARCHAR" />
<result column="fac_code" property="facCode" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
row_id, virtual_package_material_no, parent_material_no, child_material_no, parent_full_path_num, row_id, virtual_package_material_no, parent_material_no, child_material_no, parent_full_path_num,
unit_weight, total_weight, num, updated_time,devise_name,dept_name, from_lifting_layer_state, current_version,virtual_material_parent_material_no unit_weight, total_weight, num, updated_time,devise_name,dept_name, from_lifting_layer_state, current_version,virtual_material_parent_material_no,fac_code
</sql> </sql>
<delete id="delByVnoAndParentNo"> <delete id="delByVnoAndParentNo">