Merge branch 'refs/heads/feature/DM/nflg-bom' into feature/DM/nflg-bom-transition
This commit is contained in:
commit
63bc0d775a
|
|
@ -101,7 +101,7 @@ public class EbomApi extends BaseApi {
|
|||
|
||||
@PostMapping("updateChangeImpactVersion")
|
||||
@ApiOperation("变更影响-更新版本")
|
||||
public ResultVO<Boolean> updateChangeImpactVersion(@RequestBody List<Long> rowIds) {
|
||||
public ResultVO<Boolean> updateChangeImpactVersion(@RequestBody List<Long> rowIds) throws ExecutionException, InterruptedException {
|
||||
VUtils.isTure(CollUtil.isEmpty(rowIds)).throwMessage("请选择要更新版本的数据");
|
||||
upgradeChangeService.updateChangeImpactVersion(rowIds);
|
||||
return ResultVO.success(true);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
package com.nflg.product.bomnew.pojo.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_upgrade_change
|
||||
* t_bom_new_ebom_upgrade_change
|
||||
* ebom-变更影响
|
||||
*
|
||||
* @author makejava
|
||||
|
|
@ -19,94 +23,99 @@ import java.time.LocalDate;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewEbomUpgradeChangeEntity")
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewEbomUpgradeChangeEntity")
|
||||
@TableName(value = "t_bom_new_ebom_upgrade_change")
|
||||
public class BomNewEbomUpgradeChangeEntity implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 主键-行ID
|
||||
*/
|
||||
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键-行ID")
|
||||
private Long rowId;
|
||||
|
||||
|
||||
/**
|
||||
* 受影响的物料编码
|
||||
*/
|
||||
@TableField(value = "material_no")
|
||||
@ApiModelProperty(value = "受影响的物料编码")
|
||||
@TableField(value = "material_no")
|
||||
@ApiModelProperty(value = "受影响的物料编码")
|
||||
private String materialNo;
|
||||
|
||||
|
||||
/**
|
||||
* 修订版(旧)
|
||||
*/
|
||||
@TableField(value = "version_old")
|
||||
@ApiModelProperty(value = "修订版(旧)")
|
||||
@TableField(value = "version_old")
|
||||
@ApiModelProperty(value = "修订版(旧)")
|
||||
private String versionOld;
|
||||
|
||||
|
||||
/**
|
||||
* 修订版(新)
|
||||
*/
|
||||
@TableField(value = "version_new")
|
||||
@ApiModelProperty(value = "修订版(新)")
|
||||
@TableField(value = "version_new")
|
||||
@ApiModelProperty(value = "修订版(新)")
|
||||
private String versionNew;
|
||||
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "material_name")
|
||||
@ApiModelProperty(value = "名称")
|
||||
@TableField(value = "material_name")
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String materialName;
|
||||
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
@TableField(value = "drawing_no")
|
||||
@ApiModelProperty(value = "图号")
|
||||
@TableField(value = "drawing_no")
|
||||
@ApiModelProperty(value = "图号")
|
||||
private String drawingNo;
|
||||
|
||||
|
||||
/**
|
||||
* 设计人员
|
||||
*/
|
||||
@TableField(value = "devise_name")
|
||||
@ApiModelProperty(value = "设计人员")
|
||||
@TableField(value = "devise_name")
|
||||
@ApiModelProperty(value = "设计人员")
|
||||
private String deviseName;
|
||||
|
||||
|
||||
/**
|
||||
* 设计人员部门
|
||||
*/
|
||||
@TableField(value = "dept_name")
|
||||
@ApiModelProperty(value = "设计人员部门")
|
||||
@TableField(value = "dept_name")
|
||||
@ApiModelProperty(value = "设计人员部门")
|
||||
private String deptName;
|
||||
|
||||
|
||||
/**
|
||||
* 关联物料编码
|
||||
*/
|
||||
@TableField(value = "rel_material_no")
|
||||
@ApiModelProperty(value = "关联物料编码")
|
||||
@TableField(value = "rel_material_no")
|
||||
@ApiModelProperty(value = "关联物料编码")
|
||||
private String relMaterialNo;
|
||||
|
||||
|
||||
/**
|
||||
* 关联物料描述
|
||||
*/
|
||||
@TableField(value = "rel_material_desc")
|
||||
@ApiModelProperty(value = "关联物料描述")
|
||||
@TableField(value = "rel_material_desc")
|
||||
@ApiModelProperty(value = "关联物料描述")
|
||||
private String relMaterialDesc;
|
||||
|
||||
|
||||
/**
|
||||
* 状态:0-未升级处理 1-已升级处理
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
@ApiModelProperty(value = "状态:0-未升级处理 1-已升级处理")
|
||||
@TableField(value = "status")
|
||||
@ApiModelProperty(value = "状态:0-未升级处理 1-已升级处理")
|
||||
private Integer status;
|
||||
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField(value = "updated_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
|
||||
|
||||
@TableField(value = "virtual_material_parent_material_no")
|
||||
@ApiModelProperty(value = "虚拟包父级物料编码")
|
||||
private String virtualMaterialParentMaterialNo;
|
||||
|
||||
private static final long serialVersionUID = 862599074345253800L;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_virtual_package_composition
|
||||
* t_bom_new_ebom_virtual_package_composition
|
||||
* 虚拟包-提层项组成
|
||||
*
|
||||
* @author makejava
|
||||
|
|
@ -22,80 +22,107 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewEbomVirtualPackageCompositionEntity")
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewEbomVirtualPackageCompositionEntity")
|
||||
@TableName(value = "t_bom_new_ebom_virtual_package_composition")
|
||||
public class BomNewEbomVirtualPackageCompositionEntity implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 主键行ID
|
||||
*/
|
||||
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键行ID")
|
||||
private Long rowId;
|
||||
|
||||
|
||||
/**
|
||||
* 虚拟包物料编码
|
||||
*/
|
||||
@TableField(value = "virtual_package_material_no")
|
||||
@ApiModelProperty(value = "虚拟包物料编码")
|
||||
@TableField(value = "virtual_package_material_no")
|
||||
@ApiModelProperty(value = "虚拟包物料编码")
|
||||
private String virtualPackageMaterialNo;
|
||||
|
||||
|
||||
/**
|
||||
* 父级物料编码
|
||||
*/
|
||||
@TableField(value = "parent_material_no")
|
||||
@ApiModelProperty(value = "父级物料编码")
|
||||
@TableField(value = "parent_material_no")
|
||||
@ApiModelProperty(value = "父级物料编码")
|
||||
private String parentMaterialNo;
|
||||
|
||||
|
||||
/**
|
||||
* 子级物料编码
|
||||
*/
|
||||
@TableField(value = "child_material_no")
|
||||
@ApiModelProperty(value = "子级物料编码")
|
||||
@TableField(value = "child_material_no")
|
||||
@ApiModelProperty(value = "子级物料编码")
|
||||
private String childMaterialNo;
|
||||
|
||||
|
||||
/**
|
||||
* 全路径数量,从上到下。逗号隔开(不含本物料)
|
||||
*/
|
||||
@TableField(value = "parent_full_path_num")
|
||||
@ApiModelProperty(value = "全路径数量,从上到下。逗号隔开(不含本物料)")
|
||||
@TableField(value = "parent_full_path_num")
|
||||
@ApiModelProperty(value = "全路径数量,从上到下。逗号隔开(不含本物料)")
|
||||
private String parentFullPathNum;
|
||||
|
||||
|
||||
/**
|
||||
* 单重
|
||||
*/
|
||||
@TableField(value = "unit_weight")
|
||||
@ApiModelProperty(value = "单重")
|
||||
@TableField(value = "unit_weight")
|
||||
@ApiModelProperty(value = "单重")
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
@TableField(value = "total_weight")
|
||||
@ApiModelProperty(value = "总重")
|
||||
@TableField(value = "total_weight")
|
||||
@ApiModelProperty(value = "总重")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@TableField(value = "num")
|
||||
@ApiModelProperty(value = "数量")
|
||||
@TableField(value = "num")
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 子级物料项目类别
|
||||
*/
|
||||
@TableField(value = "project_type")
|
||||
@ApiModelProperty(value = "子级物料项目类别")
|
||||
@TableField(value = "project_type")
|
||||
@ApiModelProperty(value = "子级物料项目类别")
|
||||
private String projectType;
|
||||
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField(value = "updated_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
|
||||
@TableField(value = "devise_name")
|
||||
@ApiModelProperty(value = "虚拟包设计人员")
|
||||
private String deviseName;
|
||||
|
||||
@TableField(value = "dept_name")
|
||||
@ApiModelProperty(value = "虚拟包设计人员部门")
|
||||
private String deptName;
|
||||
|
||||
@TableField(value = "from_lifting_layer_state")
|
||||
@ApiModelProperty(value = "是否提层过来 0-否 1-是")
|
||||
private Integer fromLiftingLayerState=0;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@TableField(value = "current_version")
|
||||
@ApiModelProperty(value = "虚拟包版本号")
|
||||
private String currentVersion;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@TableField(value = "virtual_material_parent_material_no")
|
||||
@ApiModelProperty(value = "虚拟包父级物料编码")
|
||||
private String virtualMaterialParentMaterialNo;
|
||||
|
||||
private static final long serialVersionUID = -50661114691989818L;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,6 +272,10 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty(value = "设计维护部门名称")
|
||||
private String deptName;
|
||||
@ApiModelProperty(value = "创建人所属部门rowId")
|
||||
private Long deptRowId;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* bom树的高度
|
||||
|
|
|
|||
|
|
@ -883,15 +883,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
});
|
||||
//检查该版本是否已转换过该工厂的Pbom
|
||||
for (BomNewEbomParentEntity parent : parents){
|
||||
List<BomNewPbomParentEntity> list = pBomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo()).eq(BomNewPbomParentEntity::getCurrentVersion, parent.getCurrentVersion())
|
||||
.select(BomNewPbomParentEntity::getFacCode).list();
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
Set<String> dbExistsFac = list.stream().map(u -> u.getFacCode()).collect(Collectors.toSet());
|
||||
Set<String> checkResultFac = Sets.intersection(dbExistsFac, new HashSet<>(paramDto.getFacCodes()));
|
||||
VUtils.isTure(CollUtil.isNotEmpty(checkResultFac)).throwMessage("物料:"+parent.getMaterialNo()+"已经转换过"+ StrUtil.join(",", checkResultFac)+"工厂");
|
||||
}
|
||||
}
|
||||
// for (BomNewEbomParentEntity parent : parents){
|
||||
// List<BomNewPbomParentEntity> list = pBomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo()).eq(BomNewPbomParentEntity::getCurrentVersion, parent.getCurrentVersion())
|
||||
// .select(BomNewPbomParentEntity::getFacCode).list();
|
||||
// if(CollUtil.isNotEmpty(list)){
|
||||
// Set<String> dbExistsFac = list.stream().map(u -> u.getFacCode()).collect(Collectors.toSet());
|
||||
// Set<String> checkResultFac = Sets.intersection(dbExistsFac, new HashSet<>(paramDto.getFacCodes()));
|
||||
// VUtils.isTure(CollUtil.isNotEmpty(checkResultFac)).throwMessage("物料:"+parent.getMaterialNo()+"已经转换过"+ StrUtil.join(",", checkResultFac)+"工厂");
|
||||
// }
|
||||
// }
|
||||
|
||||
for (Long bomRowId : paramDto.getBomRowIds()) {
|
||||
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
|
||||
|
|
@ -920,6 +920,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
virtualPackageCompositionService.getBaseMapper().batchDelByVMaterialNos(vMaterialNos);
|
||||
virtualPackageCompositionService.saveBatch(eBomToPBom.getVirtualPackageCompositionResult());
|
||||
}
|
||||
//记录变更影响
|
||||
if(CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())){
|
||||
upgradeChangeService.saveBatch(eBomToPBom.getUpgradeChangeResult());
|
||||
}
|
||||
|
||||
//删除EBOM中和正式表BOM一致的数据
|
||||
List<BomNewEbomParentVO> delEBomParents = bomTree.stream().filter(u -> u.getHasChangeState().equals(1)).collect(Collectors.toList());
|
||||
|
|
@ -1972,7 +1976,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
eBomEdit.nextVersion();
|
||||
|
||||
this.saveOrUpdate(eBomEdit.getParentEntity());
|
||||
this.saveOrUpdate(eBomEdit.getParentEntity());
|
||||
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
|
||||
|
|
|
|||
|
|
@ -2,18 +2,23 @@ package com.nflg.product.bomnew.service;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.PBomStatusEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomUpdateDetailMapper;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomUpgradeChangeMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.*;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.UpdateImpact;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.*;
|
||||
import com.nflg.product.bomnew.util.EnumUtils;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
|
|
@ -22,10 +27,12 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
|
@ -41,11 +48,7 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
|
|||
|
||||
|
||||
|
||||
@Resource
|
||||
BomNewEbomUpdateDetailService updateDetailService;
|
||||
|
||||
@Resource
|
||||
BomNewEbomVirtualPackageCompositionService virtualPackageCompositionService;
|
||||
|
||||
@Resource
|
||||
BomNewPbomParentService pbomParentService;
|
||||
|
|
@ -53,6 +56,9 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
|
|||
@Resource
|
||||
BomNewPbomChildService pbomChildService;
|
||||
|
||||
@Resource
|
||||
BomNewEbomParentService ebomParentService;
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
|
|
@ -65,25 +71,39 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
|
|||
* 更新版本
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateChangeImpactVersion(List<Long> rowIds){
|
||||
public void updateChangeImpactVersion(List<Long> rowIds) throws ExecutionException, InterruptedException {
|
||||
List<BomNewEbomUpgradeChangeEntity> upList = this.getBaseMapper().selectBatchIds(rowIds);
|
||||
//
|
||||
for ( BomNewEbomUpgradeChangeEntity ent:upList) {
|
||||
UpdateImpact updateImpact=new UpdateImpact(ent);
|
||||
updateImpact.handlerImpact();
|
||||
|
||||
BomNewEbomParentEntity ebom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, ent.getVirtualMaterialParentMaterialNo())
|
||||
.eq(BomNewEbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()).last(" order by current_version desc limit 1").one();
|
||||
if(Objects.isNull(ebom)){
|
||||
|
||||
List<BomNewEbomParentVO> bomTree =ebomParentService.getFormalBomTree(ebom.getRowId());
|
||||
BomNewEbomParentVO parentBom = Convert.convert(BomNewEbomParentVO.class, ebom);
|
||||
parentBom.setBomRowId(ebom.getRowId());
|
||||
parentBom.setChildBomRowId(ebom.getRowId());
|
||||
parentBom.setParentRowId(0L);
|
||||
bomTree.add(parentBom);
|
||||
ChangeImpactUpgrade updateImpact=new ChangeImpactUpgrade(parentBom, bomTree, ImmutableList.of("1001","1020"),ent.getMaterialNo());
|
||||
updateImpact.buildVMaterialPBom();
|
||||
|
||||
if(CollUtil.isNotEmpty(updateImpact.getPBomParentResult())){
|
||||
pbomParentService.saveOrUpdateBatch(updateImpact.getPBomParentResult());
|
||||
}
|
||||
if(CollUtil.isNotEmpty(updateImpact.getPBomChildResult())){
|
||||
pbomChildService.saveOrUpdateBatch(updateImpact.getPBomChildResult());
|
||||
}
|
||||
ent.setStatus(1);
|
||||
ent.setUpdatedTime(LocalDateTime.now());
|
||||
this.save(ent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(CollUtil.isNotEmpty(updateImpact.getVirtualPBomParent())){
|
||||
pbomParentService.saveOrUpdateBatch(updateImpact.getVirtualPBomParent());
|
||||
}
|
||||
if(CollUtil.isNotEmpty(updateImpact.getVirtualPBomChildren())){
|
||||
pbomChildService.saveOrUpdateBatch(updateImpact.getVirtualPBomChildren());
|
||||
}
|
||||
if(CollUtil.isNotEmpty(updateImpact.getCompositionResult())){
|
||||
//先删除-后保存
|
||||
virtualPackageCompositionService.getBaseMapper().deleteByMap(ImmutableMap.of("virtual_package_material_no",ent.getMaterialNo(),"parent_material_no",ent.getRelMaterialNo()));
|
||||
virtualPackageCompositionService.saveOrUpdateBatch(updateImpact.getCompositionResult());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,331 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.*;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewPbomChildService;
|
||||
import com.nflg.product.bomnew.service.BomNewPbomParentService;
|
||||
import com.nflg.product.bomnew.util.BomLevelUtil;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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<>();
|
||||
|
||||
|
||||
//需升级虚拟包编码
|
||||
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, "");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建虚拟包新版本-PBOM
|
||||
*/
|
||||
public void buildVMaterialPBom() {
|
||||
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());
|
||||
|
||||
// 合并子级
|
||||
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
|
||||
|
||||
BomNewPbomParentEntity vParent = buildPBomParent(vMaterial.get(0), facCode,mergeChild);
|
||||
if(Objects.isNull(vParent)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(mergeChild)) {
|
||||
//合并子级
|
||||
for (BomNewEbomParentVO eb : mergeChild) {
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(eb, childEnt, "sourceRowId");
|
||||
childEnt.setRowId(IdWorker.getId());
|
||||
childEnt.setParentRowId(vParent.getRowId());
|
||||
childEnt.setFacCode(facCode);
|
||||
childEnt.setIdentityNo(StrUtil.join("-", vParent.getMaterialNo(), eb.getMaterialNo()));
|
||||
this.pBomChildResult.add(childEnt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并子级
|
||||
*
|
||||
* @param child
|
||||
* @return
|
||||
*/
|
||||
public List<BomNewEbomParentVO> mergeChild(List<BomNewEbomParentVO> child) {
|
||||
|
||||
List<BomNewEbomParentVO> result = child.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
|
||||
Map<String, List<BomNewEbomParentVO>> listMp = child.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getMaterialNo));
|
||||
|
||||
for (String key : listMp.keySet()) {
|
||||
List<BomNewEbomParentVO> voList = listMp.get(key);
|
||||
BomNewEbomParentVO ent = voList.get(0);
|
||||
ent.setNum(voList.stream().filter(u -> Objects.nonNull(u.getNum())).map(aa -> aa.getNum()).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
result.add(ent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建父
|
||||
*
|
||||
* @param parentVo
|
||||
* @return Pair<Integer, BomNewPbomParentEntity> key, 0-旧 1-新 value:pBomParent
|
||||
*/
|
||||
protected BomNewPbomParentEntity buildPBomParent(BomNewEbomParentVO parentVo, String facCode, List<BomNewEbomParentVO> newChild) {
|
||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
|
||||
.eq(BomNewPbomParentEntity::getMaterialNo, parentVo.getMaterialNo())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
|
||||
|
||||
if (Objects.isNull(oldParent) || !samePBomIs(oldParent.getRowId(), newChild)) {
|
||||
return null;
|
||||
}
|
||||
//pbom 处于工作表
|
||||
else if (Objects.nonNull(oldParent) && oldParent.getStatus() < EBomStatusEnum.PUBLISHED.getValue()) {
|
||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
|
||||
oldParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||
oldParent.setSourceRowId(parentVo.getRowId());
|
||||
oldParent.setCreatedTime(LocalDateTime.now());
|
||||
this.pBomParentResult.add(oldParent);
|
||||
return oldParent;
|
||||
|
||||
} else {
|
||||
|
||||
return buildParentEntity(parentVo, facCode, oldParent, VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//升级后是否和现有一致(不一致则升级)-主要是工厂-变更影响-可能涉及2个工厂
|
||||
private Boolean samePBomIs(Long parentRowId, List<BomNewEbomParentVO> newChild) {
|
||||
List<BomNewPbomChildEntity> oldPBomChild = SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, parentRowId).list();
|
||||
Set<String> oldChildSet = oldPBomChild.stream().map(u -> StrUtil.join("", u.getMaterialNo(), u.getNum(), u.getProjectType())).collect(Collectors.toSet());
|
||||
Set<String> newChildSet = newChild.stream().map(u -> StrUtil.join("", u.getMaterialNo(), u.getNum(), u.getProjectType())).collect(Collectors.toSet());
|
||||
return oldChildSet.equals(newChildSet);
|
||||
}
|
||||
|
||||
private BomNewPbomParentEntity buildParentEntity(BomNewEbomParentVO parentVo, String facCode, BomNewPbomParentEntity oldParent, String bomVersion) {
|
||||
BomNewPbomParentEntity pBomParent = new BomNewPbomParentEntity();
|
||||
BeanUtil.copyProperties(parentVo, pBomParent, "sourceRowId");
|
||||
pBomParent.setSourceRowId(parentVo.getBomRowId());
|
||||
pBomParent.setRowId(IdWorker.getId());
|
||||
pBomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||
pBomParent.setLastVersionIs(1);
|
||||
pBomParent.setFacCode(facCode);
|
||||
pBomParent.setTechnologyUserCode(SessionUtil.getUserCode());
|
||||
pBomParent.setTechnologyUserName(SessionUtil.getRealName());
|
||||
pBomParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
pBomParent.setCreatedTime(LocalDateTime.now());
|
||||
//版本=EBom版本
|
||||
pBomParent.setCurrentVersion(bomVersion);
|
||||
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
if (Objects.nonNull(oldParent)) {
|
||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||
oldParent.setLastVersionIs(0);
|
||||
}
|
||||
this.pBomParentResult.add(pBomParent);
|
||||
return pBomParent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提层
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提层汇总数量
|
||||
*
|
||||
* @param lastVirtualPackage 虚拟包
|
||||
* @param vo 提层项
|
||||
*/
|
||||
private void liftingLayerSummary(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo) {
|
||||
BigDecimal sum = vo.getNum();
|
||||
String parentLevelNo = BomLevelUtil.getParentLevelNo(vo.getLevelNo());
|
||||
|
||||
while (parentLevelNo.length() >= lastVirtualPackage.getLevelNo().length()) {
|
||||
String pNo = parentLevelNo;
|
||||
List<BomNewEbomParentVO> parentList = allBomDetail.stream().filter(u -> u.getLevelNo().equals(pNo)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(parentList)) {
|
||||
sum = NumberUtil.mul(sum, parentList.get(0).getNum());
|
||||
|
||||
|
||||
}
|
||||
parentLevelNo = BomLevelUtil.getParentLevelNo(parentLevelNo);
|
||||
|
||||
}
|
||||
vo.setNum(sum);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private BomNewEbomParentVO getLastVirtualPackage(BomNewEbomParentVO vo, VirtualPackageTypeEnum virtualPackageTypeEnum) {
|
||||
List<BomNewEbomParentVO> zhiFaList = allBomDetail.stream().filter(u -> vo.getLevelNumber().compareTo(u.getLevelNumber()) > 0 && virtualPackageTypeEnum.getVirtualPartType().equals(u.getVirtualPartType())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(zhiFaList)) {
|
||||
return Collections.max(zhiFaList, Comparator.comparing(BomNewEbomParentVO::getLevelNumber));
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private String getParentMaterialNo(Long parentRowId) {
|
||||
List<BomNewEbomParentVO> collect = allBomDetail.stream().filter(u -> u.getBomRowId().equals(parentRowId)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
return collect.get(0).getMaterialNo();
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成 层级号
|
||||
*
|
||||
* @param saveBomDetailParamDTO
|
||||
* @param bomRowID
|
||||
* @param parentDrawingNo
|
||||
*/
|
||||
public void generateDrawingNo(List<BomNewEbomParentVO> saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) {
|
||||
List<BomNewEbomParentVO> firstLevelBoms = saveBomDetailParamDTO.stream().filter(u -> u.getParentRowId().equals(bomRowID)).collect(Collectors.toList());
|
||||
String parentDrawingNoRe = StrUtil.isNotBlank(parentDrawingNo) ? parentDrawingNo : "";
|
||||
Integer gNo = 1;
|
||||
|
||||
String preAssemblyPackageLevelNo = StrUtil.isNotBlank(parentDrawingNoRe) ? StrUtil.join("-", parentDrawingNoRe, "1") : "1";
|
||||
for (BomNewEbomParentVO firstLevelBom : firstLevelBoms) {
|
||||
|
||||
if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getVirtualPartType().equals(firstLevelBom.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getVirtualPartType().equals(firstLevelBom.getVirtualPartType())) {
|
||||
firstLevelBom.setLevelNumber(levelToNum(preAssemblyPackageLevelNo));
|
||||
firstLevelBom.setLevelNo(preAssemblyPackageLevelNo);
|
||||
|
||||
} else {
|
||||
|
||||
String levelKey = StrUtil.isNotBlank(parentDrawingNoRe) ? StrUtil.join("-", parentDrawingNoRe, gNo.toString()) : gNo.toString();
|
||||
firstLevelBom.setLevelNumber(levelToNum(levelKey));
|
||||
firstLevelBom.setLevelNo(levelKey);
|
||||
gNo++;
|
||||
}
|
||||
generateDrawingNo(saveBomDetailParamDTO, firstLevelBom.getChildBomRowId(), firstLevelBom.getLevelNo());
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换层级号为数字
|
||||
*
|
||||
* @param strLevel
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal levelToNum(String strLevel) {
|
||||
if (StrUtil.isEmpty(strLevel)) {
|
||||
return null;
|
||||
}
|
||||
if (strLevel.indexOf('-') == -1) {
|
||||
return new BigDecimal(strLevel);
|
||||
}
|
||||
String[] fromArray = strLevel.split("-");
|
||||
String reuslt = "";
|
||||
for (int i = 0; i < fromArray.length; i++) {
|
||||
if (i == 0) {
|
||||
reuslt = fromArray[i] + '.';
|
||||
} else {
|
||||
reuslt += StrUtil.padPre(fromArray[i], 2, '0');
|
||||
}
|
||||
|
||||
}
|
||||
return new BigDecimal(reuslt);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -354,8 +354,10 @@ public class EBomEdit {
|
|||
if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) {
|
||||
|
||||
checkHadBom(dto.getParent().getMaterialNo());
|
||||
dto.getParent().setBomRowId(dto.getParent().getRowId());
|
||||
|
||||
parentEntity = createParentBomInfo(dto.getParent());
|
||||
// dto.getParent().setBomRowId(dto.getParent().getRowId());
|
||||
|
||||
dto.getDatas().forEach(k -> {
|
||||
k.setParentRowId(parentEntity.getRowId());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
|
||||
//效验数据是否OK
|
||||
check();
|
||||
|
||||
//变更影响
|
||||
changeImpact();
|
||||
//bom 提层
|
||||
liftingLayer();
|
||||
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
|
||||
//效验数据是否OK
|
||||
check();
|
||||
//变更影响
|
||||
changeImpact();
|
||||
//bom 提层
|
||||
liftingLayer();
|
||||
result.forEach(u->u.setLevelNo(""));
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.excel.enums.BooleanEnum;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.*;
|
||||
import com.nflg.product.bomnew.pojo.entity.*;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import com.nflg.product.bomnew.service.*;
|
||||
|
|
@ -57,11 +59,13 @@ public abstract class EBomToPbomBase {
|
|||
@Getter
|
||||
protected List<BomNewEbomVirtualPackageCompositionEntity> virtualPackageCompositionResult = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
@Getter
|
||||
protected List<BomNewEbomUpgradeChangeEntity> upgradeChangeResult = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
protected List<BomNewEbomUpdateDetailEntity> upgradeChangeDetailResult = new ArrayList<>();
|
||||
// protected List<BomNewEbomUpdateDetailEntity> upgradeChangeDetailResult = new ArrayList<>();
|
||||
|
||||
protected Set<String> hasBuildVNo = Sets.newHashSet();
|
||||
|
||||
|
|
@ -254,78 +258,6 @@ public abstract class EBomToPbomBase {
|
|||
}
|
||||
}
|
||||
|
||||
//变更记录(明细)
|
||||
protected void buildUpgradeChangeDetail(BomNewEbomParentVO parent, VirtualPackageTypeEnum packageTypeEnum) {
|
||||
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> list = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery()
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, parent.getMaterialNo())
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getProjectType, packageTypeEnum.getProductTypeKey()).list();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
//老的虚拟包组成
|
||||
Set<String> oldMaterialNoAndNumSet = list.stream().filter(u -> u.getParentMaterialNo().equals(parent.getMaterialNo())).map(u -> StrUtil.join("-", u.getChildMaterialNo(), u.getNum())).collect(Collectors.toSet());
|
||||
|
||||
List<BomNewEbomParentVO> parentChildren = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList());
|
||||
//物料编码 +数量
|
||||
Set<String> newSet = parentChildren.stream().filter(u -> Objects.nonNull(u.getProjectType()) && VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).map(u -> StrUtil.join("-", u.getMaterialNo(), u.getNum())).collect(Collectors.toSet());
|
||||
//bom 发生了改变-影响了虚拟包
|
||||
if (CollUtil.isNotEmpty(Sets.difference(oldMaterialNoAndNumSet, newSet)) || CollUtil.isNotEmpty(Sets.difference(newSet, oldMaterialNoAndNumSet))) {
|
||||
|
||||
List<String> vmaterialNoList = list.stream().map(u -> u.getVirtualPackageMaterialNo()).distinct().collect(Collectors.toList());
|
||||
//记录变更明细行
|
||||
buildChangeDetailD0(vmaterialNoList, parent, parentChildren);
|
||||
//变更
|
||||
buildUpgradeChange(list, parent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buildChangeDetailD0(List<String> vmaterialNoList, BomNewEbomParentVO parent, List<BomNewEbomParentVO> parentChildren) {
|
||||
for (BomNewEbomParentVO vo : parentChildren) {
|
||||
for (String vNo : vmaterialNoList) {
|
||||
BomNewEbomUpdateDetailEntity changeDetailEnt = new BomNewEbomUpdateDetailEntity();
|
||||
changeDetailEnt.setRowId(IdWorker.getId());
|
||||
changeDetailEnt.setVirtualPackageMaterialNo(vNo);
|
||||
changeDetailEnt.setParentMaterialNo(parent.getMaterialNo());
|
||||
changeDetailEnt.setCurrentVersion(parent.getCurrentVersion());
|
||||
changeDetailEnt.setChildMaterialNo(vo.getMaterialNo());
|
||||
changeDetailEnt.setNum(vo.getNum());
|
||||
changeDetailEnt.setProjectType(vo.getProjectType());
|
||||
changeDetailEnt.setUpdatedTime(LocalDateTime.now());
|
||||
changeDetailEnt.setEbomSourceRowId(vo.getRowId());
|
||||
this.upgradeChangeDetailResult.add(changeDetailEnt);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void buildUpgradeChange(List<BomNewEbomVirtualPackageCompositionEntity> changeList, BomNewEbomParentVO parent) {
|
||||
List<String> vmaterialNoList = changeList.stream().map(u -> u.getVirtualPackageMaterialNo()).distinct().collect(Collectors.toList());
|
||||
for (String vmaterialNo : vmaterialNoList) {
|
||||
String key = StrUtil.join("-", vmaterialNo, parent.getMaterialNo());
|
||||
if (hasBuildVNo.contains(key)) {
|
||||
continue;
|
||||
}
|
||||
BomNewEbomUpgradeChangeEntity changeEntity = new BomNewEbomUpgradeChangeEntity();
|
||||
changeEntity.setRowId(IdWorker.getId());
|
||||
changeEntity.setMaterialNo(vmaterialNo);
|
||||
changeEntity.setVersionOld(parent.getCurrentVersion());
|
||||
changeEntity.setVersionNew(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion()));
|
||||
changeEntity.setDeviseName(SessionUtil.getRealName());
|
||||
changeEntity.setDeptName(SessionUtil.getDepartName());
|
||||
changeEntity.setRelMaterialNo(parent.getMaterialNo());
|
||||
changeEntity.setRelMaterialDesc(parent.getMaterialDesc());
|
||||
changeEntity.setStatus(0);
|
||||
upgradeChangeResult.add(changeEntity);
|
||||
|
||||
hasBuildVNo.add(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提层汇总数量
|
||||
*
|
||||
|
|
@ -371,6 +303,17 @@ public abstract class EBomToPbomBase {
|
|||
packageCompositionEntity.setUnitWeight(vo.getUnitWeight());
|
||||
packageCompositionEntity.setTotalWeight(vo.getTotalWeight());
|
||||
packageCompositionEntity.setUpdatedTime(LocalDateTime.now());
|
||||
packageCompositionEntity.setDeviseName(lastVirtualPackage.getDeviseName());
|
||||
packageCompositionEntity.setDeptName(lastVirtualPackage.getDeptName());
|
||||
packageCompositionEntity.setFromLiftingLayerState(0);
|
||||
if(!lastVirtualPackage.getBomRowId().equals(vo.getParentRowId())) {
|
||||
packageCompositionEntity.setFromLiftingLayerState(1);
|
||||
}
|
||||
packageCompositionEntity.setCurrentVersion(lastVirtualPackage.getCurrentVersion());
|
||||
List<BomNewEbomParentVO> vParentM = allBomDetail.stream().filter(u -> lastVirtualPackage.getBomRowId().equals(u.getParentRowId())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(vParentM)) {
|
||||
packageCompositionEntity.setVirtualMaterialParentMaterialNo(vParentM.get(0).getMaterialNo());
|
||||
}
|
||||
this.virtualPackageCompositionResult.add(packageCompositionEntity);
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +321,7 @@ public abstract class EBomToPbomBase {
|
|||
* 变更影响
|
||||
*/
|
||||
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());
|
||||
// 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.getRowId())).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO vo : firstParent) {
|
||||
changeImpactDo(vo);
|
||||
|
|
@ -390,28 +333,95 @@ public abstract class EBomToPbomBase {
|
|||
private void changeImpactDo(BomNewEbomParentVO parentVO){
|
||||
List<BomNewEbomParentVO> subVos = allBomDetail.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) >= 0 && u.getLevelNumber().compareTo(NumberUtil.add(parentVO.getLevelNumber(), BigDecimal.valueOf(0.01))) < 0)
|
||||
.sorted(Comparator.comparing(BomNewEbomParentVO::getLevelNumber)).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO vo : subVos) {
|
||||
|
||||
List<BomNewEbomParentVO> subVosParent = subVos.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO vo : subVosParent) {
|
||||
if( compareVirtualPackage(vo)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean compareVirtualPackage(BomNewEbomParentVO vo) {
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> impactVm = virtualPackageCompositionService.lambdaQuery().eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, vo.getMaterialNo()).list();
|
||||
Boolean result=false;
|
||||
if(EBomStatusEnum.PUBLISHED.equalsValue(vo.getStatus())){
|
||||
return result;
|
||||
}
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> impactVm = virtualPackageCompositionService.lambdaQuery()
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, vo.getMaterialNo())
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getFromLiftingLayerState,1).list();
|
||||
if(CollUtil.isNotEmpty(impactVm)){
|
||||
List<BomNewEbomParentVO> childList = allBomDetail.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).collect(Collectors.toList());
|
||||
Map<String, BomNewEbomVirtualPackageCompositionEntity> impactVmMp = impactVm.stream().collect(Collectors.toMap(v -> v.getChildMaterialNo(), v -> v, (v1, v2) -> v1));
|
||||
//对比F项
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> impactVmF = impactVm.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).collect(Collectors.toList());
|
||||
|
||||
List<BomNewEbomParentVO> childListF = childList.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).collect(Collectors.toList());
|
||||
if(impactVmF.size()!=impactVmF.size()){
|
||||
return true;
|
||||
}
|
||||
for (BomNewEbomParentVO child : childList) {
|
||||
// if(impactVmMp.containsKey());
|
||||
Map<String, List<BomNewEbomVirtualPackageCompositionEntity> > impactVmMp=impactVm.stream().collect(Collectors.groupingBy(BomNewEbomVirtualPackageCompositionEntity::getVirtualPackageMaterialNo));
|
||||
//对比F项
|
||||
for (String vMaterialNo: impactVmMp.keySet()){
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> vMaterialList = impactVmMp.get(vMaterialNo);
|
||||
//当改BOM 存在该虚拟包则直接跳过
|
||||
List<BomNewEbomParentVO> existsV = allBomDetail.stream().filter(u -> u.getMaterialNo().equals(vMaterialNo)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(existsV)){
|
||||
continue;
|
||||
}
|
||||
//虚拟包原F项
|
||||
Set<String> fSet = vMaterialList.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).map(u -> StrUtil.join("", u.getChildMaterialNo(), u.getNum())).collect(Collectors.toSet());
|
||||
Set<String> newFSet = childList.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).map(u -> StrUtil.join("", u.getMaterialNo(), u.getNum())).collect(Collectors.toSet());
|
||||
if(!fSet.equals(newFSet))
|
||||
{
|
||||
buildChangeImpactEntity(vMaterialList.get(0),vo);
|
||||
result=true;
|
||||
continue;
|
||||
}
|
||||
// 虚拟包Z项
|
||||
//虚拟包原F项
|
||||
Set<String> zSet = vMaterialList.stream().filter(u -> VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).map(u -> StrUtil.join("", u.getChildMaterialNo(), u.getNum())).collect(Collectors.toSet());
|
||||
Set<String> newZSet = childList.stream().filter(u -> VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).map(u -> StrUtil.join("", u.getMaterialNo(), u.getNum())).collect(Collectors.toSet());
|
||||
if(!zSet.equals(newZSet))
|
||||
{
|
||||
buildChangeImpactEntity(vMaterialList.get(0),vo);
|
||||
result=true;
|
||||
continue;
|
||||
}
|
||||
//数量发生变化(非F,Z项 数量发生变化)
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> noZOrFList = vMaterialList.stream().filter(u -> VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getProductTypeKey().equals(u.getProjectType())).collect(Collectors.toList());
|
||||
for (BomNewEbomVirtualPackageCompositionEntity vZOrF: noZOrFList){
|
||||
List<BomNewEbomParentVO> collect = childList.stream().filter(u -> u.getMaterialNo().equals(vZOrF.getChildMaterialNo())).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(collect)){
|
||||
buildChangeImpactEntity(vMaterialList.get(0),vo);
|
||||
result=true;
|
||||
break;
|
||||
}
|
||||
//数量发生了变化
|
||||
else if(CollUtil.isNotEmpty(collect) && collect.get(0).getNum().equals(vZOrF.getNum())){
|
||||
buildChangeImpactEntity(vMaterialList.get(0),vo);
|
||||
result=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void buildChangeImpactEntity(BomNewEbomVirtualPackageCompositionEntity v , BomNewEbomParentVO vo){
|
||||
|
||||
BomNewEbomUpgradeChangeEntity changeEntity =new BomNewEbomUpgradeChangeEntity();
|
||||
changeEntity.setRowId(IdWorker.getId());
|
||||
changeEntity.setMaterialNo(v.getVirtualPackageMaterialNo());
|
||||
changeEntity.setVersionOld(vo.getCurrentVersion());
|
||||
changeEntity.setVersionNew(VersionUtil.getNextVersion(vo.getCurrentVersion()));
|
||||
List<BaseMaterialVO> materialBaseInfos = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(ImmutableList.of(v.getVirtualPackageMaterialNo()));
|
||||
changeEntity.setMaterialName(materialBaseInfos.get(0).getMaterialName());
|
||||
changeEntity.setDrawingNo(materialBaseInfos.get(0).getDrawingNo());
|
||||
changeEntity.setDeviseName(v.getDeviseName());
|
||||
changeEntity.setDeptName(v.getDeptName());
|
||||
changeEntity.setRelMaterialNo(vo.getMaterialNo());
|
||||
changeEntity.setRelMaterialDesc(vo.getMaterialDesc());
|
||||
changeEntity.setStatus(0);
|
||||
changeEntity.setUpdatedTime(LocalDateTime.now());
|
||||
changeEntity.setVirtualMaterialParentMaterialNo(v.getVirtualMaterialParentMaterialNo());
|
||||
upgradeChangeResult.add(changeEntity);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String getParentMaterialNo(Long parentRowId) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@
|
|||
<result column="convert_to_ebom_time" property="convertToEbomTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
|
||||
<result column="dept_row_id" property="deptRowId" jdbcType="BIGINT"/>
|
||||
|
||||
<result column="level_num" property="levelNum" jdbcType="INTEGER"/>
|
||||
<result column="change_desc" property="changeDesc" jdbcType="VARCHAR"/>
|
||||
<result column="notice_nums" property="noticeNums" jdbcType="VARCHAR"/>
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@
|
|||
<result column="rel_material_desc" property="relMaterialDesc" jdbcType="VARCHAR"/>
|
||||
<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"/>
|
||||
</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
|
||||
rel_material_no, rel_material_desc, status, updated_time,virtual_material_parent_material_no
|
||||
</sql>
|
||||
|
||||
<delete id="delByVNo">
|
||||
|
|
|
|||
|
|
@ -14,12 +14,17 @@
|
|||
<result column="num" property="num" jdbcType="DECIMAL"/>
|
||||
<result column="project_type" property="projectType" jdbcType="VARCHAR"/>
|
||||
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="devise_name" property="deviseName" jdbcType="VARCHAR"/>
|
||||
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
|
||||
<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" />
|
||||
</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
|
||||
unit_weight, total_weight, num, updated_time,devise_name,dept_name, from_lifting_layer_state, current_version,virtual_material_parent_material_no
|
||||
</sql>
|
||||
|
||||
<delete id="delByVnoAndParentNo">
|
||||
|
|
|
|||
Loading…
Reference in New Issue