From 019698a5311b46826b4125b0a4fd9921bf0e7f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E9=A3=9E?= Date: Fri, 25 Apr 2025 11:05:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E9=80=80=E6=96=99?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E7=8E=B0=E5=9C=BA=E4=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idm/service/impl/ToSAPServiceImpl.java | 2 +- .../controller/ProduceReturnController.java | 13 +- .../main/java/com/cim/idm/dao/ToSapDao.java | 2 + .../com/cim/idm/response/RespGenerator.java | 2 +- .../idm/service/Impl/MESToWMSServiceImpl.java | 3 + .../service/Impl/ProductIntoServiceImpl.java | 10 +- .../Impl/ReturnStockIntoServiceImpl.java | 117 +++++++++++++++--- .../com/cim/idm/dao/ProduceReturnDao.xml | 14 +-- .../resources/com/cim/idm/dao/ToSapDao.xml | 9 ++ 9 files changed, 136 insertions(+), 36 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 f926d6e..68fdb21 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 @@ -4980,7 +4980,7 @@ public class ToSAPServiceImpl { erplog.setServerName("WmsToErp"); erplog.setEventName("ReturnStockIn生产退料"); erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT)); - erplog.setMessageId(shipRequestName); + erplog.setMessageId(opCode); erplog.setSendMsg(makeReturnStockIn); erplog.setSendMsg2(makeReturnStockIn); erplog.setSendMsg(makeReturnStockIn); diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/ProduceReturnController.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/ProduceReturnController.java index 9380b25..c66bd7f 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/ProduceReturnController.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/ProduceReturnController.java @@ -213,14 +213,17 @@ public class ProduceReturnController { } else if(list2.isEmpty()) { throw new GlobalException("未打印退库标签!"); } else { - for (Map map : list2) { - if (!"StockOut".equals(map.get("STOCKSTATE").toString())) { - throw new GlobalException("条码已存在且不为出库状态!"); - } - } +// for (Map map : list2) { +// if (!"StockOut".equals(map.get("STOCKSTATE").toString())) { +// throw new GlobalException("条码已存在且不为出库状态!"); +// } +// } } // 查看单号 List> list4 = produceReturnService.getMesShip(materialPackingName); + if(list4.isEmpty()){ + throw new GlobalException("未打印退库标签!"); + } Map mapAll = new HashMap<>(); mapAll.put("list2",list2); mapAll.put("list4",list4); diff --git a/zi-wms-pda/src/main/java/com/cim/idm/dao/ToSapDao.java b/zi-wms-pda/src/main/java/com/cim/idm/dao/ToSapDao.java index 8b93a2a..4fe3669 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/dao/ToSapDao.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/dao/ToSapDao.java @@ -18,6 +18,8 @@ public interface ToSapDao { //基于boxList更新物料凭证及库存状态 public void updateStockState(@Param("boxList") List boxList,@Param("stockState") String stockState,@Param("undoId") String undoId) throws Exception; + //基于boxList更新物料凭证及库存状态 + public void updateLocationStockState(@Param("boxList") List boxList,@Param("stockState") String stockState,@Param("undoId") String undoId,@Param("aimErpFactory") String aimErpFactory,@Param("aimErpLocation") String aimErpLocation,@Param("aimLOcationName") String aimLOcationName) throws Exception; //基于boxList写入过账流水表 public void saveUnDoInfo(@Param("boxList") List boxList, @Param("unDoID") String unDoID, @Param("commitDate") String commitDate) throws Exception; diff --git a/zi-wms-pda/src/main/java/com/cim/idm/response/RespGenerator.java b/zi-wms-pda/src/main/java/com/cim/idm/response/RespGenerator.java index b95c78c..cb35d7e 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/response/RespGenerator.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/response/RespGenerator.java @@ -7,7 +7,7 @@ public class RespGenerator { * 接口返回数据 */ public static BaseResponse returnOK(Object data) { - return new BaseResponse("200", "SUCCESS!", data); + return new BaseResponse("200", "操作成功!", data); } /** 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 40a8054..3737ab4 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 @@ -430,6 +430,8 @@ public class MESToWMSServiceImpl implements MESToWMSService { String gxId = jo.getString("gxId"); // 增加管芯字段 // String makeDate = jo.getString("makeDate"); erpFactory = jo.getString("erpFactory"); + String materialPackingName = jo.getString("materialPackingName"); // 生成退料原条码二维码 + if (i == 0) { stockInType = jo.getString("stockInType"); operationType = jo.getString("operationType"); @@ -469,6 +471,7 @@ public class MESToWMSServiceImpl implements MESToWMSService { bindMap.put("MATERIALSPECTYPE", stockInType); bindMap.put("CHARGE", charge); bindMap.put("GXID", gxId); + bindMap.put("MATERIALPACKINGNAME", materialPackingName); // bindMap.put("makeDate", makeDate); if ("1".equals(operationType)) { // 自动入库 diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java index 4e24da3..8333d7a 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java @@ -326,19 +326,17 @@ public class ProductIntoServiceImpl implements FGStockInService { String aimLOcationName = boxList.get(0).getLocationName(); undoID = toSAPService.NoSourceChangeLocation(arrayList,aimErpFactory, aimErpLocation, aimLOcationName, user ); + //更新物料凭证和库存状态 + toSapDao.updateLocationStockState(boxList, "Stocked", undoID,aimErpFactory,aimErpLocation,aimLOcationName); }else { // 直接入库 //封装为Json的字符串 String json = JSON.toJSONString(fgStockInInfo); undoID = toSAPService.FGStockInByManulIn(json, user); + //更新物料凭证和库存状态 + toSapDao.updateStockState(boxList, "Stocked", undoID); } - - - - - //更新物料凭证和库存状态 - toSapDao.updateStockState(boxList, "Stocked", undoID); //更新过账流水 toSapDao.saveUnDoInfo( boxList, undoID, commitDate); //更新接口表的标记和 diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ReturnStockIntoServiceImpl.java b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ReturnStockIntoServiceImpl.java index c2e727a..f5d78e4 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ReturnStockIntoServiceImpl.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ReturnStockIntoServiceImpl.java @@ -290,7 +290,7 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { } pc += "'')"; try { - boolean refundStockIn = ReturnStockInNew(pc, user, commitDate,opCode); + boolean refundStockIn = ReturnStockInNew(pc, user, commitDate,opCode,boxList); } catch (Exception e) { e.printStackTrace(); throw new GlobalException(e.toString()); @@ -323,7 +323,7 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { sql.append(" SELECT "); sql.append(" T.LOTNAME MATERIALPACKINGNAME, "); sql.append(" T.QTY MATERIALQUANTITY, "); - sql.append(" T.UNIT , T.CHARGE, "); + sql.append(" T.UNIT ,T.RECEIVE_FLAG, T.MATERIALPACKINGNAME PREMATERIALPACKINGNAME,T.CHARGE, "); sql.append(" M2. SHIPREQUESTDETAILNAME,"); sql.append(" T.REQUESTNAME SHIPREQUESTNAME,"); sql.append(" T.PRODUCTSPECNAME MATERIALSPECNAME, "); @@ -356,8 +356,21 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { if(queryForList == null || queryForList.size() < 1) { new CustomException("不存在要入库的信息"); } - - + + + // 查出是否存在原标签 + String receive_flag = queryForList.get(0).get("RECEIVE_FLAG") == null ? "" : queryForList.get(0).get("RECEIVE_FLAG").toString(); + String PREMATERIALPACKINGNAME = queryForList.get(0).get("PREMATERIALPACKINGNAME") == null ? "" : queryForList.get(0).get("PREMATERIALPACKINGNAME").toString(); + + List> xcqueryForList = new ArrayList> (); + Map xcHashMap = new HashMap (); + xcHashMap.put("CHARGE", queryForList.get(0).get("CHARGE")); + xcHashMap.put("MATERIALPACKINGNAME", PREMATERIALPACKINGNAME); + + String xcSql = "SELECT * FROM MATERIALPACKING m WHERE m.CHARGE = :CHARGE AND m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME"; + xcqueryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(xcSql, xcHashMap); + + //判断标签是否存在,存在就更新不存在就创建新的入库 String judgeSql = "SELECT * FROM MATERIALPACKING m WHERE m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME"; List> queryForList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(judgeSql, hashMap); @@ -426,6 +439,17 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { bindMap.put("RETURNPC",queryForList.get(0).get("RETURNPC")); bindMap.put("ShipUser",queryForList.get(0).get("SHIPUSER")); + + // 如果是现场仓更新标签,需根据批次才能找到对应的原标签 + if("T".equals(receive_flag)) { + // 如果存在对应的原标签,MATERIALPACKINGNAME相等,组织 仓库 货位 用原标签,拥于后面过账 + if(xcqueryForList != null && xcqueryForList.size() > 0) { + erpFactory = xcqueryForList.get(0).get("ErpFactory") == null ? "" : xcqueryForList.get(0).get("ErpFactory").toString(); + erpLocation = xcqueryForList.get(0).get("ErpLocation") == null ? "" : xcqueryForList.get(0).get("ErpLocation").toString(); + locationName = xcqueryForList.get(0).get("LocationName") == null ? "" : xcqueryForList.get(0).get("LocationName").toString(); + } + } + bindMap.put("ErpLocation", erpLocation); bindMap.put("ErpFactory", erpFactory); bindMap.put("receiveActNo", SHIPActNo); @@ -443,6 +467,16 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { MaterialPackingKey materialPackingKey = new MaterialPackingKey(siteName,materialPackingName); MaterialPackingServiceProxy.getMaterialPackingService().create( eventInfo, createInfo); + + // 如果是现场仓更新标签,需根据批次才能找到对应的原标签 + if("T".equals(receive_flag)) { + // 如果存在对应的原标签,MATERIALPACKINGNAME相等,就删除原标签 + if(xcqueryForList != null && xcqueryForList.size() > 0) { + String delsql = "DELETE FROM MATERIALPACKING m WHERE m.CHARGE = :CHARGE AND m.MATERIALPACKINGNAME = :MATERIALPACKINGNAME"; + IDMFrameServiceProxy.getSqlTemplate().update(delsql, xcHashMap); + } + } + } else { SetEventInfo setEventInfo = new SetEventInfo(); Map bindMap = new HashMap(); @@ -477,6 +511,7 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { bindMap.put("SALESPERSON", queryForList.get(0).get("SALESPERSON"));//事业部 bindMap.put("CUSTOMNO", queryForList.get(0).get("CUSTOMNO"));//客户 bindMap.put("charge",palletName.split("\\|")[4]); + setEventInfo.setUserColumns(bindMap); MaterialPackingKey materialPackingKey = new MaterialPackingKey("SDK",materialPackingName); MaterialPackingServiceProxy.getMaterialPackingService().setEvent(materialPackingKey, eventInfo, setEventInfo); @@ -535,9 +570,11 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { //重写退料入库过账。同组织使用转库单(BLSQ4K)过账接口,跨组织使用调拨(4E)入库接口。zd.2024.9.2 @Transactional - public boolean ReturnStockInNew(String pc, String eventUser, String commitDate, String opCode) throws Exception { + public boolean ReturnStockInNew(String pc, String eventUser, String commitDate, String opCode,List boxList) throws Exception { String siteName="SDK"; + + // gf现在sap退料MATERIALSHIPREQUEST无单据,不用单据过账 // 根据退库Box查询有多少退库单据,分开过账 String wgs="SELECT DISTINCT m.RECEIVEREQUESTNAME,m.ERPLOCATION,(SELECT m2.SHIPREQUESTTYPE FROM MATERIALSHIPREQUEST m2 \r\n" + " WHERE m2.SHIPREQUESTNAME=m.RECEIVEREQUESTNAME) AS SHIPREQUESTTYPE \r\n" + @@ -548,24 +585,64 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { hashMap3.put("SITENAME", siteName); List> queryForList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(wgs, hashMap3); - //判断批次是否数量是否满足单据需求 - for (int i = 0; i < queryForList2.size(); i++) { - String receiveRequestName = queryForList2.get(i).get("RECEIVEREQUESTNAME").toString(); -// String erpLocation = queryForList2.get(i).get("ERPLOCATION").toString(); -// String shipRequestType=queryForList2.get(i).get("SHIPREQUESTTYPE").toString(); - String billCode=""; - billCode = ToSAPServiceImpl.ReturnStockInNew("SDK", eventUser, receiveRequestName, commitDate,opCode); + String flagList="SELECT bs.RECEIVE_FLAG FROM BS_MES_SHIPPED bs WHERE bs.SITENAME =:SITENAME AND bs.LOTNAME IN" +pc; + List> flgQueryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(flagList, hashMap3); + String receive_flag = flgQueryForList.get(0).get("RECEIVE_FLAG") == null ? "" : flgQueryForList.get(0).get("RECEIVE_FLAG").toString(); + + String billCode=""; + String aimErpFactory = ""; + String aimErpLocation = ""; + String aimLOcationName = ""; + + // 如果是T为现场仓退料,N无现场仓 + if (receive_flag.equals("T")) { + List arrayList = new ArrayList (); + for (int i = 0; i < boxList.size(); i++) { + MaterialPackingKey materialPackingKey = new MaterialPackingKey(siteName, boxList.get(i).getMaterialPackingName()); + arrayList.add(materialPackingKey); + } + //先入到线边仓,从线边再转库 + aimErpFactory = boxList.get(0).getErpFactory(); + aimErpLocation = boxList.get(0).getErpLocation(); + aimLOcationName = boxList.get(0).getLocationName(); + billCode = ToSAPServiceImpl.NoSourceChangeLocation(arrayList,aimErpFactory, + aimErpLocation, aimLOcationName, eventUser ); + if (billCode.length() == 0) { throw new GlobalException("报送ERP失败,请联系IT处理!"); } + }else { + billCode = ToSAPServiceImpl.ReturnStockInNew("SDK", eventUser, "", commitDate,opCode); + + if (billCode.length() == 0) { + throw new GlobalException("报送ERP失败,请联系IT处理!"); + } + } + // gf 现在退料无单据,不用单据过账 + //判断批次是否数量是否满足单据需求 +// for (int i = 0; i < queryForList2.size(); i++) { +// String receiveRequestName = queryForList2.get(i).get("RECEIVEREQUESTNAME").toString(); + String receiveRequestName = ""; +// String erpLocation = queryForList2.get(i).get("ERPLOCATION").toString(); +// String shipRequestType=queryForList2.get(i).get("SHIPREQUESTTYPE").toString(); + // 如果不是T现场仓 +// if (!receive_flag.equals("T")) { +// billCode = ToSAPServiceImpl.ReturnStockInNew("SDK", eventUser, receiveRequestName, commitDate,opCode); +// +// if (billCode.length() == 0) { +// throw new GlobalException("报送ERP失败,请联系IT处理!"); +// } +// } + EventInfo makeEventInfo = new EventInfoUtil().makeEventInfo("ReturnStockIn", eventUser, "ReturnStockIn"); // 更新抬头文本状态和Box状态 /*String sql = "SELECT M.SITENAME ,M.MATERIALPACKINGNAME FROM MATERIALPACKING M WHERE M.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME AND ERPLOCATION = :ERPLOCATION AND m.MATERIALPACKINGNAME IN " + pc;*/ - String sql = "SELECT M.SITENAME ,M.MATERIALPACKINGNAME,M.CHARGE FROM MATERIALPACKING M WHERE M.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME AND m.MATERIALPACKINGNAME IN " - + pc; +// String sql = "SELECT M.SITENAME ,M.MATERIALPACKINGNAME,M.CHARGE FROM MATERIALPACKING M WHERE M.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME AND m.MATERIALPACKINGNAME IN " +// + pc; + String sql = "SELECT M.SITENAME ,M.MATERIALPACKINGNAME,M.CHARGE FROM MATERIALPACKING M WHERE m.MATERIALPACKINGNAME IN " + pc; Map hashMap = new HashMap(); - hashMap.put("RECEIVEREQUESTNAME", receiveRequestName); +// hashMap.put("RECEIVEREQUESTNAME", receiveRequestName); // hashMap.put("ERPLOCATION", erpLocation); List chargeList = new ArrayList<> (); List> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap); @@ -576,6 +653,14 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { Map bindMap = new HashMap(); bindMap.put("unDoID", billCode); bindMap.put("stockState", "Stocked"); + + // 如果是现场仓 把原标签更新为目标组织、仓库、货位 + if("T".equals(receive_flag)) { + bindMap.put("erpFactory", aimErpFactory); + bindMap.put("erpLocation", aimErpLocation); + bindMap.put("locationName", aimLOcationName); + } + setEventInfo.setUserColumns(bindMap); MaterialPackingServiceProxy.getMaterialPackingService().setEvent(materialPackingKey, makeEventInfo, setEventInfo); @@ -603,7 +688,7 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService { // throw new GlobalException("MES返回报错:" + msg); // } - } +// } return true; diff --git a/zi-wms-pda/src/main/resources/com/cim/idm/dao/ProduceReturnDao.xml b/zi-wms-pda/src/main/resources/com/cim/idm/dao/ProduceReturnDao.xml index e6156a0..9904d75 100644 --- a/zi-wms-pda/src/main/resources/com/cim/idm/dao/ProduceReturnDao.xml +++ b/zi-wms-pda/src/main/resources/com/cim/idm/dao/ProduceReturnDao.xml @@ -4,20 +4,20 @@ \ No newline at end of file diff --git a/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml b/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml index 7de1f88..e28adf4 100644 --- a/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml +++ b/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml @@ -43,6 +43,15 @@ #{box.materialPackingName} + + + UPDATE MATERIALPACKING + SET STOCKSTATE = #{stockState},UNDOID = #{undoId}, ERPLOCATION = #{aimErpLocation}, LOCATIONNAME = #{aimLOcationName}, ERPFACTORY = #{aimErpFactory} + WHERE MATERIALPACKINGNAME IN + + #{box.materialPackingName} + + UPDATE MATERIALPACKING m