From 19136f60e0327fc784bc8912035adfa248d4e380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=B8=85?= <3115919733@qq.com> Date: Wed, 28 May 2025 14:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=B7=A5=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idm/service/impl/ToSAPServiceImpl.java | 48 +++++-------------- .../idm/service/Impl/MESToWMSServiceImpl.java | 34 +++++++++++-- 2 files changed, 42 insertions(+), 40 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 9538120..829f24b 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 @@ -6707,7 +6707,6 @@ public class ToSAPServiceImpl { sendData.put("HEAD", header); JSONObject body = new JSONObject(true); sendData.put("BODY", body); - JSONArray itemArray = new JSONArray(); /* HEAD @@ -6740,37 +6739,10 @@ public class ToSAPServiceImpl { } for (Map mm : mapList) { mm.put("BWART", bwart); - JSONObject item = new JSONObject(true); - /*if(materialPackingList.size()>0) { - // MATNR 发货物料号 - item.put("MATNR", mm.getMATNR()); - - // WERKS 发货工厂 - item.put("WERKS", mm.getWERKS()); - // LGORT 发货库存地点 - item.put("LGORT", mm.getLGORT()); - //MENGE 数量 - item.put("MENGE",mm.getMENGE()); - //MENGE 单位 - item.put("MEINS",mm.getMEINS()); - item.put("BWART", bwart); - //ZLLORDER 自定义领料单号 -// item.put("ZLLORDER", "LL1010250408001"); - item.put("ZLLORDER", mm.getZLLORDER()); - //ZLLITEM 自定义领料单行号 - -// item.put("ZLLITEM", "0001"); - item.put("ZLLITEM", mm.getZLLITEM()); - //AUFNR 订单号 - item.put("AUFNR", mm.getAUFNR()); - - } - itemArray.add(item);*/ } - System.out.println(mapList); log.info("SendTOSAP >>>>" + sendData); - /*String sendDatas = sendData.toJSONString(); + String sendDatas = sendData.toJSONString(); String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "", sendDatas); org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn); org.json.JSONObject returnJsonObject = (org.json.JSONObject) receiveJsonObject.get("RETURN"); @@ -6782,24 +6754,28 @@ public class ToSAPServiceImpl { } //将log写到表里 ErpMessageLog erplog = new ErpMessageLog(); - erplog.setEventUser(""); + erplog.setEventUser(mes); erplog.setServerName("WmsToErp"); - erplog.setEventName("MES物料消耗261和转工单"); + if ("261".equals(bwart)) { + erplog.setEventName("转工单-入库"); + } else { + erplog.setEventName("转工单-出库"); + } erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT)); erplog.setMessageId(UUID.randomUUID().toString()); erplog.setSendMsg(sendData.toJSONString()); erplog.setSendMsg2(sendData.toJSONString()); erplog.setReturnMsg2(sapreturn); erplog.setResultCode(rcode); - MessageLogUtil.writeMessageLog(erplog);*/ + MessageLogUtil.writeMessageLog(erplog); } catch (Exception e) { log.info(e.getMessage(), e); -// throw new RuntimeException("SAP返回" + e.toString()); + throw new RuntimeException("SAP返回" + e.toString()); } - /* if (!"S".equals(rcode)) { + if (!"S".equals(rcode)) { throw new RuntimeException("SAP返回" + rmsg); - }*/ - return null; + } + return undoId; } /** 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 658b7ba..074e2c5 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 @@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.*; @@ -666,24 +667,49 @@ public class MESToWMSServiceImpl implements MESToWMSService { log.info("Received work order request: {}", in.toJSONString()); List> mapList = new ArrayList<>(); for (int i = 0; i < in.size(); i++) { + String line = "第" + (i + 1) + "行,"; JSONObject jsonObject = in.getJSONObject(i); Map map = new HashMap<>(); // 料号 String materialSpecname = jsonObject.getString("materialSpecname"); + if (StringUtils.isEmpty(materialSpecname)) { + return AjaxResult.me().setSuccess(false).setErrorCode(500). + setMessage(line + "料号-materialSpecname-不能为空"); + } // 组织 String WERKS = jsonObject.getString("WERKS"); + if (StringUtils.isEmpty(WERKS)) { + return AjaxResult.me().setSuccess(false).setErrorCode(500). + setMessage(line + "组织-WERKS-不能为空"); + } // 仓库 String LGORT = jsonObject.getString("erpLocation"); + if (StringUtils.isEmpty(LGORT)) { + return AjaxResult.me().setSuccess(false).setErrorCode(500). + setMessage(line + "仓库-erpLocation-不能为空"); + } + if (StringUtils.isEmpty(jsonObject.getString("MENGE"))) { + return AjaxResult.me().setSuccess(false).setErrorCode(500). + setMessage(line + "数量-MENGE-不能为空"); + } // 数量 - String MENGE = jsonObject.getString("MENGE"); + BigDecimal MENGE = new BigDecimal(jsonObject.getString("MENGE")); // 单位 String MEINS = jsonObject.getString("MEINS"); + if (StringUtils.isEmpty(MEINS)) { + return AjaxResult.me().setSuccess(false).setErrorCode(500). + setMessage(line + "单位-MEINS-不能为空"); + } // 自定义领料单号 String ZLLORDER = jsonObject.getString("ZLLORDER"); // 自定义领料单行号 String ZLLITEM = jsonObject.getString("ZLLITEM"); // 工单 String AUFNR = jsonObject.getString("toOrder"); + if (StringUtils.isEmpty(AUFNR)) { + return AjaxResult.me().setSuccess(false).setErrorCode(500). + setMessage(line + "工单-toOrder-不能为空"); + } map.put("MATNR", materialSpecname); map.put("WERKS", WERKS); @@ -696,10 +722,10 @@ public class MESToWMSServiceImpl implements MESToWMSService { mapList.add(map); } // 出库 -// String undoidOut = toSAPService.StockOutByOrder_new(mapList, "MES", "262"); + String undoidOut = toSAPService.StockOutByOrder_new(mapList, "MES", "262"); // 入库 String undoidIn = toSAPService.StockOutByOrder_new(mapList, "MES", "261"); - /*if (StringUtils.isEmpty(undoidIn)) { + if (StringUtils.isEmpty(undoidIn)) { // 冲销 String undo = invoiceService.cancelShipInter(undoidOut, "MES"); if (undo == null || undo.isEmpty()) { @@ -707,7 +733,7 @@ public class MESToWMSServiceImpl implements MESToWMSService { } else { throw new GlobalException("发送到mes失败!"); } - }*/ + } return AjaxResult.me().setResultObj(null).setSuccess(true).setErrorCode(200).setMessage("执行成功,物料凭证 " + undoidIn); } /**