optimize: 导入SAP优化
This commit is contained in:
parent
0f40fa7618
commit
c58185771a
|
|
@ -166,7 +166,8 @@ public class EbomApi extends BaseApi {
|
||||||
//导入到sap
|
//导入到sap
|
||||||
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
|
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
|
||||||
paramDto.getBomRowIds().forEach(rootRowId -> {
|
paramDto.getBomRowIds().forEach(rootRowId -> {
|
||||||
errorMsgVOS.addAll(bomNewEbomParentService.importToSAP(rootRowId));
|
BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP();
|
||||||
|
errorMsgVOS.addAll(exportToSAP.export(rootRowId));
|
||||||
});
|
});
|
||||||
|
|
||||||
return ResultVO.success(errorMsgVOS);
|
return ResultVO.success(errorMsgVOS);
|
||||||
|
|
|
||||||
|
|
@ -280,12 +280,13 @@ public class PBomApi extends BaseApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("realesePbom")
|
@PostMapping("realesePbom")
|
||||||
@ApiOperation("发布Pbom")
|
@ApiOperation("发布Pbom")
|
||||||
@LogRecord(success = "发布PBom,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}} 操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "发布PBom")
|
@LogRecord(success = "发布PBom,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}} 操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "发布PBom")
|
||||||
public ResultVO<Boolean> realesePbom(@RequestParam("bomRowId") Long bomRowId) {
|
public ResultVO<Boolean> realesePbom(@Valid @RequestBody @NotNull PbomImportToSAPQuery query) {
|
||||||
|
bomNewPbomParentService.realesePbom(query.getRootBomRowId());
|
||||||
return ResultVO.success(bomNewPbomParentService.realesePbom(bomRowId));
|
bomNewPbomParentService.importToSAP2(query);
|
||||||
|
return ResultVO.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ public enum EBomSourceEnum implements ValueEnum<Integer> {
|
||||||
//来源1-原BOM转换 2-EXCE导入 3-MDM创建
|
//来源1-原BOM转换 2-EXCE导入 3-MDM创建
|
||||||
FROM_BOM(1, "原始BOM转换"),
|
FROM_BOM(1, "原始BOM转换"),
|
||||||
FROM_EXCE(2, "EXCE导入"),
|
FROM_EXCE(2, "EXCE导入"),
|
||||||
FROM_MDM(3, "MDM创建");
|
FROM_MDM(3, "MDM创建"),
|
||||||
|
FROM_SAP(4, "从SAP导入");
|
||||||
|
|
||||||
private final Integer value;
|
private final Integer value;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
|
||||||
|
|
@ -7,55 +7,55 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class T1DTO {
|
public class T1DTO {
|
||||||
|
|
||||||
@ApiModelProperty("客户端")
|
// @ApiModelProperty("客户端")
|
||||||
private String MANDT="";
|
// private String MANDT="";
|
||||||
|
|
||||||
@ApiModelProperty("流程标题")
|
// @ApiModelProperty("流程标题")
|
||||||
private String ZLCBT="";
|
// private String ZLCBT="";
|
||||||
|
|
||||||
@ApiModelProperty("--序号")
|
@ApiModelProperty("--序号")
|
||||||
private String ID="";
|
protected String ID = "";
|
||||||
|
|
||||||
@ApiModelProperty("日期")
|
@ApiModelProperty("日期")
|
||||||
private String DATUM="99991231";
|
protected String DATUM = "99991231";
|
||||||
|
|
||||||
@ApiModelProperty("日期")
|
// @ApiModelProperty("日期")
|
||||||
private String UZEIT="";
|
// private String UZEIT="";
|
||||||
|
|
||||||
@ApiModelProperty("父级物料")
|
@ApiModelProperty("父级物料")
|
||||||
private String MATNR="";
|
protected String MATNR = "";
|
||||||
|
|
||||||
@ApiModelProperty("物料描述")
|
// @ApiModelProperty("物料描述")
|
||||||
private String MAKTX="";
|
// private String MAKTX="";
|
||||||
|
|
||||||
@ApiModelProperty("项目类别")
|
@ApiModelProperty("项目类别")
|
||||||
private String POSTP="";
|
protected String POSTP = "";
|
||||||
|
|
||||||
@ApiModelProperty("子级物料")
|
@ApiModelProperty("子级物料")
|
||||||
private String IDNRK;
|
protected String IDNRK;
|
||||||
|
|
||||||
@ApiModelProperty("子级物料描述")
|
// @ApiModelProperty("子级物料描述")
|
||||||
private String MAKTX1;
|
// private String MAKTX1;
|
||||||
|
|
||||||
@ApiModelProperty("组件数量")
|
@ApiModelProperty("组件数量")
|
||||||
private String MENGE;
|
protected String MENGE;
|
||||||
|
|
||||||
@ApiModelProperty("单位")
|
@ApiModelProperty("单位")
|
||||||
private String MEINS;
|
protected String MEINS;
|
||||||
|
|
||||||
@ApiModelProperty("bom项目文本")
|
@ApiModelProperty("bom项目文本")
|
||||||
private String POTX1="";
|
protected String POTX1 = "";
|
||||||
|
|
||||||
@ApiModelProperty("是否发货")
|
// @ApiModelProperty("是否发货")
|
||||||
private String SFFH="";
|
// private String SFFH="";
|
||||||
|
|
||||||
@ApiModelProperty("物料检查结果")
|
// @ApiModelProperty("物料检查结果")
|
||||||
private String ZCHECK="";
|
// private String ZCHECK="";
|
||||||
|
|
||||||
@ApiModelProperty("导入状态描述")
|
// @ApiModelProperty("导入状态描述")
|
||||||
private String STATUS="";
|
// private String STATUS="";
|
||||||
|
|
||||||
@ApiModelProperty("导入标志")
|
// @ApiModelProperty("导入标志")
|
||||||
private String FLAG="";
|
// private String FLAG="";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.dto.sap.impart2;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/30 17:05:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class T1ExtDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("--序号")
|
||||||
|
protected String ID = "";
|
||||||
|
|
||||||
|
@ApiModelProperty("日期")
|
||||||
|
protected String DATUM = "99991231";
|
||||||
|
|
||||||
|
@ApiModelProperty("父级物料")
|
||||||
|
protected String MATNR = "";
|
||||||
|
|
||||||
|
@ApiModelProperty("项目类别")
|
||||||
|
protected String POSTP = "";
|
||||||
|
|
||||||
|
@ApiModelProperty("子级物料")
|
||||||
|
protected String IDNRK;
|
||||||
|
|
||||||
|
@ApiModelProperty("组件数量")
|
||||||
|
protected String MENGE;
|
||||||
|
|
||||||
|
@ApiModelProperty("单位")
|
||||||
|
protected String MEINS;
|
||||||
|
|
||||||
|
@ApiModelProperty("bom项目文本")
|
||||||
|
protected String POTX1 = "";
|
||||||
|
|
||||||
|
private boolean ignore = false;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.dto.sap.impart2;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/31 09:42:50
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class T1ResultDTO extends T1DTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("导入状态描述")
|
||||||
|
private String STATUS = "";
|
||||||
|
|
||||||
|
@ApiModelProperty("导入标志")
|
||||||
|
private String FLAG = "";
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.product.bomnew.service;
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
@ -8,12 +9,10 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||||
import com.nflg.product.bomnew.constant.BomConstant;
|
import com.nflg.product.bomnew.constant.*;
|
||||||
import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
|
||||||
import com.nflg.product.bomnew.constant.SapStatusEnum;
|
|
||||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ExtDTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
|
||||||
|
|
@ -25,6 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 曹鹏飞
|
* @author 曹鹏飞
|
||||||
|
|
@ -35,8 +35,8 @@ public class BomNewEbomExportToSAP {
|
||||||
private final static String TAG = "Ebom导入到SAP";
|
private final static String TAG = "Ebom导入到SAP";
|
||||||
|
|
||||||
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||||
private final Map<Long, List<T1DTO>> cmap = new HashMap<>();
|
private final Map<Long, List<T1ExtDTO>> cmap = new HashMap<>();
|
||||||
private final List<T1DTO> children = new ArrayList<>();
|
private final List<T1ExtDTO> children = new ArrayList<>();
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(BomNewEbomExportToSAP.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(BomNewEbomExportToSAP.class);
|
||||||
|
|
||||||
|
|
@ -55,15 +55,14 @@ public class BomNewEbomExportToSAP {
|
||||||
updateSapState(rootBomRowId, SapStatusEnum.PUB_RUNNING);
|
updateSapState(rootBomRowId, SapStatusEnum.PUB_RUNNING);
|
||||||
SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL;
|
SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL;
|
||||||
try {
|
try {
|
||||||
List<BomNewEbomChildEntity> children = getChildren(root);
|
buildChildrenForSap(0L, root, null, false);
|
||||||
children.forEach(it -> buildChildrenForSap(0L, root, it));
|
|
||||||
|
|
||||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||||
sapDto.setI_WERKS("1");
|
sapDto.setI_WERKS("1");
|
||||||
sapDto.setI_STLAN("2");
|
sapDto.setI_STLAN("2");
|
||||||
sapDto.setI_EMPNO(root.getCreatedBy());
|
sapDto.setI_EMPNO(root.getCreatedBy());
|
||||||
sapDto.setT1(this.children);
|
sapDto.setT1(Convert.toList(T1DTO.class, this.children.stream().filter(c -> !c.isIgnore()).collect(Collectors.toList())));
|
||||||
liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
||||||
if (CollUtil.isEmpty(liErrMsg)) {
|
if (CollUtil.isEmpty(liErrMsg)) {
|
||||||
state = SapStatusEnum.PUB_SUCCESS;
|
state = SapStatusEnum.PUB_SUCCESS;
|
||||||
|
|
@ -80,44 +79,44 @@ public class BomNewEbomExportToSAP {
|
||||||
/**
|
/**
|
||||||
* 构建child数据
|
* 构建child数据
|
||||||
* @param cRowId 上层的直发包rowId
|
* @param cRowId 上层的直发包rowId
|
||||||
* @param p 父级节点的parent
|
* @param p 上级节点的parent
|
||||||
* @param c 父级节点的child
|
* @param c 上级节点的child
|
||||||
* @return 是否是空的直发包
|
* @return 是否是空的直发包
|
||||||
*/
|
*/
|
||||||
private boolean buildChildrenForSap(Long cRowId, BomNewEbomParentEntity p, BomNewEbomChildEntity c) {
|
private boolean buildChildrenForSap(Long cRowId, BomNewEbomParentEntity p, BomNewEbomChildEntity c, boolean ignore) {
|
||||||
List<BomNewEbomChildEntity> cc = getChildren(p);
|
List<BomNewEbomChildEntity> cc = getChildren(p);
|
||||||
if (CollUtil.isEmpty(cc)) {
|
if (CollUtil.isEmpty(cc)) {
|
||||||
return Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue());
|
return Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue());
|
||||||
}
|
}
|
||||||
boolean isEmpty = false;
|
boolean isEmpty = false;
|
||||||
for (BomNewEbomChildEntity it : cc) {
|
for (BomNewEbomChildEntity it : cc) {
|
||||||
if (Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
if (Objects.nonNull(c) && Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||||
if (Objects.nonNull(cRowId)) {
|
if (Objects.nonNull(cRowId)) {
|
||||||
if (cRowId == 0L) {
|
if (cRowId == 0L) {
|
||||||
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||||
children.add(convert(it, c.getMaterialNo()));
|
children.add(convert(it, p.getMaterialNo(), false));
|
||||||
} else {
|
} else {
|
||||||
T1DTO cct = cmap.get(cRowId).stream()
|
T1ExtDTO cct = cmap.get(cRowId).stream()
|
||||||
.filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc()))
|
.filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc()))
|
||||||
|| (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo())))
|
|| (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo())))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (Objects.isNull(cct)) {
|
if (Objects.isNull(cct)) {
|
||||||
LOGGER.debug("{} 物料提层到上级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
LOGGER.debug("{} 物料提层到上级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||||
cct = convert(it, p.getMaterialNo());
|
cct = convert(it, p.getMaterialNo(), false);
|
||||||
cmap.get(cRowId).add(cct);
|
cmap.get(cRowId).add(cct);
|
||||||
children.add(cct);
|
children.add(cct);
|
||||||
} else {
|
} else {
|
||||||
//合并计算数量
|
//合并计算数量
|
||||||
cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString());
|
cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString());
|
||||||
LOGGER.debug("{} 物料提层到上级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc());
|
LOGGER.debug("{} 物料提层到上级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isEmpty = true;
|
isEmpty = true;
|
||||||
} else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
} else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||||
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||||
children.add(convert(it, c.getMaterialNo()));
|
children.add(convert(it, p.getMaterialNo(), ignore));
|
||||||
}
|
}
|
||||||
if (it.getVirtualPartType() > VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()
|
if (it.getVirtualPartType() > VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()
|
||||||
&& !Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue())) {
|
&& !Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue())) {
|
||||||
|
|
@ -139,14 +138,18 @@ public class BomNewEbomExportToSAP {
|
||||||
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, cRowId, zfc.getMaterialNo(), zfc.getMaterialDesc());
|
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, cRowId, zfc.getMaterialNo(), zfc.getMaterialDesc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean b = buildChildrenForSap(cRowId, cp, it);
|
if (!ignore && cp.getUserRootIs() == 1) {
|
||||||
|
ignore = true;
|
||||||
|
}
|
||||||
|
boolean b = buildChildrenForSap(cRowId, cp, it, ignore);
|
||||||
if (!b && Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
if (!b && Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||||
//非空的直发包
|
//非空的直发包
|
||||||
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||||
children.add(convert(it, c.getMaterialNo()));
|
children.add(convert(it, p.getMaterialNo(), ignore));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOGGER.debug("children数量:" + children.size());
|
||||||
return isEmpty;
|
return isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,8 +168,8 @@ public class BomNewEbomExportToSAP {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private T1DTO convert(BomNewEbomChildEntity child, String parentMaterialNo) {
|
private T1ExtDTO convert(BomNewEbomChildEntity child, String parentMaterialNo, boolean ignore) {
|
||||||
T1DTO t = new T1DTO();
|
T1ExtDTO t = new T1ExtDTO();
|
||||||
t.setID(RandomUtil.randomNumbers(5));
|
t.setID(RandomUtil.randomNumbers(5));
|
||||||
t.setMATNR(parentMaterialNo);
|
t.setMATNR(parentMaterialNo);
|
||||||
t.setMENGE(child.getNum().toString());
|
t.setMENGE(child.getNum().toString());
|
||||||
|
|
@ -174,6 +177,7 @@ public class BomNewEbomExportToSAP {
|
||||||
t.setDATUM(dateYMD);
|
t.setDATUM(dateYMD);
|
||||||
t.setMEINS(child.getMaterialUnit());
|
t.setMEINS(child.getMaterialUnit());
|
||||||
t.setIDNRK(child.getMaterialNo());
|
t.setIDNRK(child.getMaterialNo());
|
||||||
|
t.setIgnore(ignore);
|
||||||
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) {
|
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) {
|
||||||
t.setIDNRK("");
|
t.setIDNRK("");
|
||||||
t.setPOTX1(child.getMaterialDesc());
|
t.setPOTX1(child.getMaterialDesc());
|
||||||
|
|
@ -183,19 +187,25 @@ public class BomNewEbomExportToSAP {
|
||||||
|
|
||||||
private BomNewEbomParentEntity getParent(BomNewEbomChildEntity c) {
|
private BomNewEbomParentEntity getParent(BomNewEbomChildEntity c) {
|
||||||
BomNewEbomParentEntity p = bomNewEbomParentService.lambdaQuery()
|
BomNewEbomParentEntity p = bomNewEbomParentService.lambdaQuery()
|
||||||
|
.select(BomNewEbomParentEntity::getRowId, BomNewEbomParentEntity::getMaterialNo
|
||||||
|
, BomNewEbomParentEntity::getMaterialDesc, BomNewEbomParentEntity::getUserRootIs)
|
||||||
.eq(BomNewEbomParentEntity::getMaterialNo, c.getMaterialNo())
|
.eq(BomNewEbomParentEntity::getMaterialNo, c.getMaterialNo())
|
||||||
.eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
.eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||||
|
.ne(BomNewEbomParentEntity::getSource, EBomSourceEnum.FROM_SAP.getValue())
|
||||||
.orderByDesc(BomNewEbomParentEntity::getCurrentVersion)
|
.orderByDesc(BomNewEbomParentEntity::getCurrentVersion)
|
||||||
.last(" limit 1")
|
.last(" limit 1")
|
||||||
.one();
|
.one();
|
||||||
if (Objects.nonNull(p) && p.getUserRootIs() == 0) {
|
if (Objects.nonNull(p)) {
|
||||||
return p;
|
LOGGER.debug("BomNewEbomParentEntity:" + JSON.toJSONString(p));
|
||||||
}
|
}
|
||||||
return null;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BomNewEbomChildEntity> getChildren(BomNewEbomParentEntity parent) {
|
private List<BomNewEbomChildEntity> getChildren(BomNewEbomParentEntity parent) {
|
||||||
return bomNewEbomChildService.lambdaQuery()
|
return bomNewEbomChildService.lambdaQuery()
|
||||||
|
.select(BomNewEbomChildEntity::getMaterialNo, BomNewEbomChildEntity::getNum
|
||||||
|
, BomNewEbomChildEntity::getMaterialUnit, BomNewEbomChildEntity::getMaterialDesc
|
||||||
|
, BomNewEbomChildEntity::getVirtualPartType, BomNewEbomChildEntity::getProjectType)
|
||||||
.eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId())
|
.eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId())
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||||
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import com.nflg.product.bomnew.client.MaterialMainClient;
|
import com.nflg.product.bomnew.client.MaterialMainClient;
|
||||||
import com.nflg.product.bomnew.constant.*;
|
import com.nflg.product.bomnew.constant.*;
|
||||||
import com.nflg.product.bomnew.pojo.dto.AddVirtrualMaterialDTO;
|
import com.nflg.product.bomnew.pojo.dto.AddVirtrualMaterialDTO;
|
||||||
|
|
@ -20,11 +21,15 @@ import com.nflg.product.bomnew.pojo.vo.MaterialMainVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
||||||
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 nflg.product.common.constant.STATE;
|
||||||
import nflg.product.common.dto.LoginUserInfoDTO;
|
import nflg.product.common.dto.LoginUserInfoDTO;
|
||||||
import nflg.product.common.vo.ResultVO;
|
import nflg.product.common.vo.ResultVO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
import org.springframework.transaction.TransactionDefinition;
|
||||||
|
import org.springframework.transaction.TransactionStatus;
|
||||||
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
@ -43,6 +48,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
private final BomNewEbomChildService ebomChildService = SpringUtil.getBean(BomNewEbomChildService.class);
|
private final BomNewEbomChildService ebomChildService = SpringUtil.getBean(BomNewEbomChildService.class);
|
||||||
private final MaterialMainClient materialMainClient = SpringUtil.getBean(MaterialMainClient.class);
|
private final MaterialMainClient materialMainClient = SpringUtil.getBean(MaterialMainClient.class);
|
||||||
private final MaterialService materialService = SpringUtil.getBean(MaterialService.class);
|
private final MaterialService materialService = SpringUtil.getBean(MaterialService.class);
|
||||||
|
private final PlatformTransactionManager transactionManager = SpringUtil.getBean(PlatformTransactionManager.class);
|
||||||
|
|
||||||
private final List<BomNewEbomChildEntity> childrenForAdd = Collections.synchronizedList(new ArrayList<>());
|
private final List<BomNewEbomChildEntity> childrenForAdd = Collections.synchronizedList(new ArrayList<>());
|
||||||
private final List<BomNewEbomChildEntity> childrenForUpdate = Collections.synchronizedList(new ArrayList<>());
|
private final List<BomNewEbomChildEntity> childrenForUpdate = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
|
@ -161,30 +167,38 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
private void save() {
|
||||||
public void save() {
|
TransactionDefinition def = new DefaultTransactionDefinition();
|
||||||
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
TransactionStatus status = transactionManager.getTransaction(def);
|
||||||
ebomChildService.getBaseMapper().deleteBatchIds(childRowIdsForDel);
|
try {
|
||||||
}
|
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
||||||
if (CollUtil.isNotEmpty(childrenForAdd)) {
|
ebomChildService.getBaseMapper().deleteBatchIds(childRowIdsForDel);
|
||||||
LOGGER.debug("ebomChildService.saveBatch");
|
}
|
||||||
LOGGER.debug(JSON.toJSONString(childrenForAdd));
|
if (CollUtil.isNotEmpty(childrenForAdd)) {
|
||||||
ebomChildService.saveBatch(childrenForAdd);
|
LOGGER.debug("ebomChildService.saveBatch");
|
||||||
}
|
LOGGER.debug(JSON.toJSONString(childrenForAdd));
|
||||||
if (CollUtil.isNotEmpty(childrenForUpdate)) {
|
ebomChildService.saveBatch(childrenForAdd);
|
||||||
LOGGER.debug("ebomChildService.updateBatchById");
|
}
|
||||||
LOGGER.debug(JSON.toJSONString(childrenForUpdate));
|
if (CollUtil.isNotEmpty(childrenForUpdate)) {
|
||||||
ebomChildService.updateBatchById(childrenForUpdate);
|
LOGGER.debug("ebomChildService.updateBatchById");
|
||||||
}
|
LOGGER.debug(JSON.toJSONString(childrenForUpdate));
|
||||||
if (CollUtil.isNotEmpty(parentsForAdd)) {
|
ebomChildService.updateBatchById(childrenForUpdate);
|
||||||
LOGGER.debug("ebomParentService.saveBatch");
|
}
|
||||||
LOGGER.debug(JSON.toJSONString(parentsForAdd));
|
if (CollUtil.isNotEmpty(parentsForAdd)) {
|
||||||
ebomParentService.saveBatch(parentsForAdd);
|
LOGGER.debug("ebomParentService.saveBatch");
|
||||||
}
|
LOGGER.debug(JSON.toJSONString(parentsForAdd));
|
||||||
if (CollUtil.isNotEmpty(parentsForUpdate)) {
|
ebomParentService.saveBatch(parentsForAdd);
|
||||||
LOGGER.debug("ebomParentService.updateBatchById");
|
}
|
||||||
LOGGER.debug(JSON.toJSONString(parentsForUpdate));
|
if (CollUtil.isNotEmpty(parentsForUpdate)) {
|
||||||
ebomParentService.updateBatchById(parentsForUpdate);
|
LOGGER.debug("ebomParentService.updateBatchById");
|
||||||
|
LOGGER.debug(JSON.toJSONString(parentsForUpdate));
|
||||||
|
ebomParentService.updateBatchById(parentsForUpdate);
|
||||||
|
}
|
||||||
|
transactionManager.commit(status);
|
||||||
|
} catch (Exception e) {
|
||||||
|
transactionManager.rollback(status);
|
||||||
|
LOGGER.error("生成虚拟包失败", e);
|
||||||
|
throw new NflgBusinessException(STATE.BusinessError, "生成虚拟包失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -475,6 +489,7 @@ public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNew
|
||||||
private BomNewEbomParentEntity buildParent(BomNewEbomParentEntity parent, BomNewEbomChildEntity child) {
|
private BomNewEbomParentEntity buildParent(BomNewEbomParentEntity parent, BomNewEbomChildEntity child) {
|
||||||
BomNewEbomParentEntity p = Convert.convert(BomNewEbomParentEntity.class, child);
|
BomNewEbomParentEntity p = Convert.convert(BomNewEbomParentEntity.class, child);
|
||||||
p.setCreatedBy(userInfo.getUserCode());
|
p.setCreatedBy(userInfo.getUserCode());
|
||||||
|
p.setDeptRowId(userInfo.getDepartRowId());
|
||||||
p.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
p.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||||
p.setVirtualPackageIs(1);
|
p.setVirtualPackageIs(1);
|
||||||
p.setRootIs(0);
|
p.setRootIs(0);
|
||||||
|
|
|
||||||
|
|
@ -414,9 +414,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child.setChildBomRowId(child.getRowId());
|
child.setChildBomRowId(child.getRowId());
|
||||||
BaseMaterialVO mvo = materialVOS.stream().filter(m -> StrUtil.equals(m.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
|
|
||||||
child.setSapOrderNum(BomUtil.generateSapOrderNum(child.getProjectType(), Objects.isNull(mvo) ? "" : mvo.getMaterialCategoryCode()
|
|
||||||
, "1010", child.getMaterialNo(), child.getBomExist()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -945,10 +942,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
SpringUtil.getBean(BomNewEbomParentFormalService.class).copyEbomFormal(bomRowId);
|
SpringUtil.getBean(BomNewEbomParentFormalService.class).copyEbomFormal(bomRowId);
|
||||||
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
importToSAP(bomRowId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -294,8 +294,8 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
|
||||||
t1.setMENGE("1");
|
t1.setMENGE("1");
|
||||||
t1.setPOSTP(child.getProjectType());
|
t1.setPOSTP(child.getProjectType());
|
||||||
t1.setDATUM(dateYMD);
|
t1.setDATUM(dateYMD);
|
||||||
t1.setMAKTX(parent.getMaterialDesc());
|
// t1.setMAKTX(parent.getMaterialDesc());
|
||||||
t1.setMAKTX1(child.getMaterialDesc());
|
// t1.setMAKTX1(child.getMaterialDesc());
|
||||||
result.getT1().add(t1);
|
result.getT1().add(t1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.product.bomnew.service;
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
@ -9,6 +10,7 @@ import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import com.nflg.product.bomnew.constant.*;
|
import com.nflg.product.bomnew.constant.*;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ExtDTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||||
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
||||||
|
|
@ -35,8 +37,8 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
private boolean is21 = false;
|
private boolean is21 = false;
|
||||||
|
|
||||||
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||||
private final Map<Long, List<T1DTO>> cmap = new HashMap<>();
|
private final Map<Long, List<T1ExtDTO>> cmap = new HashMap<>();
|
||||||
private final List<T1DTO> children = new ArrayList<>();
|
private final List<T1ExtDTO> children = new ArrayList<>();
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(BomNewPbomExportToSAPImpl.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(BomNewPbomExportToSAPImpl.class);
|
||||||
|
|
||||||
|
|
@ -54,53 +56,53 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
List<BomNewPbomChildEntity> rcs = bomNewPbomChildService.lambdaQuery()
|
List<BomNewPbomChildEntity> rcs = bomNewPbomChildService.lambdaQuery()
|
||||||
.eq(BomNewPbomChildEntity::getParentRowId, root.getRowId())
|
.eq(BomNewPbomChildEntity::getParentRowId, root.getRowId())
|
||||||
.list();
|
.list();
|
||||||
if (root.getMaterialNo().startsWith("31")) {
|
// if (root.getMaterialNo().startsWith("31")) {
|
||||||
List<BomNewPbomChildEntity> unVirtualParts = rcs.stream()
|
// List<BomNewPbomChildEntity> unVirtualParts = rcs.stream()
|
||||||
.filter(c -> Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())
|
// .filter(c -> Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())
|
||||||
&& !StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, c.getProjectType(), true))
|
// && !StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, c.getProjectType(), true))
|
||||||
.collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(unVirtualParts)) {
|
// if (CollUtil.isNotEmpty(unVirtualParts)) {
|
||||||
return unVirtualParts.stream().map(c -> OperationErrorMsgVO.create(c.getMaterialNo(), "未生成发货包")).collect(Collectors.toList());
|
// return unVirtualParts.stream().map(c -> OperationErrorMsgVO.create(c.getMaterialNo(), "未生成发货包")).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
children.addAll(convert(rcs, root.getMaterialNo()));
|
updateSapState(rootBomRowId, SapStatusEnum.PUB_RUNNING);
|
||||||
rcs.forEach(it -> {
|
|
||||||
BomNewPbomParentEntity cp = getParent(it);
|
|
||||||
if (Objects.nonNull(cp)) {
|
|
||||||
Long ddpRowId = null;
|
|
||||||
//选出直发包
|
|
||||||
List<BomNewPbomChildEntity> cpsc = getChildren(cp);
|
|
||||||
if (CollUtil.isNotEmpty(cpsc)) {
|
|
||||||
for (BomNewPbomChildEntity cptt : cpsc) {
|
|
||||||
if (Objects.equals(cptt.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
|
||||||
BomNewPbomParentEntity cpttp = getParent(cptt);
|
|
||||||
VUtils.isTure(Objects.isNull(cpttp)).throwMessage(StrUtil.format("顶层直发包({})对应的parent丢失", cptt.getMaterialNo()));
|
|
||||||
ddpRowId = cpttp.getRowId();
|
|
||||||
cmap.put(ddpRowId, new ArrayList<>());
|
|
||||||
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, ddpRowId, cpttp.getMaterialNo(), cpttp.getMaterialDesc());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buildChildrenForSap(ddpRowId, cp, it);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
|
||||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
|
||||||
if (StrUtil.equals(root.getFacCode(), EBomConstant.MAIN_FACTORY_CODE_1010)) {
|
|
||||||
sapDto.setI_WERKS("1");
|
|
||||||
} else if (StrUtil.equals(root.getFacCode(), EBomConstant.XIAN_TAO_FACTORY_CODE_1020)) {
|
|
||||||
sapDto.setI_WERKS("2");
|
|
||||||
} else {
|
|
||||||
throw new NflgBusinessException(STATE.BusinessError, "无效的工厂编号:" + root.getFacCode());
|
|
||||||
}
|
|
||||||
sapDto.setI_STLAN("1");
|
|
||||||
sapDto.setI_EMPNO(root.getCreatedBy());
|
|
||||||
sapDto.setT1(children);
|
|
||||||
SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL;
|
SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL;
|
||||||
List<OperationErrorMsgVO> liErrMsg = null;
|
List<OperationErrorMsgVO> liErrMsg = null;
|
||||||
try {
|
try {
|
||||||
updateSapState(rootBomRowId, SapStatusEnum.PUB_RUNNING);
|
children.addAll(convert(rcs, root.getMaterialNo(), false));
|
||||||
|
rcs.forEach(it -> {
|
||||||
|
BomNewPbomParentEntity cp = getParent(it);
|
||||||
|
if (Objects.nonNull(cp)) {
|
||||||
|
Long ddpRowId = null;
|
||||||
|
//选出直发包
|
||||||
|
List<BomNewPbomChildEntity> cpsc = getChildren(cp);
|
||||||
|
if (CollUtil.isNotEmpty(cpsc)) {
|
||||||
|
for (BomNewPbomChildEntity cptt : cpsc) {
|
||||||
|
if (Objects.equals(cptt.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||||
|
BomNewPbomParentEntity cpttp = getParent(cptt);
|
||||||
|
VUtils.isTure(Objects.isNull(cpttp)).throwMessage(StrUtil.format("顶层直发包({})对应的parent丢失", cptt.getMaterialNo()));
|
||||||
|
ddpRowId = cpttp.getRowId();
|
||||||
|
cmap.put(ddpRowId, new ArrayList<>());
|
||||||
|
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, ddpRowId, cpttp.getMaterialNo(), cpttp.getMaterialDesc());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buildChildrenForSap(ddpRowId, cp, it, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||||
|
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||||
|
if (StrUtil.equals(root.getFacCode(), EBomConstant.MAIN_FACTORY_CODE_1010)) {
|
||||||
|
sapDto.setI_WERKS("1");
|
||||||
|
} else if (StrUtil.equals(root.getFacCode(), EBomConstant.XIAN_TAO_FACTORY_CODE_1020)) {
|
||||||
|
sapDto.setI_WERKS("2");
|
||||||
|
} else {
|
||||||
|
throw new NflgBusinessException(STATE.BusinessError, "无效的工厂编号:" + root.getFacCode());
|
||||||
|
}
|
||||||
|
sapDto.setI_STLAN("1");
|
||||||
|
sapDto.setI_EMPNO(root.getCreatedBy());
|
||||||
|
sapDto.setT1(Convert.toList(T1DTO.class, this.children.stream().filter(c -> !c.isIgnore()).collect(Collectors.toList())));
|
||||||
liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
||||||
LOGGER.debug("本次导入到sap数量共{}个,其中{}个有错误", sapDto.getT1().size(), liErrMsg.size());
|
LOGGER.debug("本次导入到sap数量共{}个,其中{}个有错误", sapDto.getT1().size(), liErrMsg.size());
|
||||||
if (CollUtil.isEmpty(liErrMsg)) {
|
if (CollUtil.isEmpty(liErrMsg)) {
|
||||||
|
|
@ -122,8 +124,8 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
.update();
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private T1DTO convert(BomNewPbomChildEntity child, String parentMaterialNo) {
|
private T1ExtDTO convert(BomNewPbomChildEntity child, String parentMaterialNo, boolean ignore) {
|
||||||
T1DTO t = new T1DTO();
|
T1ExtDTO t = new T1ExtDTO();
|
||||||
t.setID(RandomUtil.randomNumbers(5));
|
t.setID(RandomUtil.randomNumbers(5));
|
||||||
t.setMATNR(parentMaterialNo);
|
t.setMATNR(parentMaterialNo);
|
||||||
t.setMENGE(child.getNum().toString());
|
t.setMENGE(child.getNum().toString());
|
||||||
|
|
@ -131,6 +133,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
t.setDATUM(dateYMD);
|
t.setDATUM(dateYMD);
|
||||||
t.setMEINS(child.getMaterialUnit());
|
t.setMEINS(child.getMaterialUnit());
|
||||||
t.setIDNRK(child.getMaterialNo());
|
t.setIDNRK(child.getMaterialNo());
|
||||||
|
t.setIgnore(ignore);
|
||||||
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) {
|
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) {
|
||||||
t.setIDNRK("");
|
t.setIDNRK("");
|
||||||
t.setPOTX1(child.getMaterialDesc());
|
t.setPOTX1(child.getMaterialDesc());
|
||||||
|
|
@ -138,8 +141,8 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<T1DTO> convert(List<BomNewPbomChildEntity> children, String parentMaterialNo) {
|
private List<T1ExtDTO> convert(List<BomNewPbomChildEntity> children, String parentMaterialNo, boolean ignore) {
|
||||||
return children.stream().map(c -> convert(c, parentMaterialNo)).collect(Collectors.toList());
|
return children.stream().map(c -> convert(c, parentMaterialNo, ignore)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -149,7 +152,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
* @param c 父级节点的child
|
* @param c 父级节点的child
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private void buildChildrenForSap(Long cRowId, BomNewPbomParentEntity p, BomNewPbomChildEntity c) {
|
private void buildChildrenForSap(Long cRowId, BomNewPbomParentEntity p, BomNewPbomChildEntity c, boolean ignore) {
|
||||||
List<BomNewPbomChildEntity> cc = getChildren(p);
|
List<BomNewPbomChildEntity> cc = getChildren(p);
|
||||||
if (is21 && !isForSale && Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
if (is21 && !isForSale && Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||||
LOGGER.debug("{} 丢弃21编码非销售订单的直发包 编号:{}", TAG, c.getMaterialNo());
|
LOGGER.debug("{} 丢弃21编码非销售订单的直发包 编号:{}", TAG, c.getMaterialNo());
|
||||||
|
|
@ -161,51 +164,54 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
for (BomNewPbomChildEntity it : cc) {
|
for (BomNewPbomChildEntity it : cc) {
|
||||||
if (Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
if (Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||||
if (Objects.nonNull(cRowId)) {
|
if (Objects.nonNull(cRowId)) {
|
||||||
T1DTO cct = cmap.get(cRowId).stream()
|
T1ExtDTO cct = cmap.get(cRowId).stream()
|
||||||
.filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc()))
|
.filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc()))
|
||||||
|| (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo())))
|
|| (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo())))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (Objects.isNull(cct)) {
|
if (Objects.isNull(cct)) {
|
||||||
LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||||
cct = convert(it, p.getMaterialNo());
|
cct = convert(it, p.getMaterialNo(), false);
|
||||||
cmap.get(cRowId).add(cct);
|
cmap.get(cRowId).add(cct);
|
||||||
children.add(cct);
|
children.add(cct);
|
||||||
} else {
|
} else {
|
||||||
//合并计算数量
|
//合并计算数量
|
||||||
cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString());
|
cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString());
|
||||||
LOGGER.debug("{} 物料提层到顶级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc());
|
LOGGER.debug("{} 物料提层到顶级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
} else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||||
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), c.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||||
children.add(convert(it, c.getMaterialNo()));
|
children.add(convert(it, p.getMaterialNo(), ignore));
|
||||||
}
|
}
|
||||||
BomNewPbomParentEntity cp = getParent(it);
|
BomNewPbomParentEntity cp = getParent(it);
|
||||||
|
if (!ignore && cp.getUserRootIs() == 1) {
|
||||||
|
ignore = true;
|
||||||
|
}
|
||||||
if (Objects.nonNull(cp)) {
|
if (Objects.nonNull(cp)) {
|
||||||
buildChildrenForSap(cRowId, cp, it);
|
buildChildrenForSap(cRowId, cp, it, ignore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BomNewPbomChildEntity> getChildren(BomNewPbomParentEntity parent) {
|
private List<BomNewPbomChildEntity> getChildren(BomNewPbomParentEntity parent) {
|
||||||
return bomNewPbomChildService.lambdaQuery()
|
return bomNewPbomChildService.lambdaQuery()
|
||||||
|
.select(BomNewPbomChildEntity::getMaterialNo, BomNewPbomChildEntity::getNum
|
||||||
|
, BomNewPbomChildEntity::getMaterialUnit, BomNewPbomChildEntity::getMaterialDesc
|
||||||
|
, BomNewPbomChildEntity::getVirtualPartType, BomNewPbomChildEntity::getProjectType)
|
||||||
.eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId())
|
.eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId())
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BomNewPbomParentEntity getParent(BomNewPbomChildEntity child) {
|
private BomNewPbomParentEntity getParent(BomNewPbomChildEntity child) {
|
||||||
BomNewPbomParentEntity p = bomNewPbomParentService.lambdaQuery()
|
return bomNewPbomParentService.lambdaQuery()
|
||||||
.eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo())
|
.eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo())
|
||||||
.eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.FACTORY_CONFIRM.getValue())
|
.eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.FACTORY_CONFIRM.getValue())
|
||||||
.eq(BomNewPbomParentEntity::getFacCode, child.getFacCode())
|
.eq(BomNewPbomParentEntity::getFacCode, child.getFacCode())
|
||||||
|
.ne(BomNewPbomParentEntity::getCreatedBy, "admin")
|
||||||
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
|
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
|
||||||
.last(" limit 1")
|
.last(" limit 1")
|
||||||
.one();
|
.one();
|
||||||
if (Objects.nonNull(p) && p.getUserRootIs() == 0) {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private List<BomNewPbomChildEntity> getChildren(List<BomNewPbomParentEntity> parents) {
|
// private List<BomNewPbomChildEntity> getChildren(List<BomNewPbomParentEntity> parents) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
|
|
@ -1041,10 +1040,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
pBomToFormal(bomRowIds, parentMaterialNos,parent.getFacCode());
|
pBomToFormal(bomRowIds, parentMaterialNos,parent.getFacCode());
|
||||||
|
|
||||||
// SpringUtil.getBean(BomNewPbomParentFormalService.class).copyPbomFormal(bomRowId);
|
// SpringUtil.getBean(BomNewPbomParentFormalService.class).copyPbomFormal(bomRowId);
|
||||||
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
importToSAP(bomRowId);
|
|
||||||
});
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:" + ex.getMessage());
|
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:" + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,8 @@ public class OptionalMbomMaterialService extends ServiceImpl<OptionalMbomMateria
|
||||||
t1.setMENGE(child.getExistStatus().toString());
|
t1.setMENGE(child.getExistStatus().toString());
|
||||||
t1.setPOSTP("L");
|
t1.setPOSTP("L");
|
||||||
t1.setDATUM(dateYMD);
|
t1.setDATUM(dateYMD);
|
||||||
t1.setMAKTX(parent.getMaterialDesc());
|
// t1.setMAKTX(parent.getMaterialDesc());
|
||||||
t1.setMAKTX1(child.getMaterialDesc());
|
// t1.setMAKTX1(child.getMaterialDesc());
|
||||||
result.getT1().add(t1);
|
result.getT1().add(t1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParam2DTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParam2DTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ResultDTO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -180,9 +181,9 @@ public class SapOpUtilService {
|
||||||
Map<String, List<Map<String, Object>>> outTablesMap = sapResult.getOutTablesMap();
|
Map<String, List<Map<String, Object>>> outTablesMap = sapResult.getOutTablesMap();
|
||||||
log.info("导入到SAP--返回值:" + JSON.toJSONString(outTablesMap));
|
log.info("导入到SAP--返回值:" + JSON.toJSONString(outTablesMap));
|
||||||
List<Map<String, Object>> tOut = outTablesMap.get("T1");
|
List<Map<String, Object>> tOut = outTablesMap.get("T1");
|
||||||
List<T1DTO> list = null;
|
List<T1ResultDTO> list = null;
|
||||||
if (!CollectionUtils.isEmpty(tOut)) {
|
if (!CollectionUtils.isEmpty(tOut)) {
|
||||||
list = Convert.convert(new TypeReference<List<T1DTO>>() {
|
list = Convert.convert(new TypeReference<List<T1ResultDTO>>() {
|
||||||
}, tOut);
|
}, tOut);
|
||||||
}
|
}
|
||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,9 @@ public abstract class EBomToPbomBase {
|
||||||
//版本=EBom版本
|
//版本=EBom版本
|
||||||
pBomParent.setCurrentVersion(parentVo.getCurrentVersion());
|
pBomParent.setCurrentVersion(parentVo.getCurrentVersion());
|
||||||
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||||
|
pBomParent.setDeptName(SessionUtil.getDepartName());
|
||||||
|
pBomParent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||||
|
pBomParent.setCreatedBy(SessionUtil.getUserCode());
|
||||||
if (Objects.nonNull(oldParent)) {
|
if (Objects.nonNull(oldParent)) {
|
||||||
// pBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
// pBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
|
||||||
oldParent.setExpireEndTime(LocalDateTime.now());
|
oldParent.setExpireEndTime(LocalDateTime.now());
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,7 @@ public abstract class VirtualPackageBase {
|
||||||
parent.setDeviseName(SessionUtil.getRealName());
|
parent.setDeviseName(SessionUtil.getRealName());
|
||||||
parent.setCreatedBy(SessionUtil.getUserCode());
|
parent.setCreatedBy(SessionUtil.getUserCode());
|
||||||
parent.setDeptName(SessionUtil.getDepartName());
|
parent.setDeptName(SessionUtil.getDepartName());
|
||||||
|
parent.setDeptRowId(SessionUtil.getDepartRowId());
|
||||||
parent.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
parent.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||||
//parent.setModifyTime(LocalDateTime.now());
|
//parent.setModifyTime(LocalDateTime.now());
|
||||||
parent.setStatus(p.getStatus());
|
parent.setStatus(p.getStatus());
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||||
import org.apache.http.util.Args;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -48,8 +47,8 @@ public class Sap {
|
||||||
t1.setMEINS(child.getMaterialUnit());
|
t1.setMEINS(child.getMaterialUnit());
|
||||||
t1.setMENGE(child.getNum().toString());
|
t1.setMENGE(child.getNum().toString());
|
||||||
t1.setPOSTP(child.getProjectType());
|
t1.setPOSTP(child.getProjectType());
|
||||||
t1.setMAKTX(parentBom.getMaterialDesc());
|
// t1.setMAKTX(parentBom.getMaterialDesc());
|
||||||
t1.setMAKTX1(child.getMaterialDesc());
|
// t1.setMAKTX1(child.getMaterialDesc());
|
||||||
result.getT1().add(t1);
|
result.getT1().add(t1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue