【EBOM、PBOM】SAP报错信息转义

This commit is contained in:
10001392 2024-08-09 19:05:23 +08:00
parent f2d556fb92
commit 55900d714e
7 changed files with 83 additions and 1 deletions

View File

@ -356,7 +356,7 @@ public class MaterialSubmitService {
list.add(material);
});
result.put("List", list);
log.error("物料申请-JSON" + JSONArray.toJSONString(list));
log.error("物料申请-JSON" + JSONArray.toJSONString(result));
HttpUtils httpUtils = new HttpUtils(timeout);
try {
String url = NacosConfig.getNacosConfig().getOaUrl();

View File

@ -20,4 +20,13 @@ public enum MateiralStateEnum implements ValueEnum<Integer> {
private final Integer value;
private final String description;
public static MateiralStateEnum getDescriptionByValue(Integer value) {
for (MateiralStateEnum valueEnum : MateiralStateEnum.values()) {
if (valueEnum.getValue().equals(value)) {
return valueEnum;
}
}
return null;
}
}

View File

@ -18,6 +18,7 @@ import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.SapErrorMsgUtil;
import com.nflg.product.bomnew.util.VUtils;
import nflg.product.common.constant.STATE;
import org.slf4j.Logger;
@ -43,6 +44,7 @@ public class BomNewEbomExportToSAP {
private final BomNewEbomParentService bomNewEbomParentService = SpringUtil.getBean(BomNewEbomParentService.class);
private final BomNewEbomChildService bomNewEbomChildService = SpringUtil.getBean(BomNewEbomChildService.class);
private final BomNewSapErrorMsgService bomNewSapErrorMsgService = SpringUtil.getBean(BomNewSapErrorMsgService.class);
private final SapErrorMsgUtil sapErrorMsgUtil = SpringUtil.getBean(SapErrorMsgUtil.class);
public List<OperationErrorMsgVO> export(Long rootBomRowId) {
BomNewEbomParentEntity root = bomNewEbomParentService.getById(rootBomRowId);
@ -122,6 +124,7 @@ public class BomNewEbomExportToSAP {
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rootBomRowId));
if (CollUtil.isNotEmpty(liErrMsg)) {
sapErrorMsgUtil.translateErrorMsg(liErrMsg);
BomNewSapErrorMsgEntity sapErrorMsgEntity = new BomNewSapErrorMsgEntity();
sapErrorMsgEntity.setTargetRowId(rootBomRowId);
sapErrorMsgEntity.setType(0);

View File

@ -3040,6 +3040,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
updateParent.setChangeDesc(param.getChangeDesc());
this.updateById(updateParent);
// PBOM工作表回写通知单号升版说明
pBomParentService.lambdaUpdate()
.set(BomNewPbomParentEntity::getNoticeNums, param.getNumType() == 2 ? param.getNoticeNums() : autoCode)
.set(BomNewPbomParentEntity::getChangeDesc, param.getChangeDesc())
.eq(BomNewPbomParentEntity::getSourceRowId, versionList.get(0).getRowId())
.update();
// 新建通知单
if (param.getNumType() == 1) {

View File

@ -90,8 +90,10 @@ public class BomNewNoticeNumService extends ServiceImpl<BomNewNoticeNumMapper, B
saveDetail2List.forEach(saveDetail2 -> {
Map<String, Object> bom = new HashMap<>();
bom.put("parentMaterialNo", saveDetail2.getParentMaterialNo()); // 父级编码
bom.put("parentMaterialDesc", saveDetail2.getParentMaterialDesc()); // 父级描述
bom.put("orderNum", saveDetail2.getOrderNum()); // BOM行编号
bom.put("materialNo", saveDetail2.getMaterialNo()); // 编码
bom.put("materialDesc", saveDetail2.getMaterialDesc()); // 描述
bom.put("changeContent", saveDetail2.getChangeContent()); // 变更内容
bomList2.add(bom);
});

View File

@ -19,6 +19,7 @@ import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.BomUtil;
import com.nflg.product.bomnew.util.SapErrorMsgUtil;
import com.nflg.product.bomnew.util.VUtils;
import nflg.product.common.constant.STATE;
import org.slf4j.Logger;
@ -51,6 +52,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
private final BomNewPbomParentService bomNewPbomParentService = SpringUtil.getBean(BomNewPbomParentService.class);
private final BomNewPbomChildService bomNewPbomChildService = SpringUtil.getBean(BomNewPbomChildService.class);
private final BomNewSapErrorMsgService bomNewSapErrorMsgService = SpringUtil.getBean(BomNewSapErrorMsgService.class);
private final SapErrorMsgUtil sapErrorMsgUtil = SpringUtil.getBean(SapErrorMsgUtil.class);
public BomNewPbomExportToSAPImpl(boolean isForSale) {
this.isForSale = isForSale;
@ -155,6 +157,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rootBomRowId));
if (CollUtil.isNotEmpty(liErrMsg)) {
sapErrorMsgUtil.translateErrorMsg(liErrMsg);
BomNewSapErrorMsgEntity sapErrorMsgEntity = new BomNewSapErrorMsgEntity();
sapErrorMsgEntity.setTargetRowId(rootBomRowId);
sapErrorMsgEntity.setType(1);

View File

@ -0,0 +1,59 @@
package com.nflg.product.bomnew.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.nflg.product.bomnew.constant.MateiralStateEnum;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.service.MaterialMainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Component
public class SapErrorMsgUtil {
@Resource
private MaterialMainService materialMainService;
/**
* 转义错误信息
* @param liErrMsg
*/
public void translateErrorMsg(List<OperationErrorMsgVO> liErrMsg) {
// [{"msg":"未选定 BOM 项目工厂Z0的物料状态 Block for all usage 1010","primaryKey":"2100048422的子级F项2100048422"}]
// 转义成 [{"msg":"2100048422物料状态可能为冻结实际为XX","primaryKey":"2100048422的子级F项2100048422"}]
List<OperationErrorMsgVO> blockMsgList = liErrMsg.stream().filter(errMsg -> ObjectUtil.isNotEmpty(errMsg.msg) && errMsg.msg.contains("Block for all usage")).collect(Collectors.toList());
List<String> filterMaterialNos = new ArrayList<>();
Map<String, String> materialNoStateMap = new HashMap<>();
if (CollUtil.isNotEmpty(blockMsgList)) {
blockMsgList.forEach(item -> {
if (ObjectUtil.isNotEmpty(item.primaryKey) && item.primaryKey.length() >= 10) {
filterMaterialNos.add(item.primaryKey.substring(item.primaryKey.length() - 10));
}
});
}
if (CollUtil.isNotEmpty(filterMaterialNos)) {
List<MaterialMainEntity> materialList = materialMainService.lambdaQuery().in(MaterialMainEntity::getMaterialNo, filterMaterialNos).list();
materialList.forEach(item -> {
MateiralStateEnum stateEnum = MateiralStateEnum.getDescriptionByValue(item.getMaterialState());
materialNoStateMap.put(item.getMaterialNo(), ObjectUtil.isNotEmpty(stateEnum) ? stateEnum.getDescription() : "");
});
}
liErrMsg.forEach(errMsg -> {
if (ObjectUtil.isNotEmpty(errMsg.msg) && errMsg.msg.contains("Block for all usage") &&
ObjectUtil.isNotEmpty(errMsg.primaryKey) && errMsg.primaryKey.length() >= 10) {
String materialNo = errMsg.primaryKey.substring(errMsg.primaryKey.length() - 10);
errMsg.msg = materialNo + "物料状态可能为冻结,实际为:" + materialNoStateMap.get(materialNo);
}
});
}
}