1、变更影响
This commit is contained in:
parent
80bf577fb6
commit
a2cc8ee7ca
|
|
@ -116,6 +116,10 @@ public class BomNewEbomUpgradeChangeEntity implements Serializable {
|
|||
@ApiModelProperty(value = "虚拟包父级物料编码")
|
||||
private String virtualMaterialParentMaterialNo;
|
||||
|
||||
@TableField(value = "virtual_material_parent_material_no")
|
||||
@ApiModelProperty("工厂编码")
|
||||
private String facCode;
|
||||
|
||||
private static final long serialVersionUID = 862599074345253800L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,6 +123,13 @@ public class BomNewEbomVirtualPackageCompositionEntity implements Serializable {
|
|||
@ApiModelProperty(value = "虚拟包父级物料编码")
|
||||
private String virtualMaterialParentMaterialNo;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@TableField(value = "fac_code")
|
||||
@ApiModelProperty(value = "工厂编码--虚拟包工厂编码")
|
||||
private String facCode;
|
||||
|
||||
private static final long serialVersionUID = -50661114691989818L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
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.mapper.master.BomNewEbomUpdateDetailMapper;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomUpgradeChangeMapper;
|
||||
|
|
@ -77,7 +78,7 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
|
|||
for ( BomNewEbomUpgradeChangeEntity ent:upList) {
|
||||
|
||||
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)){
|
||||
|
||||
List<BomNewEbomParentVO> bomTree =ebomParentService.getFormalBomTree(ebom.getRowId());
|
||||
|
|
@ -86,8 +87,8 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
|
|||
parentBom.setChildBomRowId(ebom.getRowId());
|
||||
parentBom.setParentRowId(0L);
|
||||
bomTree.add(parentBom);
|
||||
ChangeImpactUpgrade updateImpact=new ChangeImpactUpgrade(parentBom, bomTree, ImmutableList.of("1001","1020"),ent.getMaterialNo());
|
||||
updateImpact.buildVMaterialPBom();
|
||||
ChangeImpactUpgrade updateImpact=new ChangeImpactUpgrade(parentBom, bomTree, ImmutableList.of(ent.getFacCode()),ent.getMaterialNo());
|
||||
updateImpact.convert();
|
||||
|
||||
if(CollUtil.isNotEmpty(updateImpact.getPBomParentResult())){
|
||||
pbomParentService.saveOrUpdateBatch(updateImpact.getPBomParentResult());
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.NumberUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
|
|
@ -25,41 +26,18 @@ import java.time.LocalDateTime;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ChangeImpactUpgrade {
|
||||
|
||||
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<>();
|
||||
|
||||
public class ChangeImpactUpgrade extends EBomToPbomBase {
|
||||
|
||||
//需升级虚拟包编码
|
||||
private String vMaterialNo;
|
||||
|
||||
|
||||
|
||||
|
||||
protected Set<String> hasBuildVNo = Sets.newHashSet();
|
||||
|
||||
public ChangeImpactUpgrade(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, String vMaterialNo) {
|
||||
this.parent = inParent;
|
||||
this.allBomDetail = inAllBomDetail;
|
||||
this.facCodes = inFacCodes;
|
||||
this.vMaterialNo = vMaterialNo;
|
||||
generateDrawingNo(allBomDetail, 0L, "");
|
||||
// generateDrawingNo(allBomDetail, 0L, "");
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -67,13 +45,13 @@ public class ChangeImpactUpgrade {
|
|||
/**
|
||||
* 构建虚拟包新版本-PBOM
|
||||
*/
|
||||
public void buildVMaterialPBom() {
|
||||
@Override
|
||||
public void convert() {
|
||||
liftingLayer();
|
||||
//找虚拟包-构建PBOM
|
||||
List<BomNewEbomParentVO> vMaterial = result.stream().filter(u -> u.getMaterialNo().equals(vMaterialNo)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(vMaterial)) {
|
||||
for (String facCode : facCodes) {
|
||||
|
||||
//虚拟包-子级
|
||||
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)) {
|
||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||
oldParent.setLastVersionIs(0);
|
||||
this.pBomParentResult.add(oldParent);
|
||||
}
|
||||
this.pBomParentResult.add(pBomParent);
|
||||
return pBomParent;
|
||||
|
|
@ -194,33 +175,7 @@ public class ChangeImpactUpgrade {
|
|||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提层汇总数量
|
||||
|
|
|
|||
|
|
@ -233,7 +233,8 @@ public abstract class EBomToPbomBase {
|
|||
liftingLayerDo(parent, null, null, ImmutableList.of());
|
||||
}
|
||||
|
||||
private List<Long> hasCupmVo=new ArrayList<>();
|
||||
private List<Long> hasCupmVo = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param parentVO 父项
|
||||
* @param directDeliveryVo 直发包
|
||||
|
|
@ -243,7 +244,7 @@ public abstract class EBomToPbomBase {
|
|||
List<BomNewEbomParentVO> firstLevelBoms = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parentVO.getBomRowId())).collect(Collectors.toList());
|
||||
|
||||
for (BomNewEbomParentVO firstLevelBom : firstLevelBoms) {
|
||||
if(hasCupmVo.contains(firstLevelBom.getRowId())){
|
||||
if (hasCupmVo.contains(firstLevelBom.getRowId())) {
|
||||
firstLevelBom.getParentRowIds().clear();
|
||||
}
|
||||
//直发包
|
||||
|
|
@ -362,6 +363,7 @@ public abstract class EBomToPbomBase {
|
|||
packageCompositionEntity.setDeviseName(lastVirtualPackage.getDeviseName());
|
||||
packageCompositionEntity.setDeptName(lastVirtualPackage.getDeptName());
|
||||
packageCompositionEntity.setFromLiftingLayerState(0);
|
||||
packageCompositionEntity.setFacCode(lastVirtualPackage.getMaterialName().contains(EBomConstant.XIAN_TAO_FACTORY_Name_1020) ? "1020" : "1010");
|
||||
if (!lastVirtualPackage.getBomRowId().equals(vo.getParentRowId())) {
|
||||
packageCompositionEntity.setFromLiftingLayerState(1);
|
||||
}
|
||||
|
|
@ -373,28 +375,28 @@ public abstract class EBomToPbomBase {
|
|||
this.virtualPackageCompositionResult.add(packageCompositionEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更影响
|
||||
*/
|
||||
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());
|
||||
List<BomNewEbomParentVO> firstParent = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO vo : firstParent) {
|
||||
changeImpactDo(vo);
|
||||
if(parent.getVirtualPartType()<=0 && compareVirtualPackage(parent)){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
changeImpactDo(parent);
|
||||
}
|
||||
|
||||
private void changeImpactDo(BomNewEbomParentVO parentVO) {
|
||||
List<BomNewEbomParentVO> subVos = getAllSubInListIncludeSelf(parentVO, allBomDetail);
|
||||
//
|
||||
protected void changeImpactDo(BomNewEbomParentVO parentVO) {
|
||||
|
||||
List<BomNewEbomParentVO> subVosParent = subVos.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO vo : subVosParent) {
|
||||
if (compareVirtualPackage(vo)) {
|
||||
break;
|
||||
List<BomNewEbomParentVO> firstLevelBoms = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parentVO.getBomRowId())).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO firstLevelBom : firstLevelBoms) {
|
||||
|
||||
if(firstLevelBom.getBomRowId()>0) {
|
||||
if(firstLevelBom.getVirtualPartType()<=0 && compareVirtualPackage(firstLevelBom)){
|
||||
break;
|
||||
}
|
||||
changeImpactDo(firstLevelBom);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Boolean compareVirtualPackage(BomNewEbomParentVO vo) {
|
||||
|
|
@ -476,6 +478,7 @@ public abstract class EBomToPbomBase {
|
|||
changeEntity.setRelMaterialDesc(vo.getMaterialDesc());
|
||||
changeEntity.setStatus(0);
|
||||
changeEntity.setUpdatedTime(LocalDateTime.now());
|
||||
changeEntity.setFacCode(v.getFacCode());
|
||||
changeEntity.setVirtualMaterialParentMaterialNo(v.getVirtualMaterialParentMaterialNo());
|
||||
upgradeChangeResult.add(changeEntity);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@
|
|||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="virtual_material_parent_material_no" property="virtualMaterialParentMaterialNo" jdbcType="VARCHAR"/>
|
||||
<result column="fac_code" property="facCode" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
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>
|
||||
|
||||
<delete id="delByVNo">
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@
|
|||
<result column="from_lifting_layer_state" property="fromLiftingLayerState" jdbcType="INTEGER"/>
|
||||
<result column="current_version" property="currentVersion" jdbcType="VARCHAR" />
|
||||
<result column="virtual_material_parent_material_no" property="virtualMaterialParentMaterialNo" jdbcType="VARCHAR" />
|
||||
<result column="fac_code" property="facCode" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
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>
|
||||
|
||||
<delete id="delByVnoAndParentNo">
|
||||
|
|
|
|||
Loading…
Reference in New Issue