Merge remote-tracking branch 'origin/DM/nflg-新需求'
This commit is contained in:
commit
1e869f6462
|
|
@ -16,4 +16,7 @@ public class BomConstant {
|
|||
|
||||
public static final Integer YES=1;
|
||||
public static final Integer NO=0;
|
||||
|
||||
//工艺包物料类别编码
|
||||
public static final String ART_PACKAGE_MATERIAL_CATEGORY_CODE="201201";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ public class EBomConstant {
|
|||
public static final String[] EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2 = {"material", "materialTexture", "projectType", "materialUnit","materialNo",
|
||||
"materialName","materialDesc","drawingNo"
|
||||
};
|
||||
//ebom编辑时,物料信息初始化时需忽略的字段
|
||||
public static final String[] EBOM_EDIT_IGNORED_FIELDS = {"material", "materialTexture", "projectType", "materialNo", "materialName","materialDesc","drawingNo"};
|
||||
|
||||
public static final String[] EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT3 = {"material", "materialTexture", "projectType", "materialUnit","materialWeight"};
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,10 @@ public class BomNewEbomChildEntity implements Serializable {
|
|||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
public BigDecimal getNum() {
|
||||
return num==null?null:num.stripTrailingZeros();
|
||||
}
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -374,6 +374,10 @@ public class BomNewPbomParentEntity implements Serializable {
|
|||
@ApiModelProperty(value = "来源状态:1-EBOM导入、2-PBOM创建、3-E->P修改")
|
||||
private Integer sourceStatus;
|
||||
|
||||
@TableField(value = "ebom_version")
|
||||
@ApiModelProperty(value = "ebom-发布后的版本")
|
||||
private String ebomVersion;
|
||||
|
||||
private static final long serialVersionUID = -31999878274445137L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -375,6 +375,9 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
return MyStrUtil.joinStr(getMaterialNo(),getNum());
|
||||
}
|
||||
|
||||
@ApiModelProperty("ebom发布后的版本")
|
||||
private String ebomVersion="";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
public BigDecimal getNum() {
|
||||
return num==null?null:num.stripTrailingZeros();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否跟节点 0-否 1-是
|
||||
|
|
@ -311,6 +314,10 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty("原始数量")
|
||||
private BigDecimal originalNum;
|
||||
|
||||
public BigDecimal getOriginalNum() {
|
||||
return originalNum==null?null:originalNum.stripTrailingZeros();
|
||||
}
|
||||
|
||||
@ApiModelProperty("原始项目类别")
|
||||
private String originalProjectType;
|
||||
|
||||
|
|
@ -338,6 +345,9 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
//发布PBOM 时 ,对比Pbom已发布版是否一致,一致则不转PBOM正式,直接删除PBOM 草稿数据
|
||||
private Integer delIs=0;
|
||||
|
||||
@ApiModelProperty(value = "ebom-发布后的版本")
|
||||
private String ebomVersion;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1879,7 +1879,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
childList.addAll(getChild(v.getBomRowId(), 0));
|
||||
});
|
||||
}
|
||||
materialMainService.intiMaterialInfo(childList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
|
||||
materialMainService.intiMaterialInfo(childList, EBomConstant.EBOM_EDIT_IGNORED_FIELDS);
|
||||
vo.setDatas(childList);
|
||||
}
|
||||
|
||||
|
|
@ -2370,7 +2370,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
public List<BomNewEbomParentVO> changeMaterial(BomNewEBomChangeDTO dto) {
|
||||
List<BaseMaterialVO> materialVOS = CheckEBomException.checkMaterialNoInMain(dto.getDatas());
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(dto.getDatas(), materialVOS, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(dto.getDatas(), materialVOS, EBomConstant.EBOM_EDIT_IGNORED_FIELDS);
|
||||
|
||||
for (BomNewEbomParentVO vo :
|
||||
dto.getDatas()) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
|
@ -440,7 +441,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
LogRecordContext.putVariable("bom",parent);
|
||||
|
||||
if (CollUtil.isNotEmpty(paramDTO.getChildList())) {
|
||||
paramDTO.getChildList().stream().filter(u->StrUtil.isBlank(u.getFacCode())).collect(Collectors.toList()).forEach(u->u.setFacCode(parent.getFacCode()));
|
||||
// paramDTO.getChildList().stream().filter(u->StrUtil.isBlank(u.getFacCode())).collect(Collectors.toList()).forEach(u->u.setFacCode(parent.getFacCode()));
|
||||
List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList());
|
||||
List<Long> childIds = paramDTO.getChildList().stream().map(BomNewPbomParentVO::getRowId).collect(Collectors.toList());
|
||||
List<BomNewPbomChildEntity> pChildList = Lists.newArrayList();
|
||||
|
|
@ -454,6 +455,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
u.setParentRowId(paramDTO.getBomRowId());
|
||||
if(u.getRowId() == null){
|
||||
u.setSourceStatus(PbomSourceStatusEnum.PBOM.getValue());
|
||||
u.setFacCode(parent.getFacCode());
|
||||
}else{
|
||||
BomNewPbomChildEntity oChild = childMap.get(u.getRowId());
|
||||
//判断是否有变更记录
|
||||
|
|
@ -546,13 +548,13 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
return hasTechnologypackage;
|
||||
}
|
||||
//删除辅助物料
|
||||
List<BomNewPbomParentVO> noDelList = childListVO.stream()
|
||||
.filter(u -> !u.getMaterialCategoryCode().startsWith("1003")
|
||||
&& !u.getMaterialCategoryCode().startsWith("1020")
|
||||
&& !u.getMaterialCategoryCode().startsWith("1021")
|
||||
&& !u.getMaterialCategoryCode().equals(MaterialMainConstant.CATEGORYCODE_TECHNOLOGYPACKAGE))
|
||||
.collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料");
|
||||
// List<BomNewPbomParentVO> noDelList = childListVO.stream()
|
||||
// .filter(u -> !u.getMaterialCategoryCode().startsWith("1003")
|
||||
// && !u.getMaterialCategoryCode().startsWith("1020")
|
||||
// && !u.getMaterialCategoryCode().startsWith("1021")
|
||||
// && !u.getMaterialCategoryCode().equals(MaterialMainConstant.CATEGORYCODE_TECHNOLOGYPACKAGE))
|
||||
// .collect(Collectors.toList());
|
||||
// VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料");
|
||||
|
||||
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
|
||||
resetBomExist(parent.getRowId());
|
||||
|
|
@ -1209,7 +1211,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
*/
|
||||
private void initPBomCurrentVersion(List<BomNewPbomParentVO> allPBom){
|
||||
|
||||
List<BomNewPbomParentVO> waitReleaseBom = allPBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
List<BomNewPbomParentVO> waitReleaseBom = allPBom.stream().filter(u ->SessionUtil.getUserCode().equals(u.getCreatedBy()) && PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO newPBom : waitReleaseBom) {
|
||||
|
||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
|
||||
|
|
@ -1217,7 +1219,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
.ge(BomNewPbomParentEntity::getStatus,PBomStatusEnum.PUBLISH.getValue())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, newPBom.getFacCode()).last(" order by current_version desc limit 1").one();
|
||||
if(Objects.isNull(oldParent)){
|
||||
newPBom.setCurrentVersion(VersionUtil.getNextVersion(""));
|
||||
// newPBom.setCurrentVersion(VersionUtil.getNextVersion(""));
|
||||
continue;
|
||||
}
|
||||
if(StrUtil.isNotBlank(newPBom.getEbomVersion()) ){
|
||||
continue;
|
||||
}
|
||||
//旧bom除T项之外
|
||||
|
|
@ -1226,6 +1231,11 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
//新BOM 除T项外
|
||||
List<BomNewPbomParentVO> newChildren = this.getBaseMapper().getParentChild(newPBom.getBomRowId());
|
||||
List<BomNewPbomParentVO> newBomNoTChildren = newChildren.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||
if(oldBomNoTChildren.size()!=newBomNoTChildren.size()){
|
||||
// newPBom.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<String> oldChildSet = oldBomNoTChildren.stream().map(u -> u.getMaterialNoAndNum()).collect(Collectors.toSet());
|
||||
Set<String> newChildSet = newBomNoTChildren.stream().map(u -> u.getMaterialNoAndNum()).collect(Collectors.toSet());
|
||||
|
||||
|
|
@ -1234,13 +1244,40 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
if(oldChildSet0.equals(newChildSet0)){
|
||||
newPBom.setStatus(PBomStatusEnum.PUBLISH.getValue());
|
||||
newPBom.setDelIs(1);
|
||||
|
||||
//当T项外都一致时,直接更新T项
|
||||
List<BomNewPbomParentVO> oldBomT = oldBomDetail.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
|
||||
//新T项
|
||||
List<BomNewPbomParentVO> newBomT = newChildren.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
|
||||
Set<String> oldTSet = oldBomT.stream().map(BomNewPbomParentVO::getMaterialNoAndNumAndProjectType).collect(Collectors.toSet());
|
||||
Set<String> newTSet = newBomT.stream().map(BomNewPbomParentVO::getMaterialNoAndNumAndProjectType).collect(Collectors.toSet());
|
||||
|
||||
if(CollUtil.isNotEmpty(newBomT) && !newTSet.equals(oldTSet)){
|
||||
if (CollUtil.isNotEmpty(oldBomT)) {
|
||||
List<Long> bomRowIdsForT = oldBomT.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteBatchIds(bomRowIdsForT);
|
||||
}
|
||||
List<BomNewPbomChildEntity> tNewChildren=new ArrayList<>();
|
||||
for (BomNewPbomParentVO netT : newBomT) {
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(netT, childEnt);
|
||||
childEnt.setRowId(IdWorker.getId());
|
||||
childEnt.setParentRowId(oldParent.getRowId());
|
||||
childEnt.setFacCode(oldParent.getFacCode());
|
||||
childEnt.setIdentityNo(StrUtil.join("-", oldParent.getMaterialNo(), netT.getMaterialNo()));
|
||||
tNewChildren.add(childEnt);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(tNewChildren)) {
|
||||
pbomChildService.saveBatch(tNewChildren);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(oldChildSet.equals(newChildSet)){
|
||||
newPBom.setCurrentVersion( VersionUtil.getNextVersionForSmallVersion(oldParent.getCurrentVersion()));
|
||||
}
|
||||
else {
|
||||
newPBom.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
||||
}
|
||||
// else if(oldChildSet.equals(newChildSet)){
|
||||
// newPBom.setCurrentVersion( VersionUtil.getNextVersionForSmallVersion(oldParent.getCurrentVersion()));
|
||||
// }
|
||||
// else {
|
||||
// newPBom.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.alibaba.excel.enums.BooleanEnum;
|
|||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.ConvertToPBomModelEnum;
|
||||
import com.nflg.product.bomnew.constant.EBomConstant;
|
||||
import com.nflg.product.bomnew.constant.PBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
|
|
@ -16,9 +17,7 @@ import com.nflg.product.bomnew.util.ListCommonUtil;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -27,6 +26,7 @@ import java.util.stream.Collectors;
|
|||
@NoArgsConstructor
|
||||
public class EBomToPBom extends EBomToPbomBase {
|
||||
|
||||
private Map<String, List<BomNewEbomParentVO>> facBomDataMp = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
|
|
@ -39,6 +39,39 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
initEBomVersion();
|
||||
}
|
||||
|
||||
private void splitData() {
|
||||
// this.facCodes = new ArrayList<>();
|
||||
//1020数据
|
||||
List<BomNewEbomParentVO> data1020 = new ArrayList<>();
|
||||
List<BomNewEbomParentVO> deliveryPackage1020 = result.stream().filter(u -> u.getParentRowId().equals(parent.getRowId()) && u.getMaterialName().contains("仙桃")).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(deliveryPackage1020)) {
|
||||
// facCodes.add(EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
||||
data1020.add(parent);
|
||||
for (BomNewEbomParentVO data : deliveryPackage1020) {
|
||||
List<BomNewEbomParentVO> subVos = getResultAllSubIncludeSelf(data);
|
||||
data1020.addAll(subVos);
|
||||
}
|
||||
facBomDataMp.put(EBomConstant.XIAN_TAO_FACTORY_CODE_1020, data1020);
|
||||
}
|
||||
|
||||
//1010 数据
|
||||
List<BomNewEbomParentVO> data1010 = new ArrayList<>();
|
||||
List<BomNewEbomParentVO> deliveryPackage1010 = result.stream().filter(u -> u.getParentRowId().equals(parent.getRowId())).collect(Collectors.toList()); //&& !u.getMaterialName().contains("仙桃")
|
||||
if (CollUtil.isNotEmpty(deliveryPackage1010)) {
|
||||
// facCodes.add(EBomConstant.MAIN_FACTORY_CODE_1010);
|
||||
data1010.add(parent);
|
||||
for (BomNewEbomParentVO data : deliveryPackage1010) {
|
||||
List<BomNewEbomParentVO> subVos = new ArrayList<>();
|
||||
if (!data.getMaterialName().contains("仙桃") ) { //只获取下降虚拟包(排除仙桃油漆包)
|
||||
subVos=getResultAllSubIncludeSelf(data);
|
||||
}
|
||||
data1010.addAll(subVos);
|
||||
}
|
||||
facBomDataMp.put(EBomConstant.MAIN_FACTORY_CODE_1010, data1010);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 31項体层
|
||||
|
|
@ -53,11 +86,20 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
changeImpact();
|
||||
//bom 提层
|
||||
liftingLayer();
|
||||
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
|
||||
splitData();
|
||||
|
||||
List<String> hasConvert = new ArrayList<>();
|
||||
|
||||
for (String facCode : facCodes) {
|
||||
//buildPBomParent(parent, facCode);
|
||||
//仙桃的不发1010工厂
|
||||
if(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode) && parent.getMaterialName().contains("仙桃") ){
|
||||
continue;
|
||||
}
|
||||
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
if(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode)){
|
||||
parentList = ListCommonUtil.toDistinct(facBomDataMp.get(facCode).stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
}
|
||||
for (BomNewEbomParentVO vo : parentList) {
|
||||
String hasConvertKey = StrUtil.join("-", facCode, vo.getBomRowId());
|
||||
if (hasConvert.contains(hasConvertKey)) {
|
||||
|
|
@ -69,23 +111,21 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
if(BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs()) ){
|
||||
continue;
|
||||
}
|
||||
//构建变更明细
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
|
||||
//子级
|
||||
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId()) && !childDelMaterialNos.contains(u.getMaterialNo())).distinct().collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
|
||||
//判断pbom 是否一致
|
||||
// if( compareContentIsSame(vo, mergeChild, facCode) && !vo.getMaterialNo().equals(parent.getMaterialNo())){
|
||||
// continue;
|
||||
// }
|
||||
List<BomNewEbomParentVO> mergeChild=child;
|
||||
//直发包/发货前包不合并
|
||||
if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
mergeChild = mergeChild(child);
|
||||
}
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//处理子级BOM
|
||||
mergeChild= handlerArtPackage(parentEnt,mergeChild,facCode,parentList,vo.getVirtualPartType());
|
||||
//子级
|
||||
if (CollUtil.isNotEmpty(child)) {
|
||||
if (CollUtil.isNotEmpty(mergeChild)) {
|
||||
//合并子级
|
||||
for (BomNewEbomParentVO eb : mergeChild) {
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
|
|
|
|||
|
|
@ -111,23 +111,23 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
if (BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs())) {
|
||||
continue;
|
||||
}
|
||||
//构建变更明细
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
|
||||
//子级
|
||||
List<BomNewEbomParentVO> child = facBomDataMp.get(facCode).stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId()) && !childDelMaterialNos.contains(u.getMaterialNo())).distinct().collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
|
||||
// if(compareContentIsSame(vo, mergeChild, facCode) && !vo.getMaterialNo().equals(parent.getMaterialNo())){
|
||||
// continue;
|
||||
// }
|
||||
List<BomNewEbomParentVO> mergeChild=child;
|
||||
//直发包/发货前包不合并
|
||||
if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
mergeChild = mergeChild(child);
|
||||
}
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode, parentList);
|
||||
if (Objects.isNull(parentEnt)) {
|
||||
continue;
|
||||
}
|
||||
//处理bom子级
|
||||
if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())) {
|
||||
mergeChild = handlerArtPackage(parentEnt, mergeChild, facCode, parentList, vo.getVirtualPartType());
|
||||
}
|
||||
//子级
|
||||
if (CollUtil.isNotEmpty(child)) {
|
||||
//合并子级
|
||||
if (CollUtil.isNotEmpty(mergeChild)) {
|
||||
for (BomNewEbomParentVO eb : mergeChild) {
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(eb, childEnt, "sourceRowId");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ 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.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
|
|
@ -18,6 +19,7 @@ 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.MyStrUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -85,6 +87,7 @@ public abstract class EBomToPbomBase {
|
|||
//当子级为F项或Z项时-无需转的父级物料
|
||||
protected Set<String> childDelMaterialNos = new HashSet<>();
|
||||
|
||||
|
||||
public abstract void convert();
|
||||
|
||||
/**
|
||||
|
|
@ -186,6 +189,8 @@ public abstract class EBomToPbomBase {
|
|||
else if (Objects.nonNull(oldParent) && oldParent.getStatus() < EBomStatusEnum.PUBLISHED.getValue()) {
|
||||
//if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy())) {
|
||||
if (ConvertToPBomModelEnum.OVERRIDE.equalsValue(convertMode.getValue())) {
|
||||
//当bom创建人为本人 或 版本大于当前版本则覆盖
|
||||
if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy()) || parentVo.getCurrentVersion()==null || VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0){
|
||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
|
||||
// this.delParentRowIds.add(oldParent.getRowId());
|
||||
oldParent.setSourceRowId(parentVo.getBomRowId());
|
||||
|
|
@ -193,9 +198,13 @@ public abstract class EBomToPbomBase {
|
|||
oldParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
oldParent.setDeptName(SessionUtil.getDepartName());
|
||||
oldParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
oldParent.setEbomVersion(parentVo.getEbomVersion());
|
||||
if(StrUtil.isNotBlank(parentVo.getEbomVersion())){
|
||||
oldParent.setCurrentVersion(parentVo.getEbomVersion());
|
||||
}
|
||||
this.pBomParentResult.add(oldParent);
|
||||
return oldParent;
|
||||
// }
|
||||
}
|
||||
|
||||
} else {
|
||||
// 降parentVo 及其子节点标记为不转换
|
||||
|
|
@ -204,15 +213,88 @@ public abstract class EBomToPbomBase {
|
|||
return null;
|
||||
|
||||
} else { //pbom-处于正式表
|
||||
//Ebom为已发布时则直接跳过 (直发包,发货前装配包是则需对比Bom明细,一致则跳过,否则升级)
|
||||
|
||||
return buildParentEntity(parentVo, facCode, oldParent, VersionUtil.getNextVersionForSmallVersion(oldParent.getCurrentVersion()));
|
||||
|
||||
return buildParentEntity(parentVo, facCode, oldParent, VersionUtil.getPBomUpgradNextVersion(oldParent.getCurrentVersion()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private BomNewPbomChildEntity buildPBomAddChild(BomNewPbomParentEntity parent, String facCode, BomNewPbomParentVO oldChild){
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(oldChild, childEnt, "sourceRowId");
|
||||
childEnt.setRowId(IdWorker.getId());
|
||||
childEnt.setParentRowId(parent.getRowId());
|
||||
childEnt.setFacCode(facCode);
|
||||
childEnt.setIdentityNo(StrUtil.join("-", parent.getMaterialNo(), oldChild.getMaterialNo()));
|
||||
childEnt.setCreatedTime(LocalDateTime.now());
|
||||
childEnt.setCreatedBy(SessionUtil.getUserCode());
|
||||
|
||||
this.pBomChildResult.add(childEnt);
|
||||
return childEnt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理PBOM新增物料
|
||||
*/
|
||||
protected List<BomNewEbomParentVO> handlerArtPackage(BomNewPbomParentEntity parent , List<BomNewEbomParentVO> newBomChildren ,String facCode ,List<BomNewEbomParentVO> parentList,Integer parentVirtualPartType){
|
||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
|
||||
List<String> delResult=new ArrayList<>();
|
||||
//pBom为已发布时
|
||||
if(Objects.nonNull(oldParent) && PBomStatusEnum.PUBLISH.getValue()<= oldParent.getStatus()) {
|
||||
List<BomNewPbomParentVO> oldChildren=SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldParent.getRowId(),1);
|
||||
|
||||
//pBom 手工新增物料
|
||||
List<BomNewPbomParentVO> oldPBomAddChildren = oldChildren.stream().filter(u -> StrUtil.isBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
Map<String, BomNewEbomParentVO> newBomChildrenMap = newBomChildren.stream().collect(Collectors.toMap(BomNewEbomParentVO::getMaterialNo, u -> u));
|
||||
|
||||
for (BomNewPbomParentVO oldPBomAddItem : oldPBomAddChildren) {
|
||||
//加入当前BOM明细中
|
||||
if(!newBomChildrenMap.containsKey(oldPBomAddItem.getMaterialNo()) && !VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(parentVirtualPartType) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(parentVirtualPartType)) {
|
||||
buildPBomAddChild(parent, facCode, oldPBomAddItem);
|
||||
}
|
||||
//直发包,发货前-允许物料重复
|
||||
// if(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(parentVirtualPartType) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(parentVirtualPartType)) {
|
||||
// buildPBomAddChild(parent, facCode, oldPBomAddItem);
|
||||
// }
|
||||
|
||||
//如为工艺包,且在当前BOM中不存在
|
||||
if (BomConstant.ART_PACKAGE_MATERIAL_CATEGORY_CODE.equals(oldPBomAddItem.getMaterialCategoryCode()) && !newBomChildrenMap.containsKey(oldPBomAddItem.getMaterialNo())) {
|
||||
//创建工艺包版本
|
||||
BomNewPbomParentEntity artParent = buildPBomParent(Convert.convert(BomNewEbomParentVO.class, oldPBomAddItem), facCode, parentList);
|
||||
//old 工艺包子级
|
||||
List<BomNewPbomParentVO> oldArtChildren = SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldPBomAddItem.getBomRowId(), 1);
|
||||
for (BomNewPbomParentVO oldArtChild : oldArtChildren) {
|
||||
//工艺包新增
|
||||
if (StrUtil.isBlank(oldArtChild.getOriginalMaterialNo())) {
|
||||
buildPBomAddChild(artParent, facCode, oldArtChild);
|
||||
}
|
||||
if(StrUtil.isNotBlank(oldArtChild.getOriginalMaterialNo()) && newBomChildrenMap.containsKey(oldArtChild.getOriginalMaterialNo())){
|
||||
// newBomChildrenMap.get(oldArtChild.getOriginalMaterialNo()).setParentRowId(artParent.getRowId());
|
||||
buildPBomAddChild(artParent, facCode, Convert.convert(BomNewPbomParentVO.class,newBomChildrenMap.get(oldArtChild.getOriginalMaterialNo()) ));
|
||||
delResult.add(oldArtChild.getOriginalMaterialNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//pBom中修改过的
|
||||
List<BomNewPbomParentVO> oldPBomUpdateChildren = oldChildren.stream().filter(u -> StrUtil.isNotBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO oldPBomUpdateChild : oldPBomUpdateChildren) {
|
||||
if (!oldPBomUpdateChild.getOriginalMaterialNo().equals(oldPBomUpdateChild.getMaterialNo()) || !oldPBomUpdateChild.getOriginalProjectType().equals(oldPBomUpdateChild.getProjectType()) || !oldPBomUpdateChild.getOriginalNum().equals(oldPBomUpdateChild.getNum())) {
|
||||
List<BomNewEbomParentVO> upEnts = newBomChildren.stream().filter(u -> u.getMaterialNo().equals(oldPBomUpdateChild.getOriginalMaterialNo())
|
||||
&& u.getProjectType().equals(oldPBomUpdateChild.getOriginalProjectType()) && VUtils.compareSafely(u.getNum(), oldPBomUpdateChild.getOriginalNum())==0).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(upEnts)) {
|
||||
buildPBomAddChild(parent, facCode, oldPBomUpdateChild);
|
||||
newBomChildren.remove(upEnts.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
return newBomChildren.stream().filter(u->!delResult.contains(u.getMaterialNo())).collect(Collectors.toList());
|
||||
}
|
||||
return newBomChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pbom明细对比
|
||||
* @param pVo
|
||||
|
|
@ -257,6 +339,11 @@ public abstract class EBomToPbomBase {
|
|||
pBomParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
pBomParent.setSource(PbomSourceEnum.FROM_EBOM.getValue());
|
||||
pBomParent.setSourceStatus(PbomSourceStatusEnum.EBOM.getValue());
|
||||
pBomParent.setEbomVersion(parentVo.getEbomVersion());
|
||||
if(StrUtil.isNotBlank(parentVo.getEbomVersion()) ){
|
||||
pBomParent.setCurrentVersion(parentVo.getEbomVersion());
|
||||
}
|
||||
|
||||
if (Objects.nonNull(oldParent)) {
|
||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||
oldParent.setLastVersionIs(0);
|
||||
|
|
@ -369,7 +456,7 @@ public abstract class EBomToPbomBase {
|
|||
buildVirtualPackageComposition(lastVirtualPackage, ent);
|
||||
}
|
||||
}
|
||||
newEnt.setBomRowId(0L);
|
||||
// newEnt.setBomRowId(0L);
|
||||
newEnt.setChildBomRowId(0L);
|
||||
newEnt.setNum(sum);
|
||||
return newEnt;
|
||||
|
|
@ -703,7 +790,7 @@ public abstract class EBomToPbomBase {
|
|||
}
|
||||
Map<String, List<BomNewEbomChildEntity>> oldChildMap = oldChildList.stream().collect(Collectors.groupingBy(u -> StrUtil.join("", u.getMaterialNo(), u.getProjectType(), u.getNum())));
|
||||
for (BomNewEbomParentVO newChild : newChildList) {
|
||||
String key = StrUtil.join("", newChild.getMaterialNo(), newChild.getProjectType(), newChild.getNum());
|
||||
String key = MyStrUtil.joinStr(newChild.getMaterialNo(), newChild.getProjectType(), newChild.getNum());
|
||||
if (!oldChildMap.containsKey(key)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -756,17 +843,20 @@ public abstract class EBomToPbomBase {
|
|||
} else if (isSameEBomV2FormMaterialNoAndNum(oldParentChild, newParentChild)) {
|
||||
parentBom.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(oldEBom.getCurrentVersion()));
|
||||
parentBom.setHasChangeState(2);
|
||||
parentBom.setEbomVersion(parentBom.getCurrentVersion());
|
||||
delOldEBom.add(oldEBom.getRowId());
|
||||
addEBomNew.add(parentBom.getBomRowId());
|
||||
} else {
|
||||
parentBom.setCurrentVersion(VersionUtil.getNextVersion(oldEBom.getCurrentVersion()));
|
||||
parentBom.setHasChangeState(2);
|
||||
parentBom.setEbomVersion(parentBom.getCurrentVersion());
|
||||
delOldEBom.add(oldEBom.getRowId());
|
||||
addEBomNew.add(parentBom.getBomRowId());
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
parentBom.setEbomVersion(VersionUtil.getNextVersion(""));
|
||||
addEBomNew.add(parentBom.getBomRowId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,9 @@ public abstract class VirtualPackageBase {
|
|||
}
|
||||
}
|
||||
List<AddVirtrualMaterialDTO> addM = params.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
vMNos.putAll(SpringUtil.getBean(MaterialService.class).batchAddMaterial(addM)); ;
|
||||
if(CollUtil.isNotEmpty(addM)) {
|
||||
vMNos.putAll(SpringUtil.getBean(MaterialService.class).batchAddMaterial(addM));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,20 +114,20 @@ public class EBomToPBomForFormal31New extends FormalEBomToPbomBase {
|
|||
}
|
||||
//子级
|
||||
List<BomNewEbomParentVO> child = facBomDataMp.get(facCode).stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId()) && !childDelMaterialNos.contains(u.getMaterialNo())).distinct().collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
|
||||
//对比PBOM 版本是否一致(跟节点除外)
|
||||
// if(!parent.getMaterialNo().equals(vo.getMaterialNo()) && !VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
// continue;
|
||||
// }
|
||||
// if(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
// if(compareContentIsSame(vo,mergeChild,facCode)){
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
List<BomNewEbomParentVO> mergeChild=child;
|
||||
//直发包/发货前包不合并
|
||||
if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
mergeChild = mergeChild(child);
|
||||
}
|
||||
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//处理子级
|
||||
if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())) {
|
||||
mergeChild = handlerArtPackage(parentEnt, mergeChild, facCode, parentList, vo.getVirtualPartType());
|
||||
}
|
||||
//检查是否用户跟用户节点()
|
||||
if(parentEnt.getMaterialNo().equals(parent.getMaterialNo())) {
|
||||
List<String> childMaterialNos = SpringUtil.getBean(BomNewPbomParentMapper.class).getPBomExistMaterialInChildForWorkList(parent.getMaterialNo());
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.alibaba.excel.enums.BooleanEnum;
|
|||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.ConvertToPBomModelEnum;
|
||||
import com.nflg.product.bomnew.constant.EBomConstant;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
|
|
@ -18,9 +19,7 @@ import com.nflg.product.bomnew.util.ListCommonUtil;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -30,6 +29,7 @@ import java.util.stream.Collectors;
|
|||
public class EBomToPBomForFormalNew extends FormalEBomToPbomBase {
|
||||
|
||||
|
||||
private Map<String, List<BomNewEbomParentVO>> facBomDataMp = new HashMap<>();
|
||||
|
||||
|
||||
public EBomToPBomForFormalNew(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId, ConvertToPBomModelEnum convertModelEnum) {
|
||||
|
|
@ -42,6 +42,39 @@ public class EBomToPBomForFormalNew extends FormalEBomToPbomBase {
|
|||
|
||||
}
|
||||
|
||||
private void splitData() {
|
||||
|
||||
//1020数据
|
||||
List<BomNewEbomParentVO> data1020 = new ArrayList<>();
|
||||
List<BomNewEbomParentVO> deliveryPackage1020 = result.stream().filter(u -> u.getParentRowId().equals(parent.getRowId()) && u.getMaterialName().contains("仙桃")).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(deliveryPackage1020)) {
|
||||
|
||||
data1020.add(parent);
|
||||
for (BomNewEbomParentVO data : deliveryPackage1020) {
|
||||
List<BomNewEbomParentVO> subVos = getResultAllSubIncludeSelf(data);
|
||||
data1020.addAll(subVos);
|
||||
}
|
||||
facBomDataMp.put(EBomConstant.XIAN_TAO_FACTORY_CODE_1020, data1020);
|
||||
}
|
||||
|
||||
//1010 数据
|
||||
List<BomNewEbomParentVO> data1010 = new ArrayList<>();
|
||||
List<BomNewEbomParentVO> deliveryPackage1010 = result.stream().filter(u -> u.getParentRowId().equals(parent.getRowId())).collect(Collectors.toList()); //&& !u.getMaterialName().contains("仙桃")
|
||||
if (CollUtil.isNotEmpty(deliveryPackage1010)) {
|
||||
|
||||
data1010.add(parent);
|
||||
for (BomNewEbomParentVO data : deliveryPackage1010) {
|
||||
List<BomNewEbomParentVO> subVos = new ArrayList<>();
|
||||
if (!data.getMaterialName().contains("仙桃") ) { //只获取下降虚拟包(排除仙桃油漆包)
|
||||
subVos=getResultAllSubIncludeSelf(data);
|
||||
}
|
||||
data1010.addAll(subVos);
|
||||
}
|
||||
facBomDataMp.put(EBomConstant.MAIN_FACTORY_CODE_1010, data1010);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 31項体层
|
||||
|
|
@ -53,10 +86,21 @@ public class EBomToPBomForFormalNew extends FormalEBomToPbomBase {
|
|||
check();
|
||||
//bom 提层
|
||||
liftingLayer();
|
||||
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
|
||||
splitData();
|
||||
|
||||
List<String> hasConvert = new ArrayList<>();
|
||||
|
||||
for (String facCode : facCodes) {
|
||||
//仙桃的不发1010工厂
|
||||
if(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode) && parent.getMaterialName().contains("仙桃") ){
|
||||
continue;
|
||||
}
|
||||
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
if(EBomConstant.MAIN_FACTORY_CODE_1010.equals(facCode)){
|
||||
parentList = ListCommonUtil.toDistinct(facBomDataMp.get(facCode).stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||
}
|
||||
|
||||
//buildPBomParent(parent, facCode);
|
||||
for (BomNewEbomParentVO vo : parentList) {
|
||||
String hasConvertKey = StrUtil.join("-", facCode, vo.getBomRowId());
|
||||
|
|
@ -71,23 +115,17 @@ public class EBomToPBomForFormalNew extends FormalEBomToPbomBase {
|
|||
}
|
||||
//子级
|
||||
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId()) && !childDelMaterialNos.contains(u.getMaterialNo())).distinct().collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
|
||||
|
||||
//对比PBOM 版本是否一致(跟节点除外)
|
||||
// if(!parent.getMaterialNo().equals(vo.getMaterialNo()) && !VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
// continue;
|
||||
// }
|
||||
// if(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
// if(compareContentIsSame(vo,mergeChild,facCode)){
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
List<BomNewEbomParentVO> mergeChild=child;
|
||||
//直发包/发货前包不合并
|
||||
if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
mergeChild = mergeChild(child);
|
||||
}
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//处理子级
|
||||
mergeChild=handlerArtPackage(parentEnt,mergeChild,facCode,parentList,vo.getVirtualPartType());
|
||||
//检查是否用户跟用户节点()
|
||||
if(parentEnt.getMaterialNo().equals(parent.getMaterialNo())) {
|
||||
List<String> childMaterialNos = SpringUtil.getBean(BomNewPbomParentMapper.class).getPBomExistMaterialInChildForWorkList(parent.getMaterialNo());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.product.bomnew.service.domain.EBom.topbomnew;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
|
|
@ -25,6 +26,7 @@ import lombok.Getter;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class FormalEBomToPbomBase {
|
||||
|
|
@ -131,6 +133,14 @@ public abstract class FormalEBomToPbomBase {
|
|||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* pbom- 排除工艺包,新增行,更新行的处理
|
||||
* 1、
|
||||
*/
|
||||
private void pBomHandler(BomNewEbomParentVO pVo){
|
||||
|
||||
}
|
||||
|
||||
//合并子级
|
||||
|
|
@ -183,14 +193,20 @@ public abstract class FormalEBomToPbomBase {
|
|||
else if (Objects.nonNull(oldParent) && oldParent.getStatus() < EBomStatusEnum.PUBLISHED.getValue()) {
|
||||
//if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy())) {
|
||||
if (ConvertToPBomModelEnum.OVERRIDE.equalsValue(convertMode.getValue())) {
|
||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
|
||||
oldParent.setSourceRowId(parentVo.getBomRowId());
|
||||
oldParent.setCreatedTime(LocalDateTime.now());
|
||||
oldParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
oldParent.setDeptName(SessionUtil.getDepartName());
|
||||
oldParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
this.pBomParentResult.add(oldParent);
|
||||
return oldParent;
|
||||
if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy()) || parentVo.getCurrentVersion()==null || VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0) {
|
||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
|
||||
oldParent.setSourceRowId(parentVo.getBomRowId());
|
||||
oldParent.setCreatedTime(LocalDateTime.now());
|
||||
oldParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
oldParent.setDeptName(SessionUtil.getDepartName());
|
||||
oldParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
if(StrUtil.isNotBlank(parentVo.getCurrentVersion()) && VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0){
|
||||
oldParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||
oldParent.setEbomVersion(parentVo.getCurrentVersion());
|
||||
}
|
||||
this.pBomParentResult.add(oldParent);
|
||||
return oldParent;
|
||||
}
|
||||
|
||||
} else {
|
||||
// 降parentVo 及其子节点标记为不转换
|
||||
|
|
@ -199,51 +215,88 @@ public abstract class FormalEBomToPbomBase {
|
|||
return null;
|
||||
|
||||
} else { //pbom-处于正式表(全部生成小版本)
|
||||
return buildParentEntity(parentVo, facCode, oldParent, VersionUtil.getNextVersionForSmallVersion(oldParent.getCurrentVersion()));
|
||||
return buildParentEntity(parentVo, facCode, oldParent, VersionUtil.getPBomUpgradNextVersion(oldParent.getCurrentVersion()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Pbom-下一个版本(只是项目类别发生变化则生成小版本,否则大版本)
|
||||
*/
|
||||
private String getPBomNextVersion(BomNewPbomParentEntity oldPBomParent, List<BomNewEbomParentVO> newChildren){
|
||||
//旧bom除T项之外
|
||||
List<BomNewPbomParentVO> oldBomDetail = SpringUtil.getBean(BomNewPbomParentService.class).getBaseMapper().getParentChild(oldPBomParent.getRowId());
|
||||
List<BomNewPbomParentVO> oldBomNoTChildren = oldBomDetail.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||
//新BOM 除T项外
|
||||
List<BomNewEbomParentVO> newBomNoTChildren = newChildren.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||
Set<String> oldChildSet = oldBomNoTChildren.stream().map(u -> u.getMaterialNoAndNum()).collect(Collectors.toSet());
|
||||
Set<String> newChildSet = newBomNoTChildren.stream().map(u -> u.getMaterialNoAndNum()).collect(Collectors.toSet());
|
||||
if(oldChildSet.equals(newChildSet)){
|
||||
return VersionUtil.getNextVersionForSmallVersion(oldPBomParent.getCurrentVersion());
|
||||
}
|
||||
return VersionUtil.getNextVersion(oldPBomParent.getCurrentVersion());
|
||||
private BomNewPbomChildEntity buildPBomAddChild(BomNewPbomParentEntity parent, String facCode, BomNewPbomParentVO oldChild){
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(oldChild, childEnt, "sourceRowId");
|
||||
childEnt.setRowId(IdWorker.getId());
|
||||
childEnt.setParentRowId(parent.getRowId());
|
||||
childEnt.setFacCode(facCode);
|
||||
childEnt.setIdentityNo(StrUtil.join("-", parent.getMaterialNo(), oldChild.getMaterialNo()));
|
||||
childEnt.setCreatedTime(LocalDateTime.now());
|
||||
childEnt.setCreatedBy(SessionUtil.getUserCode());
|
||||
|
||||
this.pBomChildResult.add(childEnt);
|
||||
return childEnt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pbom明细对比
|
||||
* @param pVo
|
||||
* @param newChildren
|
||||
* @param facCode
|
||||
* @return 一样则返回true 否则返回 false
|
||||
* 处理PBOM新增物料
|
||||
*/
|
||||
protected boolean pBomSameIs(BomNewEbomParentVO pVo, List<BomNewEbomParentVO> newChildren, String facCode){
|
||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
|
||||
.eq(BomNewPbomParentEntity::getMaterialNo, pVo.getMaterialNo())
|
||||
protected List<BomNewEbomParentVO> handlerArtPackage(BomNewPbomParentEntity parent , List<BomNewEbomParentVO> newBomChildren ,String facCode ,List<BomNewEbomParentVO> parentList,Integer patentVirtualPartType){
|
||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
|
||||
//正式才需对比
|
||||
if(Objects.nonNull(oldParent) && PBomStatusEnum.PUBLISH.getValue()<= oldParent.getStatus()){
|
||||
List<BomNewPbomChildEntity> pBomChildList = SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, oldParent.getRowId()).list();
|
||||
Set<String> oldSet = pBomChildList.stream().map(u -> StrUtil.join("",u.getMaterialNo(), u.getNum(), u.getProjectType())).collect(Collectors.toSet());
|
||||
Set<String> newSet = newChildren.stream().map(u -> StrUtil.join("", u.getMaterialNo(), u.getNum(), u.getProjectType())).collect(Collectors.toSet());
|
||||
if(oldSet.equals(newSet)){
|
||||
return true;
|
||||
List<String> delResult=new ArrayList<>();
|
||||
//pBom为已发布时
|
||||
if(Objects.nonNull(oldParent) && PBomStatusEnum.PUBLISH.getValue()<= oldParent.getStatus()) {
|
||||
List<BomNewPbomParentVO> oldChildren=SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldParent.getRowId(),1);
|
||||
|
||||
//pBom 手工新增物料
|
||||
List<BomNewPbomParentVO> oldPBomAddChildren = oldChildren.stream().filter(u -> StrUtil.isBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
Map<String, BomNewEbomParentVO> newBomChildrenMap = newBomChildren.stream().collect(Collectors.toMap(BomNewEbomParentVO::getMaterialNo, Function.identity(),(u,u1) -> u));
|
||||
|
||||
for (BomNewPbomParentVO oldPBomAddItem : oldPBomAddChildren) {
|
||||
//加入当前BOM明细中
|
||||
if(!newBomChildrenMap.containsKey(oldPBomAddItem.getMaterialNo()) && !VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(patentVirtualPartType) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(patentVirtualPartType)) {
|
||||
buildPBomAddChild(parent, facCode, oldPBomAddItem);
|
||||
}
|
||||
//直发包,发货前-允许物料重复
|
||||
if(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(patentVirtualPartType) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(patentVirtualPartType)) {
|
||||
buildPBomAddChild(parent, facCode, oldPBomAddItem);
|
||||
}
|
||||
|
||||
//如为工艺包,且在当前BOM中不存在
|
||||
if (!VirtualPackageTypeEnum.DELIVERY_PACKAGE.equalsValue(oldPBomAddItem.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(oldPBomAddItem.getVirtualPartType()) && !VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(oldPBomAddItem.getVirtualPartType()) && BomConstant.ART_PACKAGE_MATERIAL_CATEGORY_CODE.equals(oldPBomAddItem.getMaterialCategoryCode()) && !newBomChildrenMap.containsKey(oldPBomAddItem.getMaterialNo())) {
|
||||
//创建工艺包版本
|
||||
BomNewPbomParentEntity artParent = buildPBomParent(Convert.convert(BomNewEbomParentVO.class, oldPBomAddItem), facCode, parentList);
|
||||
//old 工艺包子级
|
||||
List<BomNewPbomParentVO> oldArtChildren = SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldPBomAddItem.getBomRowId(), 1);
|
||||
for (BomNewPbomParentVO oldArtChild : oldArtChildren) {
|
||||
//工艺包新增
|
||||
if (StrUtil.isBlank(oldArtChild.getOriginalMaterialNo())) {
|
||||
buildPBomAddChild(artParent, facCode, oldArtChild);
|
||||
}
|
||||
if(StrUtil.isNotBlank(oldArtChild.getOriginalMaterialNo()) && newBomChildrenMap.containsKey(oldArtChild.getOriginalMaterialNo())){
|
||||
// newBomChildrenMap.get(oldArtChild.getOriginalMaterialNo()).setParentRowId(artParent.getRowId());
|
||||
buildPBomAddChild(artParent, facCode, Convert.convert(BomNewPbomParentVO.class,newBomChildrenMap.get(oldArtChild.getOriginalMaterialNo()) ));
|
||||
delResult.add(oldArtChild.getOriginalMaterialNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//pBom中修改过的
|
||||
List<BomNewPbomParentVO> oldPBomUpdateChildren = oldChildren.stream().filter(u -> StrUtil.isNotBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO oldPBomUpdateChild : oldPBomUpdateChildren) {
|
||||
if (!oldPBomUpdateChild.getOriginalMaterialNo().equals(oldPBomUpdateChild.getMaterialNo()) || !oldPBomUpdateChild.getOriginalProjectType().equals(oldPBomUpdateChild.getProjectType()) || !oldPBomUpdateChild.getOriginalNum().equals(oldPBomUpdateChild.getNum())) {
|
||||
List<BomNewEbomParentVO> upEnts = newBomChildren.stream().filter(u -> u.getMaterialNo().equals(oldPBomUpdateChild.getOriginalMaterialNo())
|
||||
&& u.getProjectType().equals(oldPBomUpdateChild.getOriginalProjectType()) && VUtils.compareSafely(u.getNum(),oldPBomUpdateChild.getOriginalNum())==0).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(upEnts)) {
|
||||
upEnts.get(0).setMaterialNo(oldPBomUpdateChild.getMaterialNo());
|
||||
upEnts.get(0).setNum(oldPBomUpdateChild.getNum());
|
||||
upEnts.get(0).setProjectType(oldPBomUpdateChild.getProjectType());
|
||||
}
|
||||
}
|
||||
}
|
||||
return newBomChildren.stream().filter(u->!delResult.contains(u.getMaterialNo())).collect(Collectors.toList());
|
||||
}
|
||||
return false;
|
||||
return newBomChildren;
|
||||
}
|
||||
|
||||
private BomNewPbomParentEntity buildParentEntity(BomNewEbomParentVO parentVo, String facCode, BomNewPbomParentEntity oldParent, String bomVersion) {
|
||||
|
|
@ -267,6 +320,11 @@ public abstract class FormalEBomToPbomBase {
|
|||
pBomParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
pBomParent.setSource(PbomSourceEnum.FROM_EBOM.getValue());
|
||||
pBomParent.setSourceStatus(PbomSourceStatusEnum.EBOM.getValue());
|
||||
//EBOM版本大于pbom版本则用EBOm版本
|
||||
if(oldParent!=null && VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0){
|
||||
pBomParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||
pBomParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||
}
|
||||
if (Objects.nonNull(oldParent)) {
|
||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||
oldParent.setLastVersionIs(0);
|
||||
|
|
@ -379,7 +437,7 @@ public abstract class FormalEBomToPbomBase {
|
|||
buildVirtualPackageComposition(lastVirtualPackage, ent);
|
||||
}
|
||||
}
|
||||
newEnt.setBomRowId(0L);
|
||||
// newEnt.setBomRowId(0L);
|
||||
newEnt.setChildBomRowId(0L);
|
||||
newEnt.setNum(sum);
|
||||
return newEnt;
|
||||
|
|
|
|||
|
|
@ -312,7 +312,11 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
parentEntity.setMaterialName(baseMaterialVO.getMaterialName());
|
||||
parentEntity.setMaterialDesc(baseMaterialVO.getMaterialDesc());
|
||||
parentEntity.setMaterialTexture(baseMaterialVO.getMaterialTexture());
|
||||
parentEntity.setMaterialUnit("KG");
|
||||
parentEntity.setMaterialUnit(baseMaterialVO.getMaterialUnit());
|
||||
if(!baseMaterialVO.getMaterialUnit().equalsIgnoreCase("KG")){
|
||||
parentEntity.setNum(null);
|
||||
}
|
||||
// parentEntity.setMaterialUnit("KG");
|
||||
parentEntity.setProjectType("L");
|
||||
parentEntity.setDrawingNo(baseMaterialVO.getDrawingNo());
|
||||
parentEntity.setRegReplaceIs(1);
|
||||
|
|
@ -321,6 +325,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private BaseMaterialVO getCommonMaterialByRel(BomOriginalListVO parentEntity) {
|
||||
|
|
@ -358,7 +363,11 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
childEntity.setUnitWeight(parentV.getUnitWeight());
|
||||
childEntity.setNum(parentV.getUnitWeight());
|
||||
childEntity.setCreatedBy(SessionUtil.getUserCode());
|
||||
childEntity.setMaterialUnit("KG");
|
||||
if(!material.getMaterialUnit().equalsIgnoreCase("KG")){
|
||||
childEntity.setNum(null);
|
||||
}
|
||||
childEntity.setMaterialUnit(material.getMaterialUnit());
|
||||
// childEntity.setMaterialUnit("KG");
|
||||
childEntity.setProjectType("L");
|
||||
childEntity.setMaterialOriginalUnit(material.getMaterialUnit());
|
||||
childEntity.setSourceRowId(parentV.getRowId().toString());
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ public class PBomDetailTask extends RecursiveTask<List<BomNewPbomParentVO>> {
|
|||
detailVO.setBomExist(ebomParentEntity.getBomExist());
|
||||
detailVO.setShouldBomExist(ebomParentEntity.getShouldBomExist());
|
||||
detailVO.setVirtualPackageIs(ebomParentEntity.getVirtualPackageIs());
|
||||
detailVO.setEbomVersion(ebomParentEntity.getEbomVersion());
|
||||
} else {
|
||||
BomNewPbomParentEntity parent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getRowId, detailVO.getParentRowId()).one();
|
||||
detailVO.setDeviseUserCode(parent.getDeviseUserCode());
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class PBomUpgrade {
|
|||
pbomParent.setCreatedBy(SessionUtil.getUserCode());
|
||||
pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||
pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
pbomParent.setCurrentVersion(VersionUtil.getNextVersion(parentVO.getCurrentVersion()));
|
||||
pbomParent.setCurrentVersion(VersionUtil.getPBomUpgradNextVersion(parentVO.getCurrentVersion()));
|
||||
pbomParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
pbomParent.setDeptName(SessionUtil.getDepartName());
|
||||
pbomParent.setDeviseName(SessionUtil.getRealName());
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.PBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.PbomSourceStatusEnum;
|
||||
import com.nflg.product.bomnew.pojo.dto.TechnologyPackageParam;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
|
|
@ -232,6 +233,7 @@ public class TechnologyPackageParamBuilder {
|
|||
child.setCreatedTime(LocalDateTime.now());
|
||||
child.setModifyTime(LocalDateTime.now());
|
||||
child.setSourceRowId(0L);
|
||||
child.setSourceStatus(PbomSourceStatusEnum.PBOM.getValue());
|
||||
this.packageChildren.add(child);
|
||||
return child;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.nflg.product.bomnew.inteface.ThrowExceptionFunction;
|
|||
import com.nflg.product.bomnew.inteface.TrueHandleFunction;
|
||||
import nflg.product.common.constant.STATE;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
|
@ -89,4 +90,16 @@ public class VUtils {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static int compareSafely(BigDecimal a, BigDecimal b) {
|
||||
if (a == null && b == null) {
|
||||
return 0; // 两个都是null,认为相等
|
||||
} else if (a == null) {
|
||||
return -1; // 只有a是null,认为a更小
|
||||
} else if (b == null) {
|
||||
return -1; // 只有b是null,认为b更小
|
||||
} else {
|
||||
return a.compareTo(b); // 两个都不为null,直接比较
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import cn.hutool.core.convert.Convert;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.data.util.Version;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.naming.SelectorContext.prefix;
|
||||
|
||||
|
|
@ -59,6 +61,7 @@ public class VersionUtil {
|
|||
// Split the previous version number into its components
|
||||
String[] previousComponents = previousVersion.replace(versionPrefix, "").split("\\.");
|
||||
|
||||
previousComponents= filterNumericStrings(previousComponents).toArray(new String[0]);
|
||||
int previousMajor = Integer.parseInt(previousComponents[0]);
|
||||
int previousMinor = previousComponents.length < 2 ? 0 : Integer.parseInt(previousComponents[1]);
|
||||
|
||||
|
|
@ -86,6 +89,43 @@ public class VersionUtil {
|
|||
return nextVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤出数组中仅包含数字的字符串。
|
||||
*
|
||||
* @param array 输入的字符串数组
|
||||
* @return 包含数字字符串的列表
|
||||
*/
|
||||
public static List<String> filterNumericStrings(String[] array) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String s : array) {
|
||||
if (isNumeric(s)) {
|
||||
result.add(s);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查给定的字符串是否表示一个数字。
|
||||
* 支持整数、浮点数和科学计数法表示的数字。
|
||||
*
|
||||
* @param str 要检查的字符串
|
||||
* @return 如果字符串表示一个数字,则返回true;否则返回false
|
||||
*/
|
||||
private static boolean isNumeric(String str) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
// 尝试将字符串转换为Double类型
|
||||
Double.parseDouble(str);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果转换失败,说明不是有效的数字格式
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本比较
|
||||
* @param version1
|
||||
|
|
@ -122,4 +162,48 @@ public class VersionUtil {
|
|||
return Integer.compare(split1.length, split2.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取PBOM 升级版本号(PBOM升级版本号规则)
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public static String getPBomUpgradNextVersion(String version) {
|
||||
if (version == null || version.isEmpty()) {
|
||||
throw new IllegalArgumentException("输入版本号不能为空");
|
||||
}
|
||||
char lastChar = version.charAt(version.length() - 1);
|
||||
boolean isLetter = Character.isLetter(lastChar);
|
||||
if (!isLetter) {
|
||||
if(version.contains(".")){
|
||||
return version + "a";
|
||||
}
|
||||
return version + ".0a";
|
||||
} else {
|
||||
int lastCharIndex = version.length() - 1;
|
||||
char newLastChar = (char) (lastChar + 1);
|
||||
|
||||
if (newLastChar > 'z') {
|
||||
// Handle case where the last character is 'z'
|
||||
StringBuilder sb = new StringBuilder(version.substring(0, lastCharIndex));
|
||||
if(!sb.toString().contains(".")) {
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append("a").append('a');
|
||||
return sb.toString();
|
||||
} else {
|
||||
return version.substring(0, lastCharIndex) + newLastChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getNextLetter(char currentLetter) {
|
||||
char nextLetter = (char) (currentLetter + 1);
|
||||
if (nextLetter > 'z') {
|
||||
return "a" + getNextLetter('a');
|
||||
} else {
|
||||
return "" + nextLetter;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
<result column="notice_nums" property="noticeNums" jdbcType="VARCHAR"/>
|
||||
<result column="order_no" property="orderNo" jdbcType="VARCHAR"/>
|
||||
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="ebom_version" property="ebomVersion" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
|
|
@ -57,7 +58,7 @@
|
|||
should_bom_exist, super_material_status, bom_exist, last_version_is, edit_status, status, user_root_is,
|
||||
virtual_package_is, source_row_id, devise_user_code, devise_name,technology_user_code,technology_user_name, created_by, created_time, created_job,
|
||||
release_time, release_user_name,last_convert_mbom_user_name,last_convert_mbom_time, expire_end_time, remark, dept_name, level_num, change_desc, notice_nums,
|
||||
order_no, modify_time
|
||||
order_no, modify_time,ebom_version
|
||||
</sql>
|
||||
|
||||
<sql id="whr">
|
||||
|
|
@ -323,9 +324,9 @@
|
|||
</update>
|
||||
|
||||
<insert id="insertPBomParentToFormal">
|
||||
INSERT INTO `t_bom_new_pbom_parent_formal` (`row_id`, `batch_no`, `drawing_no`, `fac_code`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `project_type`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `technology_user_code`, `technology_user_name`, `created_by`, `created_time`, `created_job`, `release_time`, `release_user_name`, `last_convert_mbom_user_name`, `last_convert_mbom_time`, `expire_end_time`, `remark`, `dept_name`, `dept_row_id`,`level_num`, `change_desc`, `notice_nums`, `order_no`, `modify_time`, `sap_state`, `sap_time`,`source`)
|
||||
INSERT INTO `t_bom_new_pbom_parent_formal` (`row_id`, `batch_no`, `drawing_no`, `fac_code`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `project_type`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `technology_user_code`, `technology_user_name`, `created_by`, `created_time`, `created_job`, `release_time`, `release_user_name`, `last_convert_mbom_user_name`, `last_convert_mbom_time`, `expire_end_time`, `remark`, `dept_name`, `dept_row_id`,`level_num`, `change_desc`, `notice_nums`, `order_no`, `modify_time`, `sap_state`, `sap_time`,`source`,`ebom_version`)
|
||||
|
||||
select `row_id`, `batch_no`, `drawing_no`, `fac_code`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `project_type`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `technology_user_code`, `technology_user_name`, `created_by`, `created_time`, `created_job`, `release_time`, `release_user_name`, `last_convert_mbom_user_name`, `last_convert_mbom_time`, `expire_end_time`, `remark`, `dept_name`, dept_row_id,`level_num`, `change_desc`, `notice_nums`, `order_no`, `modify_time`, `sap_state`, `sap_time`,`source`
|
||||
select `row_id`, `batch_no`, `drawing_no`, `fac_code`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `project_type`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `technology_user_code`, `technology_user_name`, `created_by`, `created_time`, `created_job`, `release_time`, `release_user_name`, `last_convert_mbom_user_name`, `last_convert_mbom_time`, `expire_end_time`, `remark`, `dept_name`, dept_row_id,`level_num`, `change_desc`, `notice_nums`, `order_no`, `modify_time`, `sap_state`, `sap_time`,`source`,`ebom_version`
|
||||
from t_bom_new_pbom_parent
|
||||
where row_id in
|
||||
<foreach collection="bomRowIds" item="item" open="(" separator="," close=")">
|
||||
|
|
|
|||
Loading…
Reference in New Issue