From 7cf2e143941e1548cc468992ada42106a27805a1 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期二, 09 十二月 2025 19:22:40 +0800
Subject: [PATCH] Merge branch 'jsxswms' of http://47.97.1.152:5880/r/zy-asrs into jsxswms

---
 src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 7 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 e8625d6..d89b147 100644
--- a/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
@@ -5,13 +5,9 @@
 import com.core.common.Cools;
 import com.core.common.DateUtils;
 import com.core.exception.CoolException;
-import com.zy.asrs.entity.DocType;
-import com.zy.asrs.entity.Order;
-import com.zy.asrs.entity.OrderDetl;
-import com.zy.asrs.service.ApiLogService;
-import com.zy.asrs.service.DocTypeService;
-import com.zy.asrs.service.OrderDetlService;
-import com.zy.asrs.service.OrderService;
+import com.zy.asrs.entity.*;
+import com.zy.asrs.enums.OrderTypeEnum;
+import com.zy.asrs.service.*;
 import com.zy.asrs.task.AbstractHandler;
 import com.zy.asrs.task.core.ReturnT;
 import com.zy.asrs.utils.OrderInAndOutUtil;
@@ -21,6 +17,7 @@
 import com.zy.common.model.MesPakoutParam;
 import com.zy.common.utils.HttpHandler;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
@@ -46,6 +43,10 @@
     private ApiLogService apiLogService;
     @Autowired
     private DocTypeService docTypeService;
+    @Autowired
+    private OrderPakinService  orderPakinService;
+    @Autowired
+    private OrderDetlPakinService orderDetlPakinService;
 
     @Transactional
     public ReturnT<String> startOrderIssuedOnceMore(Order order) {
@@ -114,6 +115,15 @@
         for (OrderDetl orderDetl : orderDetlList){
             orderDetl.setWorkQty(0D);
             OrderInAndOutUtil.insertOrderDetl(order.getPakinPakoutStatus$(),order,orderDetl);
+            //灏忔澗锛氬鏋滀笅鍙戝璐ф淳宸ュ崟锛屽垯鐢熸垚澶囪揣鍑哄簱+澶囪揣鍏ュ簱
+            if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())){
+                try {
+                    ifTransfetInsertStockIn(order,orderDetl);
+                }catch (Exception e){
+                    throw new CoolException(e.getMessage());
+                }
+            }
+
         }
         // 淇敼璁㈠崟鐘舵�� 1.鏈綔涓� ===>> 2.浣滀笟涓�
         if (!orderService.updateSettle(order.getId(), 2L, null)) {
@@ -122,8 +132,41 @@
         return SUCCESS;
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    public void ifTransfetInsertStockIn(Order order, OrderDetl orderDetl){
+        OrderPakin orderPakin = new OrderPakin();
+        BeanUtils.copyProperties(order,orderPakin);
+        orderPakin.setDocType(OrderTypeEnum.STOCK_IN.type.longValue());
+
+        if (!orderPakinService.insert(orderPakin)){
+            throw new CoolException("鎻掑叆澶囪揣鍏ュ簱鍗曞け璐�");
+        }
+        OrderDetlPakin orderDetlPakin = new OrderDetlPakin();
+        BeanUtils.copyProperties(orderDetl,orderDetlPakin);
+        orderDetlPakin.setOrderId(orderPakin.getId());
+
+
+        if (!orderDetlPakinService.insert(orderDetlPakin)){
+            throw new CoolException("鎻掑叆澶囪揣鍏ュ簱鍗曞け璐�");
+        }
+
+
+    }
+
     @Transactional
     public ReturnT<String> startOrderInAndOutUtil(Order order) {
+        //灏忔澗锛氳疆璁埌澶囪揣娲惧伐鍗曟槸鏌ヨ澶囪揣鍏ュ簱鍗曟槸鍚﹀畬鎴�
+        if (order.getDocType().equals(OrderTypeEnum.STOCK_IN.type.longValue())){
+            return SUCCESS;
+        }
+        if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())){
+            OrderPakin orderPakin = orderPakinService.selectByNo(order.getOrderNo());
+            if (null != orderPakin) {
+                if (!orderPakin.getSettle().equals(4L)){
+                    return SUCCESS;
+                }
+            }
+        }
         DocType docType = docTypeService.selectById(order.getDocType());
         if (null == docType) {
             return SUCCESS;

--
Gitblit v1.9.1