feat(pbom): 导入SAP增加SORT(排序字符串)

This commit is contained in:
曹鹏飞 2024-06-19 17:39:03 +08:00
parent f030e56db5
commit d05db2d869
3 changed files with 24 additions and 10 deletions

View File

@ -46,6 +46,9 @@ public class T1DTO {
@ApiModelProperty("bom项目文本") @ApiModelProperty("bom项目文本")
protected String POTX1 = ""; protected String POTX1 = "";
@ApiModelProperty("排序字符串")
protected String SORT = "";
// @ApiModelProperty("是否发货") // @ApiModelProperty("是否发货")
// private String SFFH=""; // private String SFFH="";

View File

@ -34,6 +34,9 @@ public class T1ExtDTO {
@ApiModelProperty("bom项目文本") @ApiModelProperty("bom项目文本")
protected String POTX1 = ""; protected String POTX1 = "";
@ApiModelProperty("排序字符串")
protected String SORT = "";
private boolean ignore = false; private boolean ignore = false;
/* /*

View File

@ -18,6 +18,7 @@ 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.entity.BomNewSapErrorMsgEntity; import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO; import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.BomUtil;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import nflg.product.common.constant.STATE; import nflg.product.common.constant.STATE;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -74,9 +75,9 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL; SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL;
List<OperationErrorMsgVO> liErrMsg = null; List<OperationErrorMsgVO> liErrMsg = null;
try { try {
children.addAll(convert(rcs, root.getMaterialNo(), false));
rcs.forEach(it -> { rcs.forEach(it -> {
BomNewPbomParentEntity cp = getParent(it); BomNewPbomParentEntity cp = getParent(it);
children.add(convert(cp, it, root.getMaterialNo(), false));
if (Objects.nonNull(cp)) { if (Objects.nonNull(cp)) {
Long ddpRowId = null; Long ddpRowId = null;
//选出直发包 //选出直发包
@ -151,7 +152,15 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
.update(); .update();
} }
private T1ExtDTO convert(BomNewPbomChildEntity child, String parentMaterialNo, boolean ignore) { /**
* 转换为sap的t1
* @param parent 该节点对应的parent
* @param child 该节点对应的child
* @param parentMaterialNo 父级物料编号
* @param ignore 导入时是否忽略
* @return
*/
private T1ExtDTO convert(BomNewPbomParentEntity parent, BomNewPbomChildEntity child, String parentMaterialNo, Boolean ignore) {
T1ExtDTO t = new T1ExtDTO(); T1ExtDTO t = new T1ExtDTO();
t.setID(RandomUtil.randomNumbers(5)); t.setID(RandomUtil.randomNumbers(5));
t.setMATNR(parentMaterialNo); t.setMATNR(parentMaterialNo);
@ -160,6 +169,8 @@ 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.setSORT(BomUtil.generateSapOrderNum(child.getProjectType(), child.getMaterialCategoryCode()
, child.getFacCode(), child.getMaterialNo(), Objects.isNull(parent) ? 0 : parent.getBomExist()));
t.setIgnore(ignore); t.setIgnore(ignore);
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) { if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) {
t.setIDNRK(""); t.setIDNRK("");
@ -168,10 +179,6 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
return t; return t;
} }
private List<T1ExtDTO> convert(List<BomNewPbomChildEntity> children, String parentMaterialNo, boolean ignore) {
return children.stream().map(c -> convert(c, parentMaterialNo, ignore)).collect(Collectors.toList());
}
/** /**
* 构建child数据 * 构建child数据
* @param cRowId 顶层的直发包rowId * @param cRowId 顶层的直发包rowId
@ -194,6 +201,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
} }
private void handlerItem(Long cRowId, BomNewPbomChildEntity it, BomNewPbomParentEntity p, BomNewPbomChildEntity c, boolean ignore) { private void handlerItem(Long cRowId, BomNewPbomChildEntity it, BomNewPbomParentEntity p, BomNewPbomChildEntity c, boolean ignore) {
BomNewPbomParentEntity cp = getParent(it);
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)) {
T1ExtDTO cct = cmap.get(cRowId).stream() T1ExtDTO cct = cmap.get(cRowId).stream()
@ -203,7 +211,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
.orElse(null); .orElse(null);
if (Objects.isNull(cct)) { if (Objects.isNull(cct)) {
LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc()); LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
cct = convert(it, p.getMaterialNo(), false); cct = convert(cp, it, p.getMaterialNo(), false);
cmap.get(cRowId).add(cct); cmap.get(cRowId).add(cct);
children.add(cct); children.add(cct);
} else { } else {
@ -214,9 +222,8 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
} }
} 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(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc()); LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
children.add(convert(it, p.getMaterialNo(), ignore)); children.add(convert(cp, it, p.getMaterialNo(), ignore));
} }
BomNewPbomParentEntity cp = getParent(it);
if (Objects.nonNull(cp)) { if (Objects.nonNull(cp)) {
if (!ignore && cp.getUserRootIs() == 1) { if (!ignore && cp.getUserRootIs() == 1) {
ignore = true; ignore = true;
@ -229,7 +236,8 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
return bomNewPbomChildService.lambdaQuery() return bomNewPbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo, BomNewPbomChildEntity::getNum .select(BomNewPbomChildEntity::getMaterialNo, BomNewPbomChildEntity::getNum
, BomNewPbomChildEntity::getMaterialUnit, BomNewPbomChildEntity::getMaterialDesc , BomNewPbomChildEntity::getMaterialUnit, BomNewPbomChildEntity::getMaterialDesc
, BomNewPbomChildEntity::getVirtualPartType, BomNewPbomChildEntity::getProjectType) , BomNewPbomChildEntity::getVirtualPartType, BomNewPbomChildEntity::getProjectType
, BomNewPbomChildEntity::getFacCode, BomNewPbomChildEntity::getMaterialCategoryCode)
.eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId()) .eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId())
.orderByAsc(BomNewPbomChildEntity::getOrderNumber) .orderByAsc(BomNewPbomChildEntity::getOrderNumber)
.list(); .list();