update meswms_cancelship_request取消物料入库请求接口修改,增加payMentDate过账日期字段,并在调用SAP接口时赋值给BUDAT
This commit is contained in:
parent
07a4ad25aa
commit
88a5582996
@ -6031,4 +6031,91 @@ public class ToSAPServiceImpl {
|
||||
return sendData;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 物料冲销
|
||||
* 2025-05-08
|
||||
* @param undoId 物料凭证
|
||||
* @param user 用户
|
||||
* @param payMentDate 过账日期
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String cancelShipInter(String undoId, String user, String payMentDate) throws Exception {
|
||||
|
||||
String makeFGStockIn = matailInReverse(user, undoId, payMentDate);
|
||||
String sapreturn = "";
|
||||
String rcode = "";
|
||||
String rmsg = "";
|
||||
String undoId2 = "";
|
||||
|
||||
|
||||
try {
|
||||
sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materilUndoUrl, "",
|
||||
makeFGStockIn);
|
||||
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
|
||||
|
||||
org.json.JSONObject returnJsonObject = (org.json.JSONObject) receiveJsonObject.get("RETURN");
|
||||
rcode = returnJsonObject.get("STATUS").toString();
|
||||
rmsg = returnJsonObject.get("MSGTXT").toString();
|
||||
if ("S".equals(rcode)) {
|
||||
String MBLNR1 = returnJsonObject.get("MBLNR1") == null ? "" : returnJsonObject.get("MBLNR1").toString();
|
||||
String MJAHR1 = returnJsonObject.get("MJAHR1") == null ? "" : returnJsonObject.get("MJAHR1").toString();
|
||||
undoId2 = MBLNR1+"_"+MJAHR1;//将物料凭证号与凭证年度拼在一起
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("WMS请求SAP异常:" + e.getMessage(), e);
|
||||
throw new RuntimeException("WMS请求SAP异常:" + rmsg);
|
||||
} finally {
|
||||
// 将消息记录log表
|
||||
ErpMessageLog erplog = new ErpMessageLog();
|
||||
erplog.setEventUser(user);
|
||||
erplog.setServerName("WmsToSAP");
|
||||
erplog.setEventName("MatailInReverse取消入库冲销");
|
||||
erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT));
|
||||
// erplog.setMessageId(undoId);
|
||||
erplog.setMessageId(undoId);
|
||||
erplog.setSendMsg(makeFGStockIn);
|
||||
erplog.setSendMsg2(makeFGStockIn);
|
||||
erplog.setSendMsg(makeFGStockIn);
|
||||
erplog.setReturnMsg2(sapreturn);
|
||||
erplog.setResultCode(rcode);
|
||||
MessageLogUtil.writeMessageLog(erplog);
|
||||
}
|
||||
if (!"S".equals(rcode)) {
|
||||
throw new RuntimeException("SAP返回" + rmsg);
|
||||
}
|
||||
return undoId2;
|
||||
}
|
||||
/**
|
||||
* 取消物料入库冲销
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
* @throws JsonMappingException
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
public String matailInReverse(String user, String undoId, String payMentDate) throws JsonMappingException, JsonProcessingException {
|
||||
String[] parts = undoId.split("_");
|
||||
String MBLNR = parts[0];
|
||||
String MJAHR = parts[1];
|
||||
String uniqueID = UUID.randomUUID().toString();
|
||||
JSONObject MainData = new JSONObject(true);
|
||||
Map<String,String> headJSonData = new HashMap<>();
|
||||
Map<String,String> bodyJSonData = new HashMap<>();
|
||||
MainData.put("HEAD",headJSonData);
|
||||
MainData.put("BODY",bodyJSonData);
|
||||
headJSonData.put("INTF_ID","MM068");
|
||||
headJSonData.put("SRC_SYSTEM","WMS");
|
||||
headJSonData.put("DEST_SYSTEM","SAP");
|
||||
headJSonData.put("SRC_MSGID",uniqueID);
|
||||
headJSonData.put("BACKUP1","");
|
||||
headJSonData.put("BACKUP2","");
|
||||
bodyJSonData.put("MBLNR", MBLNR);
|
||||
bodyJSonData.put("MJAHR", MJAHR);
|
||||
bodyJSonData.put("BLDAT", payMentDate);
|
||||
bodyJSonData.put("BUDAT", payMentDate);
|
||||
return MainData.toJSONString();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
package com.cim.idm.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cim.idm.service.Impl.MaterialUndoServiceImpl;
|
||||
import com.cim.idm.service.MESToWMSService;
|
||||
import com.cim.idm.service.Impl.MESToWMSServiceImpl;
|
||||
import com.cim.idm.util.MessageLogUtil;
|
||||
import com.cim.idm.utils.AjaxResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -65,9 +68,13 @@ public class MESToWMSController {
|
||||
log.info("Received cancel ship request: {}", in.toJSONString());
|
||||
String undoId = in.getJSONObject(0).getString("undoId");
|
||||
String userId = in.getJSONObject(0).getString("userId");
|
||||
String payMentDate = in.getJSONObject(0).get("payMentDate") == null ? "" : in.getJSONObject(0).get("payMentDate").toString(); //过账日期
|
||||
if (StringUtils.isBlank(payMentDate)) {
|
||||
return AjaxResult.me().setSuccess(false).setErrorCode(500).setMessage("payMentDate过账日期不能为空");
|
||||
}
|
||||
// return mesToWMSService.cancelShipByMES(in);
|
||||
try {
|
||||
return mesToWMSService.sapcprkUndo(undoId, userId);
|
||||
return mesToWMSService.sapcprkUndo(undoId, userId, payMentDate);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -230,9 +230,9 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult sapcprkUndo(String undoId, String user) throws Exception {
|
||||
public AjaxResult sapcprkUndo(String undoId, String user, String payMentDate) throws Exception {
|
||||
|
||||
String billCode = toSAPService.cancelShipInter(undoId, user);
|
||||
String billCode = toSAPService.cancelShipInter(undoId, user, payMentDate);
|
||||
if (billCode == null) {
|
||||
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public interface MESToWMSService {
|
||||
AjaxResult cancelShipByMES(JSONArray in);
|
||||
|
||||
@Transactional
|
||||
AjaxResult sapcprkUndo(String undoId, String user) throws Exception;
|
||||
AjaxResult sapcprkUndo(String undoId, String user, String payMentDate) throws Exception;
|
||||
|
||||
/**
|
||||
* 接收MES请求物料入库请求
|
||||
|
Loading…
x
Reference in New Issue
Block a user