Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom
This commit is contained in:
commit
8557c82d0a
|
|
@ -5,7 +5,7 @@ import lombok.Getter;
|
|||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EBomExceptionStatusEnum {
|
||||
public enum EBomExceptionStatusEnum implements ValueEnum<Integer> {
|
||||
//-1 初始状态
|
||||
//1=正常
|
||||
// 2=冻结/完全弃用异常:物料的状态冻结或者完全弃用的状态
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nflg.product.bomnew.mapper.master;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity;
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_upgrade_change 表数据库访问层
|
||||
* ebom-变更影响
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-12-22 13:44:47
|
||||
*/
|
||||
public interface BomNewEbomUpgradeChangeMapper extends BaseMapper<BomNewEbomUpgradeChangeEntity> {
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nflg.product.bomnew.mapper.master;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomVirtualPackageCompositionEntity;
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_virtual_package_composition 表数据库访问层
|
||||
*
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-12-22 13:44:10
|
||||
*/
|
||||
public interface BomNewEbomVirtualPackageCompositionMapper extends BaseMapper<BomNewEbomVirtualPackageCompositionEntity> {
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
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
|
||||
* ebom-变更影响
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-12-22 13:44:47
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@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 = "受影响的物料编码")
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 修订版(旧)
|
||||
*/
|
||||
@TableField(value = "version_old")
|
||||
@ApiModelProperty(value = "修订版(旧)")
|
||||
private String versionOld;
|
||||
|
||||
/**
|
||||
* 修订版(新)
|
||||
*/
|
||||
@TableField(value = "version_new")
|
||||
@ApiModelProperty(value = "修订版(新)")
|
||||
private String versionNew;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "material_name")
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
@TableField(value = "drawing_no")
|
||||
@ApiModelProperty(value = "图号")
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 设计人员
|
||||
*/
|
||||
@TableField(value = "devise_name")
|
||||
@ApiModelProperty(value = "设计人员")
|
||||
private String deviseName;
|
||||
|
||||
/**
|
||||
* 设计人员部门
|
||||
*/
|
||||
@TableField(value = "dept_name")
|
||||
@ApiModelProperty(value = "设计人员部门")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 关联物料编码
|
||||
*/
|
||||
@TableField(value = "rel_material_no")
|
||||
@ApiModelProperty(value = "关联物料编码")
|
||||
private String relMaterialNo;
|
||||
|
||||
/**
|
||||
* 关联物料描述
|
||||
*/
|
||||
@TableField(value = "rel_material_desc")
|
||||
@ApiModelProperty(value = "关联物料描述")
|
||||
private String relMaterialDesc;
|
||||
|
||||
/**
|
||||
* 状态:0-未升级处理 1-已升级处理
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
@ApiModelProperty(value = "状态:0-未升级处理 1-已升级处理")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
private static final long serialVersionUID = 862599074345253800L;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package com.nflg.product.bomnew.pojo.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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_virtual_package_composition
|
||||
*
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-12-22 13:44:10
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@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 = "虚拟包物料编码")
|
||||
private String virtualPackageMaterialNo;
|
||||
|
||||
/**
|
||||
* 父级物料编码
|
||||
*/
|
||||
@TableField(value = "parent_material_no")
|
||||
@ApiModelProperty(value = "父级物料编码")
|
||||
private String parentMaterialNo;
|
||||
|
||||
/**
|
||||
* 标识全路径
|
||||
*/
|
||||
@TableField(value = "parent_full_path_material_no")
|
||||
@ApiModelProperty(value = "标识全路径")
|
||||
private String parentFullPathMaterialNo;
|
||||
|
||||
/**
|
||||
* 子级物料编码
|
||||
*/
|
||||
@TableField(value = "child_material_no")
|
||||
@ApiModelProperty(value = "子级物料编码")
|
||||
private String childMaterialNo;
|
||||
|
||||
/**
|
||||
* 子级物料数量
|
||||
*/
|
||||
@TableField(value = "child_num")
|
||||
@ApiModelProperty(value = "子级物料数量")
|
||||
private BigDecimal childNum;
|
||||
|
||||
/**
|
||||
* 单重
|
||||
*/
|
||||
@TableField(value = "unit_weight")
|
||||
@ApiModelProperty(value = "单重")
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
@TableField(value = "total_weight")
|
||||
@ApiModelProperty(value = "总重")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@TableField(value = "num")
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updated_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
private static final long serialVersionUID = -45385735428516334L;
|
||||
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -84,6 +85,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
@Resource
|
||||
private BomNewEbomMaterialUseService bomNewEbomMaterialUseService;
|
||||
|
||||
@Resource
|
||||
private BomNewEbomVirtualPackageCompositionService virtualPackageCompositionService;
|
||||
|
||||
@Resource
|
||||
private BomNewEbomUpgradeChangeService upgradeChangeService;
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
|
|
@ -440,6 +447,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
|
||||
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
|
||||
}
|
||||
if(CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())){
|
||||
virtualPackageCompositionService.saveOrUpdateBatch(eBomToPBom.getVirtualPackageCompositionResult());
|
||||
}
|
||||
if(CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())){
|
||||
upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult());
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomUpgradeChangeMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_upgrade_change 表服务实现类
|
||||
* ebom-变更影响
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-12-22 13:44:47
|
||||
*/
|
||||
@Service
|
||||
public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgradeChangeMapper, BomNewEbomUpgradeChangeEntity> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomVirtualPackageCompositionMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomVirtualPackageCompositionEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_virtual_package_composition 表服务实现类
|
||||
*
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-12-22 13:44:10
|
||||
*/
|
||||
@Service
|
||||
public class BomNewEbomVirtualPackageCompositionService extends ServiceImpl<BomNewEbomVirtualPackageCompositionMapper, BomNewEbomVirtualPackageCompositionEntity> {
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.cache.Cache;
|
||||
import cn.hutool.cache.CacheUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
|
@ -34,7 +36,10 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class MaterialMainService extends ServiceImpl<MaterialMainMapper, MaterialMainEntity> {
|
||||
|
||||
// private Integer expireTime = 1000 * 60 * 60 * 4;
|
||||
|
||||
//物料缓存
|
||||
// private Cache<String, BaseMaterialVO> materialCache =CacheUtil.newLRUCache(1000,expireTime);
|
||||
/**
|
||||
* 获取物料信息
|
||||
*
|
||||
|
|
@ -74,6 +79,7 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public <T> void initShouldBomExist(List<T> list, Function<T, String> getMaterialCategoryCodeFun, BiConsumer<T, Integer> setShouldBomExistFun, Function<T,Integer> getMaterialGetTypeFun) {
|
||||
|
||||
for (T t : list) {
|
||||
|
|
|
|||
|
|
@ -2,25 +2,31 @@ package com.nflg.product.bomnew.service.domain.EBom;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
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.EBomExceptionStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomVirtualPackageCompositionEntity;
|
||||
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.BomNewEbomVirtualPackageCompositionService;
|
||||
import com.nflg.product.bomnew.service.BomNewPbomChildService;
|
||||
import com.nflg.product.bomnew.service.BomNewPbomParentService;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -46,9 +52,17 @@ public class EBomToPBom {
|
|||
@Getter
|
||||
private List<BomNewPbomChildEntity> pBomChildResult = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private List<BomNewEbomVirtualPackageCompositionEntity> virtualPackageCompositionResult = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private List<BomNewEbomUpgradeChangeEntity> upgradeChangeResult = new ArrayList<>();
|
||||
|
||||
|
||||
private Map<String, String> generateDrawingNoMap = new HashMap<>();
|
||||
|
||||
private Set<String> upChangeMaterialSet=new HashSet<>();
|
||||
|
||||
|
||||
public EBomToPBom(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes) {
|
||||
this.parent = inParent;
|
||||
|
|
@ -63,7 +77,7 @@ public class EBomToPBom {
|
|||
*/
|
||||
public void convert() {
|
||||
//效验数据是否OK
|
||||
check();
|
||||
// check();
|
||||
//bom 提层
|
||||
liftingLayer();
|
||||
List<BomNewEbomParentVO> parentList = result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
|
|
@ -114,7 +128,7 @@ public class EBomToPBom {
|
|||
return oldParent;
|
||||
} else {
|
||||
BomNewPbomParentEntity pBomParent = new BomNewPbomParentEntity();
|
||||
BeanUtil.copyProperties(pBomParent, parentVo);
|
||||
BeanUtil.copyProperties( parentVo,pBomParent);
|
||||
pBomParent.setRowId(IdWorker.getId());
|
||||
pBomParent.setLastVersionIs(1);
|
||||
pBomParent.setFacCode(facCode);
|
||||
|
|
@ -142,6 +156,9 @@ public class EBomToPBom {
|
|||
vo.setParentRowId(lastVirtualPackage.getBomRowId());
|
||||
result.add(vo);
|
||||
}
|
||||
else { //当没找到直发包时,记录到变更影响
|
||||
buildUpgradeChange(vo);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (vo.getProjectType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey())) {
|
||||
|
|
@ -153,12 +170,61 @@ public class EBomToPBom {
|
|||
vo.setParentRowId(lastVirtualPackage.getBomRowId());
|
||||
result.add(vo);
|
||||
}
|
||||
else { //当没找到直发包时,记录到变更影响
|
||||
buildUpgradeChange(vo);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
result.add(vo);
|
||||
}
|
||||
}
|
||||
|
||||
//变更记录
|
||||
private void buildUpgradeChange(BomNewEbomParentVO vo){
|
||||
List<BomNewEbomParentVO> voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(voParent)).throwMessage(vo.getMaterialNo() + " 未找到父级");
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> list = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery()
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, voParent.get(0).getMaterialNo()).list();
|
||||
if(CollUtil.isNotEmpty(list)) {
|
||||
if(upChangeMaterialSet.contains(voParent.get(0).getMaterialNo())){
|
||||
return;
|
||||
}
|
||||
Map<String, List<BomNewEbomVirtualPackageCompositionEntity>> vMaterialMap = ListCommonUtil.listGroupMap(list, BomNewEbomVirtualPackageCompositionEntity::getParentFullPathMaterialNo);
|
||||
Set<String> oldMaterialNoAndNumSet=new HashSet<>();
|
||||
for (String key: vMaterialMap.keySet()) {
|
||||
oldMaterialNoAndNumSet=vMaterialMap.get(key).stream().map(u->StrUtil.join("-", u.getChildMaterialNo(),u.getNum())).collect(Collectors.toSet());
|
||||
|
||||
}
|
||||
Set<String> newSet = allBomDetail.stream().filter(u -> u.getParentRowId().equals(vo.getParentRowId()) && Objects.nonNull(u.getProjectType()) && vo.getProjectType().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)) ){
|
||||
upChangeMaterialSet.add(parent.getMaterialNo());
|
||||
buildUpgradeChange(list, voParent.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 提层汇总数量
|
||||
*
|
||||
|
|
@ -168,13 +234,59 @@ public class EBomToPBom {
|
|||
private void liftingLayerSummary(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo) {
|
||||
BigDecimal sum = vo.getNum();
|
||||
String parentLevelNo = vo.getLevelNo().substring(0, vo.getLevelNo().length() - 2);
|
||||
List<String> parentFullPathMaterialNoList=new ArrayList<>();
|
||||
while (parentLevelNo.length() >= lastVirtualPackage.getLevelNo().length()) {
|
||||
List<BomNewEbomParentVO> parentList = allBomDetail.stream().filter(u -> u.getLevelNo().equals(parentLevelNo)).collect(Collectors.toList());
|
||||
String pNo=parentLevelNo;
|
||||
List<BomNewEbomParentVO> parentList = allBomDetail.stream().filter(u -> u.getLevelNo().equals(pNo) && !u.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName()) &&
|
||||
!u.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName()) && !u.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(parentList)) {
|
||||
sum = NumberUtil.mul(sum, parentList.get(0).getNum());
|
||||
parentFullPathMaterialNoList.add(parentList.get(0).getMaterialNo());
|
||||
}else {
|
||||
parentFullPathMaterialNoList.add(vo.getMaterialNo());
|
||||
}
|
||||
parentLevelNo = parentLevelNo.substring(0, parentLevelNo.length() - 2);
|
||||
|
||||
}
|
||||
vo.setNum(sum);
|
||||
//构建虚拟包组成
|
||||
buildVirtualPackageComposition(lastVirtualPackage, vo,parentFullPathMaterialNoList);
|
||||
|
||||
}
|
||||
|
||||
private void buildVirtualPackageComposition(BomNewEbomParentVO lastVirtualPackage,BomNewEbomParentVO vo, List<String> parentFullPathMaterialNoList){
|
||||
Collections.reverse(parentFullPathMaterialNoList);
|
||||
String fullPath= StrUtil.join("-", parentFullPathMaterialNoList);
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> list = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery()
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentFullPathMaterialNo, fullPath)
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getVirtualPackageMaterialNo, lastVirtualPackage.getMaterialNo()).list();
|
||||
//删除旧的
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
List<Long> delRowIds = list.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).getBaseMapper().deleteBatchIds(delRowIds);
|
||||
}
|
||||
BomNewEbomVirtualPackageCompositionEntity packageCompositionEntity=new BomNewEbomVirtualPackageCompositionEntity();
|
||||
packageCompositionEntity.setRowId(IdWorker.getId());
|
||||
packageCompositionEntity.setVirtualPackageMaterialNo(lastVirtualPackage.getMaterialNo());
|
||||
List<BomNewEbomParentVO> voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId()) ).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isEmpty(voParent)).throwMessage(vo.getMaterialNo() + " 未找到父级");
|
||||
if(voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName()) &&
|
||||
!voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName()) && !voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName()))
|
||||
{
|
||||
packageCompositionEntity.setParentMaterialNo(voParent.get(0).getMaterialNo());
|
||||
}
|
||||
else{
|
||||
packageCompositionEntity.setParentMaterialNo(vo.getMaterialNo());
|
||||
}
|
||||
|
||||
packageCompositionEntity.setParentFullPathMaterialNo(fullPath);
|
||||
packageCompositionEntity.setChildMaterialNo(vo.getMaterialNo());
|
||||
packageCompositionEntity.setChildNum(vo.getNum());
|
||||
packageCompositionEntity.setUnitWeight(vo.getUnitWeight());
|
||||
packageCompositionEntity.setTotalWeight(vo.getTotalWeight());
|
||||
packageCompositionEntity.setUpdatedTime(LocalDateTime.now());
|
||||
this.virtualPackageCompositionResult.add(packageCompositionEntity);
|
||||
}
|
||||
|
||||
private String getParentMaterialNo(Long parentRowId) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.product.bomnew.mapper.master.BomNewEbomUpgradeChangeMapper">
|
||||
<resultMap id="BaseResultMap" type="com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table t_bom_new_ebom_upgrade_change -->
|
||||
<id column="row_id" property="rowId" jdbcType="BIGINT"/>
|
||||
<result column="material_no" property="materialNo" jdbcType="VARCHAR"/>
|
||||
<result column="version_old" property="versionOld" jdbcType="VARCHAR"/>
|
||||
<result column="version_new" property="versionNew" jdbcType="VARCHAR"/>
|
||||
<result column="material_name" property="materialName" jdbcType="VARCHAR"/>
|
||||
<result column="drawing_no" property="drawingNo" jdbcType="VARCHAR"/>
|
||||
<result column="devise_name" property="deviseName" jdbcType="VARCHAR"/>
|
||||
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
|
||||
<result column="rel_material_no" property="relMaterialNo" jdbcType="VARCHAR"/>
|
||||
<result column="rel_material_desc" property="relMaterialDesc" jdbcType="VARCHAR"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
|
||||
</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
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.product.bomnew.mapper.master.BomNewEbomVirtualPackageCompositionMapper">
|
||||
<resultMap id="BaseResultMap" type="com.nflg.product.bomnew.pojo.entity.BomNewEbomVirtualPackageCompositionEntity">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table t_bom_new_ebom_virtual_package_composition -->
|
||||
<id column="row_id" property="rowId" jdbcType="BIGINT"/>
|
||||
<result column="virtual_package_material_no" property="virtualPackageMaterialNo" jdbcType="VARCHAR"/>
|
||||
<result column="parent_material_no" property="parentMaterialNo" jdbcType="VARCHAR"/>
|
||||
<result column="parent_full_path_material_no" property="parentFullPathMaterialNo" jdbcType="VARCHAR"/>
|
||||
<result column="child_material_no" property="childMaterialNo" jdbcType="VARCHAR"/>
|
||||
<result column="child_num" property="childNum" jdbcType="DECIMAL"/>
|
||||
<result column="unit_weight" property="unitWeight" jdbcType="DECIMAL"/>
|
||||
<result column="total_weight" property="totalWeight" jdbcType="DECIMAL"/>
|
||||
<result column="num" property="num" jdbcType="DECIMAL"/>
|
||||
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
row_id, virtual_package_material_no, parent_material_no, parent_full_path_material_no, child_material_no,
|
||||
child_num, unit_weight, total_weight, num, updated_time
|
||||
</sql>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue