Merge branch 'refs/heads/feature/DM/nflg-bom' into feature/DM/nflg-bom-transition

This commit is contained in:
曹鹏飞 2024-05-15 08:48:20 +08:00
commit c0a9a36d42
8 changed files with 122 additions and 82 deletions

View File

@ -418,42 +418,6 @@ public class EbomApi extends BaseApi {
return ResultVO.success(true);
}
// @GetMapping("getrel")
// @ApiOperation("模糊匹配物料")
// public ResultVO<MaterialMateVO> getRelMaterial(@RequestParam(value = "materialName", required = false) String materialName ,@RequestParam(value = "materialTexture" ,required = false) String materialTexture ){
// MaterialMateCache mateCache = new MaterialMateCache();
// MaterialMateVO materialMate = mateCache.findMaterialByNameOrmaterialTexture(materialName,materialTexture);
// return ResultVO.success(materialMate) ;
// }
@LogRecord(success = "luo下了一个订单,购买商品「{{#bom.currentVersion}}}」,测试变量「dsfsdf」,下单结果:{{#_ret}}",
bizNo = "sfsfsa", type = "dsfdsf")
@PostMapping("log")
@ApiOperation("测试日志")
public boolean createOrder() {
bomNewEbomParentService.createOrder();
return true;
}
@GetMapping("loginDebug")
@ApiOperation("模拟登录")
public ResultVO<Boolean> loginDebug() {
LoginUserInfoDTO dto = new LoginUserInfoDTO();
dto.setUserCode("QHI17062100");
dto.setUserName("郑军榕");
dto.setRealName("郑军榕");
dto.setDepartName("信息流程中心/IT支持");
dto.setFullDeptName("信息流程中心/IT支持");
dto.setRowId(1585164668335439881L);
BaseApi.loginUser.set(dto);
return ResultVO.success();
}
/**
* 导入到SAP
* @param rootBomRowIds 顶级bom的rowId

View File

@ -35,6 +35,9 @@ public class EBomConstant {
public static final List<String> VIRTUAL_PACKAGE_DRAWING_NO_1010_AND_1020= ImmutableList.of("",EBomConstant.XIAN_TAO_FACTORY_Name_1020);
public static final String PROJECT_TYPE_T="T";
@AllArgsConstructor
@Getter
public enum EBomExcelImportEnum implements ValueEnum<Integer> {

View File

@ -45,7 +45,9 @@ public enum EBomExceptionStatusEnum implements ValueEnum<Integer> {
EXCEPT_NO_13(13, "项目类型需要用户确认") ,
EXCEPT_NO_14(14, "黄色警告(下级节点存在异常)"),
EXCEPT_NO_15(15, "物料名称不一致"),
EXCEPT_NO_16(16, "物料单位不一致");
EXCEPT_NO_16(16, "物料单位不一致"),
EXCEPT_NO_17(17, "T项物料描述为空");
private final Integer value;
private final String description;

View File

@ -1,19 +1,18 @@
package com.nflg.product.bomnew.pojo.entity;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDate;
/**
* t_bom_new_ebom_child
@ -227,8 +226,11 @@ public class BomNewEbomChildEntity implements Serializable {
private String materialOriginalUnit;
private String materialNoAndProjectType;
public String getMaterialNoAndProjectType() {
return StrUtil.join(materialNo,projectType);
}
private static final long serialVersionUID = -14147430944632372L;

View File

@ -1,5 +1,6 @@
package com.nflg.product.bomnew.pojo.vo;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -279,5 +280,12 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty("所有父级的rowId")
private Set<Long> allParentRowIds = new HashSet<>();
private String materialNoAndProjectType;
public String getMaterialNoAndProjectType() {
return StrUtil.join(getMaterialNo(),getProjectType());
}
private static final long serialVersionUID = 1L;
}

View File

@ -140,6 +140,9 @@ public class CheckEBomException {
&& (StrUtil.isBlank(vo.getExceptionTag()) || !vo.getExceptionTag().contains("16"))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_16.getValue());
}
else if (EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(vo.getProjectType()) && StrUtil.isBlank(vo.getMaterialDesc())){
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_17.getValue());
}
}
checkOther();

View File

@ -12,6 +12,7 @@ import com.nflg.product.base.core.conmon.util.SessionUtil;
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;
@ -94,12 +95,17 @@ public class EBomToPBom {
buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode);
//子级
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);
//子级
if (CollUtil.isNotEmpty(child)) {
//合并子级
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
for (BomNewEbomParentVO eb : mergeChild) {
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
BeanUtil.copyProperties(eb, childEnt);
@ -115,6 +121,55 @@ public class EBomToPBom {
}
}
}
/**
* BOM 明细对比如只有T项变化则不升级直接修改
*/
private Boolean compareContentIsSame(BomNewEbomParentVO pVo, List<BomNewEbomParentVO> newChildren, String facCode) {
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, pVo.getMaterialNo())
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
if (oldParent != null) {
List<BomNewPbomParentVO> oldBomDetail = SpringUtil.getBean(BomNewPbomParentService.class).getBaseMapper().getParentChild(oldParent.getRowId());
//旧bom除T项之外
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;
}
//除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;
}
}
//当T项外都一致时直接更新T项
List<BomNewPbomParentVO> bomDetailForT = oldBomDetail.stream().filter(u -> EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProcureType())).collect(Collectors.toList());
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)) {
for (BomNewEbomParentVO netT : newBomT) {
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
BeanUtil.copyProperties(netT, childEnt);
childEnt.setRowId(IdWorker.getId());
childEnt.setParentRowId(oldParent.getRowId());
childEnt.setFacCode(facCode);
childEnt.setIdentityNo(StrUtil.join("-", oldParent.getMaterialNo(), netT.getMaterialNo()));
this.pBomChildResult.add(childEnt);
}
}
return true;
}
return false;
}
//合并子级
public List<BomNewEbomParentVO> mergeChild(List<BomNewEbomParentVO> child) {
@ -276,13 +331,11 @@ public class EBomToPBom {
}
private void buildUpgradeChange(List<BomNewEbomVirtualPackageCompositionEntity> changeList, BomNewEbomParentVO parent) {
List<String> vmaterialNoList = changeList.stream().map(u -> u.getVirtualPackageMaterialNo()).distinct().collect(Collectors.toList());
for (String vmaterialNo : vmaterialNoList) {
String key = StrUtil.join("-", vmaterialNo, parent.getMaterialNo());
if(hasBuildVNo.contains(key))
{
if (hasBuildVNo.contains(key)) {
continue;
}
BomNewEbomUpgradeChangeEntity changeEntity = new BomNewEbomUpgradeChangeEntity();

View File

@ -24,11 +24,15 @@ import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
import com.nflg.product.bomnew.util.VersionUtil;
import lombok.Data;
import java.io.ObjectInputStream;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
*
@ -302,13 +306,14 @@ public abstract class BaseConvert {
if (oldChildList.size() != newChildList.size()) {
return false;
}
final List<String> compareFields = ImmutableList.of("materialNo", "num","projectType");
Map<String, Map<String, Object>> stringMapMap = ClassCompareUtil.compareObject(oldChildList, newChildList, compareFields);
if (stringMapMap.size() > 0) {
Map<String, BomNewEbomChildEntity> oldChildMap = oldChildList.stream().collect(Collectors.toMap(BomNewEbomChildEntity::getMaterialNoAndProjectType , Function.identity()));
for (BomNewEbomChildEntity newChild : newChildList) {
String key=StrUtil.join(newChild.getMaterialNo(),newChild.getProjectType());
if(!oldChildMap.containsKey(key) || Objects.equals(newChild.getNum(), oldChildMap.get(key).getNum()) ){
return false;
}
}
return true;
}