From a9f7a73efb4fc132ad2c9a353d300b708430e961 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期三, 22 十月 2025 17:16:16 +0800
Subject: [PATCH] 3.销售订单出库上报完善 4.普通订单上报

---
 src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java |   78 ++++++++++++++++++++++++++++++++++----
 1 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java b/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
index a4e6f86..9903c31 100644
--- a/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
@@ -1,5 +1,6 @@
 package com.zy.asrs.task.handler;
 
+import com.core.common.Cools;
 import com.core.common.DateUtils;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.DocType;
@@ -43,7 +44,6 @@
     @Autowired
     private ExdInstockTargetService exdInstockTargetService;
 
-
     @Autowired
     private ExdOutstockTargetService exdOutstockTargetService;
 
@@ -54,6 +54,9 @@
             return SUCCESS;
         }
         List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId());
+        if (orderDetls.isEmpty()) {
+            return SUCCESS;
+        }
         // 鍏ュ簱瀹屾垚涓婃姤
         if (docType.getPakin() == 1) {
             ExdInstockTarget exdInstockTarge = null;
@@ -69,9 +72,9 @@
                 exdInstockTarge.setWritor("WMS");
                 exdInstockTarge.setStatus(0);
                 exdInstockTargetService.insert(exdInstockTarge);
-                if (!orderService.updateSettle(order.getId(), 6L, null)) {
-                    throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
-                }
+            }
+            if (!orderService.updateSettle(order.getId(), 6L, null)) {
+                throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
             }
         } else if (docType.getPakout() == 1) {
             // 鍑哄簱瀹屾垚涓婃姤
@@ -82,8 +85,6 @@
                 exdOutstockTarget.setFbillno(orderDetl.getOrderNo());
                 if (order.getDocType() == 42) {
                     exdOutstockTarget.setFtrantype(41);
-                } else if (order.getDocType() == 21) {
-                    exdOutstockTarget.setFtrantype(81);
                 } else {
                     exdOutstockTarget.setFtrantype(order.getDocType().intValue());
                 }
@@ -94,9 +95,68 @@
                 exdOutstockTarget.setWritor("WMS");
                 exdOutstockTarget.setStatus(0);
                 exdOutstockTargetService.insert(exdOutstockTarget);
-                if (!orderService.updateSettle(order.getId(), 6L, null)) {
-                    throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
-                }
+
+            }
+            if (!orderService.updateSettle(order.getId(), 6L, null)) {
+                throw new CoolException("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇紝璇疯仈绯荤鐞嗗憳");
+            }
+        }
+        return SUCCESS;
+    }
+
+    @Transactional
+    public ReturnT<String> start1(Order order, OrderDetl orderDetl) {
+        DocType docType = docTypeService.selectById(order.getDocType());
+        if (null == docType) {
+            return SUCCESS;
+        }
+        List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId());
+        if (orderDetls.isEmpty()) {
+            return SUCCESS;
+        }
+
+        double count = orderDetl.getQty() - (Cools.isEmpty(orderDetl.getUnits()) ? 0.0 : orderDetl.getUnits());
+        if (docType.getPakout() == 1) {
+            // 鍑哄簱瀹屾垚涓婃姤
+            ExdOutstockTarget exdOutstockTarget = null;
+            exdOutstockTarget = new ExdOutstockTarget();
+            //璁㈠崟鍐呯爜
+            exdOutstockTarget.setFinterid(orderDetl.getDeadWarn());
+            //鍗曞彿 = erp璁㈠崟鍙�+鐗╂枡缂栧彿+涓婃姤娆℃暟
+            exdOutstockTarget.setFbillno(orderDetl.getOrderNo() + "--" + orderDetl.getMatnr() + "--" + orderDetl.getInspect());
+
+            //閮ㄩ棬ID
+            exdOutstockTarget.setFdeptid(0);
+            //渚涘簲鍟�/瀹㈡埛ID
+            exdOutstockTarget.setFsupplyid(0);
+            //鍒跺崟鐢ㄦ埛ID
+            exdOutstockTarget.setFbillerid(0);
+            //缁嗚〃ID
+            exdOutstockTarget.setFentryid(0);
+            //鐗╂枡ID
+            exdOutstockTarget.setFitemid(0);
+            //婧愬崟鏁伴噺
+            exdOutstockTarget.setFqtymust(0.0);
+            //鍑哄簱鏁伴噺
+            //鍗曟嵁绫诲瀷
+            exdOutstockTarget.setFtrantype(21);
+
+            //鍗曟嵁鏃ユ湡
+            exdOutstockTarget.setFdate(DateUtils.convert(order.getOrderTime()));
+            //绾㈣摑瀛�
+            exdOutstockTarget.setFrob(orderDetl.getBeBatch());
+            //鎿嶄綔鐢ㄦ埛
+            exdOutstockTarget.setFuserid(Integer.getInteger(orderDetl.getColor()));
+            //鍐欏叆鏃堕棿
+            exdOutstockTarget.setWritetime(new Date());
+            //鍐欏叆鑰�
+            exdOutstockTarget.setWritor("WMS");
+            //鐘舵��
+            exdOutstockTarget.setStatus(0);
+            if (exdOutstockTargetService.insert(exdOutstockTarget)) {
+                orderDetl.setInspect((Cools.isEmpty(orderDetl.getInspect()) ? 1 : (orderDetl.getInspect() + 1)));
+                orderDetl.setUnits(count + (Cools.isEmpty(orderDetl.getUnits()) ? 0.0 : orderDetl.getUnits()));
+                orderDetlService.updateById(orderDetl);
             }
         }
         return SUCCESS;

--
Gitblit v1.9.1