fix(线边物料库存差异调整):262
This commit is contained in:
parent
cc93724161
commit
8b8d6f58d4
@ -35,4 +35,7 @@ public interface RemoteInvokeService {
|
||||
|
||||
@PostMapping("/requestOAPort")
|
||||
JSONObject requestOAPort(@RequestBody JSONObject jsonObject);
|
||||
|
||||
@PostMapping("/shopOrderStatisticTransCallErp/sapLotMaterialConsumption")
|
||||
JSONObject sapLotMaterialConsumption(@RequestBody JSONObject jsonObject, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
}
|
||||
|
||||
@ -12,9 +12,11 @@ import com.foreverwin.iep.integration.service.IntInDataLogService;
|
||||
import com.foreverwin.iep.integration.service.IntInDataService;
|
||||
import com.foreverwin.iep.integration.service.LotMaterialDealSendSapService;
|
||||
import com.foreverwin.iep.integration.service.RegisterDocumentService;
|
||||
import com.foreverwin.iep.prd.entity.ZLotMaterialCancel;
|
||||
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
|
||||
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
|
||||
import com.foreverwin.iep.prd.entity.ZShoporderStatisticsTransaction;
|
||||
import com.foreverwin.iep.prd.mapper.ZLotMaterialCancelMapper;
|
||||
import com.foreverwin.iep.prd.mapper.ZLotMaterialCompleteTransactionMapper;
|
||||
import com.foreverwin.iep.prd.mapper.ZLotMaterialConsumptionTransactionMapper;
|
||||
import com.foreverwin.iep.prd.mapper.ZShoporderStatisticsTransactionMapper;
|
||||
@ -24,6 +26,7 @@ import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.common.log.annotation.SysLog;
|
||||
import com.foreverwin.mom.common.security.annotation.Inner;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -66,6 +69,8 @@ public class ShopOrderStatisticTransController {
|
||||
private final LotMaterialMapper lotMaterialMapper;
|
||||
private final LotMaterialDealSendSapService lotMaterialDealSendSapService;
|
||||
|
||||
private final ZLotMaterialCancelMapper zLotMaterialCancelMapper;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("ZMM_MES_GOODMVT_REVERSE") // 通过 Bean 名称注入
|
||||
private GoodMvtReverseService goodMvtReverseService;
|
||||
@ -347,6 +352,10 @@ public class ShopOrderStatisticTransController {
|
||||
@PostMapping("/callErpLotCancel")
|
||||
public R callErpLotCancel(@RequestBody List<ZLotMaterialConsumptionTransaction> lotMaterialConsumptionTransactions) {
|
||||
for (ZLotMaterialConsumptionTransaction consumptionTransaction : lotMaterialConsumptionTransactions) {
|
||||
ZLotMaterialCancel zLotMaterialCancel = zLotMaterialCancelMapper.selectById(consumptionTransaction.getSid());
|
||||
if (zLotMaterialCancel != null) {
|
||||
throw BusinessException.build("批次" + zLotMaterialCancel.getLotNo() + "已报262!");
|
||||
}
|
||||
// 重新校验一遍是否已经报过工,防止重复报工
|
||||
ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
|
||||
if ("S".equals(targetObj.getSyncStatus()) && "Y".equals(targetObj.getErpReverse())) {
|
||||
@ -449,4 +458,21 @@ public class ShopOrderStatisticTransController {
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "262", notes = "262")
|
||||
@SysLog("262")
|
||||
@PostMapping("/sapLotMaterialConsumption")
|
||||
@Inner(value = false)
|
||||
public JSONObject sapLotMaterialConsumption(@RequestBody JSONObject jsonObject) {
|
||||
JSONObject response = new JSONObject();
|
||||
String result = "S";
|
||||
String message = "成功";
|
||||
InvokeResponse invokeResponse = lotMaterialDealSendSapService.sapLotMaterialConsumption(jsonObject);
|
||||
if ("E".equals(invokeResponse.getResult())) {
|
||||
result = "E";
|
||||
message = "工单【"+jsonObject.getString("shopOrder")+"】和物料【"+jsonObject.getString("item")+"】SAP错误:" + invokeResponse.getMessageContent();
|
||||
}
|
||||
response.put("RESULT", result);
|
||||
response.put("MESSAGE", message);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
package com.foreverwin.iep.integration.handler.def.sap;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.iep.integration.constant.Msg;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.service.HandlerService;
|
||||
import com.foreverwin.iep.integration.utils.JS;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 262
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service("SAP_LOT_MATERIAL_CONSUMPTION")
|
||||
public class SapLotMaterialConsumption implements HandlerService {
|
||||
|
||||
@Override
|
||||
public InvokeResponse call(InvokeRequest invokeRequest) {
|
||||
JSONObject messageContentjsonObject = JS.parseObject(invokeRequest.getMessageContent());
|
||||
String jsonInputString = messageContentjsonObject.get(Msg.MESSAGE_CONTENT).toString(); // JSON 格式的请求数据
|
||||
|
||||
try {
|
||||
// 统一调用 SAP 接口
|
||||
InvokeResponse invokeResponse = SapUtil.sendSap(jsonInputString);
|
||||
if(!Msg.E.equals(invokeResponse.getResult())){
|
||||
// 请求处理成功
|
||||
JSONObject jsonObject = JS.parseObject(invokeResponse.getMessageContent());
|
||||
invokeResponse = new InvokeResponse();
|
||||
invokeResponse.setTransSid(invokeRequest.getTransSid());
|
||||
invokeResponse.setResult(Msg.S);
|
||||
invokeResponse.setMessageContent(Msg.SUCCESS);
|
||||
JSONObject responseContextJson = jsonObject.getJSONObject("RESPONSE_CONTEXT");
|
||||
if ("200".equals(responseContextJson.getString("RFC_CODE"))) {
|
||||
JSONObject responseBodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
if (ObjectUtil.isNotEmpty(responseBodyJson)) {
|
||||
JSONObject esOutputJson = responseBodyJson.getJSONObject("ES_OUTPUT");
|
||||
if (esOutputJson != null) {
|
||||
String msgty = esOutputJson.getString("MSGTY");
|
||||
if (Msg.E.equals(msgty)) {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
}
|
||||
invokeResponse.setMessageContent(esOutputJson.getString("MSGTX"));
|
||||
} else {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
invokeResponse.setMessageContent("ERP接口调用返回ES_OUTPUT无数据!");
|
||||
}
|
||||
} else {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
invokeResponse.setMessageContent("ERP接口调用返回RESPONSE_BODY无数据!");
|
||||
}
|
||||
} else {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
invokeResponse.setMessageContent(responseContextJson.getString("RFC_REASON"));
|
||||
}
|
||||
}
|
||||
return invokeResponse;
|
||||
} catch (Exception e) {
|
||||
return getDefaultInvoke().fail(invokeRequest.getTransSid(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String validation(InvokeRequest invokeRequest) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.foreverwin.iep.integration.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
|
||||
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
|
||||
@ -11,4 +12,6 @@ public interface LotMaterialDealSendSapService {
|
||||
InvokeResponse callLotMaterialComplete(List<ZLotMaterialCompleteTransaction> zLotMaterialCompleteTransactions, boolean isPass, String postingDate, List<String> cjList);
|
||||
|
||||
InvokeResponse callLotMaterialConsumption(List<ZLotMaterialConsumptionTransaction> zLotMaterialConsumptionTransactions, boolean isPass, String postingDate, List<String> cjList);
|
||||
|
||||
InvokeResponse sapLotMaterialConsumption(JSONObject jsonObject);
|
||||
}
|
||||
|
||||
@ -312,4 +312,63 @@ public class LotMaterialDealSendSapServiceImpl implements LotMaterialDealSendSap
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvokeResponse sapLotMaterialConsumption(JSONObject json) {
|
||||
InvokeResponse invokeResponse = new InvokeResponse();
|
||||
String site = json.getString("site");
|
||||
JSONArray itemList = new JSONArray();
|
||||
String postingDate = json.getString("postingDate");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("ZEILE", ""); // 物料凭证中的项目
|
||||
jsonObject.put("MATNR", json.getString("item")); // 物料编号
|
||||
jsonObject.put("MATKL", ""); // 物料组
|
||||
jsonObject.put("WERKS", site); // 工厂
|
||||
jsonObject.put("LGORT", ""); // 存储地点
|
||||
jsonObject.put("CHARG", ""); // 批次号
|
||||
jsonObject.put("BWART", "262"); // 移动类型
|
||||
jsonObject.put("SOBKZ", ""); // 特殊库存标识
|
||||
jsonObject.put("AUFNR", json.getString("shopOrder")); // 订单号
|
||||
jsonObject.put("EBELN", ""); // 采购订单号
|
||||
jsonObject.put("EBELP", ""); // 采购凭证的项目编号
|
||||
jsonObject.put("MENGE", json.getString("qty")); // 数量
|
||||
jsonObject.put("MEINS", ""); // 基本计量单位
|
||||
jsonObject.put("ERFMG", null); // 以录入项单位表示的数量
|
||||
jsonObject.put("ERFME", ""); // 录入单位
|
||||
jsonObject.put("MAT_KDAUF", ""); // 评估销售定单库存的销售定单号
|
||||
jsonObject.put("MAT_KDPOS", ""); // 评估销售订单库存的销售订单项目
|
||||
jsonObject.put("UMWRK", ""); // 收货工厂/发货工厂
|
||||
jsonObject.put("UMLGO", ""); // 收货/发货库存地点
|
||||
jsonObject.put("UMCHA", ""); // 收货/发货批量
|
||||
jsonObject.put("RSNUM", ""); // 预留/相关需求的编号
|
||||
jsonObject.put("RSPOS", ""); // 预留 / 相关需求的项目编号
|
||||
itemList.add(jsonObject);
|
||||
if (itemList.size() > 0) {
|
||||
InvokeRequest invokeRequest = new InvokeRequest();
|
||||
// 传参对象
|
||||
try {
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
String nowTime = nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
invokeRequest.setTransSid(SapUtil.generateReqId());
|
||||
invokeRequest.setTransTime(nowTime);
|
||||
invokeRequest.setFromSystem("IEP");
|
||||
invokeRequest.setToSystem("ERP");
|
||||
invokeRequest.setSite(site);
|
||||
invokeRequest.setMessageId(messageId);
|
||||
|
||||
// 组装抛送的报完呢
|
||||
String jsonObjectStr = SapUtil.appendHead(assembleMaterialMsgBody(itemList, postingDate));
|
||||
invokeRequest.setMessageContent(jsonObjectStr);
|
||||
invokeRequest.setStart(nowTime);
|
||||
invokeRequest.setKeyValue(nowTime);
|
||||
invokeRequest.setRetry(false);
|
||||
TenantContextHolder.setTenantId(site);
|
||||
invokeResponse = goodMvtCreateService.call(invokeRequest);
|
||||
} catch (Exception e) {
|
||||
// 不用回滚,将错误抛出
|
||||
invokeResponse.setResult("E");
|
||||
invokeResponse.setMessageContent(e.getMessage());
|
||||
}
|
||||
}
|
||||
return invokeResponse;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user