变更影响

This commit is contained in:
大米 2024-01-15 16:22:42 +08:00
parent 0332756cea
commit 1887be724f
11 changed files with 395 additions and 87 deletions

View File

@ -12,6 +12,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* t_bom_new_ebom_update_detail
@ -22,7 +23,7 @@ import java.time.LocalDateTime;
*/
@Data
@Accessors(chain = true)
@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewEbomUpdateDetailEntity")
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewEbomUpdateDetailEntity")
@TableName(value = "t_bom_new_ebom_update_detail")
public class BomNewEbomUpdateDetailEntity implements Serializable {
@ -36,50 +37,57 @@ public class BomNewEbomUpdateDetailEntity implements Serializable {
/**
* 影响到的物料编码虚拟件编码
*/
@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 = "current_version")
@ApiModelProperty(value = "影响行父级版本号")
@TableField(value = "current_version")
@ApiModelProperty(value = "影响行父级版本号")
private String currentVersion;
/**
* 影响行物料编码
*/
@TableField(value = "child_material_no")
@ApiModelProperty(value = "影响行物料编码")
@TableField(value = "child_material_no")
@ApiModelProperty(value = "影响行物料编码")
private String childMaterialNo;
/**
* 影响行数量
*/
@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;
/**
* 来源行ID
*/
@TableField(value = "ebom_source_row_id")
@ApiModelProperty(value = "项目类别")
private Long ebomSourceRowId;
/**
* 更新时间
*/
@TableField(value = "updated_time")
@ApiModelProperty(value = "更新时间")
@TableField(value = "updated_time")
@ApiModelProperty(value = "更新时间")
private LocalDateTime updatedTime;
private static final long serialVersionUID = 591631695584079922L;

View File

@ -269,6 +269,11 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty("虚拟件类型 0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包")
private Integer virtualPartType;
@ApiModelProperty("层级数字")
private BigDecimal levelNumber;
private String levelNo;
@ApiModelProperty("子级")
List<BomNewPbomParentVO> childNodes;

View File

@ -630,7 +630,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
}
if (CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())) {
if (CollUtil.isNotEmpty(eBomToPBom.getVirtualPackageCompositionResult())) {
//先删除
Set<String> delSet = eBomToPBom.getVirtualPackageCompositionResult().stream().map(u -> StrUtil.join("-", u.getVirtualPackageMaterialNo(), u.getParentMaterialNo())).collect(Collectors.toSet());
for (String s : delSet) {

View File

@ -1,16 +1,23 @@
package com.nflg.product.bomnew.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
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.ImmutableMap;
import com.google.common.collect.Sets;
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.BomNewEbomUpdateDetailEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomVirtualPackageCompositionEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
import com.nflg.product.bomnew.service.domain.EBom.UpdateImpact;
import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.VersionUtil;
import nonapi.io.github.classgraph.json.Id;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -18,6 +25,8 @@ import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -41,6 +50,9 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
@Resource
BomNewPbomParentService pbomParentService;
@Resource
BomNewPbomChildService pbomChildService;
/**
* 删除
@ -57,40 +69,31 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
List<BomNewEbomUpgradeChangeEntity> upList = this.getBaseMapper().selectBatchIds(rowIds);
//
for ( BomNewEbomUpgradeChangeEntity ent:upList) {
handlerImpact(ent);
}
UpdateImpact updateImpact=new UpdateImpact(ent);
updateImpact.handlerImpact();
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());
}
};
}
private void handlerImpact(BomNewEbomUpgradeChangeEntity ent){
//新的提层明细
List<BomNewEbomUpdateDetailEntity> newVirtualDetail = updateDetailService.lambdaQuery()
.eq(BomNewEbomUpdateDetailEntity::getVirtualPackageMaterialNo, ent.getMaterialNo())
.eq(BomNewEbomUpdateDetailEntity::getParentMaterialNo,ent.getRelMaterialNo())
.list();
//旧的体层明细
List<BomNewEbomVirtualPackageCompositionEntity> oldVirtualDetail = virtualPackageCompositionService.lambdaQuery()
.eq(BomNewEbomVirtualPackageCompositionEntity::getVirtualPackageMaterialNo, ent.getMaterialNo())
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo,ent.getRelMaterialNo())
.list();
// newVirtualDetail.
//
//
//
// BomNewPbomParentEntity vPbom = pbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, ent.getMaterialNo()).eq(BomNewPbomParentEntity::getLastVersionIs, 1).one();
//
//
// VUtils.isTure(Objects.isNull(vPbom)).throwMessage("未找到该虚拟包的Pbom 的版本");
// //现有Pbom明细
// List<BomNewPbomParentVO> pBomChild = pbomParentService.getChild(vPbom.getRowId());
}
private void addChild(){
}

View File

@ -24,6 +24,8 @@ import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.PBom.*;
import com.nflg.product.bomnew.util.*;
import com.nflg.product.bomnew.util.sap.LevelNumUtil;
import io.swagger.models.auth.In;
import nflg.product.common.constant.STATE;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@ -36,6 +38,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ExecutionException;
@ -481,7 +484,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
* @throws ExecutionException
* @throws InterruptedException
*/
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException {
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum ) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
AtomicInteger levelNum = new AtomicInteger(1);
PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum);
@ -492,6 +495,34 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum ,Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
AtomicInteger levelNum = new AtomicInteger(1);
PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum);
ForkJoinTask<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewPbomParentVO> result = submit.join();
if(generateDrawingNumberFalg){
generateDrawingNo(result,rowId,"");
}
return result;
}
public void generateDrawingNo(List<BomNewPbomParentVO> saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) {
List<BomNewPbomParentVO> firstLevelBoms = saveBomDetailParamDTO.stream().filter(u -> u.getParentRowId().equals(bomRowID)).collect(Collectors.toList());
parentDrawingNo = StrUtil.isNotBlank(parentDrawingNo) ? parentDrawingNo : "";
Integer gNo = 1;
for (BomNewPbomParentVO firstLevelBom : firstLevelBoms) {
String levelKey = StrUtil.isNotBlank(parentDrawingNo) ? StrUtil.join("-", parentDrawingNo, gNo.toString()) : gNo.toString();
firstLevelBom.setLevelNumber(LevelNumUtil.levelToNum(levelKey));
firstLevelBom.setLevelNo(levelKey);
gNo++;
generateDrawingNo(saveBomDetailParamDTO, firstLevelBom.getBomRowId(), firstLevelBom.getLevelNo());
}
}
public List<BomNewPbomParentVO> getAllBomTree(Long bomRowId) throws ExecutionException, InterruptedException {
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
@ -523,7 +554,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 1);
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 0);
materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
StringBuilder relPattern = new StringBuilder();
@ -570,6 +601,12 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
break;
}
}
if(child.getProjectType().equals("Q")){
intiQFac(child,childrenVO);
}else {
intiNotQFac(child,childrenVO);
}
}
if (CollUtil.isNotEmpty(result)) {
pbomChildService.saveOrUpdateBatch(result);
@ -578,13 +615,54 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
//处理Q下子级分工厂
// private void intiQFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child){
//
// String zero ="1"+ StrUtil.padAfter("0", parentVO.getLevelNum().toString().split(".")[1].length(), "0");
//
// int i = parentVO.getlev() + (1 / NumberUtil.parseInt(zero));
// child.stream().filter(u->u.getLevelNum()>parentVO.getLevelNum() && )
// }
private void intiQFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child){
setSubNodeFac(parentVO, child,parentVO.getProductionFactoryCode() );
}
//非Q
private void intiNotQFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child){
//当为1020时 子级为1020
if(parentVO.getProductionFactoryCode().equals(EBomConstant.XIAN_TAO_FACTORY_CODE_1020)){
setSubNodeFac(parentVO,child, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
}
if(parentVO.getProductionFactoryCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)){
//父级
setParentFac(parentVO,child,EBomConstant.MAIN_FACTORY_CODE_1010);
//子级
setSubNodeFac(parentVO,child, EBomConstant.MAIN_FACTORY_CODE_1010);
}
}
private void setParentFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child , String facCode){
List<String> parentByLevel = BomLevelUtil.getParentByLevel(parentVO.getLevelNo());
for ( String level: parentByLevel) {
List<BomNewPbomParentVO> parents = child.stream().filter(u -> u.getLevelNo().equals(level) && u.getVirtualPartIs().equals(0)).collect(Collectors.toList());
if(CollUtil.isNotEmpty(parents)){
parents.get(0).setProductionFactoryCode(facCode);
parents.get(0).setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue());
}
}
}
private void setSubNodeFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child , String facCode){
String zero ="1"+ StrUtil.padAfter("0", parentVO.getLevelNum().toString().split(".")[1].length(), "0");
BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), new BigDecimal(1).divide(NumberUtil.div ( new BigDecimal(1) , new BigDecimal(zero))) );
List<BomNewPbomParentVO> subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList());
for (BomNewPbomParentVO node : subNodes) {
node.setProductionFactoryCode(facCode);
node.setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue());
}
}
public void reConvertToMBom(Long bomRowId, List<Long> backRowId) {

View File

@ -116,10 +116,7 @@ public class CheckEBomException {
&& (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState())
|| MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else if (StrUtil.isBlank(vo.getMaterialNo())
|| Objects.isNull(vo.getNum())
|| (Objects.nonNull(vo.getNum())
&& BigDecimal.ZERO.compareTo(vo.getNum()) >= 0)) {
} else if (StrUtil.isBlank(vo.getMaterialNo()) || Objects.isNull(vo.getNum()) || BigDecimal.ZERO.compareTo(vo.getNum()) >= 0) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue());
} else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
@ -144,15 +141,7 @@ public class CheckEBomException {
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
for (BomNewEbomParentVO parent : parents) {
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList());
// if(CollUtil.isNotEmpty(child)){
// child.forEach(u->{
// CheckEBomExceptionDTO ent=new CheckEBomExceptionDTO();
// ent.setRowId(u.getRowId());
// ent.setParentMaterialNo(parent.getMaterialNo());
// ent.setChildMaterialNo(u.getMaterialNo());
// checkEBomExceptionDTOS.add(ent);
// });
// }
//是否存在重复物料
List<BomNewEbomParentVO> hasMaterialNoList = child.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).collect(Collectors.toList());
Map<String, List<BomNewEbomParentVO>> childMaterialMap = ListCommonUtil.listGroupMap(hasMaterialNoList, BomNewEbomParentVO::getMaterialNo);
@ -194,7 +183,7 @@ public class CheckEBomException {
*/
public void initExceptionYellowWarn(List<BomNewEbomParentVO> list) {
List<BomNewEbomParentVO> exceptionList = allBomDetail.stream().filter(u -> u.getExceptionStatus() > EBomExceptionStatusEnum.OK.getValue()).collect(Collectors.toList());
// List<String> exceptionMaterialNos = exceptionList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
if (CollUtil.isEmpty(exceptionList)) {
return;
}

View File

@ -253,7 +253,7 @@ public class EBomToPBom {
changeDetailEnt.setNum(vo.getNum());
changeDetailEnt.setProjectType(vo.getProjectType());
changeDetailEnt.setUpdatedTime(LocalDateTime.now());
changeDetailEnt.setEbomSourceRowId(vo.getRowId());
this.upgradeChangeDetailResult.add(changeDetailEnt);
}

View File

@ -0,0 +1,221 @@
package com.nflg.product.bomnew.service.domain.EBom;
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 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.Sets;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.PBomStatusEnum;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.service.*;
import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.VersionUtil;
import lombok.Getter;
import org.bouncycastle.asn1.x509.IetfAttrSyntax;
import org.bouncycastle.cms.PasswordRecipient;
import org.omg.CORBA.PRIVATE_MEMBER;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* 变更影响
*/
public class UpdateImpact {
private BomNewEbomUpgradeChangeEntity changeEntity;
@Getter
private List<BomNewPbomParentEntity> virtualPBomParent = new ArrayList<>();
@Getter
private List<BomNewPbomChildEntity> virtualPBomChildren = new ArrayList<>();
@Getter
private List<BomNewEbomVirtualPackageCompositionEntity> compositionResult = new ArrayList<>();
public UpdateImpact(BomNewEbomUpgradeChangeEntity inChangeEntity) {
changeEntity = inChangeEntity;
getVirtualPackageVersion(inChangeEntity.getMaterialNo());
}
public void handlerImpact() {
//新的提层明细
List<BomNewEbomUpdateDetailEntity> newVirtualDetail = SpringUtil.getBean(BomNewEbomUpdateDetailService.class).lambdaQuery()
.eq(BomNewEbomUpdateDetailEntity::getVirtualPackageMaterialNo, changeEntity.getMaterialNo())
.eq(BomNewEbomUpdateDetailEntity::getParentMaterialNo, changeEntity.getRelMaterialNo())
.list();
//旧的体层明细
compositionResult = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery()
.eq(BomNewEbomVirtualPackageCompositionEntity::getVirtualPackageMaterialNo, changeEntity.getMaterialNo())
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, changeEntity.getRelMaterialNo())
.list();
List<String> parentFullPathNum = Arrays.asList(StrUtil.split(compositionResult.get(0).getParentFullPathNum(), ","));
for (BomNewEbomUpdateDetailEntity newItem : newVirtualDetail) {
List<BomNewEbomVirtualPackageCompositionEntity> oldItem = compositionResult.stream().filter(u -> u.getChildMaterialNo().equals(newItem.getChildMaterialNo())).collect(Collectors.toList());
//旧的没有则新增子级
if (CollUtil.isEmpty(oldItem)) {
handlerAdd(newItem, parentFullPathNum);
//更新虚拟包组成
buildComposetion(oldItem.get(0), newItem);
}
//数量变更
else if (CollUtil.isNotEmpty(oldItem) && !oldItem.get(0).getNum().equals(newItem.getNum())) {
handlerUp(newItem, parentFullPathNum,NumberUtil.sub(newItem.getNum(),oldItem.get(0).getNum()));
//更新虚拟包组成
oldItem.get(0).setNum(newItem.getNum());
}
}
//旧的有 新的无 则删除
Set<String> newMaterialNos = newVirtualDetail.stream().map(u -> u.getChildMaterialNo()).collect(Collectors.toSet());
Set<String> oldMaterialNos = compositionResult.stream().map(u -> u.getChildMaterialNo()).collect(Collectors.toSet());
Set<String> difference = Sets.difference(oldMaterialNos, newMaterialNos);
List<BomNewEbomVirtualPackageCompositionEntity> delNodes = compositionResult.stream().filter(u -> difference.contains(u.getChildMaterialNo())).collect(Collectors.toList());
for (BomNewEbomVirtualPackageCompositionEntity delItem : delNodes) {
//刪除
handlerDel(delItem, parentFullPathNum);
//更新虚拟包组成
compositionResult.remove(delItem);
}
}
private void buildComposetion(BomNewEbomVirtualPackageCompositionEntity oldVirtualDetail, BomNewEbomUpdateDetailEntity newItem){
BomNewEbomVirtualPackageCompositionEntity nEnt = new BomNewEbomVirtualPackageCompositionEntity();
BeanUtil.copyProperties(oldVirtualDetail, nEnt);
nEnt.setRowId(IdWorker.getId());
nEnt.setChildMaterialNo(newItem.getChildMaterialNo());
nEnt.setNum(newItem.getNum());
nEnt.setProjectType(newItem.getProjectType());
nEnt.setUpdatedTime(LocalDateTime.now());
this.compositionResult.add(nEnt);
}
/**
* 处理Pbom
*
* @param parentFullPathNum
* @param
*/
private void handlerAdd(BomNewEbomUpdateDetailEntity newItem, List<String> parentFullPathNum) {
List<BomNewPbomChildEntity> childNodes = this.virtualPBomChildren.stream().filter(u -> u.getMaterialNo().equals(newItem.getChildMaterialNo())).collect(Collectors.toList());
BigDecimal mulValue = new BigDecimal(1);
if (CollUtil.isNotEmpty(parentFullPathNum)) {
List<BigDecimal> relFullPatnNum = Convert.toList(BigDecimal.class, parentFullPathNum);
mulValue = relFullPatnNum.stream().reduce(BigDecimal.ONE, BigDecimal::multiply);
}
if (CollUtil.isNotEmpty(childNodes)) {
for (BomNewPbomChildEntity child : childNodes) {
child.setNum(NumberUtil.mul(child.getNum(), mulValue));
}
} else {
for (BomNewPbomParentEntity vParent : this.virtualPBomParent) {
BomNewPbomChildEntity vChild = new BomNewPbomChildEntity();
BomNewEbomChildEntity sourceEnd = SpringUtil.getBean(BomNewEbomChildService.class).getById(newItem.getEbomSourceRowId());
BeanUtil.copyProperties(sourceEnd, vChild);
vChild.setRowId(IdWorker.getId());
vChild.setParentRowId(vParent.getRowId());
vChild.setFacCode(vParent.getFacCode());
vChild.setOrderNumber(StrUtil.padPre(String.valueOf(this.virtualPBomChildren.size()), 3, "0"));
vChild.setCreatedBy(SessionUtil.getUserCode());
vChild.setCreatedTime(LocalDateTime.now());
vChild.setModifyTime(LocalDateTime.now());
this.virtualPBomChildren.add(vChild);
}
}
}
private void handlerUp(BomNewEbomUpdateDetailEntity newItem, List<String> parentFullPathNum,BigDecimal diffNum) {
List<BomNewPbomChildEntity> childNodes = this.virtualPBomChildren.stream().filter(u -> u.getMaterialNo().equals(newItem.getChildMaterialNo())).collect(Collectors.toList());
BigDecimal mulValue = new BigDecimal(1);
if (CollUtil.isNotEmpty(parentFullPathNum)) {
List<BigDecimal> relFullPatnNum = Convert.toList(BigDecimal.class, parentFullPathNum);
mulValue = relFullPatnNum.stream().reduce(BigDecimal.ONE, BigDecimal::multiply);
}
if (CollUtil.isNotEmpty(childNodes)) {
for (BomNewPbomChildEntity child : childNodes) {
child.setNum(NumberUtil.add(child.getNum(),NumberUtil.mul(diffNum,mulValue)));
}
}
}
private void handlerDel(BomNewEbomVirtualPackageCompositionEntity delItem, List<String> parentFullPathNum) {
List<BomNewPbomChildEntity> childNodes = this.virtualPBomChildren.stream().filter(u -> u.getMaterialNo().equals(delItem.getChildMaterialNo())).collect(Collectors.toList());
BigDecimal mulValue = new BigDecimal(1);
if (CollUtil.isNotEmpty(parentFullPathNum)) {
List<BigDecimal> relFullPatnNum = Convert.toList(BigDecimal.class, parentFullPathNum);
mulValue = relFullPatnNum.stream().reduce(BigDecimal.ONE, BigDecimal::multiply);
}
if (CollUtil.isNotEmpty(childNodes)) {
for (BomNewPbomChildEntity child : childNodes) {
if(child.getNum().equals(NumberUtil.mul(delItem.getNum(),mulValue))){
this.virtualPBomChildren.remove(child);
}
else {
child.setNum(NumberUtil.sub(child.getNum(), NumberUtil.mul(delItem.getNum(), mulValue)));
}
}
}
}
private void getVirtualPackageVersion(String virtualPackageMaterialNo) {
List<BomNewPbomParentEntity> pBoms = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, virtualPackageMaterialNo)
.eq(BomNewPbomParentEntity::getLastVersionIs, 1).list();
VUtils.isTure(CollUtil.isEmpty(pBoms)).throwMessage("未找到该虚拟包的Pbom版本");
//已发布则升级
for (BomNewPbomParentEntity pBom : pBoms) {
List<BomNewPbomChildEntity> childs = SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, pBom.getRowId()).list();
if (pBom.getStatus() > (PBomStatusEnum.PUBLISH.getValue())) {
BomNewPbomParentEntity newVirParent = new BomNewPbomParentEntity();
BeanUtil.copyProperties(pBom, newVirParent);
newVirParent.setRowId(IdWorker.getId());
newVirParent.setCurrentVersion(VersionUtil.getNextVersion(pBom.getCurrentVersion()));
newVirParent.setLastVersionIs(1);
childs.forEach(u -> {
u.setRowId(IdWorker.getId());
u.setParentRowId(newVirParent.getRowId());
});
virtualPBomParent.add(newVirParent);
virtualPBomChildren.addAll(childs);
pBom.setLastVersionIs(0);
} else {
virtualPBomParent.add(pBom);
virtualPBomChildren.addAll(childs);
}
}
}
}

View File

@ -69,7 +69,7 @@ public class ConvertToMBom {
* 转换MBom
*/
public void convertToMBom() {
handler1010();
//handler1010();
handler1020();
buildMBom(EBomConstant.MAIN_FACTORY_CODE_1010);
@ -102,7 +102,10 @@ public class ConvertToMBom {
mBomParent.setLastVersionIs(1);
this.mBomParentResult.add(mBomParent);
buildChild(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode) ? allChildTreeList_1010 : allChildTreeList_1020, mBomParent.getRowId());
//1010 不做处理
// buildChild(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode) ? allChildTreeList_1010 : allChildTreeList_1020, mBomParent.getRowId());
buildChild(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode) ? allChild_1010 : allChildTreeList_1020, mBomParent.getRowId());
}

View File

@ -12,12 +12,13 @@
<result column="child_material_no" property="childMaterialNo" jdbcType="VARCHAR"/>
<result column="num" property="num" jdbcType="DECIMAL"/>
<result column="project_type" property="projectType" jdbcType="VARCHAR"/>
<result column="ebom_source_row_id" property="ebomSourceRowId" jdbcType="BIGINT" />
<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, current_version, child_material_no, num, updated_time </sql>
row_id, virtual_package_material_no, parent_material_no, current_version, child_material_no, num,ebom_source_row_id, updated_time </sql>
<delete id="delByVnoAndParentNo">

View File

@ -69,7 +69,7 @@
and drawing_no = #{query.drawingNo}
</if>
<if test="query.startDate!= null and query.endDate!=null">
and created_time between #{query.startDate} and #{query.endDate}
and created_time between #{query.startDate} and DATE_ADD(#{query.endDate}, INTERVAL 1 DAY)
</if>
</sql>
@ -99,7 +99,7 @@
select * , row_id as bomRowId
from t_bom_new_pbom_parent where status &gt;= 4
<if test="query.startDate== null">
and release_time > DATE_SUB(release_time, INTERVAL 3 DAY)
and release_time > DATE_SUB(release_time, INTERVAL 4 DAY)
</if>
<if test="query.facCode!= null and query.facCode!=''">
and fac_code = #{query.facCode}