Merge branch 'refs/heads/feature/DM/nflg-bom' into feature/DM/nflg-bom-transition
# Conflicts: # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java
This commit is contained in:
commit
b4606483d6
|
|
@ -941,11 +941,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
if(CollUtil.isNotEmpty(materialNos)){
|
||||
pBomParentService.getBaseMapper().updateWaitPublicRootState(materialNos);
|
||||
}
|
||||
List<Long> bomRowIds = bomTree.stream().filter(u ->!EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(bomRowIds)) {
|
||||
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), SessionUtil.getRealName(), bomRowIds);
|
||||
//List<Long> bomRowIds = bomTree.stream().filter(u ->!EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(eBomToPBom.getAddEBomNew())) {
|
||||
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), eBomToPBom.getAddEBomNew());
|
||||
//将历史已发布版-转移到正式历史表
|
||||
eBomToFormal(bomRowIds, bomTree.stream().filter(u ->!u.getHasChangeState().equals(1) && !EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()) && u.getBomRowId() > 0).collect(Collectors.toList()) );
|
||||
eBomToFormal(eBomToPBom.getAddEBomNew(), eBomToPBom.getDelOldEBom() );
|
||||
}
|
||||
//替换需覆盖的受影响的虚拟包
|
||||
if(CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResultForCover())){
|
||||
|
|
@ -2666,31 +2666,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* ebom发布时将历史正式版-移到正式表(所有正式数据都会移到formal正式表中)
|
||||
* @param exceptRowIds
|
||||
* @param addRowIds 新增的Ebom正式版
|
||||
* @param delRowIds 需从EBom正式版删除的正式版
|
||||
*/
|
||||
private void eBomToFormal(List<Long> exceptRowIds, List<BomNewEbomParentVO> parents){
|
||||
private void eBomToFormal(List<Long> addRowIds, List<Long> delRowIds){
|
||||
|
||||
List<String> materialNos = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(materialNos)){
|
||||
return;
|
||||
}
|
||||
List<BomNewEbomParentEntity> toParents = this.lambdaQuery().eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).notIn(BomNewEbomParentEntity::getRowId, exceptRowIds)
|
||||
.in(BomNewEbomParentEntity::getMaterialNo, materialNos).select(BomNewEbomParentEntity::getRowId).list();
|
||||
if(CollUtil.isNotEmpty(toParents)) {
|
||||
|
||||
List<Long> childParentRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
List<Long> toFormalRowIds = new ArrayList<>();
|
||||
toFormalRowIds.addAll(exceptRowIds);
|
||||
toFormalRowIds.addAll(childParentRowIds);
|
||||
this.getBaseMapper().insertEBomFormalParent(toFormalRowIds);
|
||||
this.getBaseMapper().insertEBomFormalChild(toFormalRowIds);
|
||||
|
||||
if(CollUtil.isNotEmpty(addRowIds)) {
|
||||
this.getBaseMapper().insertEBomFormalParent(addRowIds);
|
||||
this.getBaseMapper().insertEBomFormalChild(addRowIds);
|
||||
//转移后删除
|
||||
this.getBaseMapper().delEBomHistory(childParentRowIds);
|
||||
this.getBaseMapper().delEBomHistory(delRowIds);
|
||||
|
||||
} else {
|
||||
this.getBaseMapper().insertEBomFormalParent(exceptRowIds);
|
||||
this.getBaseMapper().insertEBomFormalChild(exceptRowIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1223,20 +1223,18 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
List<BomNewPbomParentEntity> toParents = this.lambdaQuery()
|
||||
.ge(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||
.notIn(BomNewPbomParentEntity::getRowId, exceptRowIds)
|
||||
.in(BomNewPbomParentEntity::getMaterialNo, parentMaterialNos).select(BomNewPbomParentEntity::getRowId)
|
||||
.eq(BomNewPbomParentEntity::getFacCode,facCode)
|
||||
.in(BomNewPbomParentEntity::getMaterialNo, parentMaterialNos)
|
||||
.eq(BomNewPbomParentEntity::getFacCode,facCode).select(BomNewPbomParentEntity::getRowId)
|
||||
.list();
|
||||
if(CollUtil.isNotEmpty(toParents)) {
|
||||
|
||||
List<Long> oldPBomRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
List<Long> toFormalPBomRowIds = new ArrayList<>();
|
||||
|
||||
if(CollUtil.isNotEmpty(exceptRowIds)) {
|
||||
this.getBaseMapper().insertPBomParentToFormal(exceptRowIds);
|
||||
this.getBaseMapper().insertPBomChildToFormal(exceptRowIds);
|
||||
|
||||
}
|
||||
//需删除的
|
||||
if(CollUtil.isNotEmpty(toParents)) {
|
||||
List<Long> oldPBomRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
//转移后删除
|
||||
this.getBaseMapper().delPBom(oldPBomRowIds);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.alibaba.excel.enums.BooleanEnum;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.bomnew.constant.ConvertToPBomModelEnum;
|
||||
import com.nflg.product.bomnew.constant.PBomStatusEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
|
|
@ -46,6 +45,7 @@ public class EBomToPBomForFormal extends EBomToPbomBase {
|
|||
|
||||
//效验数据是否OK
|
||||
check();
|
||||
// changeImpact();
|
||||
//bom 提层
|
||||
liftingLayer();
|
||||
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ 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 com.alibaba.excel.enums.BooleanEnum;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
|
|
@ -14,7 +13,6 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
|||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -88,6 +86,7 @@ public class EBomToPBomForFormal31 extends EBomToPbomBase {
|
|||
|
||||
//效验数据是否OK
|
||||
check();
|
||||
// changeImpact();
|
||||
//bom 提层
|
||||
liftingLayer();
|
||||
// result.forEach(u->u.setLevelNo(""));
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ package com.nflg.product.bomnew.service.domain.EBom;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
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;
|
||||
|
|
@ -19,16 +17,15 @@ 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.*;
|
||||
import com.nflg.product.bomnew.util.*;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class EBomToPbomBase {
|
||||
|
||||
|
|
@ -65,6 +62,14 @@ public abstract class EBomToPbomBase {
|
|||
@Getter
|
||||
protected List<BomNewEbomUpgradeChangeEntity> upgradeChangeResultForCover=new ArrayList<>();
|
||||
|
||||
//生成新版正式表后,需删除的旧版Ebom
|
||||
@Getter
|
||||
private List<Long> delOldEBom=new ArrayList<>();
|
||||
|
||||
//新生成正式的EBOM版本
|
||||
@Getter
|
||||
private List<Long> addEBomNew=new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
// protected List<BomNewEbomUpdateDetailEntity> upgradeChangeDetailResult = new ArrayList<>();
|
||||
|
||||
|
|
@ -356,10 +361,18 @@ public abstract class EBomToPbomBase {
|
|||
*/
|
||||
private void buildVirtualPackageComposition(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo) {
|
||||
|
||||
String facCode=lastVirtualPackage.getMaterialName().contains(EBomConstant.XIAN_TAO_FACTORY_Name_1020) ? "1020" : "1010";
|
||||
List<BomNewEbomParentVO> voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList());
|
||||
String key=StrUtil.join("", lastVirtualPackage.getMaterialNo(),voParent.get(0).getMaterialNo(),vo.getMaterialNo(),facCode);
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> hasExists = virtualPackageCompositionResult.stream().filter(u -> u.getVirtualPackageMaterialNo().equals(lastVirtualPackage.getMaterialNo())
|
||||
&& u.getParentMaterialNo().equals(voParent.get(0).getMaterialNo()) && u.getChildMaterialNo().equals(vo.getMaterialNo()) && u.getFacCode().equals(facCode)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(hasExists)){
|
||||
return;
|
||||
}
|
||||
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());
|
||||
|
||||
packageCompositionEntity.setParentMaterialNo(voParent.get(0).getMaterialNo());
|
||||
packageCompositionEntity.setChildMaterialNo(vo.getMaterialNo());
|
||||
packageCompositionEntity.setNum(vo.getNum());
|
||||
|
|
@ -370,7 +383,7 @@ public abstract class EBomToPbomBase {
|
|||
packageCompositionEntity.setDeviseName(lastVirtualPackage.getDeviseName());
|
||||
packageCompositionEntity.setDeptName(lastVirtualPackage.getDeptName());
|
||||
packageCompositionEntity.setFromLiftingLayerState(0);
|
||||
packageCompositionEntity.setFacCode(lastVirtualPackage.getMaterialName().contains(EBomConstant.XIAN_TAO_FACTORY_Name_1020) ? "1020" : "1010");
|
||||
packageCompositionEntity.setFacCode(facCode);
|
||||
if (!lastVirtualPackage.getBomRowId().equals(vo.getParentRowId())) {
|
||||
packageCompositionEntity.setFromLiftingLayerState(1);
|
||||
}
|
||||
|
|
@ -408,9 +421,9 @@ public abstract class EBomToPbomBase {
|
|||
|
||||
private Boolean compareVirtualPackage(BomNewEbomParentVO vo) {
|
||||
Boolean result = false;
|
||||
if (EBomStatusEnum.PUBLISHED.equalsValue(vo.getStatus())) {
|
||||
return result;
|
||||
}
|
||||
// if (EBomStatusEnum.PUBLISHED.equalsValue(vo.getStatus())) {
|
||||
// return result;
|
||||
// }
|
||||
List<BomNewEbomVirtualPackageCompositionEntity> impactVm = virtualPackageCompositionService.lambdaQuery()
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, vo.getMaterialNo())
|
||||
.eq(BomNewEbomVirtualPackageCompositionEntity::getFromLiftingLayerState, 1).list();
|
||||
|
|
@ -699,21 +712,31 @@ public abstract class EBomToPbomBase {
|
|||
} else if (isSameEBomV2FormMaterialNoAndNum(oldParentChild, newParentChild)) {
|
||||
parentBom.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(oldEBom.getCurrentVersion()));
|
||||
parentBom.setHasChangeState(2);
|
||||
delOldEBom.add(oldEBom.getRowId());
|
||||
addEBomNew.add(parentBom.getRowId());
|
||||
} else {
|
||||
parentBom.setCurrentVersion(VersionUtil.getNextVersion(oldEBom.getCurrentVersion()));
|
||||
parentBom.setHasChangeState(2);
|
||||
delOldEBom.add(oldEBom.getRowId());
|
||||
addEBomNew.add(parentBom.getRowId());
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
addEBomNew.add(parentBom.getRowId());
|
||||
}
|
||||
|
||||
//如子级都为F 项父级也不转
|
||||
Set<String> projectSet = newParentChild.stream().map(u -> u.getProjectType().toUpperCase()).collect(Collectors.toSet());
|
||||
if (CollUtil.isNotEmpty(projectSet)) {
|
||||
if (!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) &&
|
||||
(ImmutableSet.of("F").equals(projectSet) || ImmutableSet.of("F", "Z").equals(projectSet) || ImmutableSet.of("Z").equals(projectSet))) {
|
||||
parentBom.setNoConvertToPBomIs(1);
|
||||
childDelMaterialNos.add(parentBom.getMaterialNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
//如子级都为F 项父级也不转
|
||||
Set<String> projectSet = newParentChild.stream().map(u -> u.getProjectType().toUpperCase()).collect(Collectors.toSet());
|
||||
if (CollUtil.isNotEmpty(projectSet)) {
|
||||
if (!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) &&
|
||||
(ImmutableSet.of("F").equals(projectSet) || ImmutableSet.of("F", "Z").equals(projectSet) || ImmutableSet.of("Z").equals(projectSet))) {
|
||||
parentBom.setNoConvertToPBomIs(1);
|
||||
childDelMaterialNos.add(parentBom.getMaterialNo());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -569,12 +569,12 @@
|
|||
a.`expire_end_time`, a.`convert_to_ebom_time`, a.`remark`, a.`dept_name`,a.`dept_row_id`, a.`level_num`,
|
||||
a.`change_desc`, a.`notice_nums`, a.`modify_time`, a.`sap_state`, a.`sap_time`
|
||||
from t_bom_new_ebom_parent a
|
||||
left join t_bom_new_ebom_parent_formal b on a.row_id = b.row_id
|
||||
|
||||
where a.row_id in
|
||||
<foreach collection="parentRowIds" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
and b.row_id is null
|
||||
|
||||
</insert>
|
||||
|
||||
<insert id="insertEBomFormalChild">
|
||||
|
|
@ -584,11 +584,7 @@
|
|||
where parent_row_id in
|
||||
<foreach collection="parentRowIds" item="parentRowId" open="(" separator="," close=")">
|
||||
#{parentRowId}
|
||||
</foreach> and parent_row_id not in(
|
||||
select row_id from t_bom_new_ebom_parent_formal where row_id in
|
||||
<foreach collection="parentRowIds" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</foreach>
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue