From 7bbf052b99992e7849a33703e8d03bf11a67f490 Mon Sep 17 00:00:00 2001 From: 18110972313 <780768673@qq.com> Date: Tue, 20 May 2025 14:21:46 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=88=B0=E8=B4=A7=E5=8D=95=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=8C=89=E9=92=AE=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=85=A5=E5=BA=93=E5=8D=95=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idm/service/impl/ToSAPServiceImpl.java | 10 ++-- .../idm/controller/DeliveryController.java | 3 ++ .../MaterialReceiveActController.java | 14 ++++-- .../cim/idm/service/IMaterialShipService.java | 7 +++ .../service/Impl/MaterialShipServiceImpl.java | 46 +++++++++++++++++++ 5 files changed, 71 insertions(+), 9 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 db43cf3..24c9252 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 @@ -6417,8 +6417,7 @@ public class ToSAPServiceImpl { * @return * @throws Exception */ - public String DeliveryToSAPMontage(String deliveryName, String siteName, String user,String commitDate, String opCode, List saleList) throws Exception { - EventInfo eventInfo = new EventInfoUtil().makeEventInfo("NormalStockInDelivery", user, "NormalStockInDelivery", "", ""); + public String DeliveryToSAPMontage(EventInfo eventInfo, String deliveryName, String siteName, String user,String commitDate, String opCode, List saleList) throws Exception { String rcode; String undoId = ""; String rmsg = ""; @@ -6430,7 +6429,8 @@ public class ToSAPServiceImpl { List materialPackingKeyList = new ArrayList<>(); List> qmsDataList = new ArrayList<>(); //依据采购订单,查询待入库的物料(MATERIALPACKING) - String querySql = " SUM(DR.DELIVERYNUM) AS MATERIALQUANTITY,\n" + + String querySql = " SELECT " + + " SUM(DR.DELIVERYNUM) AS MATERIALQUANTITY,\n" + " DR.RECEIVEREQUESTNAME,\n" + " DR.RECEIVEREQUESTDETAILNAME,\n" + " P.ERPLOCATION,\n" + @@ -6529,8 +6529,8 @@ public class ToSAPServiceImpl { sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData, commitDate); exceptionMsg = "SAP返回"; - //sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData); - sapreturn = "{\"HEAD\":{\"INTF_ID\":\"MM067\",\"SRC_SYSTEM\":\"WMS\",\"DEST_SYSTEM\":\"SAP\",\"SRC_MSGID\":\"4908eca1-e70f-4b09-8c79-fb3d34f0f42c\"},\"RETURN\":{\"STATUS\":\"S\",\"MSGTXT\":\"\",\"MBLNR\":\"5000000303\",\"MJAHR\":\"2025\"}}"; + sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData); + //sapreturn = "{\"HEAD\":{\"INTF_ID\":\"MM067\",\"SRC_SYSTEM\":\"WMS\",\"DEST_SYSTEM\":\"SAP\",\"SRC_MSGID\":\"4908eca1-e70f-4b09-8c79-fb3d34f0f42c\"},\"RETURN\":{\"STATUS\":\"S\",\"MSGTXT\":\"\",\"MBLNR\":\"5000000303\",\"MJAHR\":\"2025\"}}"; org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn); org.json.JSONObject returnJsonObject = (org.json.JSONObject) receiveJsonObject.get("RETURN"); diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/DeliveryController.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/DeliveryController.java index b87feff..5acc9ca 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/DeliveryController.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/DeliveryController.java @@ -155,6 +155,9 @@ public class DeliveryController { MaterialDelivery byKey = deliveryService.getByKey(storeDetailDto); // 到货单 if (Objects.nonNull(byKey)) { + if ("03".equals(byKey.getDeliveryState())){ + return AjaxResult.me().setErrorCode(400).setMessage("到货单:" + byKey.getDeliveryName() + "已入库,请勿重复操作"); + } deliveryName = byKey.getDeliveryName(); // 到库单(找出该单据下的所有的采购单) nameList = deliveryService.getRelByDelivery(storeDetailDto) diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/MaterialReceiveActController.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/MaterialReceiveActController.java index 5c3105f..f57497d 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/MaterialReceiveActController.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/MaterialReceiveActController.java @@ -16,6 +16,7 @@ import com.cim.idm.model.po.delivery.MaterialDelivery; import com.cim.idm.mwmsextend.materialpacking.service.MaterialPackingServiceImpl; import com.cim.idm.service.IDeliveryService; import com.cim.idm.service.IMaterialPackingService; +import com.cim.idm.service.IMaterialShipService; import com.cim.idm.service.impl.QMSServiceImpl; import com.cim.idm.service.impl.ToSAPServiceImpl; import com.cim.idm.utils.AjaxResult; @@ -66,6 +67,9 @@ public class MaterialReceiveActController { private QMSServiceImpl qMSServiceImpl = new QMSServiceImpl(); + @Autowired + private IMaterialShipService materialShipService; + @RequestMapping(value = "/dessiginBoxByAct", method = RequestMethod.POST) public AjaxResult dessiginBoxByAct(@RequestBody JSONObject in ) throws Exception{ @@ -641,22 +645,24 @@ public class MaterialReceiveActController { String opCode = trackOutBoDto.getOpCode(); String commitDate = trackOutBoDto.getCommitDate(); String siteName = trackOutBoDto.getSiteName(); - toSAPServiceImpl.DeliveryToSAPMontage(materialDelivery.getDeliveryName(), siteName, user, commitDate,opCode,ReceiveTypeEnums.getsaleReturn()); + EventInfo eventInfo = new com.cim.idm.wmsextend.generic.util.EventInfoUtil().makeEventInfo("NormalStockInDelivery", user, "NormalStockInDelivery", "", ""); + toSAPServiceImpl.DeliveryToSAPMontage(eventInfo, materialDelivery.getDeliveryName(), siteName, user, commitDate,opCode,ReceiveTypeEnums.getsaleReturn()); + //更新入库单数量 + materialShipService.DeliveryStockInUpdateReceiveRequestQty(eventInfo, materialDelivery); // 到货单据更新状态 if (Objects.nonNull(materialDelivery.getDeliveryName())) { DeliveryEditDto deliveryEditDto = new DeliveryEditDto(); deliveryEditDto.setDeliveryName(trackOutBoDto.getReceiveRequestName()); deliveryEditDto.setSiteName(trackOutBoDto.getSiteName()); - // @TODO 完成状态下,更新为 DeliveryStateEnums.FINISH deliveryEditDto.setDeliveryState(DeliveryStateEnums.FINISH.getCode()); deliveryService.editDelivery(deliveryEditDto); } } else { - return AjaxResult.me().setSuccess(false).setMessage("到货单:" + trackOutBoDto.getReceiveRequestName() + "不存在").setErrorCode(400); + return AjaxResult.me().setMessage("到货单:" + trackOutBoDto.getReceiveRequestName() + "不存在").setErrorCode(400); } } catch (Exception e) { e.printStackTrace(); - return AjaxResult.me().setSuccess(false).setMessage(e.toString()); + return AjaxResult.me().setErrorCode(400).setMessage(e.toString()); } return AjaxResult.me().setSuccess(true); } diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/IMaterialShipService.java b/zi-wms-pda/src/main/java/com/cim/idm/service/IMaterialShipService.java index 564ea70..ba9e9da 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/IMaterialShipService.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/IMaterialShipService.java @@ -4,6 +4,7 @@ package com.cim.idm.service; import com.cim.idm.exception.GlobalException; import com.cim.idm.framework.data.EventInfo; import com.cim.idm.model.OutStockDto; +import com.cim.idm.model.po.delivery.MaterialDelivery; import com.cim.idm.utils.AjaxResult; import java.util.LinkedHashMap; @@ -62,4 +63,10 @@ public interface IMaterialShipService { */ AjaxResult MaterialShipRequestAuxiliaryCancelConfirmStocking(EventInfo eventInfo, String siteName, String shipRequestName, String user); + /** + * 根据到货单号更新入库单数量 + * @param eventInfo 事件信息 + * @param materialDelivery 到货单信息 + */ + void DeliveryStockInUpdateReceiveRequestQty(EventInfo eventInfo, MaterialDelivery materialDelivery); } diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java index 1158a03..48a33c5 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java @@ -2,12 +2,16 @@ package com.cim.idm.service.Impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.cim.idm.dao.DeliveryDao; import com.cim.idm.data.ErpMessageLog; import com.cim.idm.exception.GlobalException; import com.cim.idm.framework.IDMFrameServiceProxy; import com.cim.idm.framework.data.EventInfo; import com.cim.idm.framework.util.time.TimeStampUtil; import com.cim.idm.model.OutStockDto; +import com.cim.idm.model.dto.delivery.StoreDetailDto; +import com.cim.idm.model.po.delivery.MaterialDelivery; +import com.cim.idm.model.po.delivery.MaterialDeliveryReceive; import com.cim.idm.mwmsextend.materialpacking.service.MaterialPackingServiceImpl; import com.cim.idm.service.IMaterialShipService; import com.cim.idm.service.impl.MESServiceImpl; @@ -30,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; @@ -45,6 +50,8 @@ public class MaterialShipServiceImpl implements IMaterialShipService { private ToSAPMessageUtil toSAPMessageUtil; private EventInfo makeEventInfo; + @Autowired + private DeliveryDao deliveryDao; /** * 出库方法实现 */ @@ -2044,4 +2051,43 @@ public class MaterialShipServiceImpl implements IMaterialShipService { } return true; } + + /** + * 2025-05-20 + * 根据到货单号更新入库单数量 + * @param eventInfo 事件信息 + * @param materialDelivery 到货单信息 + */ + public void DeliveryStockInUpdateReceiveRequestQty(EventInfo eventInfo, MaterialDelivery materialDelivery){ + //获取到货单关联的所有入库单 + StoreDetailDto storeDetailDto = new StoreDetailDto(); + storeDetailDto.setDocumentName(materialDelivery.getDeliveryName()); + List materialDeliveryReceivesList = deliveryDao.getRelByDelivery(storeDetailDto); + //更新入库单信息 + for (MaterialDeliveryReceive materialDeliveryReceive : materialDeliveryReceivesList) { + String updateReceiveRequestQtySql = " UPDATE MATERIALRECEIVEREQUESTDETAIL m \n" + + "SET m.RECEIVEDQUANTITY = m.RECEIVEDQUANTITY - :QTY" + + " , m.LASTEVENTNAME =:LASTEVENTNAME \n" + + " , m.LASTEVENTTIMEKEY =:LASTEVENTTIMEKEY \n" + + " , m.LASTEVENTTIME =:LASTEVENTTIME \n" + + " , m.LASTEVENTUSER =:LASTEVENTUSER \n" + + " , m.LASTEVENTCOMMENT =:LASTEVENTCOMMENT \n" + + "WHERE\n" + + "\tm.SITENAME = :SITENAME \n" + + "\tAND m.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME \n" + + "\tAND m.MATERIALSPECNAME = :MATERIALSPECNAME \n" + + "\tAND m.RECEIVEREQUESTDETAILNAME = :RECEIVEREQUESTDETAILNAME "; + Map updateReceiveRequestQtyMap = new HashMap(); + updateReceiveRequestQtyMap.put("QTY", materialDeliveryReceive.getDeliveryNum()); + updateReceiveRequestQtyMap.put("SITENAME", materialDelivery.getSiteName()); + updateReceiveRequestQtyMap.put("MATERIALSPECNAME", materialDeliveryReceive.getMaterialSpecName()); + updateReceiveRequestQtyMap.put("RECEIVEREQUESTNAME", materialDeliveryReceive.getReceiveRequestName()); + updateReceiveRequestQtyMap.put("LASTEVENTNAME", eventInfo.getEventUser()); + updateReceiveRequestQtyMap.put("LASTEVENTTIMEKEY", eventInfo.getEventTimeKey()); + updateReceiveRequestQtyMap.put("LASTEVENTTIME", eventInfo.getEventTime()); + updateReceiveRequestQtyMap.put("LASTEVENTUSER", eventInfo.getEventUser()); + updateReceiveRequestQtyMap.put("LASTEVENTCOMMENT", eventInfo.getEventComment()); + IDMFrameServiceProxy.getSqlTemplate().update(updateReceiveRequestQtySql, updateReceiveRequestQtyMap); + } + } }