From b25e52d74d642314eacf964e3237d3725001f9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E9=A3=9E?= Date: Wed, 14 May 2025 15:21:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:mes=E4=B8=8B=E5=8F=91=E5=A4=B1=E8=B4=A5,sap?= =?UTF-8?q?=E8=BF=87=E8=B4=A6=E5=86=B2=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cim/idm/service/impl/MESServiceImpl.java | 24 +-- .../idm/service/Impl/InvoiceServiceImpl.java | 166 +++++++++++++++++- .../java/com/cim/idm/utils/CommonUtils.java | 40 ++--- 3 files changed, 190 insertions(+), 40 deletions(-) diff --git a/zi-wms-inf/src/main/java/com/cim/idm/service/impl/MESServiceImpl.java b/zi-wms-inf/src/main/java/com/cim/idm/service/impl/MESServiceImpl.java index f4fc4b9..5e9bc2c 100644 --- a/zi-wms-inf/src/main/java/com/cim/idm/service/impl/MESServiceImpl.java +++ b/zi-wms-inf/src/main/java/com/cim/idm/service/impl/MESServiceImpl.java @@ -111,7 +111,7 @@ public class MESServiceImpl implements MESService{ } //zd.2024.8.4重写发送MES方法 - public String OutMaterialInfoSend_NEW(String shipRequestName, String siteName, String receiveActNo, String wo, + public Boolean OutMaterialInfoSend_NEW(String shipRequestName, String siteName, String receiveActNo, String wo, String erpReceiveLocation,String erpReceiveFactory,List boxList) throws CustomException{ //根据单据获取要发送MES的信息 @@ -172,10 +172,10 @@ public class MESServiceImpl implements MESService{ erplog.setResultCode(code); MessageLogUtil.writeMessageLog(erplog); - if (!success) { - String msg = jsonObject.getString("msg"); - throw new CustomException("发送MES失败!"); - } +// if (!success) { +// String msg = jsonObject.getString("msg"); +// throw new CustomException("发送MES失败!"); +// } //插入MATERIALPCKINGMDC表 for(int i=0;i boxList) throws CustomException{ //根据单据获取要发送MES的信息 @@ -297,10 +297,10 @@ public class MESServiceImpl implements MESService{ erplog.setResultCode(code); MessageLogUtil.writeMessageLog(erplog); - if (!success) { - String msg = jsonObject.getString("msg"); - throw new CustomException("发送MES失败!"); - } +// if (!success) { +// String msg = jsonObject.getString("msg"); +// throw new CustomException("发送MES失败!"); +// } //插入MATERIALPCKINGMDC表 for(int i=0;i bodyData = new HashMap<>(); +// List> itemsData = new ArrayList<>(); +// +// for (Map mm : list) { +// Map item = new HashMap<>(); +// //UMWRK 收货工厂 +// //LGORT 发货库存地点 +// //UMLOG 收货库存地点 +// //MATNR 发货物料号 +// //UMMAT 收货物料 +// +// item.put("MATNR", mm.get("MATERIALSPECNAME")); +// item.put("LGORT", mm.get("ERPLOCATION")); +// item.put("WERKS", mm.get("ERPFACTORY")); +// if("FG".equals((String)mm.get("MATERIALSPECTYPE")) ) { +// item.put("BWART", "101"); //产成品,移动类型 101 +// }else if("BFG".equals((String)mm.get("MATERIALSPECTYPE")) ) { +// item.put("BWART", "531"); //副产品, 移动类型 531 +// }else if("FGDEV".equals((String)mm.get("MATERIALSPECTYPE")) ) { +// item.put("BWART", "511"); //研发品, 移动类型 511 +// }else { +// item.put("BWART", "101"); //为了兼容之前的未提到的成品,统一暂用 101 +// } +// +// item.put("MENGE", mm.get("MATERIALQUANTITY")); +// item.put("MEINS", mm.get("UNIT")); +// item.put("AUFNR", mm.get("PRODUCTORDER")); +// item.put("BPMNG", ""); +// item.put("BPRME", ""); +// item.put("SGTXT", mm.get("REMARK")); +// String insmk = ""; +// if (StringUtils.isEmpty((String)mm.get("PACKINGGRADE"))) { +// insmk = "2"; +// }else if ("NG".equals((String)mm.get("PACKINGGRADE"))) { +// insmk = "3"; +// } +//// String insmk = StringUtils.equals(mm.get("OQARESULTSTATE").toString(),"END")?"":"X"; +// item.put("INSMK", insmk); +// itemsData.add(item); +// +// } +//String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData); + 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("BUDAT", "20250430"); + //凭证日期 + bodyJSonData.put("BLDAT", "20250430"); + + String sendData = MainData.toJSONString(); + return sendData; + } } diff --git a/zi-wms-pda/src/main/java/com/cim/idm/utils/CommonUtils.java b/zi-wms-pda/src/main/java/com/cim/idm/utils/CommonUtils.java index 349358f..991edfc 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/utils/CommonUtils.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/utils/CommonUtils.java @@ -673,7 +673,7 @@ public void SaveUnDoInfo_ForSap(List list, String undoid, EventInfo mak * @param receiveActNo 收货活动编号,用于指定收货活动 * @param boxList 箱号列表,包含所有需要发送的物料箱号 */ - public void sendMaterialInfoToMES_NEW(String invoiceNo,String receiveActNo,List boxList,String billCode,String user){ + public Boolean sendMaterialInfoToMES_NEW(String invoiceNo,String receiveActNo,List boxList,String billCode,String user){ // 定义SQL查询语句,用于获取物料接收位置和接收工厂信息 String sql="SELECT m.ERPRECEIVELOCATION,m.ERPRECEIVEFACTORY FROM MATERIALSHIPREQUEST a,MATERIALSHIPREQUESTDETAIL m \r\n" + " WHERE m.SHIPREQUESTNAME =:SHIPREQUESTNAME and m.SHIPREQUESTNAME=a.SHIPREQUESTNAME " @@ -681,6 +681,7 @@ public void SaveUnDoInfo_ForSap(List list, String undoid, EventInfo mak // 创建参数映射,用于执行SQL查询 Map bp=new HashMap<>(); bp.put("SHIPREQUESTNAME", invoiceNo); + Boolean success = true; try { // 执行SQL查询,获取查询结果列表 List> sr=IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bp); @@ -690,27 +691,20 @@ public void SaveUnDoInfo_ForSap(List list, String undoid, EventInfo mak // 创建MESServiceImpl实例,用于调用发送物料信息到MES系统的方法 MESServiceImpl mesService=new MESServiceImpl() ; // 调用MESServiceImpl的OutMaterialInfoSend_NEW方法,发送物料信息到MES系统 - String code = mesService.OutMaterialInfoSend_NEW(invoiceNo, "SDK", receiveActNo, "", + success = mesService.OutMaterialInfoSend_NEW(invoiceNo, "SDK", receiveActNo, "", sr.get(0).get("ERPRECEIVELOCATION")==null?"":sr.get(0).get("ERPRECEIVELOCATION").toString() ,sr.get(0).get("ERPRECEIVEFACTORY")==null?"":sr.get(0).get("ERPRECEIVEFACTORY").toString(),boxList ); - if("1".equals(code)) { - String undo = toSAPService.cancelShipInter(billCode, user); - if (undo == null ) { - throw new GlobalException("报送ERP失败,请联系IT处理!"); - } - } - } + } } catch (CustomException e) { // 异常处理:打印异常堆栈跟踪信息 e.printStackTrace(); - } catch (Exception e) { - throw new RuntimeException(e); - } + } + return success; } - public void sendMaterialInfoToMES_NEW2(String invoiceNo,String receiveActNo,List boxList, String billCode, String user){ + public Boolean sendMaterialInfoToMES_NEW2(String invoiceNo,String receiveActNo,List boxList, String billCode, String user){ // 定义SQL查询语句,用于获取物料接收位置和接收工厂信息 String sql="SELECT m.ERPRECEIVELOCATION,m.ERPRECEIVEFACTORY FROM MATERIALSHIPREQUEST a,MATERIALSHIPREQUESTDETAIL m \r\n" + " WHERE m.SHIPREQUESTNAME =:SHIPREQUESTNAME and m.SHIPREQUESTNAME=a.SHIPREQUESTNAME " @@ -718,6 +712,7 @@ public void SaveUnDoInfo_ForSap(List list, String undoid, EventInfo mak // 创建参数映射,用于执行SQL查询 Map bp=new HashMap<>(); bp.put("SHIPREQUESTNAME", invoiceNo); + Boolean success = true; try { // 执行SQL查询,获取查询结果列表 List> sr=IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bp); @@ -727,23 +722,16 @@ public void SaveUnDoInfo_ForSap(List list, String undoid, EventInfo mak // 创建MESServiceImpl实例,用于调用发送物料信息到MES系统的方法 MESServiceImpl mesService=new MESServiceImpl() ; // 调用MESServiceImpl的OutMaterialInfoSend_NEW方法,发送物料信息到MES系统 - String code = mesService.OutMaterialInfoSend_NEW2(invoiceNo, "SDK", receiveActNo, "", + success = mesService.OutMaterialInfoSend_NEW2(invoiceNo, "SDK", receiveActNo, "", sr.get(0).get("ERPRECEIVELOCATION")==null?"":sr.get(0).get("ERPRECEIVELOCATION").toString() ,sr.get(0).get("ERPRECEIVEFACTORY")==null?"":sr.get(0).get("ERPRECEIVEFACTORY").toString(),boxList ); - if("1".equals(code)) { - String undo = toSAPService.cancelShipInter(billCode, user); - if (undo == null ) { - throw new GlobalException("报送ERP失败,请联系IT处理!"); - } - } } } catch (CustomException e) { // 异常处理:打印异常堆栈跟踪信息 e.printStackTrace(); - } catch (Exception e) { - throw new RuntimeException(e); - } + } + return success; } /** @@ -860,9 +848,13 @@ public void SaveUnDoInfo_ForSap(List list, String undoid, EventInfo mak ,sr.get(0).get("ERPRECEIVEFACTORY")==null?"":sr.get(0).get("ERPRECEIVEFACTORY").toString(),boxList ); */ - mesService.sendMESAndInsertMaterialPackingMDC(invoiceNo, "SDK", receiveActNo, "", + String code = mesService.sendMESAndInsertMaterialPackingMDC(invoiceNo, "SDK", receiveActNo, "", sr.get(0).get("ERPRECEIVELOCATION")==null?"":sr.get(0).get("ERPRECEIVELOCATION").toString() ,sr.get(0).get("ERPRECEIVEFACTORY")==null?"":sr.get(0).get("ERPRECEIVEFACTORY").toString(),boxList ); + + if("1".equals(code)) { + throw new GlobalException("下发到mes失败!"); + } } } catch (CustomException e) { // 异常处理:打印异常堆栈跟踪信息