Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom
This commit is contained in:
commit
9a44353c8d
|
|
@ -18,6 +18,7 @@ import com.nflg.product.bomnew.pojo.vo.*;
|
|||
import com.nflg.product.bomnew.service.*;
|
||||
import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import nflg.product.common.constant.STATE;
|
||||
|
|
@ -36,6 +37,7 @@ import javax.validation.constraints.NotEmpty;
|
|||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
@ -152,13 +154,9 @@ public class EbomApi extends BaseApi {
|
|||
public ResultVO<List<OperationErrorMsgVO>> convertToPBom(@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.convertToPBom(paramDto);
|
||||
|
||||
//更新PBomUse 数据
|
||||
// CompletableFuture.runAsync(()->{
|
||||
// bomNewPbomParentService.getBaseMapper().updatePBomMaterialUse();
|
||||
// });
|
||||
|
||||
//导入到sap
|
||||
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
|
||||
paramDto.getBomRowIds().forEach(rootRowId -> {
|
||||
|
|
@ -168,6 +166,19 @@ public class EbomApi extends BaseApi {
|
|||
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")
|
||||
@ApiOperation("发起变更")
|
||||
@LogRecord(success = "发起变更:物料编码:{{#bom.materialNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}",
|
||||
|
|
|
|||
|
|
@ -51,23 +51,19 @@ public class EbomV2Api extends BaseApi {
|
|||
@ApiOperation("从CAD获取BOM数据并转为EBom")
|
||||
public ResultVO<List<ImportOriginalBomVO>> pullFromCadAndToEBom() throws ExecutionException, InterruptedException {
|
||||
List<BomOriginalCadParentEntity> parents = originalCadParentService.lambdaQuery().eq(BomOriginalCadParentEntity::getStatus, 1).eq(BomOriginalCadParentEntity::getCreatedBy, SessionUtil.getUserCode()).list();
|
||||
List<ImportOriginalBomVO> result=new ArrayList<>();
|
||||
List<ImportOriginalBomVO> result = new ArrayList<>();
|
||||
try {
|
||||
|
||||
result = originalParentV2Service.pullFromCadAndToEBom(parents);
|
||||
//更新物料使用
|
||||
// ebomChildService.updateEBomMaterialUse(parents.stream().map(BomOriginalCadParentEntity::getMaterialNo).collect(Collectors.toSet()));
|
||||
|
||||
//跟新EBom 根节点
|
||||
ebomParentService.getBaseMapper().updateRootState();
|
||||
ebomParentService.getBaseMapper().updateRootForWaitReview();
|
||||
|
||||
ebomParentService.resetAllBomExist();
|
||||
}
|
||||
catch (Exception e){
|
||||
VUtils.isTure(true).throwMessage("转换失败:"+e.getMessage());
|
||||
}
|
||||
finally {
|
||||
} catch (Exception e) {
|
||||
VUtils.isTure(true).throwMessage("转换失败:" + e.getMessage());
|
||||
} finally {
|
||||
List<Integer> delRowIds = parents.stream().map(BomOriginalCadParentEntity::getRowId).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(delRowIds)) {
|
||||
originalParentV2Service.delCadData(delRowIds);
|
||||
|
|
|
|||
|
|
@ -137,7 +137,8 @@ public class MasterDataSourceConfig {
|
|||
|
||||
@Bean("getBomDetailPool")
|
||||
public ForkJoinPool getBomNewDetailPool() {
|
||||
return new ForkJoinPool();
|
||||
|
||||
return new ForkJoinPool(4, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, false);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -27,4 +27,6 @@ public interface BomNewEbomChildMapper extends BaseMapper<BomNewEbomChildEntity>
|
|||
List<ChildMaxExceptionStateVO> getChildMaxExceptionState(@Param("bomRowIds") List<Long> bomRowIds);
|
||||
|
||||
Integer shouldSetRootIs(String materialNo);
|
||||
|
||||
void delBomChild(@Param("bomRowIds") List<Long> bomRowIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nflg.product.bomnew.pojo.dto;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -14,6 +15,10 @@ public class EBomToPBomParamDTO {
|
|||
@ApiModelProperty("物料bom行ID")
|
||||
private List<Long> bomRowIds;
|
||||
|
||||
@ApiModelProperty("转换模式:0-常规 1-覆盖")
|
||||
@NotBlank( message = "转换模式:0-常规 1-覆盖 不能为空")
|
||||
private Integer convertMode;
|
||||
|
||||
@ApiModelProperty("工厂编码列表")
|
||||
private List<String> facCodes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,6 +341,12 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty(value = "导入SAP状态")
|
||||
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 static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
|
|
@ -540,6 +540,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树
|
||||
*
|
||||
|
|
@ -842,11 +861,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
//31 码 须有虚拟包
|
||||
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 -> {
|
||||
if (p.getMaterialNo().startsWith("31")) {
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
|
@ -879,7 +893,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
parent.setChildBomRowId(parent.getRowId());
|
||||
parent.setParentRowId(0L);
|
||||
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();
|
||||
|
||||
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
|
||||
|
|
@ -889,43 +903,36 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
if (CollUtil.isNotEmpty(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未发布跟节点
|
||||
Set<String> materialNos = bomTree.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
||||
if(CollUtil.isNotEmpty(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());
|
||||
if (CollUtil.isNotEmpty(bomRowIds)) {
|
||||
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), bomRowIds);
|
||||
|
|
@ -948,6 +955,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) {
|
||||
BomNewEbomParentEntity root = this.getById(rootBomRowId);
|
||||
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
||||
|
|
@ -2440,7 +2492,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
|
||||
/**
|
||||
* ebom发布时将历史正式版-移到正式表
|
||||
* ebom发布时将历史正式版-移到正式表(所有正式数据都会移到formal正式表中)
|
||||
* @param exceptRowIds
|
||||
*/
|
||||
private void eBomToFormal(List<Long> exceptRowIds, List<BomNewEbomParentVO> parents){
|
||||
|
|
@ -2450,8 +2502,11 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
if(CollUtil.isNotEmpty(toParents)) {
|
||||
|
||||
List<Long> childParentRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
this.getBaseMapper().insertEBomFormalParent(childParentRowIds);
|
||||
this.getBaseMapper().insertEBomFormalChild(childParentRowIds);
|
||||
List<Long> toFormalRowIds = new ArrayList<>();
|
||||
toFormalRowIds.addAll(exceptRowIds);
|
||||
toFormalRowIds.addAll(childParentRowIds);
|
||||
this.getBaseMapper().insertEBomFormalParent(toFormalRowIds);
|
||||
this.getBaseMapper().insertEBomFormalChild(toFormalRowIds);
|
||||
|
||||
//转移后删除
|
||||
this.getBaseMapper().delEBomHistory(childParentRowIds);
|
||||
|
|
|
|||
|
|
@ -9,11 +9,13 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewOriginalParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewOriginalExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomOriginalCadChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomOriginalCadParentEntity;
|
||||
|
|
@ -108,10 +110,9 @@ public class BomNewOriginalParentV2Service extends ServiceImpl<BomNewOriginalPar
|
|||
* @param
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ImportOriginalBomVO> pullFromCadAndToEBom(List<BomOriginalCadParentEntity> parents) throws ExecutionException, InterruptedException {
|
||||
|
||||
List<ImportOriginalBomVO> toEBomResult = new ArrayList();
|
||||
|
||||
VUtils.isTure(CollUtil.isEmpty(parents)).throwMessage("没有你的数据,你无需转换");
|
||||
//检查物料编码在主数据中是否存在
|
||||
List<BomOriginalCadChildEntity> childs = originalCadChildService.lambdaQuery().in(BomOriginalCadChildEntity::getParentRowId, parents.stream().map(u -> u.getRowId()).collect(Collectors.toList())).list();
|
||||
|
|
@ -123,7 +124,45 @@ public class BomNewOriginalParentV2Service extends ServiceImpl<BomNewOriginalPar
|
|||
Set<String> noMaterialNoChartNos = parents.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).map(u -> u.getChartNo()).collect(Collectors.toSet());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noMaterialNoChartNos)).throwMessage(StrUtil.join(",", noMaterialNoChartNos) + "物料编码为空,请检查(父级物料编码不能为空)");
|
||||
|
||||
//判断当前用户创建的bom(工作列表)是否已创建了虚拟包,有则中断此次转换
|
||||
List<String> parentMaterialNos = parents.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
List<BomNewEbomParentEntity> checkList = ebomParentService.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, parentMaterialNos).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||
.gt(BomNewEbomParentEntity::getVirtrualPackageEnum, 0).list();
|
||||
if(CollUtil.isNotEmpty(checkList)){
|
||||
List<String> hasVirtualPackageMaterialNo = checkList.stream().map(u ->StrUtil.join("-",u.getMaterialNo(),u.getCurrentVersion()) ).collect(Collectors.toList());
|
||||
VUtils.isTure(true).throwMessage(StrUtil.join(",", hasVirtualPackageMaterialNo)+"已生成虚拟包,请先删除再导入");
|
||||
}
|
||||
|
||||
PlmBomToOriginalConvertV2 convert = new PlmBomToOriginalConvertV2();
|
||||
//存原始BOM
|
||||
toOriginalBom(parents,convert);
|
||||
//转Ebom
|
||||
return toEbom(convert);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换EBOM
|
||||
* @param convert
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ImportOriginalBomVO> toEbom(PlmBomToOriginalConvertV2 convert) throws ExecutionException, InterruptedException {
|
||||
if (CollUtil.isNotEmpty(convert.getResultParent())) {
|
||||
return convertToEBomV2(convert.getResultParent().stream().map(u -> u.getRowId()).collect(Collectors.toList()));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转原始BOM
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void toOriginalBom(List<BomOriginalCadParentEntity> parents,PlmBomToOriginalConvertV2 convert ){
|
||||
|
||||
for (BomOriginalCadParentEntity parent : parents) {
|
||||
//转原始BOM
|
||||
convert.convertOriginalBom(parent);
|
||||
|
|
@ -135,13 +174,6 @@ public class BomNewOriginalParentV2Service extends ServiceImpl<BomNewOriginalPar
|
|||
if (CollUtil.isNotEmpty(convert.getResultChild())) {
|
||||
originalChildService.saveOrUpdateBatch(convert.getResultChild());
|
||||
}
|
||||
//转Ebom
|
||||
|
||||
if (CollUtil.isNotEmpty(convert.getResultParent())) {
|
||||
toEBomResult = convertToEBomV2(convert.getResultParent().stream().map(u -> u.getRowId()).collect(Collectors.toList()));
|
||||
}
|
||||
return toEBomResult;
|
||||
|
||||
}
|
||||
|
||||
@Transactional()
|
||||
|
|
|
|||
|
|
@ -1210,8 +1210,11 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
if(CollUtil.isNotEmpty(toParents)) {
|
||||
|
||||
List<Long> oldPBomRowIds = toParents.stream().map(u -> u.getRowId()).collect(Collectors.toList());
|
||||
this.getBaseMapper().insertPBomParentToFormal(oldPBomRowIds);
|
||||
this.getBaseMapper().insertPBomChildToFormal(oldPBomRowIds);
|
||||
List<Long> toFormalPBomRowIds = new ArrayList<>();
|
||||
toFormalPBomRowIds.addAll(exceptRowIds);
|
||||
toFormalPBomRowIds.addAll(oldPBomRowIds);
|
||||
this.getBaseMapper().insertPBomParentToFormal(toFormalPBomRowIds);
|
||||
this.getBaseMapper().insertPBomChildToFormal(toFormalPBomRowIds);
|
||||
|
||||
//转移后删除
|
||||
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.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.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
|
|
@ -14,6 +16,7 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
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.allBomDetail = inAllBomDetail;
|
||||
this.facCodes = inFacCodes;
|
||||
this.convertMode=convertModelEnum;
|
||||
generateDrawingNo(allBomDetail, parentRowId, "");
|
||||
initEBomVersion();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -54,9 +59,14 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
continue;
|
||||
}
|
||||
hasConvert.add(hasConvertKey);
|
||||
|
||||
//无需转换bom
|
||||
if(BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs()) ){
|
||||
continue;
|
||||
}
|
||||
//构建变更明细
|
||||
buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
// 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());
|
||||
|
|
@ -65,7 +75,10 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
continue;
|
||||
}
|
||||
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode);
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//子级
|
||||
if (CollUtil.isNotEmpty(child)) {
|
||||
//合并子级
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ 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.constant.PBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
|
|
@ -14,10 +16,7 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
|
||||
|
|
@ -32,11 +31,14 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
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.allBomDetail = inAllBomDetail;
|
||||
this.facCodes = inFacCodes;
|
||||
this.convertMode=convertModelEnum;
|
||||
generateDrawingNo(allBomDetail, parentRowId, "");
|
||||
//初始化Ebom版本
|
||||
initEBomVersion();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -87,13 +89,19 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
List<String> hasConvert = new ArrayList<>();
|
||||
|
||||
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) {
|
||||
String hasConvertKey = StrUtil.join("-", facCode, vo.getBomRowId());
|
||||
if (hasConvert.contains(hasConvertKey) || PBomStatusEnum.PUBLISH.equalsValue(vo.getStatus())) {
|
||||
continue;
|
||||
}
|
||||
hasConvert.add(hasConvertKey);
|
||||
//无需转换bom
|
||||
if(BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs()) ){
|
||||
continue;
|
||||
}
|
||||
//构建变更明细
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
|
|
@ -104,8 +112,10 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
if( compareContentIsSame(vo, mergeChild, facCode)){
|
||||
continue;
|
||||
}
|
||||
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode);
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode,parentList);
|
||||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//子级
|
||||
if (CollUtil.isNotEmpty(child)) {
|
||||
//合并子级
|
||||
|
|
@ -118,8 +128,6 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo()));
|
||||
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.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.excel.enums.BooleanEnum;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomVirtualPackageCompositionService;
|
||||
import com.nflg.product.bomnew.service.BomNewPbomChildService;
|
||||
import com.nflg.product.bomnew.service.BomNewPbomParentService;
|
||||
import com.nflg.product.bomnew.service.*;
|
||||
import com.nflg.product.bomnew.util.BomLevelUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
|
@ -30,6 +31,9 @@ public abstract class EBomToPbomBase {
|
|||
|
||||
protected BomNewEbomParentVO parent;
|
||||
|
||||
@ApiModelProperty("转换模式:0-常规 1-覆盖")
|
||||
protected ConvertToPBomModelEnum convertMode;
|
||||
|
||||
//工厂编码列表
|
||||
protected List<String> facCodes;
|
||||
|
||||
|
|
@ -56,7 +60,7 @@ public abstract class EBomToPbomBase {
|
|||
|
||||
protected Set<String> hasBuildVNo = Sets.newHashSet();
|
||||
|
||||
public abstract void convert();
|
||||
public abstract void convert();
|
||||
|
||||
/**
|
||||
* BOM 明细对比,如只有T项变化则,不升级直接修改
|
||||
|
|
@ -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());
|
||||
//新BOM 除T项外
|
||||
List<BomNewEbomParentVO> newBomNoTChildren = newChildren.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||
if(oldBomNoTChildren.size()!= newBomNoTChildren.size()) {
|
||||
return false;
|
||||
if (oldBomNoTChildren.size() != newBomNoTChildren.size()) {
|
||||
return false;
|
||||
}
|
||||
//除T项外的对比
|
||||
Map<String, BomNewPbomParentVO> oldBomMap = oldBomNoTChildren.stream().collect(Collectors.toMap(BomNewPbomParentVO::getMaterialNoAndProjectType, u -> u, (k1, k2) -> k1));
|
||||
for (BomNewEbomParentVO newVo : newBomNoTChildren) {
|
||||
if(!oldBomMap.containsKey(newVo.getMaterialNoAndProductType()) || !Objects.equals(newVo.getNum(),oldBomMap.get(newVo.getMaterialNoAndProductType()).getNum())){
|
||||
return false;
|
||||
if (!oldBomMap.containsKey(newVo.getMaterialNoAndProductType()) || !Objects.equals(newVo.getNum(), oldBomMap.get(newVo.getMaterialNoAndProductType()).getNum())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//当T项外都一致时,直接更新T项
|
||||
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());
|
||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteBatchIds(bomRowIdsForT);
|
||||
}
|
||||
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) {
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
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());
|
||||
|
||||
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()) {
|
||||
List<BomNewEbomParentVO> voList = listMp.get(key);
|
||||
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);
|
||||
}
|
||||
return result;
|
||||
|
|
@ -142,44 +146,70 @@ public abstract class EBomToPbomBase {
|
|||
* @param parentVo
|
||||
* @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()
|
||||
.eq(BomNewPbomParentEntity::getMaterialNo, parentVo.getMaterialNo())
|
||||
.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()) {
|
||||
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
|
||||
oldParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||
oldParent.setSourceRowId(parentVo.getRowId());
|
||||
this.pBomParentResult.add(oldParent);
|
||||
return oldParent;
|
||||
} else {
|
||||
BomNewPbomParentEntity pBomParent = new BomNewPbomParentEntity();
|
||||
BeanUtil.copyProperties(parentVo, pBomParent,"sourceRowId");
|
||||
pBomParent.setSourceRowId(parentVo.getBomRowId());
|
||||
pBomParent.setRowId(IdWorker.getId());
|
||||
pBomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||
pBomParent.setLastVersionIs(1);
|
||||
pBomParent.setFacCode(facCode);
|
||||
pBomParent.setTechnologyUserCode(SessionUtil.getUserCode());
|
||||
pBomParent.setTechnologyUserName(SessionUtil.getRealName());
|
||||
//pBomParent.setCurrentVersion(VersionUtil.getNextVersion(""));
|
||||
//版本=EBom版本
|
||||
pBomParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
if (Objects.nonNull(oldParent)) {
|
||||
// pBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||
oldParent.setLastVersionIs(0);
|
||||
|
||||
if(Objects.isNull(oldParent)){
|
||||
return buildParentEntity(parentVo,facCode,oldParent,parentVo.getCurrentVersion());
|
||||
|
||||
}
|
||||
//pbom 处于工作表
|
||||
else 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()));
|
||||
oldParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||
oldParent.setSourceRowId(parentVo.getRowId());
|
||||
this.pBomParentResult.add(oldParent);
|
||||
return oldParent;
|
||||
}
|
||||
|
||||
} else {
|
||||
// 降parentVo 及其子节点标记为不转换
|
||||
markNoConvert(parentVo, parentList);
|
||||
}
|
||||
this.pBomParentResult.add(pBomParent);
|
||||
return pBomParent;
|
||||
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();
|
||||
BeanUtil.copyProperties(parentVo, pBomParent, "sourceRowId");
|
||||
pBomParent.setSourceRowId(parentVo.getBomRowId());
|
||||
pBomParent.setRowId(IdWorker.getId());
|
||||
pBomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||
pBomParent.setLastVersionIs(1);
|
||||
pBomParent.setFacCode(facCode);
|
||||
pBomParent.setTechnologyUserCode(SessionUtil.getUserCode());
|
||||
pBomParent.setTechnologyUserName(SessionUtil.getRealName());
|
||||
pBomParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||
//版本=EBom版本
|
||||
pBomParent.setCurrentVersion(bomVersion);
|
||||
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
if (Objects.nonNull(oldParent)) {
|
||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||
oldParent.setLastVersionIs(0);
|
||||
}
|
||||
this.pBomParentResult.add(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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 31提层
|
||||
*
|
||||
|
|
@ -350,7 +380,7 @@ public abstract class EBomToPbomBase {
|
|||
|
||||
|
||||
private BomNewEbomParentVO getLastVirtualPackage(BomNewEbomParentVO vo, VirtualPackageTypeEnum virtualPackageTypeEnum) {
|
||||
List<BomNewEbomParentVO> zhiFaList = allBomDetail.stream().filter(u -> vo.getLevelNumber().compareTo(u.getLevelNumber()) > 0 && virtualPackageTypeEnum.getVirtualPartType().equals(u.getVirtualPartType())).collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> zhiFaList = allBomDetail.stream().filter(u -> vo.getLevelNumber().compareTo(u.getLevelNumber()) > 0 && virtualPackageTypeEnum.getVirtualPartType().equals(u.getVirtualPartType())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(zhiFaList)) {
|
||||
return Collections.max(zhiFaList, Comparator.comparing(BomNewEbomParentVO::getLevelNumber));
|
||||
}
|
||||
|
|
@ -360,7 +390,7 @@ public abstract class EBomToPbomBase {
|
|||
|
||||
|
||||
private BomNewEbomParentVO getVirtualPackageByName(VirtualPackageTypeEnum virtualPackageTypeEnum) {
|
||||
List<BomNewEbomParentVO> list = allBomDetail.stream().filter(u -> u.getLevelNumber().compareTo(u.getLevelNumber()) > 0 && virtualPackageTypeEnum.getVirtualPartType().equals(u.getVirtualPartType())).collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> list = allBomDetail.stream().filter(u -> u.getLevelNumber().compareTo(u.getLevelNumber()) > 0 && virtualPackageTypeEnum.getVirtualPartType().equals(u.getVirtualPartType())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
return list.get(0);
|
||||
}
|
||||
|
|
@ -387,13 +417,14 @@ public abstract class EBomToPbomBase {
|
|||
if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getVirtualPartType().equals(firstLevelBom.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getVirtualPartType().equals(firstLevelBom.getVirtualPartType())) {
|
||||
firstLevelBom.setLevelNumber(levelToNum(preAssemblyPackageLevelNo));
|
||||
firstLevelBom.setLevelNo(preAssemblyPackageLevelNo);
|
||||
continue;
|
||||
}
|
||||
|
||||
String levelKey = StrUtil.isNotBlank(parentDrawingNoRe) ? StrUtil.join("-", parentDrawingNoRe, gNo.toString()) : gNo.toString();
|
||||
firstLevelBom.setLevelNumber(levelToNum(levelKey));
|
||||
firstLevelBom.setLevelNo(levelKey);
|
||||
gNo++;
|
||||
}else {
|
||||
|
||||
String levelKey = StrUtil.isNotBlank(parentDrawingNoRe) ? StrUtil.join("-", parentDrawingNoRe, gNo.toString()) : gNo.toString();
|
||||
firstLevelBom.setLevelNumber(levelToNum(levelKey));
|
||||
firstLevelBom.setLevelNo(levelKey);
|
||||
gNo++;
|
||||
}
|
||||
generateDrawingNo(saveBomDetailParamDTO, firstLevelBom.getChildBomRowId(), firstLevelBom.getLevelNo());
|
||||
|
||||
|
||||
|
|
@ -426,4 +457,80 @@ public abstract class EBomToPbomBase {
|
|||
}
|
||||
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.getBomRowId() > 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,10 +307,10 @@ public abstract class BaseConvert {
|
|||
if (oldChildList.size() != newChildList.size()) {
|
||||
return false;
|
||||
}
|
||||
Map<String, List<BomNewEbomChildEntity> > oldChildMap = oldChildList.stream().collect(Collectors.groupingBy(u->StrUtil.join(u.getMaterialNo(),u.getProjectType()) ));
|
||||
Map<String, List<BomNewEbomChildEntity> > oldChildMap = oldChildList.stream().collect(Collectors.groupingBy(u->StrUtil.join("",u.getMaterialNo(),u.getProjectType(),u.getNum()) ));
|
||||
for (BomNewEbomChildEntity newChild : newChildList) {
|
||||
String key=StrUtil.join(newChild.getMaterialNo(),newChild.getProjectType());
|
||||
if(!oldChildMap.containsKey(key) || Objects.equals(newChild.getNum(), oldChildMap.get(key).get(0).getNum()) ){
|
||||
String key=StrUtil.join("",newChild.getMaterialNo(),newChild.getProjectType(),newChild.getNum());
|
||||
if(!oldChildMap.containsKey(key)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
|
||||
/**
|
||||
* 合并一般零部件
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -106,21 +107,21 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
|
||||
List<BomOriginalListVO> result = new ArrayList();
|
||||
//子级中,一般零部件
|
||||
List<BomOriginalListVO> commonPartList = list.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) && u.getRegReplaceIs().equals(1)).collect(Collectors.toList());
|
||||
List<BomOriginalListVO> commonPartList = list.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) && u.getRegReplaceIs().equals(1)).collect(Collectors.toList());
|
||||
|
||||
Map<String, List<BomOriginalListVO>> materialNoGroupMp =commonPartList.stream().collect(Collectors.groupingBy(BomOriginalListVO::getMaterialNo));
|
||||
Map<String, List<BomOriginalListVO>> materialNoGroupMp = commonPartList.stream().collect(Collectors.groupingBy(BomOriginalListVO::getMaterialNo));
|
||||
for (Map.Entry<String, List<BomOriginalListVO>> entry : materialNoGroupMp.entrySet()) {
|
||||
List<BomOriginalListVO> list1 = entry.getValue();
|
||||
BomOriginalListVO one = list1.get(0);
|
||||
BigDecimal numResult = BigDecimal.ZERO;
|
||||
BigDecimal totalWeightResult = BigDecimal.ZERO;
|
||||
List<Long> rowIds=new ArrayList<>();
|
||||
List<Long> rowIds = new ArrayList<>();
|
||||
for (BomOriginalListVO item : list1) {
|
||||
BigDecimal numNew=BigDecimal.ZERO;
|
||||
if( EBomConstant.KG.equalsIgnoreCase(item.getMaterialUnit())){
|
||||
BigDecimal numNew = BigDecimal.ZERO;
|
||||
if (EBomConstant.KG.equalsIgnoreCase(item.getMaterialUnit())) {
|
||||
numNew = item.getTotalWeight();
|
||||
}else {
|
||||
numNew= item.getNum();
|
||||
} else {
|
||||
numNew = item.getNum();
|
||||
}
|
||||
// numResult = NumberUtil.add(numResult, Objects.nonNull( item.getNum()) ? item.getNum() : BigDecimal.ZERO);
|
||||
numResult = NumberUtil.add(numResult, numNew);
|
||||
|
|
@ -129,11 +130,11 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
}
|
||||
one.setNum(numResult);
|
||||
one.setTotalWeight(totalWeightResult);
|
||||
one.setSourceRowId(StrUtil.join(",",rowIds) );
|
||||
one.setSourceRowId(StrUtil.join(",", rowIds));
|
||||
result.add(one);
|
||||
}
|
||||
Set<Long> commonPartRowIds = commonPartList.stream().map(u -> u.getRowId()).collect(Collectors.toSet());
|
||||
result.addAll(list.stream().filter(u->!commonPartRowIds.contains(u.getRowId())).collect(Collectors.toList()));
|
||||
result.addAll(list.stream().filter(u -> !commonPartRowIds.contains(u.getRowId())).collect(Collectors.toList()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -148,67 +149,59 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
//子节点
|
||||
List<BomOriginalListVO> parentChild = bomDetail.stream().filter(u -> Objects.nonNull(u.getParentRowId()) && u.getParentRowId().equals(parentEnt.getBomRowId())).distinct().collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
BomNewEbomParentEntity oldEBom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parentEnt.getMaterialNo()).last(" order by current_version desc limit 1").one();
|
||||
List<BomNewEbomChildEntity> oldParenChild = ebomChildService.getBaseMapper().getChildByMaterialNo(parentEnt.getMaterialNo());
|
||||
//无Ebom时
|
||||
if (Objects.isNull(oldEBom)) {
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
Long parentRowId = buildEBomParent(parentEnt, VersionUtil.getNextVersion(""));
|
||||
parentEnt.setEBomRowId(parentRowId);
|
||||
handlerChild(parentEnt, parentChild);
|
||||
return;
|
||||
}
|
||||
|
||||
// List<BomNewEbomChildEntity> oldParenChild = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId,oldEBom.getRowId()).list();
|
||||
//草稿态
|
||||
if (!EBomStatusEnum.PUBLISHED.equalsValue(oldEBom.getStatus())) {
|
||||
|
||||
//不是同一个人,跳过并返回告知用户
|
||||
if (!parent.getCreatedBy().equals(oldEBom.getCreatedBy())) {
|
||||
VUtils.isTure(true).throwMessage(parent.getMaterialNo() + ":已存在" + oldEBom.getCreatedBy() + "创建的BOM版本,改BOM已跳过");
|
||||
return;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(parentChild)) {
|
||||
//结构不一致且用户是一人则覆盖
|
||||
if (!isSameEBomV2(Convert.toList(BomNewEbomChildEntity.class, parentChild), oldParenChild)) {
|
||||
if (parent.getCreatedBy().equals(oldEBom.getCreatedBy())) {
|
||||
ebomParentService.getBaseMapper().deleteById(oldEBom.getRowId());
|
||||
ebomChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldEBom.getRowId()));
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
parentEnt.setEBomRowId(parentRowId);
|
||||
handlerChild(parentEnt, parentChild);
|
||||
}
|
||||
// 当前处理人为同一人则直接覆盖
|
||||
if (parent.getCreatedBy().equals(oldEBom.getCreatedBy())) {
|
||||
ebomParentService.getBaseMapper().deleteById(oldEBom.getRowId());
|
||||
ebomChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldEBom.getRowId()));
|
||||
Long parentRowId = buildEBomParent(parentEnt, oldEBom.getCurrentVersion());
|
||||
parentEnt.setEBomRowId(parentRowId);
|
||||
handlerChild(parentEnt, parentChild);
|
||||
}
|
||||
} else {
|
||||
if (parentEnt.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
//通过名称找子级
|
||||
BaseMaterialVO materialBaseInfo = getCommonMaterialByRel(parentEnt);
|
||||
if (Objects.nonNull(materialBaseInfo)) {
|
||||
List<BomNewEbomChildEntity> oldChild = ebomChildService.getBaseMapper().getChildByMaterialNo(parentEnt.getMaterialNo());
|
||||
// List<BomNewEbomChildEntity> oldChild = ebomChildService.getBaseMapper().getChildByMaterialNo(parentEnt.getMaterialNo());
|
||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo, parentEnt);
|
||||
//存在旧版本
|
||||
if (CollUtil.isNotEmpty(oldChild)) {
|
||||
//结构是否相同 且为同一处理人
|
||||
if (!isSameEBom(oldChild, ImmutableList.of(newChild)) && parent.getCreatedBy().equals(oldEBom.getCreatedBy())) {
|
||||
//结构是否相同 且为同一处理人
|
||||
if (parent.getCreatedBy().equals(oldEBom.getCreatedBy())) {
|
||||
|
||||
ebomParentService.getBaseMapper().deleteById(oldEBom.getRowId());
|
||||
ebomChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldEBom.getRowId()));
|
||||
ebomParentService.getBaseMapper().deleteById(oldEBom.getRowId());
|
||||
ebomChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldEBom.getRowId()));
|
||||
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
Long parentRowId = buildEBomParent(parentEnt, oldEBom.getCurrentVersion());
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
|
||||
} else {
|
||||
buildEBomParent(parentEnt);
|
||||
}
|
||||
} else {
|
||||
buildEBomParent(parentEnt);
|
||||
//
|
||||
}
|
||||
//
|
||||
}
|
||||
} else { //正式版
|
||||
//bom不
|
||||
if (!isSameEBomV2(Convert.toList(BomNewEbomChildEntity.class, parentChild), oldParenChild)) {
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
parentEnt.setEBomRowId(parentRowId);
|
||||
handlerChild(parentEnt, parentChild);
|
||||
}
|
||||
} else { //正式版(生成临时小版本)
|
||||
|
||||
String smallBomVersion = VersionUtil.getNextVersionForSmallVersion(oldEBom.getCurrentVersion());
|
||||
Long parentRowId = buildEBomParent(parentEnt, smallBomVersion);
|
||||
parentEnt.setEBomRowId(parentRowId);
|
||||
handlerChild(parentEnt, parentChild);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -241,7 +234,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
}
|
||||
|
||||
//合并一般零部件
|
||||
parentChild= mergeCommonPartBOM(parentChild);
|
||||
parentChild = mergeCommonPartBOM(parentChild);
|
||||
|
||||
for (BomOriginalListVO childVo : parentChild) {
|
||||
if (StrUtil.isNotBlank(childVo.getMaterialNo()) && StrUtil.isNotBlank(childVo.getMaterialCategoryCode()) && childVo.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
|
|
@ -252,24 +245,24 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
BomNewEbomParentEntity oldEBom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, childVo.getMaterialNo()).last(" order by current_version desc limit 1").one();
|
||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
||||
//不存在EBom 时
|
||||
if(Objects.isNull(oldEBom)){
|
||||
buildCommonMaterialChildBom(childVo, materialBaseInfo);
|
||||
if (Objects.isNull(oldEBom)) {
|
||||
buildCommonMaterialChildBom(childVo, materialBaseInfo, VersionUtil.getNextVersion(""));
|
||||
|
||||
}else {
|
||||
if(!EBomStatusEnum.PUBLISHED.equalsValue(oldEBom.getStatus())){
|
||||
} else {
|
||||
if (!EBomStatusEnum.PUBLISHED.equalsValue(oldEBom.getStatus())) {
|
||||
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());
|
||||
ebomChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldEBom.getRowId()));
|
||||
|
||||
Long parentRowId = buildEBomParent(childVo);
|
||||
Long parentRowId = buildEBomParent(childVo, oldEBom.getCurrentVersion());
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
}
|
||||
else { //正式则直接升级
|
||||
buildCommonMaterialChildBom(childVo, materialBaseInfo);
|
||||
} else { //正式则直接升级
|
||||
String smallBomVersion = VersionUtil.getNextVersionForSmallVersion(oldEBom.getCurrentVersion());
|
||||
buildCommonMaterialChildBom(childVo, materialBaseInfo, smallBomVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -280,12 +273,13 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
}
|
||||
|
||||
/**
|
||||
* 创建一般零部件BOM
|
||||
* 创建一般零部件BOM
|
||||
*
|
||||
* @param childVo
|
||||
* @param materialBaseInfo
|
||||
*/
|
||||
private void buildCommonMaterialChildBom(BomOriginalListVO childVo,BaseMaterialVO materialBaseInfo){
|
||||
Long parentRowId = buildEBomParent(childVo);
|
||||
private void buildCommonMaterialChildBom(BomOriginalListVO childVo, BaseMaterialVO materialBaseInfo, String bomVersion) {
|
||||
Long parentRowId = buildEBomParent(childVo, bomVersion);
|
||||
childVo.setEBomRowId(parentRowId);
|
||||
BomNewEbomChildEntity childEntity = buildCommonEbomChildEntity(materialBaseInfo, childVo);
|
||||
this.eBomChildResult.add(childEntity);
|
||||
|
|
@ -362,7 +356,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
/**
|
||||
* 构建EBom父级
|
||||
*/
|
||||
private Long buildEBomParent(BomOriginalListVO parentEnt) {
|
||||
private Long buildEBomParent(BomOriginalListVO parentEnt, String bomVersion) {
|
||||
Map<String, BomNewEbomParentEntity> parentMap = ListCommonUtil.listToMap(this.getEBomParentResult(), BomNewEbomParentEntity::getMaterialNo);
|
||||
if (parentMap.containsKey(parentEnt.getMaterialNo())) {
|
||||
return parentMap.get(parentEnt.getMaterialNo()).getRowId();
|
||||
|
|
@ -372,9 +366,9 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
BeanUtil.copyProperties(parentEnt, eBomParent, "materialGetType");
|
||||
eBomParent.setRowId(parentEnt.getEBomRowId() > 0 ? parentEnt.getEBomRowId() : IdWorker.getId());
|
||||
eBomParent.setSource(EBomSourceEnum.FROM_BOM.getValue());
|
||||
eBomParent.setCurrentVersion(VersionUtil.getNextVersion(Objects.isNull(ebom) ? "" : ebom.getCurrentVersion()));
|
||||
eBomParent.setCurrentVersion(bomVersion);
|
||||
eBomParent.setConvertToEbomTime(LocalDateTime.now());
|
||||
eBomParent.setSourceRowId(StrUtil.isNotBlank(parentEnt.getSourceRowId())?parentEnt.getSourceRowId(): parentEnt.getRowId().toString());
|
||||
eBomParent.setSourceRowId(StrUtil.isNotBlank(parentEnt.getSourceRowId()) ? parentEnt.getSourceRowId() : parentEnt.getRowId().toString());
|
||||
eBomParent.setLastVersionIs(1);
|
||||
eBomParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
//eBomParent.setModifyTime(LocalDateTime.now());
|
||||
|
|
@ -428,7 +422,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
|
|||
childEntity.setParentRowId(parent.getEBomRowId());
|
||||
childEntity.setIdentityNo(StrUtil.join("_", parent.getEBomRowId().toString(), childEntity.getRowId()));
|
||||
childEntity.setModifyTime(LocalDateTime.now());
|
||||
childEntity.setSourceRowId(StrUtil.isNotBlank(child.getSourceRowId())?child.getSourceRowId(): child.getRowId().toString());
|
||||
childEntity.setSourceRowId(StrUtil.isNotBlank(child.getSourceRowId()) ? child.getSourceRowId() : child.getRowId().toString());
|
||||
//当为原材料时,数量=总重 单位改为KG 图号=编码
|
||||
// if((StrUtil.isNotBlank(childEntity.getMaterialCategoryCode())&& childEntity.getMaterialCategoryCode().startsWith("10") ) || (StrUtil.isNotBlank(childEntity.getMaterialNo()) && childEntity.getMaterialNo().startsWith("11"))){
|
||||
// childEntity.setNum(childEntity.getTotalWeight());
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import java.util.stream.Collectors;
|
|||
* @Author 大米
|
||||
* @Date 2022-11-08
|
||||
*/
|
||||
public class ListCommonUtil extends ListUtil {
|
||||
public class ListCommonUtil extends ListUtil {
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import static org.apache.naming.SelectorContext.prefix;
|
|||
*/
|
||||
public class VersionUtil {
|
||||
|
||||
static final String versionPrefix = "A";
|
||||
public static final String versionPrefix = "A";
|
||||
|
||||
static final String mBomVersionPrefix = "B";
|
||||
|
||||
|
|
@ -92,12 +92,34 @@ public class VersionUtil {
|
|||
* @param version2
|
||||
* @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);
|
||||
Version v2 = Version.parse(version2);
|
||||
return v1.compareTo(v2);
|
||||
|
||||
|
||||
|
||||
public static int compare(String s1, String s2) {
|
||||
// 分割字符串为字母部分和数字部分
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,4 +94,11 @@
|
|||
ELSE 0
|
||||
END AS result;
|
||||
</select>
|
||||
|
||||
<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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue