From b53e4ba7d0b3ea9006b7af20362f78c14bcc1c03 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期四, 05 二月 2026 09:47:20 +0800
Subject: [PATCH] 修复订单出库选择出库站点后报错

---
 src/main/java/com/zy/third/task/handler/OrderHandler.java |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/zy/third/task/handler/OrderHandler.java b/src/main/java/com/zy/third/task/handler/OrderHandler.java
index dcea148..7eed914 100644
--- a/src/main/java/com/zy/third/task/handler/OrderHandler.java
+++ b/src/main/java/com/zy/third/task/handler/OrderHandler.java
@@ -219,17 +219,23 @@
                 throw new CoolException(fbillno + "鍗曟嵁姝e湪浣滀笟涓紝鏃犳硶鍒犻櫎");
             }
             Mat mat = matService.selectBySku(exdInstockSource.getFitemid() + "");
-            boolean delete = orderDetlService.delete(new EntityWrapper<OrderDetl>()
-                    .eq("order_no", order.getOrderNo())
+            OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", order.getOrderNo())
                     .eq("matnr", mat.getMatnr())
                     .eq("batch", exdInstockSource.getFbatchno())
-                    .eq("anfme", exdInstockSource.getFqty()));
-            if (delete) {
-                log.info("鍒犻櫎璁㈠崟鏄庣粏鎴愬姛锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}鎴愬姛",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                    .eq("anfme", exdInstockSource.getFqty()<0 ? -exdInstockSource.getFqty():exdInstockSource.getFqty()));
+            if (orderDetl != null) {
+                boolean delete = orderDetlService.deleteById(orderDetl.getId());
+                if (delete) {
+                    log.info("鍒犻櫎璁㈠崟鏄庣粏鎴愬姛锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}鎴愬姛",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                }else {
+                    log.error("鍒犻櫎璁㈠崟鏄庣粏澶辫触锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                    throw new CoolException(fbillno + "鍗曟嵁鏄庣粏鍒犻櫎澶辫触");
+                }
             }else {
-                log.error("鍒犻櫎璁㈠崟鏄庣粏澶辫触锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
-                throw new CoolException(fbillno + "鍗曟嵁鏄庣粏鍒犻櫎澶辫触");
+                log.error("娌℃湁鏌ヨ鍒拌鍗曟槑缁嗭紝璁㈠崟鍙�={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                throw new CoolException(fbillno + "娌℃湁鏌ヨ鍒拌鍗曟槑缁�");
             }
+
             int orderNo = orderDetlService.selectCount(new EntityWrapper<OrderDetl>().eq("order_no", order.getOrderNo()));
             if(orderNo==0){
                 orderService.remove(order.getId());
@@ -353,16 +359,21 @@
                 throw new CoolException(fbillno + "鍗曟嵁姝e湪浣滀笟涓紝鏃犳硶鍒犻櫎");
             }
             Mat mat = matService.selectBySku(exdInstockSource.getFitemid() + "");
-            boolean delete = orderDetlService.delete(new EntityWrapper<OrderDetl>()
-                    .eq("order_no", order.getOrderNo())
+            OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", order.getOrderNo())
                     .eq("matnr", mat.getMatnr())
                     .eq("batch", exdInstockSource.getFbatchno())
-                    .eq("anfme", exdInstockSource.getFqty()));
-            if (delete) {
-                log.info("鍒犻櫎璁㈠崟鏄庣粏鎴愬姛锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}鎴愬姛",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                    .eq("anfme", exdInstockSource.getFqty()<0 ? -exdInstockSource.getFqty():exdInstockSource.getFqty()));
+            if (orderDetl != null) {
+                boolean delete = orderDetlService.deleteById(orderDetl.getId());
+                if (delete) {
+                    log.info("鍒犻櫎璁㈠崟鏄庣粏鎴愬姛锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}鎴愬姛",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                }else {
+                    log.error("鍒犻櫎璁㈠崟鏄庣粏澶辫触锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                    throw new CoolException(fbillno + "鍗曟嵁鏄庣粏鍒犻櫎澶辫触");
+                }
             }else {
-                log.error("鍒犻櫎璁㈠崟鏄庣粏澶辫触锛岃鍗曞彿={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
-                throw new CoolException(fbillno + "鍗曟嵁鏄庣粏鍒犻櫎澶辫触");
+                log.error("娌℃湁鏌ヨ鍒拌鍗曟槑缁嗭紝璁㈠崟鍙�={},鐗╂枡鍙�={}锛屾壒鍙�={}锛屾暟閲�={}",order.getOrderNo(),exdInstockSource.getFitemid(),exdInstockSource.getFbatchno(),exdInstockSource.getFqty());
+                throw new CoolException(fbillno + "娌℃湁鏌ヨ鍒拌鍗曟槑缁�");
             }
             int orderNo = orderDetlService.selectCount(new EntityWrapper<OrderDetl>().eq("order_no", order.getOrderNo()));
             if(orderNo==0){

--
Gitblit v1.9.1