From 88a5582996d01308d0a86b831e50070968d30ed4 Mon Sep 17 00:00:00 2001 From: 18110972313 <780768673@qq.com> Date: Thu, 8 May 2025 14:50:13 +0800 Subject: [PATCH] =?UTF-8?q?update=20meswms=5Fcancelship=5Frequest=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E7=89=A9=E6=96=99=E5=85=A5=E5=BA=93=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?payMentDate=E8=BF=87=E8=B4=A6=E6=97=A5=E6=9C=9F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5,=E5=B9=B6=E5=9C=A8=E8=B0=83=E7=94=A8SAP=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=97=B6=E8=B5=8B=E5=80=BC=E7=BB=99BUDAT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idm/service/impl/ToSAPServiceImpl.java | 87 +++++++++++++++++++ .../idm/controller/MESToWMSController.java | 9 +- .../idm/service/Impl/MESToWMSServiceImpl.java | 4 +- .../com/cim/idm/service/MESToWMSService.java | 2 +- 4 files changed, 98 insertions(+), 4 deletions(-) diff --git a/zi-wms-inf/src/main/java/com/cim/idm/service/impl/ToSAPServiceImpl.java b/zi-wms-inf/src/main/java/com/cim/idm/service/impl/ToSAPServiceImpl.java index 09c90ab..1804975 100644 --- a/zi-wms-inf/src/main/java/com/cim/idm/service/impl/ToSAPServiceImpl.java +++ b/zi-wms-inf/src/main/java/com/cim/idm/service/impl/ToSAPServiceImpl.java @@ -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 headJSonData = new HashMap<>(); + Map 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(); + } } diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/MESToWMSController.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/MESToWMSController.java index 7fa7a94..9d0d40d 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/MESToWMSController.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/MESToWMSController.java @@ -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); } diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java index f7ef386..8f76687 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java @@ -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处理!"); } diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/MESToWMSService.java b/zi-wms-pda/src/main/java/com/cim/idm/service/MESToWMSService.java index 1806e5e..d277873 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/MESToWMSService.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/MESToWMSService.java @@ -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请求物料入库请求