From 6efbf154b3ed88d376763b9d9807256c7bd5eaeb Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期一, 09 三月 2026 20:23:38 +0800
Subject: [PATCH] no message

---
 src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java |  142 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 102 insertions(+), 40 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 23276e6..3286885 100644
--- a/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
@@ -19,6 +19,9 @@
 import com.zy.asrs.entity.*;
 import com.zy.asrs.enums.OrderTypeEnum;
 import com.zy.asrs.service.*;
+import com.zy.asrs.service.impl.TaskDetlLogServiceImpl;
+import com.zy.asrs.service.impl.TaskDetlServiceImpl;
+import com.zy.asrs.service.impl.WrkDetlLogServiceImpl;
 import com.zy.asrs.task.AbstractHandler;
 import com.zy.asrs.task.core.ReturnT;
 import com.zy.asrs.utils.OrderInAndOutUtil;
@@ -69,6 +72,10 @@
     private LocDetlService locDetlService;
     @Autowired
     CheckOrderDetlService checkOrderDetlService;
+    @Autowired
+    private TaskDetlLogService taskDetlLogService;
+    @Autowired
+    private WrkDetlLogServiceImpl wrkDetlLogService;
 
 
     @Transactional
@@ -140,6 +147,7 @@
                 orderDetlList.add(detail);
             }
         }
+
         for (OrderDetl orderDetl : orderDetlList) {
             orderDetl.setWorkQty(0D);
             OrderInAndOutUtil.insertOrderDetl(order.getPakinPakoutStatus$(), order, orderDetl);
@@ -161,17 +169,22 @@
 
     @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("鎻掑叆澶囪揣鍏ュ簱鍗曞け璐�");
+        OrderPakin pakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>()
+                .eq("order_no", order.getOrderNo())
+                .eq("doc_type", OrderTypeEnum.STOCK_IN.type.longValue()));
+        if (Objects.isNull(pakin)) {
+            OrderPakin orderPakin = new OrderPakin();
+            BeanUtils.copyProperties(order, orderPakin);
+            orderPakin.setDocType(OrderTypeEnum.STOCK_IN.type.longValue());
+            if (!orderPakinService.insert(orderPakin)) {
+                throw new CoolException("鎻掑叆澶囪揣鍏ュ簱鍗曞け璐�");
+            }
+            pakin = orderPakin;
         }
+
         OrderDetlPakin orderDetlPakin = new OrderDetlPakin();
         BeanUtils.copyProperties(orderDetl, orderDetlPakin);
-        orderDetlPakin.setOrderId(orderPakin.getId());
-
+        orderDetlPakin.setOrderId(pakin.getId());
         if (!orderDetlPakinService.insert(orderDetlPakin)) {
             throw new CoolException("鎻掑叆澶囪揣鍏ュ簱鍗曞け璐�");
         }
@@ -266,7 +279,7 @@
             orderDetls.forEach(detl -> {
                 Mat material = matService.selectByMatnr(detl.getMatnr());
                 if (Objects.isNull(material)) {
-                    throw new CoolException("鐗╂枡涓嶅瓨鍦�");
+                    throw new CoolException(material.getMatnr() +  "鐗╂枡涓嶅瓨鍦�");
                 }
                 ReportOrderParams itemParam = new ReportOrderParams();
 
@@ -275,29 +288,46 @@
                         .eq("supp_code", detl.getSuppCode())
                         .eq("order_no", detl.getOrderNo()));
                 if (Objects.isNull(locDetl)) {
-                    throw new CoolException("搴撳瓨鏄庣粏涓嶅瓨鍦� 锛岃妫�鏌ュ崟鎹槸鍚﹀畬鎴愶紒锛�");
+                    // BS Code
+                    itemParam.setTotal_serial(detl.getThreeCode())
+                            // 涓婃姤鏃讹紝榛樿浜у搧绫诲瀷鏄痭ull
+                            .setPro_type(material.getProType())
+                            // 涓婃姤鏃讹紝榛樿浜у搧缂栫爜
+                            .setPro_komcode(detl.getMatnr())
+                            // 涓婃姤鏃讹紝榛樿浜у搧id鏄緵搴斿晢缂栫爜
+                            .setPro_id(detl.getSuppCode())
+                            .setLocation_no("LX000000000")
+                            .setSj_emp("9527")
+                            .setLocation_type(MatLocType.getMatTag(material.getTagId() + ""))
+                            // 涓婃姤鏃讹紝榛樿涓婃姤鏃堕棿鏄洿鏂版椂闂�
+                            .setSj_date(Utils.dateToStr(order.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"))
+                            // 涓婃姤鏃讹紝濡傛灉涓虹┖榛樿涓婃姤 0
+                            .setPick_qty(0)
+                            // 涓婃姤鏃讹紝榛樿鎹熷潖鏁伴噺鏄�0
+                            .setDamage_qty(0)
+                            // 涓婃姤鏃讹紝榛樿宸紓鏁伴噺鏄�0
+                            .setDiff_qty(0);
+                } else {
+                    // BS Code
+                    itemParam.setTotal_serial(detl.getThreeCode())
+                            // 涓婃姤鏃讹紝榛樿浜у搧绫诲瀷鏄痭ull
+                            .setPro_type(material.getProType())
+                            // 涓婃姤鏃讹紝榛樿浜у搧缂栫爜
+                            .setPro_komcode(detl.getMatnr())
+                            // 涓婃姤鏃讹紝榛樿浜у搧id鏄緵搴斿晢缂栫爜
+                            .setPro_id(detl.getSuppCode())
+                            .setLocation_no(locDetl.getZpallet())
+                            .setSj_emp(locDetl.getModiUser$())
+                            .setLocation_type(MatLocType.getMatTag(material.getTagId() + ""))
+                            // 涓婃姤鏃讹紝榛樿涓婃姤鏃堕棿鏄洿鏂版椂闂�
+                            .setSj_date(Utils.dateToStr(order.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"))
+                            // 涓婃姤鏃讹紝榛樿涓婃姤鏁伴噺鏄鍗曟暟閲�
+                            .setPick_qty(locDetl.getAnfme().intValue())
+                            // 涓婃姤鏃讹紝榛樿鎹熷潖鏁伴噺鏄�0
+                            .setDamage_qty(0)
+                            // 涓婃姤鏃讹紝榛樿宸紓鏁伴噺鏄�0
+                            .setDiff_qty(0);
                 }
-
-                // BS Code
-                itemParam.setTotal_serial(detl.getThreeCode())
-                        // 涓婃姤鏃讹紝榛樿浜у搧绫诲瀷鏄痭ull
-                        .setPro_type(material.getProType())
-                        // 涓婃姤鏃讹紝榛樿浜у搧缂栫爜
-                        .setPro_komcode(detl.getMatnr())
-                        // 涓婃姤鏃讹紝榛樿浜у搧id鏄緵搴斿晢缂栫爜
-                        .setPro_id(detl.getSuppCode())
-                        .setLocation_no(locDetl.getZpallet())
-                        .setSj_emp(locDetl.getModiUser$())
-                        .setLocation_type(MatLocType.getMatTag(material.getTagId()  + ""))
-                        // 涓婃姤鏃讹紝榛樿涓婃姤鏃堕棿鏄洿鏂版椂闂�
-                        .setSj_date(Utils.dateToStr(order.getUpdateTime(), "yyyy-MM-dd HH:mm:ss") )
-                        // 涓婃姤鏃讹紝榛樿涓婃姤鏁伴噺鏄鍗曟暟閲�
-                        .setPick_qty(detl.getQty().intValue())
-                        // 涓婃姤鏃讹紝榛樿鎹熷潖鏁伴噺鏄�0
-                        .setDamage_qty(0)
-                        // 涓婃姤鏃讹紝榛樿宸紓鏁伴噺鏄�0
-                        .setDiff_qty(0);
-
                 reportOrderParams.add(itemParam);
             });
 
@@ -353,14 +383,31 @@
                     .setUpdate_time(Utils.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"))
                     //鐩爣搴撳尯
                     .setTarget_location("")
-                    .setTarget_location("1");
+                    .setSource_location("1");
 
             List<OrderItemsParam> reportOrderParams = new ArrayList<>();
             orderDetls.forEach(detl -> {
                 Mat material = matService.selectByMatnr(detl.getMatnr());
                 if (Objects.isNull(material)) {
-                    throw new CoolException("鐗╂枡涓嶅瓨鍦�");
+                    throw new CoolException(material.getMatnr() +  "鐗╂枡涓嶅瓨鍦�");
                 }
+                TaskDetlLog detlLog = taskDetlLogService.selectOne(new EntityWrapper<TaskDetlLog>()
+                        .eq("matnr", detl.getMatnr())
+                        .eq("supp_code", detl.getStandby1())
+                        .eq("order_no", detl.getOrderNo()));
+                if (Objects.isNull(detlLog)) {
+                    throw new CoolException("鏁版嵁閿欒 锛岃妫�鏌GV浠诲姟妗f槸鍚﹀凡瀹屾垚锛侊紒");
+                }
+/*                WrkDetlLog detlLog = wrkDetlLogService.selectOne(new EntityWrapper<WrkDetlLog>()
+                        .eq("matnr", detl.getMatnr())
+                        .eq("supp_code", detl.getStandby1())
+                        .eq("order_no", detl.getOrderNo()));
+                if (Objects.isNull(detlLog)) {
+                    throw new CoolException("鐗╂枡缂栫爜锛�" + detl.getMatnr() + "鏁版嵁閿欒 锛岃妫�鏌ュ爢鍨涙満浠诲姟妗f槸鍚﹀凡瀹屾垚锛侊紒");
+                }*/
+                //鐩爣搴撳尯
+//                orderParam.setTarget_location("2");
+                orderParam.setTarget_location(detlLog.getAreaType());
                 OrderItemsParam itemParam = new OrderItemsParam();
                 // BS Code
                 itemParam
@@ -371,12 +418,19 @@
                         // 涓婃姤鏃讹紝榛樿浜у搧id鏄緵搴斿晢缂栫爜
                         .setPro_id(detl.getSuppCode())
 //                        // 涓婃姤鏃讹紝榛樿鏉ユ簮浣嶇疆鏄痭ull
-                        .setLocation_no(null)
+                        .setLocation_no(detlLog.getZpallet())
                         // 涓婃姤鏃讹紝榛樿涓婃姤鏁伴噺鏄鍗曟暟閲�
-                        .setPick_qty(detl.getQty().intValue());
+                        .setPick_qty(Objects.isNull(detl.getQty()) ? 0 : detl.getQty().intValue());
                 reportOrderParams.add(itemParam);
             });
 
+            if (orderParam.getTarget_location().equals("2")) {
+                orderParam.setType("11");
+            } else if (orderParam.getTarget_location().equals("3")) {
+                orderParam.setType("12");
+            } else {
+                orderParam.setType("13");
+            }
             orderParam.setPartList(reportOrderParams);
 
             XSR response = null;
@@ -436,7 +490,14 @@
             orderDetls.forEach(detl -> {
                 Mat material = matService.selectByMatnr(detl.getMatnr());
                 if (Objects.isNull(material)) {
-                    throw new CoolException("鐗╂枡涓嶅瓨鍦�");
+                    throw new CoolException(material.getMatnr() +  "鐗╂枡涓嶅瓨鍦�");
+                }
+                TaskDetlLog detlLog = taskDetlLogService.selectOne(new EntityWrapper<TaskDetlLog>()
+                        .eq("matnr", detl.getMatnr())
+                        .eq("supp_code", detl.getStandby1())
+                        .eq("order_no", detl.getOrderNo()));
+                if (Objects.isNull(detlLog)) {
+                    throw new CoolException("鏁版嵁閿欒 锛岃妫�鏌GV浠诲姟妗f槸鍚﹀凡瀹屾垚锛侊紒");
                 }
                 OrderItemsParam itemParam = new OrderItemsParam();
                 // 涓婃姤鏃讹紝榛樿浜у搧绫诲瀷鏄痭ull
@@ -446,9 +507,10 @@
                 // 涓婃姤鏃讹紝榛樿浜у搧id鏄緵搴斿晢缂栫爜
                 itemParam.setPro_id(detl.getSuppCode());
                 //todo 鍙拌溅缂栫爜
-                itemParam.setTruck_no("TC310080014");
+                itemParam.setTruck_no(detlLog.getZpallet());
                 // 涓婃姤鏃讹紝榛樿涓婃姤鏃堕棿鏄洿鏂版椂闂�
                 itemParam.setPick_qty(detl.getQty().intValue());
+
                 reportOrderParams.add(itemParam);
             });
             pubOrderParams.setPartList(reportOrderParams);
@@ -516,7 +578,7 @@
 
     /**
      * 鎹熸孩鍗曞畬缁撲笂鎶�
-     * 
+     *
      * @param order
      * @return
      */
@@ -544,7 +606,7 @@
         detls.forEach(detl -> {
             Mat material = matService.selectByMatnr(detl.getMatnr());
             if (Objects.isNull(material)) {
-                throw new CoolException("鐗╂枡涓嶅瓨鍦�");
+                throw new CoolException(material.getMatnr() +  "鐗╂枡涓嶅瓨鍦�");
             }
             OrderItemsParam itemParam = new OrderItemsParam();
             itemParam.setLocation_no(detl.getZpallet())
@@ -562,7 +624,7 @@
             if (response.getSuccess()) {
                 return SUCCESS;
             } else {
-                return  FAIL;
+                return FAIL;
             }
         }
 

--
Gitblit v1.9.1