From 6c1650327a9719ed00d6d8497df537627b66483e Mon Sep 17 00:00:00 2001
From: zengxiangping <318732054@qq.com>
Date: Wed, 6 Mar 2024 13:59:59 +0800
Subject: [PATCH] 修改出库单详情数量后出库单头总数同步修改

---
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java
index 92d268c..236a4fc 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java
@@ -253,7 +253,25 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS
     @RequiresPermissions("shipmentDetail:edit")
     @RequestMapping(value = "/editShipmentDetail", method = {RequestMethod.PUT, RequestMethod.POST})
     public Result<String> editShipmentDetail(@RequestBody ShipmentDetail shipmentDetail) {
-        shipmentDetailService.updateById(shipmentDetail);
+        if (shipmentDetail == null) {
+            return Result.error("修改详情失败, 没有找到出库单详情");
+        }
+        ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId());
+        if (shipmentHeader == null) {
+            return Result.error("修改详情失败, 没有找到出库单");
+        }
+        if (shipmentHeader.getFirstStatus().intValue() != QuantityConstant.SHIPMENT_HEADER_BUILD) {
+            return Result.error("修改详情失败, 出库单必须是新建状态才能修改详情");
+        }
+        boolean success = shipmentDetailService.updateById(shipmentDetail);
+        if (!success) {
+            throw new JeecgBootException("修改详情失败");
+        }
+        success = shipmentHeaderService.updateShipmentHeader(shipmentDetail.getShipmentId());
+        if (!success) {
+            throw new JeecgBootException("修改详情时,更新出库单头数量失败");
+        }
+        LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(Collections.singletonList(shipmentDetail)));// 操作日志收集
         return Result.OK("编辑成功!");
     }
 
--
libgit2 0.22.2