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/api/user/EbomApi.java # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewEbomChildMapper.java # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java # nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomChildMapper.xml
This commit is contained in:
commit
d91db60c95
|
|
@ -19,6 +19,7 @@ import com.nflg.product.bomnew.pojo.vo.*;
|
||||||
import com.nflg.product.bomnew.service.*;
|
import com.nflg.product.bomnew.service.*;
|
||||||
import com.nflg.product.bomnew.util.EecExcelUtil;
|
import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
|
import com.nflg.product.bomnew.util.VersionUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import nflg.product.common.constant.STATE;
|
import nflg.product.common.constant.STATE;
|
||||||
|
|
@ -38,6 +39,7 @@ import javax.validation.constraints.NotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
@ -161,13 +163,9 @@ public class EbomApi extends BaseApi {
|
||||||
public ResultVO<List<OperationErrorMsgVO>> convertToPBom(@RequestBody EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
|
public ResultVO<List<OperationErrorMsgVO>> convertToPBom(@RequestBody EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
|
||||||
VUtils.isTure(CollUtil.isEmpty(paramDto.getBomRowIds())).throwMessage("请选择要转换的物料");
|
VUtils.isTure(CollUtil.isEmpty(paramDto.getBomRowIds())).throwMessage("请选择要转换的物料");
|
||||||
VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂");
|
VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂");
|
||||||
|
VUtils.isTure(Objects.isNull(paramDto.getConvertMode())).throwMessage("转换模式不能为空");
|
||||||
bomNewEbomParentService.convertToPBom(paramDto);
|
bomNewEbomParentService.convertToPBom(paramDto);
|
||||||
|
|
||||||
//更新PBomUse 数据
|
|
||||||
// CompletableFuture.runAsync(()->{
|
|
||||||
// bomNewPbomParentService.getBaseMapper().updatePBomMaterialUse();
|
|
||||||
// });
|
|
||||||
|
|
||||||
//导入到sap
|
//导入到sap
|
||||||
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
|
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
|
||||||
paramDto.getBomRowIds().forEach(rootRowId -> {
|
paramDto.getBomRowIds().forEach(rootRowId -> {
|
||||||
|
|
@ -178,6 +176,19 @@ public class EbomApi extends BaseApi {
|
||||||
return ResultVO.success(errorMsgVOS);
|
return ResultVO.success(errorMsgVOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("convertToPBomForFormalEBom")
|
||||||
|
@ApiOperation("EBom正式版转PBom")
|
||||||
|
@LogRecord(success = "转PBom:物料编码:{{#CToPbom.materialNo}} 版本:{{#CToPbom.currentVersion}},操作结果:{{#_ret}}",
|
||||||
|
bizNo = "{{#paramDto.bomRowIds.toString()}}", type = "转PBom")
|
||||||
|
public ResultVO<List<OperationErrorMsgVO>> convertToPBomForFormalEBom(@RequestBody EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
|
||||||
|
VUtils.isTure(CollUtil.isEmpty(paramDto.getBomRowIds())).throwMessage("请选择要转换的物料");
|
||||||
|
VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂");
|
||||||
|
VUtils.isTure(Objects.isNull(paramDto.getConvertMode())).throwMessage("转换模式不能为空");
|
||||||
|
bomNewEbomParentService.convertToPBomForFormalEBom(paramDto);
|
||||||
|
|
||||||
|
return ResultVO.success(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("upgradeChanges")
|
@PostMapping("upgradeChanges")
|
||||||
@ApiOperation("发起变更")
|
@ApiOperation("发起变更")
|
||||||
@LogRecord(success = "发起变更:物料编码:{{#bom.materialNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}",
|
@LogRecord(success = "发起变更:物料编码:{{#bom.materialNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.nflg.product.bomnew.constant;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ebom转Pbom 转换模式
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum ConvertToPBomModelEnum implements ValueEnum<Integer>{
|
||||||
|
// 转换模式:0-常规 1-覆盖
|
||||||
|
NORMAL(0, "常规"),
|
||||||
|
OVERRIDE(1, "覆盖");
|
||||||
|
|
||||||
|
private final Integer value;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -32,4 +32,6 @@ public interface BomNewEbomChildMapper extends BaseMapper<BomNewEbomChildEntity>
|
||||||
List<BomNewEbomParentVO> getBom(Long parentRowId, String materialNo);
|
List<BomNewEbomParentVO> getBom(Long parentRowId, String materialNo);
|
||||||
|
|
||||||
void deleteAllChildren(Long rowId);
|
void deleteAllChildren(Long rowId);
|
||||||
|
|
||||||
|
void delBomChild(@Param("bomRowIds") List<Long> bomRowIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.nflg.product.bomnew.pojo.dto;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -14,6 +15,10 @@ public class EBomToPBomParamDTO {
|
||||||
@ApiModelProperty("物料bom行ID")
|
@ApiModelProperty("物料bom行ID")
|
||||||
private List<Long> bomRowIds;
|
private List<Long> bomRowIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("转换模式:0-常规 1-覆盖")
|
||||||
|
@NotBlank( message = "转换模式:0-常规 1-覆盖 不能为空")
|
||||||
|
private Integer convertMode;
|
||||||
|
|
||||||
@ApiModelProperty("工厂编码列表")
|
@ApiModelProperty("工厂编码列表")
|
||||||
private List<String> facCodes;
|
private List<String> facCodes;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,12 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
||||||
@ApiModelProperty(value = "导入SAP状态")
|
@ApiModelProperty(value = "导入SAP状态")
|
||||||
private Integer sapState;
|
private Integer sapState;
|
||||||
|
|
||||||
|
@ApiModelProperty("无需转PBom-和正式版BOM一致")
|
||||||
|
private Integer noConvertToPBomIs=0;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否发生了变更 0:不变 1:删除-和正式版一致 2-版本发版变化")
|
||||||
|
private Integer hasChangeState=0;
|
||||||
|
|
||||||
private List<BomNewEbomParentVO> childNodes = Collections.emptyList();
|
private List<BomNewEbomParentVO> childNodes = Collections.emptyList();
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -542,6 +542,25 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取正式表整个BOM树
|
||||||
|
*
|
||||||
|
* @param rowId
|
||||||
|
* @return
|
||||||
|
* @throws ExecutionException
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
public List<BomNewEbomParentVO> getFormalBomTree(Long rowId) throws ExecutionException, InterruptedException {
|
||||||
|
List<BomNewEbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
||||||
|
EBomFormalDetailTask detailTask = new EBomFormalDetailTask(bomDetail);
|
||||||
|
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
|
||||||
|
|
||||||
|
List<BomNewEbomParentVO> result = submit.join();
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取整个BOM树
|
* 获取整个BOM树
|
||||||
*
|
*
|
||||||
|
|
@ -844,11 +863,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
//31 码 须有虚拟包
|
//31 码 须有虚拟包
|
||||||
List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds());
|
List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds());
|
||||||
|
|
||||||
// VUtils.isTure(paramDto.getFacCodes().contains("1020") && parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31")))
|
|
||||||
// .throwMessage("31码不能生成仙桃(1020)的pbom");
|
|
||||||
|
|
||||||
// VUtils.isTure(parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0))
|
|
||||||
// .throwMessage("31码须有虚拟包");
|
|
||||||
parents.forEach(p -> {
|
parents.forEach(p -> {
|
||||||
if (p.getMaterialNo().startsWith("31")) {
|
if (p.getMaterialNo().startsWith("31")) {
|
||||||
List<String> errors = new ArrayList<>();
|
List<String> errors = new ArrayList<>();
|
||||||
|
|
@ -881,7 +895,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
parent.setChildBomRowId(parent.getRowId());
|
parent.setChildBomRowId(parent.getRowId());
|
||||||
parent.setParentRowId(0L);
|
parent.setParentRowId(0L);
|
||||||
bomTree.add(parent);
|
bomTree.add(parent);
|
||||||
EBomToPbomBase eBomToPBom =parent.getMaterialNo().startsWith("31")? new EBomToPBomFor31(parent, bomTree, paramDto.getFacCodes(), 0L):new EBomToPBom(parent, bomTree, paramDto.getFacCodes(), 0L);
|
EBomToPbomBase eBomToPBom =parent.getMaterialNo().startsWith("31")? new EBomToPBomFor31(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode())):new EBomToPBom(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode()));
|
||||||
eBomToPBom.convert();
|
eBomToPBom.convert();
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
|
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
|
||||||
|
|
@ -891,43 +905,36 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
|
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
|
||||||
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
|
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除EBOM中和正式表BOM一致的数据
|
||||||
|
List<BomNewEbomParentVO> delEBomParents = bomTree.stream().filter(u -> u.getHasChangeState().equals(1)).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(delEBomParents)){
|
||||||
|
List<Long> delParentBom = delEBomParents.stream().filter(u -> u.getBomRowId() > 0).map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(delParentBom)){
|
||||||
|
this.getBaseMapper().delBatch(delParentBom);
|
||||||
|
ebomChildService.getBaseMapper().delBomChild(delParentBom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//需修改正式版BOM的版本
|
||||||
|
List<BomNewEbomParentVO> upVersionEBomParents = bomTree.stream().filter(u -> u.getHasChangeState().equals(2)).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(upVersionEBomParents)){
|
||||||
|
List<BomNewEbomParentEntity> upVersionList=new ArrayList<>();
|
||||||
|
for (BomNewEbomParentVO upVersionEBomParent : upVersionEBomParents) {
|
||||||
|
BomNewEbomParentEntity upVersion = new BomNewEbomParentEntity();
|
||||||
|
upVersion.setRowId(upVersionEBomParent.getBomRowId());
|
||||||
|
upVersion.setCurrentVersion(upVersionEBomParent.getCurrentVersion());
|
||||||
|
upVersionList.add(upVersion);
|
||||||
|
}
|
||||||
|
if(CollUtil.isNotEmpty(upVersionList)){
|
||||||
|
this.saveOrUpdateBatch(upVersionList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//标记PBom未发布跟节点
|
//标记PBom未发布跟节点
|
||||||
Set<String> materialNos = bomTree.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
Set<String> materialNos = bomTree.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
||||||
if(CollUtil.isNotEmpty(materialNos)){
|
if(CollUtil.isNotEmpty(materialNos)){
|
||||||
pBomParentService.getBaseMapper().updateWaitPublicRootState(materialNos);
|
pBomParentService.getBaseMapper().updateWaitPublicRootState(materialNos);
|
||||||
}
|
}
|
||||||
//标记跟节点
|
|
||||||
// upRootMark(parent);
|
|
||||||
// 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) {
|
|
||||||
// String[] split = StrUtil.split(s, "-");
|
|
||||||
// virtualPackageCompositionService.getBaseMapper().delByVnoAndParentNo(split[0], split[1]);
|
|
||||||
// }
|
|
||||||
// virtualPackageCompositionService.saveOrUpdateBatch(eBomToPBom.getVirtualPackageCompositionResult());
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// //记录变更影响
|
|
||||||
// if (CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())) {
|
|
||||||
//
|
|
||||||
// List<String> vNos = eBomToPBom.getUpgradeChangeResult().stream().map(u -> StrUtil.join(u.getMaterialNo(), u.getRelMaterialNo())).collect(Collectors.toList());
|
|
||||||
// if (CollUtil.isNotEmpty(vNos)) {
|
|
||||||
// upgradeChangeService.getBaseMapper().delByVNo(vNos);
|
|
||||||
// }
|
|
||||||
// upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult());
|
|
||||||
// }
|
|
||||||
// if (CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeDetailResult())) {
|
|
||||||
//
|
|
||||||
// //先删除
|
|
||||||
// Set<String> delSet = eBomToPBom.getUpgradeChangeDetailResult().stream().map(u -> StrUtil.join("-", u.getVirtualPackageMaterialNo(), u.getParentMaterialNo())).collect(Collectors.toSet());
|
|
||||||
// for (String s : delSet) {
|
|
||||||
// String[] split = StrUtil.split(s, "-");
|
|
||||||
// updateDetailService.getBaseMapper().delByVnoAndParentNo(split[0], split[1]);
|
|
||||||
// }
|
|
||||||
// updateDetailService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeDetailResult());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
List<Long> bomRowIds = bomTree.stream().filter(u -> u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
List<Long> bomRowIds = bomTree.stream().filter(u -> u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(bomRowIds)) {
|
if (CollUtil.isNotEmpty(bomRowIds)) {
|
||||||
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), SessionUtil.getRealName(), bomRowIds);
|
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), SessionUtil.getRealName(), bomRowIds);
|
||||||
|
|
@ -950,6 +957,51 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EBOM 正式版转PBom
|
||||||
|
* @param paramDto
|
||||||
|
* @throws ExecutionException
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void convertToPBomForFormalEBom(EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
|
||||||
|
//31 码 须有虚拟包
|
||||||
|
List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds());
|
||||||
|
|
||||||
|
parents.forEach(p -> {
|
||||||
|
if (p.getMaterialNo().startsWith("31")) {
|
||||||
|
List<String> errors = new ArrayList<>();
|
||||||
|
if (ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, p.getRowId())
|
||||||
|
.eq(BomNewEbomChildEntity::getVirtualPartType, VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())
|
||||||
|
.exists()) {
|
||||||
|
errors.add(p.getMaterialNo() + "下还有未生成发货包的物料");
|
||||||
|
}
|
||||||
|
VUtils.isTure(CollUtil.isNotEmpty(errors)).throwMessage(StrUtil.join("<br/>", errors));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (Long bomRowId : paramDto.getBomRowIds()) {
|
||||||
|
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
|
||||||
|
VUtils.isTure(Objects.isNull(parent)).throwMessage("Bom版本不存在:" + bomRowId.toString());
|
||||||
|
LogRecordContext.putVariable("CToPbom", parent);
|
||||||
|
List<BomNewEbomParentVO> bomTree = getFormalBomTree(bomRowId);
|
||||||
|
VUtils.isTure(CollUtil.isEmpty(bomTree)).throwMessage("该BOM不存在下级,无需转换:" + bomRowId.toString());
|
||||||
|
parent.setBomRowId(parent.getRowId());
|
||||||
|
parent.setChildBomRowId(parent.getRowId());
|
||||||
|
parent.setParentRowId(0L);
|
||||||
|
bomTree.add(parent);
|
||||||
|
EBomToPbomBase eBomToPBom =parent.getMaterialNo().startsWith("31")? new EBomToPBomForFormal31(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode())):new EBomToPBomForFormal(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode()));
|
||||||
|
eBomToPBom.convert();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
|
||||||
|
pBomParentService.saveOrUpdateBatch(eBomToPBom.getPBomParentResult());
|
||||||
|
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
|
||||||
|
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<OperationErrorMsgVO> importToSAP(Long rootBomRowId) {
|
public List<OperationErrorMsgVO> importToSAP(Long rootBomRowId) {
|
||||||
BomNewEbomParentEntity root = this.getById(rootBomRowId);
|
BomNewEbomParentEntity root = this.getById(rootBomRowId);
|
||||||
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
||||||
|
|
@ -2556,7 +2608,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ebom发布时将历史正式版-移到正式表
|
* ebom发布时将历史正式版-移到正式表(所有正式数据都会移到formal正式表中)
|
||||||
* @param exceptRowIds
|
* @param exceptRowIds
|
||||||
*/
|
*/
|
||||||
private void eBomToFormal(List<Long> exceptRowIds, List<BomNewEbomParentVO> parents){
|
private void eBomToFormal(List<Long> exceptRowIds, List<BomNewEbomParentVO> parents){
|
||||||
|
|
@ -2566,8 +2618,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
if(CollUtil.isNotEmpty(toParents)) {
|
if(CollUtil.isNotEmpty(toParents)) {
|
||||||
|
|
||||||
List<Long> childParentRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
List<Long> childParentRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||||
this.getBaseMapper().insertEBomFormalParent(childParentRowIds);
|
List<Long> toFormalRowIds = new ArrayList<>();
|
||||||
this.getBaseMapper().insertEBomFormalChild(childParentRowIds);
|
toFormalRowIds.addAll(exceptRowIds);
|
||||||
|
toFormalRowIds.addAll(childParentRowIds);
|
||||||
|
this.getBaseMapper().insertEBomFormalParent(toFormalRowIds);
|
||||||
|
this.getBaseMapper().insertEBomFormalChild(toFormalRowIds);
|
||||||
|
|
||||||
//转移后删除
|
//转移后删除
|
||||||
this.getBaseMapper().delEBomHistory(childParentRowIds);
|
this.getBaseMapper().delEBomHistory(childParentRowIds);
|
||||||
|
|
|
||||||
|
|
@ -1236,8 +1236,11 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
if(CollUtil.isNotEmpty(toParents)) {
|
if(CollUtil.isNotEmpty(toParents)) {
|
||||||
|
|
||||||
List<Long> oldPBomRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
List<Long> oldPBomRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||||
this.getBaseMapper().insertPBomParentToFormal(oldPBomRowIds);
|
List<Long> toFormalPBomRowIds = new ArrayList<>();
|
||||||
this.getBaseMapper().insertPBomChildToFormal(oldPBomRowIds);
|
toFormalPBomRowIds.addAll(exceptRowIds);
|
||||||
|
toFormalPBomRowIds.addAll(oldPBomRowIds);
|
||||||
|
this.getBaseMapper().insertPBomParentToFormal(toFormalPBomRowIds);
|
||||||
|
this.getBaseMapper().insertPBomChildToFormal(toFormalPBomRowIds);
|
||||||
|
|
||||||
//转移后删除
|
//转移后删除
|
||||||
this.getBaseMapper().delPBom(oldPBomRowIds);
|
this.getBaseMapper().delPBom(oldPBomRowIds);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
package com.nflg.product.bomnew.service.domain.EBom;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||||
|
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||||
|
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.RecursiveTask;
|
||||||
|
import java.util.function.BinaryOperator;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 大米
|
||||||
|
* @descreption EBOM 正式版BOM树
|
||||||
|
* @date 2023/7/8 9:18
|
||||||
|
*/
|
||||||
|
public class EBomFormalDetailTask extends RecursiveTask<List<BomNewEbomParentVO>> {
|
||||||
|
|
||||||
|
private List<BomNewEbomParentVO> bomDetail;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public static int levelNum=1;
|
||||||
|
|
||||||
|
List<BomNewEbomParentVO> result = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public EBomFormalDetailTask(List<BomNewEbomParentVO> inBomDetail) {
|
||||||
|
bomDetail = inBomDetail;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理BOM明细中未选择Bom版本的明细;使用最新版
|
||||||
|
*/
|
||||||
|
public void handlerChildBomVersionDetail() {
|
||||||
|
List<String> materialNos = bomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) ).map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(materialNos)) {
|
||||||
|
|
||||||
|
List<BomNewEbomParentEntity> childBomlist = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos)
|
||||||
|
.eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
|
||||||
|
Map<String, BomNewEbomParentEntity> stringBomNewOriginalParentEntityMap = childBomlist.parallelStream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
BomNewEbomParentEntity::getMaterialNo, // key: DrawingNo
|
||||||
|
Function.identity(),
|
||||||
|
BinaryOperator.maxBy(Comparator.comparing(BomNewEbomParentEntity::getCurrentVersion))
|
||||||
|
));
|
||||||
|
// Map<String, BomNewEbomParentEntity> stringBomNewOriginalParentEntityMap = ListCommonUtil.listToMap(childBomlist, BomNewEbomParentEntity::getMaterialNo);
|
||||||
|
for (BomNewEbomParentVO detailVO : bomDetail) {
|
||||||
|
if (stringBomNewOriginalParentEntityMap.containsKey(detailVO.getMaterialNo())) {
|
||||||
|
BomNewEbomParentEntity ebomParentEntity = stringBomNewOriginalParentEntityMap.get(detailVO.getMaterialNo());
|
||||||
|
detailVO.setChildBomRowId(ebomParentEntity.getRowId());
|
||||||
|
detailVO.setBomRowId(ebomParentEntity.getRowId());
|
||||||
|
detailVO.setSourceRowId(ebomParentEntity.getSourceRowId());
|
||||||
|
detailVO.setCurrentVersion(ebomParentEntity.getCurrentVersion());
|
||||||
|
detailVO.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
|
||||||
|
detailVO.setDeptName(ebomParentEntity.getDeptName());
|
||||||
|
detailVO.setDeviseName(ebomParentEntity.getDeviseName());
|
||||||
|
detailVO.setBomExist(ebomParentEntity.getBomExist());
|
||||||
|
detailVO.setStatus(ebomParentEntity.getStatus());
|
||||||
|
detailVO.setBatchNo(ebomParentEntity.getBatchNo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归调用零部件BOM
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected List<BomNewEbomParentVO> compute() {
|
||||||
|
|
||||||
|
handlerChildBomVersionDetail();
|
||||||
|
// 最新 BOM 版本
|
||||||
|
|
||||||
|
result.addAll(bomDetail);
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(bomDetail)) {
|
||||||
|
levelNumAdd();
|
||||||
|
List<Long> childBowIds = bomDetail.stream().filter(u-> u.getChildBomRowId()!=null && u.getChildBomRowId() > 0).map(u->u.getChildBomRowId()).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(childBowIds)) {
|
||||||
|
List<BomNewEbomParentVO> bom = SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().getParentChildBatch(childBowIds);
|
||||||
|
|
||||||
|
EBomFormalDetailTask task = new EBomFormalDetailTask(bom);
|
||||||
|
task.fork();
|
||||||
|
bomDetail.addAll(task.join());
|
||||||
|
return bomDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void levelNumAdd(){
|
||||||
|
levelNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,9 @@ package com.nflg.product.bomnew.service.domain.EBom;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.excel.enums.BooleanEnum;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
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.constant.PBomStatusEnum;
|
||||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||||
|
|
@ -14,6 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,11 +28,13 @@ public class EBomToPBom extends EBomToPbomBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public EBomToPBom(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId) {
|
public EBomToPBom(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId, ConvertToPBomModelEnum convertModelEnum) {
|
||||||
this.parent = inParent;
|
this.parent = inParent;
|
||||||
this.allBomDetail = inAllBomDetail;
|
this.allBomDetail = inAllBomDetail;
|
||||||
this.facCodes = inFacCodes;
|
this.facCodes = inFacCodes;
|
||||||
|
this.convertMode=convertModelEnum;
|
||||||
generateDrawingNo(allBomDetail, parentRowId, "");
|
generateDrawingNo(allBomDetail, parentRowId, "");
|
||||||
|
initEBomVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -54,9 +59,14 @@ public class EBomToPBom extends EBomToPbomBase {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hasConvert.add(hasConvertKey);
|
hasConvert.add(hasConvertKey);
|
||||||
|
|
||||||
|
//无需转换bom
|
||||||
|
if(BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs()) ){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//构建变更明细
|
//构建变更明细
|
||||||
buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||||
buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||||
|
|
||||||
//子级
|
//子级
|
||||||
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).distinct().collect(Collectors.toList());
|
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).distinct().collect(Collectors.toList());
|
||||||
|
|
@ -65,7 +75,10 @@ public class EBomToPBom extends EBomToPbomBase {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode);
|
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||||
|
if(Objects.isNull(parentEnt)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//子级
|
//子级
|
||||||
if (CollUtil.isNotEmpty(child)) {
|
if (CollUtil.isNotEmpty(child)) {
|
||||||
//合并子级
|
//合并子级
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.excel.enums.BooleanEnum;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.nflg.product.bomnew.constant.ConvertToPBomModelEnum;
|
||||||
import com.nflg.product.bomnew.constant.EBomConstant;
|
import com.nflg.product.bomnew.constant.EBomConstant;
|
||||||
import com.nflg.product.bomnew.constant.PBomStatusEnum;
|
import com.nflg.product.bomnew.constant.PBomStatusEnum;
|
||||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||||
|
|
@ -14,10 +16,7 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||||
|
|
||||||
|
|
@ -32,11 +31,14 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
||||||
private Map<String,List<BomNewEbomParentVO>> facBomDataMp=new HashMap<>();
|
private Map<String,List<BomNewEbomParentVO>> facBomDataMp=new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public EBomToPBomFor31(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId) {
|
public EBomToPBomFor31(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId, ConvertToPBomModelEnum convertModelEnum) {
|
||||||
this.parent = inParent;
|
this.parent = inParent;
|
||||||
this.allBomDetail = inAllBomDetail;
|
this.allBomDetail = inAllBomDetail;
|
||||||
this.facCodes = inFacCodes;
|
this.facCodes = inFacCodes;
|
||||||
|
this.convertMode=convertModelEnum;
|
||||||
generateDrawingNo(allBomDetail, parentRowId, "");
|
generateDrawingNo(allBomDetail, parentRowId, "");
|
||||||
|
//初始化Ebom版本
|
||||||
|
initEBomVersion();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,13 +89,19 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
||||||
List<String> hasConvert = new ArrayList<>();
|
List<String> hasConvert = new ArrayList<>();
|
||||||
|
|
||||||
for (String facCode : facCodes) {
|
for (String facCode : facCodes) {
|
||||||
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(facBomDataMp.get(facCode).stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(facBomDataMp.get(facCode).stream().filter(u -> u.getBomRowId() > 0)
|
||||||
|
.sorted(Comparator.comparing(BomNewEbomParentVO::getLevelNumber))
|
||||||
|
.collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||||
for (BomNewEbomParentVO vo : parentList) {
|
for (BomNewEbomParentVO vo : parentList) {
|
||||||
String hasConvertKey = StrUtil.join("-", facCode, vo.getBomRowId());
|
String hasConvertKey = StrUtil.join("-", facCode, vo.getBomRowId());
|
||||||
if (hasConvert.contains(hasConvertKey) || PBomStatusEnum.PUBLISH.equalsValue(vo.getStatus())) {
|
if (hasConvert.contains(hasConvertKey) || PBomStatusEnum.PUBLISH.equalsValue(vo.getStatus())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hasConvert.add(hasConvertKey);
|
hasConvert.add(hasConvertKey);
|
||||||
|
//无需转换bom
|
||||||
|
if(BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs()) ){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//构建变更明细
|
//构建变更明细
|
||||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||||
|
|
@ -104,8 +112,10 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
||||||
if( compareContentIsSame(vo, mergeChild, facCode)){
|
if( compareContentIsSame(vo, mergeChild, facCode)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode);
|
if(Objects.isNull(parentEnt)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//子级
|
//子级
|
||||||
if (CollUtil.isNotEmpty(child)) {
|
if (CollUtil.isNotEmpty(child)) {
|
||||||
//合并子级
|
//合并子级
|
||||||
|
|
@ -118,8 +128,6 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
||||||
childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo()));
|
childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo()));
|
||||||
this.pBomChildResult.add(childEnt);
|
this.pBomChildResult.add(childEnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
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.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;
|
||||||
|
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正式版 Ebom 转Pbom
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class EBomToPBomForFormal extends EBomToPbomBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public EBomToPBomForFormal(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId, ConvertToPBomModelEnum convertModelEnum) {
|
||||||
|
this.parent = inParent;
|
||||||
|
this.allBomDetail = inAllBomDetail;
|
||||||
|
this.facCodes = inFacCodes;
|
||||||
|
this.convertMode=convertModelEnum;
|
||||||
|
generateDrawingNo(allBomDetail, parentRowId, "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 31項体层
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void convert() {
|
||||||
|
|
||||||
|
//效验数据是否OK
|
||||||
|
check();
|
||||||
|
//bom 提层
|
||||||
|
liftingLayer();
|
||||||
|
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||||
|
List<String> hasConvert = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String facCode : facCodes) {
|
||||||
|
//buildPBomParent(parent, facCode);
|
||||||
|
for (BomNewEbomParentVO vo : parentList) {
|
||||||
|
String hasConvertKey = StrUtil.join("-", facCode, vo.getBomRowId());
|
||||||
|
if (hasConvert.contains(hasConvertKey) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
hasConvert.add(hasConvertKey);
|
||||||
|
|
||||||
|
//无需转换bom
|
||||||
|
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())).distinct().collect(Collectors.toList());
|
||||||
|
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
|
||||||
|
if( compareContentIsSame(vo, mergeChild, facCode)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||||
|
if(Objects.isNull(parentEnt)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//子级
|
||||||
|
if (CollUtil.isNotEmpty(child)) {
|
||||||
|
//合并子级
|
||||||
|
for (BomNewEbomParentVO eb : mergeChild) {
|
||||||
|
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||||
|
BeanUtil.copyProperties(eb, childEnt,"sourceRowId");
|
||||||
|
childEnt.setRowId(IdWorker.getId());
|
||||||
|
childEnt.setParentRowId(parentEnt.getRowId());
|
||||||
|
childEnt.setFacCode(facCode);
|
||||||
|
childEnt.setSourceRowId(eb.getRowId());
|
||||||
|
childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo()));
|
||||||
|
this.pBomChildResult.add(childEnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
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;
|
||||||
|
import com.nflg.product.bomnew.constant.ConvertToPBomModelEnum;
|
||||||
|
import com.nflg.product.bomnew.constant.EBomConstant;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||||
|
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 31码转PBOM
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class EBomToPBomForFormal31 extends EBomToPbomBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String,List<BomNewEbomParentVO>> facBomDataMp=new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
public EBomToPBomForFormal31(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId, ConvertToPBomModelEnum convertModelEnum) {
|
||||||
|
this.parent = inParent;
|
||||||
|
this.allBomDetail = inAllBomDetail;
|
||||||
|
this.facCodes = inFacCodes;
|
||||||
|
this.convertMode=convertModelEnum;
|
||||||
|
generateDrawingNo(allBomDetail, parentRowId, "");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = result.stream().filter(u -> u.getLevelNumber().compareTo(data.getLevelNumber()) >= 0 && u.getLevelNumber().compareTo(NumberUtil.add(data.getLevelNumber(), BigDecimal.valueOf(0.01))) < 0).collect(Collectors.toList());
|
||||||
|
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()) && !u.getMaterialName().contains("仙桃")).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(deliveryPackage1010)){
|
||||||
|
facCodes.add(EBomConstant.MAIN_FACTORY_CODE_1010);
|
||||||
|
data1010.add(parent);
|
||||||
|
for (BomNewEbomParentVO data: deliveryPackage1010){
|
||||||
|
List<BomNewEbomParentVO> subVos = result.stream().filter(u -> u.getLevelNumber().compareTo(data.getLevelNumber()) >= 0 && u.getLevelNumber().compareTo(NumberUtil.add(data.getLevelNumber(), BigDecimal.valueOf(0.01))) < 0).collect(Collectors.toList());
|
||||||
|
data1010.addAll(subVos);
|
||||||
|
}
|
||||||
|
facBomDataMp.put(EBomConstant.MAIN_FACTORY_CODE_1010,data1010);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 31項体层
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void convert() {
|
||||||
|
|
||||||
|
//效验数据是否OK
|
||||||
|
check();
|
||||||
|
//bom 提层
|
||||||
|
liftingLayer();
|
||||||
|
result.forEach(u->u.setLevelNo(""));
|
||||||
|
generateDrawingNo(result, parent.getRowId(), "1");
|
||||||
|
splitData();
|
||||||
|
List<String> hasConvert = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String facCode : facCodes) {
|
||||||
|
List<BomNewEbomParentVO> parentList = ListCommonUtil.toDistinct(facBomDataMp.get(facCode).stream().filter(u -> u.getBomRowId() > 0)
|
||||||
|
.sorted(Comparator.comparing(BomNewEbomParentVO::getLevelNumber))
|
||||||
|
.collect(Collectors.toList()), BomNewEbomParentVO::getBomRowId);
|
||||||
|
for (BomNewEbomParentVO vo : parentList) {
|
||||||
|
String hasConvertKey = StrUtil.join("-", facCode, vo.getBomRowId());
|
||||||
|
if (hasConvert.contains(hasConvertKey)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
hasConvert.add(hasConvertKey);
|
||||||
|
//无需转换bom
|
||||||
|
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())).distinct().collect(Collectors.toList());
|
||||||
|
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
|
||||||
|
if( compareContentIsSame(vo, mergeChild, facCode)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||||
|
if(Objects.isNull(parentEnt)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//子级
|
||||||
|
if (CollUtil.isNotEmpty(child)) {
|
||||||
|
//合并子级
|
||||||
|
for (BomNewEbomParentVO eb : mergeChild) {
|
||||||
|
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||||
|
BeanUtil.copyProperties(eb, childEnt,"sourceRowId");
|
||||||
|
childEnt.setRowId(IdWorker.getId());
|
||||||
|
childEnt.setParentRowId(parentEnt.getRowId());
|
||||||
|
childEnt.setFacCode(facCode);
|
||||||
|
childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo()));
|
||||||
|
this.pBomChildResult.add(childEnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.alibaba.excel.enums.BooleanEnum;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
@ -13,14 +14,14 @@ import com.nflg.product.bomnew.constant.*;
|
||||||
import com.nflg.product.bomnew.pojo.entity.*;
|
import com.nflg.product.bomnew.pojo.entity.*;
|
||||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||||
import com.nflg.product.bomnew.service.BomNewEbomVirtualPackageCompositionService;
|
import com.nflg.product.bomnew.service.*;
|
||||||
import com.nflg.product.bomnew.service.BomNewPbomChildService;
|
|
||||||
import com.nflg.product.bomnew.service.BomNewPbomParentService;
|
|
||||||
import com.nflg.product.bomnew.util.BomLevelUtil;
|
import com.nflg.product.bomnew.util.BomLevelUtil;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
import com.nflg.product.bomnew.util.VersionUtil;
|
import com.nflg.product.bomnew.util.VersionUtil;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -30,6 +31,9 @@ public abstract class EBomToPbomBase {
|
||||||
|
|
||||||
protected BomNewEbomParentVO parent;
|
protected BomNewEbomParentVO parent;
|
||||||
|
|
||||||
|
@ApiModelProperty("转换模式:0-常规 1-覆盖")
|
||||||
|
protected ConvertToPBomModelEnum convertMode;
|
||||||
|
|
||||||
//工厂编码列表
|
//工厂编码列表
|
||||||
protected List<String> facCodes;
|
protected List<String> facCodes;
|
||||||
|
|
||||||
|
|
@ -71,24 +75,24 @@ public abstract class EBomToPbomBase {
|
||||||
List<BomNewPbomParentVO> oldBomNoTChildren = oldBomDetail.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
List<BomNewPbomParentVO> oldBomNoTChildren = oldBomDetail.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||||
//新BOM 除T项外
|
//新BOM 除T项外
|
||||||
List<BomNewEbomParentVO> newBomNoTChildren = newChildren.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
List<BomNewEbomParentVO> newBomNoTChildren = newChildren.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||||
if(oldBomNoTChildren.size()!= newBomNoTChildren.size()) {
|
if (oldBomNoTChildren.size() != newBomNoTChildren.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//除T项外的对比
|
//除T项外的对比
|
||||||
Map<String, BomNewPbomParentVO> oldBomMap = oldBomNoTChildren.stream().collect(Collectors.toMap(BomNewPbomParentVO::getMaterialNoAndProjectType, u -> u, (k1, k2) -> k1));
|
Map<String, BomNewPbomParentVO> oldBomMap = oldBomNoTChildren.stream().collect(Collectors.toMap(BomNewPbomParentVO::getMaterialNoAndProjectType, u -> u, (k1, k2) -> k1));
|
||||||
for (BomNewEbomParentVO newVo : newBomNoTChildren) {
|
for (BomNewEbomParentVO newVo : newBomNoTChildren) {
|
||||||
if(!oldBomMap.containsKey(newVo.getMaterialNoAndProductType()) || !Objects.equals(newVo.getNum(),oldBomMap.get(newVo.getMaterialNoAndProductType()).getNum())){
|
if (!oldBomMap.containsKey(newVo.getMaterialNoAndProductType()) || !Objects.equals(newVo.getNum(), oldBomMap.get(newVo.getMaterialNoAndProductType()).getNum())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//当T项外都一致时,直接更新T项
|
//当T项外都一致时,直接更新T项
|
||||||
List<BomNewPbomParentVO> bomDetailForT = oldBomDetail.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
|
List<BomNewPbomParentVO> bomDetailForT = oldBomDetail.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
|
||||||
if(CollUtil.isNotEmpty(bomDetailForT)){
|
if (CollUtil.isNotEmpty(bomDetailForT)) {
|
||||||
List<Long> bomRowIdsForT = bomDetailForT.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
List<Long> bomRowIdsForT = bomDetailForT.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteBatchIds(bomRowIdsForT);
|
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteBatchIds(bomRowIdsForT);
|
||||||
}
|
}
|
||||||
List<BomNewEbomParentVO> newBomT = newChildren.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
|
List<BomNewEbomParentVO> newBomT = newChildren.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
|
||||||
if(CollUtil.isNotEmpty(newBomT)) {
|
if (CollUtil.isNotEmpty(newBomT)) {
|
||||||
for (BomNewEbomParentVO netT : newBomT) {
|
for (BomNewEbomParentVO netT : newBomT) {
|
||||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||||
BeanUtil.copyProperties(netT, childEnt);
|
BeanUtil.copyProperties(netT, childEnt);
|
||||||
|
|
@ -111,12 +115,12 @@ public abstract class EBomToPbomBase {
|
||||||
|
|
||||||
List<BomNewEbomParentVO> result = child.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
List<BomNewEbomParentVO> result = child.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||||
|
|
||||||
Map<String, List<BomNewEbomParentVO>> listMp =child.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getMaterialNo));
|
Map<String, List<BomNewEbomParentVO>> listMp = child.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getMaterialNo));
|
||||||
|
|
||||||
for (String key : listMp.keySet()) {
|
for (String key : listMp.keySet()) {
|
||||||
List<BomNewEbomParentVO> voList = listMp.get(key);
|
List<BomNewEbomParentVO> voList = listMp.get(key);
|
||||||
BomNewEbomParentVO ent = voList.get(0);
|
BomNewEbomParentVO ent = voList.get(0);
|
||||||
ent.setNum(voList.stream().filter(u->Objects.nonNull(u.getNum())).map(aa -> aa.getNum()).reduce(BigDecimal.ZERO, BigDecimal::add));
|
ent.setNum(voList.stream().filter(u -> Objects.nonNull(u.getNum())).map(aa -> aa.getNum()).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
result.add(ent);
|
result.add(ent);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -142,21 +146,43 @@ public abstract class EBomToPbomBase {
|
||||||
* @param parentVo
|
* @param parentVo
|
||||||
* @return Pair<Integer, BomNewPbomParentEntity> key, 0-旧 1-新 value:pBomParent
|
* @return Pair<Integer, BomNewPbomParentEntity> key, 0-旧 1-新 value:pBomParent
|
||||||
*/
|
*/
|
||||||
protected BomNewPbomParentEntity buildPBomParent(BomNewEbomParentVO parentVo, String facCode) {
|
protected BomNewPbomParentEntity buildPBomParent(BomNewEbomParentVO parentVo, String facCode, List<BomNewEbomParentVO> parentList) {
|
||||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
|
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
|
||||||
.eq(BomNewPbomParentEntity::getMaterialNo, parentVo.getMaterialNo())
|
.eq(BomNewPbomParentEntity::getMaterialNo, parentVo.getMaterialNo())
|
||||||
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
|
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
|
||||||
|
|
||||||
// this.hasConvertEBomRowIds.add(parentVo.getRowId());
|
|
||||||
if (Objects.nonNull(oldParent) && oldParent.getStatus()< EBomStatusEnum.PUBLISHED.getValue()) {
|
if(Objects.isNull(oldParent)){
|
||||||
|
buildParentEntity(parentVo,facCode,oldParent,parentVo.getCurrentVersion());
|
||||||
|
}
|
||||||
|
//pbom 处于工作表
|
||||||
|
if (Objects.nonNull(oldParent) && oldParent.getStatus() < EBomStatusEnum.PUBLISHED.getValue()) {
|
||||||
|
if (oldParent.getCreatedBy() == parentVo.getCreatedBy()) {
|
||||||
|
if (ConvertToPBomModelEnum.OVERRIDE.equals(convertMode.getValue())) {
|
||||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
|
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
|
||||||
oldParent.setCurrentVersion(parentVo.getCurrentVersion());
|
oldParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||||
oldParent.setSourceRowId(parentVo.getRowId());
|
oldParent.setSourceRowId(parentVo.getRowId());
|
||||||
this.pBomParentResult.add(oldParent);
|
this.pBomParentResult.add(oldParent);
|
||||||
return oldParent;
|
return oldParent;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// 降parentVo 及其子节点标记为不转换
|
||||||
|
markNoConvert(parentVo, parentList);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} else { //pbom-处于正式表
|
||||||
|
String bomVersion= VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>=0?parentVo.getCurrentVersion():VersionUtil.getNextVersion(oldParent.getCurrentVersion());
|
||||||
|
return buildParentEntity(parentVo, facCode, oldParent,bomVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private BomNewPbomParentEntity buildParentEntity(BomNewEbomParentVO parentVo, String facCode,BomNewPbomParentEntity oldParent,String bomVersion){
|
||||||
BomNewPbomParentEntity pBomParent = new BomNewPbomParentEntity();
|
BomNewPbomParentEntity pBomParent = new BomNewPbomParentEntity();
|
||||||
BeanUtil.copyProperties(parentVo, pBomParent,"sourceRowId");
|
BeanUtil.copyProperties(parentVo, pBomParent, "sourceRowId");
|
||||||
pBomParent.setSourceRowId(parentVo.getBomRowId());
|
pBomParent.setSourceRowId(parentVo.getBomRowId());
|
||||||
pBomParent.setRowId(IdWorker.getId());
|
pBomParent.setRowId(IdWorker.getId());
|
||||||
pBomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
pBomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||||
|
|
@ -164,15 +190,13 @@ public abstract class EBomToPbomBase {
|
||||||
pBomParent.setFacCode(facCode);
|
pBomParent.setFacCode(facCode);
|
||||||
pBomParent.setTechnologyUserCode(SessionUtil.getUserCode());
|
pBomParent.setTechnologyUserCode(SessionUtil.getUserCode());
|
||||||
pBomParent.setTechnologyUserName(SessionUtil.getRealName());
|
pBomParent.setTechnologyUserName(SessionUtil.getRealName());
|
||||||
//pBomParent.setCurrentVersion(VersionUtil.getNextVersion(""));
|
|
||||||
//版本=EBom版本
|
//版本=EBom版本
|
||||||
pBomParent.setCurrentVersion(parentVo.getCurrentVersion());
|
pBomParent.setCurrentVersion(bomVersion);
|
||||||
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||||
pBomParent.setDeptName(SessionUtil.getDepartName());
|
pBomParent.setDeptName(SessionUtil.getDepartName());
|
||||||
pBomParent.setDeptRowId(SessionUtil.getDepartRowId());
|
pBomParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||||
pBomParent.setCreatedBy(SessionUtil.getUserCode());
|
pBomParent.setCreatedBy(SessionUtil.getUserCode());
|
||||||
if (Objects.nonNull(oldParent)) {
|
if (Objects.nonNull(oldParent)) {
|
||||||
// pBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
|
||||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||||
oldParent.setLastVersionIs(0);
|
oldParent.setLastVersionIs(0);
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +204,11 @@ public abstract class EBomToPbomBase {
|
||||||
return pBomParent;
|
return pBomParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markNoConvert(BomNewEbomParentVO parentVo, List<BomNewEbomParentVO> parentList) {
|
||||||
|
List<BomNewEbomParentVO> subVos = parentList.stream().filter(u -> u.getLevelNumber().compareTo(parentVo.getLevelNumber()) >= 0 && u.getLevelNumber().compareTo(NumberUtil.add(parentVo.getLevelNumber(), BigDecimal.valueOf(0.01))) < 0).collect(Collectors.toList());
|
||||||
|
for (BomNewEbomParentVO vo : subVos) {
|
||||||
|
vo.setNoConvertToPBomIs(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -429,4 +457,80 @@ public abstract class EBomToPbomBase {
|
||||||
}
|
}
|
||||||
return new BigDecimal(reuslt);
|
return new BigDecimal(reuslt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BOM是否一致(物料编码+数量+项目类别)
|
||||||
|
*
|
||||||
|
* @param oldChildList
|
||||||
|
* @param newChildList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isSameEBomV2(List<BomNewEbomChildEntity> oldChildList, List<BomNewEbomParentVO> newChildList) {
|
||||||
|
if (oldChildList.size() != newChildList.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
if (!oldChildMap.containsKey(key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BOM是否一致(物料编码+数量)
|
||||||
|
*
|
||||||
|
* @param oldChildList
|
||||||
|
* @param newChildList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isSameEBomV2FormMaterialNoAndNum(List<BomNewEbomChildEntity> oldChildList, List<BomNewEbomParentVO> newChildList) {
|
||||||
|
if (oldChildList.size() != newChildList.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Map<String, List<BomNewEbomChildEntity>> oldChildMap = oldChildList.stream().collect(Collectors.groupingBy(u -> StrUtil.join("", u.getMaterialNo(), u.getNum())));
|
||||||
|
for (BomNewEbomParentVO newChild : newChildList) {
|
||||||
|
String key = StrUtil.join("", newChild.getMaterialNo(), newChild.getNum());
|
||||||
|
if (!oldChildMap.containsKey(key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换前生产EBom 版本号
|
||||||
|
*/
|
||||||
|
public void initEBomVersion() {
|
||||||
|
List<BomNewEbomParentVO> parentBoms = allBomDetail.stream().filter(u -> u.getChildBomRowId() > 0).collect(Collectors.toList());
|
||||||
|
for (BomNewEbomParentVO parentBom : parentBoms) {
|
||||||
|
if (!EBomStatusEnum.PUBLISHED.equalsValue(parentBom.getStatus())) {
|
||||||
|
//获取正式版
|
||||||
|
BomNewEbomParentEntity oldEBom = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parentBom.getMaterialNo())
|
||||||
|
.eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||||
|
.last(" order by current_version desc limit 1").one();
|
||||||
|
if (Objects.nonNull(oldEBom)) {
|
||||||
|
List<BomNewEbomChildEntity> oldParentChild = SpringUtil.getBean(BomNewEbomChildService.class).lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, oldEBom.getRowId()).list();
|
||||||
|
|
||||||
|
List<BomNewEbomParentVO> newParentChild = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parentBom.getBomRowId())).collect(Collectors.toList());
|
||||||
|
//一样则无需转换
|
||||||
|
if (isSameEBomV2(oldParentChild, newParentChild)) {
|
||||||
|
parentBom.setNoConvertToPBomIs(1);
|
||||||
|
parentBom.setHasChangeState(1);
|
||||||
|
//只变化项目类别-则使用小版本
|
||||||
|
} else if (isSameEBomV2FormMaterialNoAndNum(oldParentChild, newParentChild)) {
|
||||||
|
parentBom.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(oldEBom.getCurrentVersion()));
|
||||||
|
parentBom.setHasChangeState(2);
|
||||||
|
} else {
|
||||||
|
parentBom.setCurrentVersion(VersionUtil.getNextVersion(oldEBom.getCurrentVersion()));
|
||||||
|
parentBom.setHasChangeState(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
||||||
BomNewEbomParentEntity oldEBom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parentEnt.getMaterialNo()).last(" order by current_version desc limit 1").one();
|
BomNewEbomParentEntity oldEBom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parentEnt.getMaterialNo()).last(" order by current_version desc limit 1").one();
|
||||||
//无Ebom时
|
//无Ebom时
|
||||||
if (Objects.isNull(oldEBom)) {
|
if (Objects.isNull(oldEBom)) {
|
||||||
Long parentRowId = buildEBomParent(parentEnt, "V00");
|
Long parentRowId = buildEBomParent(parentEnt, VersionUtil.getNextVersion(""));
|
||||||
parentEnt.setEBomRowId(parentRowId);
|
parentEnt.setEBomRowId(parentRowId);
|
||||||
handlerChild(parentEnt, parentChild);
|
handlerChild(parentEnt, parentChild);
|
||||||
return;
|
return;
|
||||||
|
|
@ -246,13 +246,13 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
||||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
||||||
//不存在EBom 时
|
//不存在EBom 时
|
||||||
if (Objects.isNull(oldEBom)) {
|
if (Objects.isNull(oldEBom)) {
|
||||||
buildCommonMaterialChildBom(childVo, materialBaseInfo, "V00");
|
buildCommonMaterialChildBom(childVo, materialBaseInfo, VersionUtil.getNextVersion(""));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!EBomStatusEnum.PUBLISHED.equalsValue(oldEBom.getStatus())) {
|
if (!EBomStatusEnum.PUBLISHED.equalsValue(oldEBom.getStatus())) {
|
||||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo, parentEntity);
|
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo, parentEntity);
|
||||||
//结构是否相同 且为同一个人
|
//结构是否相同 且为同一个人
|
||||||
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild)) && oldEBom.getCreatedBy().equals(parentEntity.getCreatedBy())) {
|
if ( oldEBom.getCreatedBy().equals(parentEntity.getCreatedBy())) {
|
||||||
ebomParentService.getBaseMapper().deleteById(oldEBom.getRowId());
|
ebomParentService.getBaseMapper().deleteById(oldEBom.getRowId());
|
||||||
ebomChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldEBom.getRowId()));
|
ebomChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldEBom.getRowId()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import static org.apache.naming.SelectorContext.prefix;
|
||||||
*/
|
*/
|
||||||
public class VersionUtil {
|
public class VersionUtil {
|
||||||
|
|
||||||
static final String versionPrefix = "A";
|
public static final String versionPrefix = "A";
|
||||||
|
|
||||||
static final String mBomVersionPrefix = "B";
|
static final String mBomVersionPrefix = "B";
|
||||||
|
|
||||||
|
|
@ -92,12 +92,34 @@ public class VersionUtil {
|
||||||
* @param version2
|
* @param version2
|
||||||
* @return version1>version2 返回>0,version1<version2返回 <0,version1=version2返回0
|
* @return version1>version2 返回>0,version1<version2返回 <0,version1=version2返回0
|
||||||
*/
|
*/
|
||||||
public static int compare(String version1, String version2) {
|
|
||||||
version1=StrUtil.replace(version1,versionPrefix,"");
|
|
||||||
version1=StrUtil.replace(version2,versionPrefix,"");
|
|
||||||
Version v1 = Version.parse(version1);
|
public static int compare(String s1, String s2) {
|
||||||
Version v2 = Version.parse(version2);
|
// 分割字符串为字母部分和数字部分
|
||||||
return v1.compareTo(v2);
|
String[] split1 = s1.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
|
||||||
|
String[] split2 = s2.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
|
||||||
|
|
||||||
|
// 遍历每个部分进行比较
|
||||||
|
for (int i = 0; i < Math.min(split1.length, split2.length); i++) {
|
||||||
|
if (split1[i].matches("\\d+\\.\\d+") && split2[i].matches("\\d+\\.\\d+")) {
|
||||||
|
// 如果都是小数,则转为浮点数比较
|
||||||
|
double num1 = Double.parseDouble(split1[i]);
|
||||||
|
double num2 = Double.parseDouble(split2[i]);
|
||||||
|
if (num1 != num2) {
|
||||||
|
return Double.compare(num1, num2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 否则按字符串比较
|
||||||
|
int result = split1[i].compareTo(split2[i]);
|
||||||
|
if (result != 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 长度不同的情况下,长度较长的字符串视为较大
|
||||||
|
return Integer.compare(split1.length, split2.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,4 +111,11 @@
|
||||||
SET bom_exist=0
|
SET bom_exist=0
|
||||||
WHERE row_id = #{parentRowId};
|
WHERE row_id = #{parentRowId};
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<delete id="delBomChild">
|
||||||
|
delete from t_bom_new_ebom_child where parent_row_id in
|
||||||
|
<foreach collection="bomRowIds" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue