From 3aed7236f2db67dd90115a39bc8f1465e4cc8b73 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期二, 16 十二月 2025 14:34:08 +0800
Subject: [PATCH] 立库完成入库添加库区信息

---
 src/main/java/com/zy/api/service/impl/KopenApiServiceImpl.java |   39 ++++++++-----
 src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java    |   14 ++++
 src/main/resources/mapper/LocDetlMapper.xml                    |  112 ++++++++++++++++++------------------
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java  |    7 ++
 src/main/java/com/zy/api/controller/KopenApiController.java    |    1 
 5 files changed, 100 insertions(+), 73 deletions(-)

diff --git a/src/main/java/com/zy/api/controller/KopenApiController.java b/src/main/java/com/zy/api/controller/KopenApiController.java
index 33df387..bdbe26e 100644
--- a/src/main/java/com/zy/api/controller/KopenApiController.java
+++ b/src/main/java/com/zy/api/controller/KopenApiController.java
@@ -43,7 +43,6 @@
         return kopenApiService.receiveOrders(params);
     }
 
-
     /**
      * 涓婃父涓嬪彂闆朵欢鏁版嵁鍙樻洿
      * s
diff --git a/src/main/java/com/zy/api/service/impl/KopenApiServiceImpl.java b/src/main/java/com/zy/api/service/impl/KopenApiServiceImpl.java
index b94b1fe..640c170 100644
--- a/src/main/java/com/zy/api/service/impl/KopenApiServiceImpl.java
+++ b/src/main/java/com/zy/api/service/impl/KopenApiServiceImpl.java
@@ -2,7 +2,6 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.core.common.DateUtils;
 import com.core.common.R;
 import com.core.exception.CoolException;
 import com.zy.api.entity.OrderParams;
@@ -10,7 +9,6 @@
 import com.zy.api.entity.ReportOrderParam;
 import com.zy.api.entity.SyncMatParmas;
 import com.zy.api.enums.MatLocType;
-import com.zy.api.enums.MatType;
 import com.zy.api.enums.OrderType;
 import com.zy.api.enums.OrderWkType;
 import com.zy.api.service.KopenApiService;
@@ -62,6 +60,7 @@
 
     /**
      * 涓婃灦娲惧伐鍗曞弽棣�
+     * 
      * @author Ryan
      * @date 2025/11/24 15:33
      */
@@ -95,14 +94,15 @@
         }
     }
 
-     /* */
-     /**
-      * 澶囪揣鎸囩ず娲惧伐鍗曚笅鍙�
-      * @author Ryan
-      * @date 2025/11/24 15:21
-      * @param params
-      * @return com.core.common.R
-      */
+    /* */
+    /**
+     * 澶囪揣鎸囩ず娲惧伐鍗曚笅鍙�
+     * 
+     * @author Ryan
+     * @date 2025/11/24 15:21
+     * @param params
+     * @return com.core.common.R
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R sendOutDispatch(PubOrderParams params) {
@@ -121,12 +121,13 @@
         }
 
         addOrUpdateOrders(params, "add");
-        
+
         return R.ok("澶囪揣鎸囩ず娲惧伐鍗曚笅鍙戞垚鍔燂紒锛�");
     }
 
     /**
      * 澶囪揣鎸囩ず娲惧伐鍗�
+     * 
      * @author Ryan
      * @date 2025/12/16 9:15
      * @param params
@@ -153,7 +154,8 @@
             // 鍒犻櫎鏃ц鍗曟槑缁�
             if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId()))) {
                 throw new CoolException("璁㈠崟鏄庣粏鍒犻櫎澶辫触锛侊紒");
-            };
+            }
+            ;
             if (!orderService.deleteById(order.getId())) {
                 throw new CoolException("鍘熷崟鎹垹闄ゅけ璐ワ紒锛�");
             }
@@ -231,7 +233,14 @@
             throw new CoolException("璁㈠崟绫诲瀷涓嶈兘涓虹┖锛侊紒");
         }
         OrderParams orderParams = JSONObject.parseObject(JSONObject.toJSONString(params), OrderParams.class);
-        Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderParams.getInv_no()));
+        Order order = new Order();
+        if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) {
+            // 鍏ュ簱
+          order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderParams.getInv_no()));
+        } else if (OrderType.ORDER_OUT.type.equals(OrderWkType.getTypeVal(params.getType()))) {
+            // 鍑哄簱
+           order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderParams.getDispatch_no()));
+        }
         if (type.equals("add") && !Objects.isNull(order)) {
             throw new CoolException("鍗曟嵁宸插瓨鍦�, 涓嶅彲閲嶅娣诲姞锛侊紒");
         }
@@ -256,10 +265,10 @@
     public static String generateUUID(OrderParams params) {
         return java.util.UUID.randomUUID().toString();
     }
-    
 
     /**
      * 鐢熸垚璁㈠崟淇℃伅
+     * 
      * @param params
      */
     @Transactional(rollbackFor = Exception.class)
@@ -321,7 +330,7 @@
                 orderItem.setBrand(matnr.getBrand());
                 orderItem.setBatch(1 + "");
                 orderItem.setStandby1(item.getPro_id());
-                //鍏宠仈涓婂姞娲惧伐鍗曞彿+闆朵欢浠g爜+渚涘簲鍟嗕唬鐮�
+                // 鍏宠仈涓婂姞娲惧伐鍗曞彿+闆朵欢浠g爜+渚涘簲鍟嗕唬鐮�
                 orderItem.setThreeCode(item.getTotal_serial());
                 // 渚涘簲鍟嗕唬鐮�
                 orderItem.setSuppCode(item.getPro_id());
diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 2eb3bf8..b938865 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -599,6 +599,12 @@
         if (Objects.isNull(param.getBarcode())) {
             throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
         }
+
+        BasContainer container = basContainerService
+                .selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
+        if (Objects.isNull(container)) {
+            throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
+        }
         // if (param.getBarcode().length() != 8) {
         // throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
         // }
@@ -1604,6 +1610,7 @@
         if (Objects.isNull(param.getBarcode())) {
             throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
         }
+
         if (Objects.isNull(param.getCombMats()) || param.getCombMats().isEmpty()) {
             throw new CoolException("缁勬墭鏄庣粏涓嶈兘涓虹┖锛侊紒");
         }
diff --git a/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java b/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
index 15d054a..1f8e762 100644
--- a/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -4,6 +4,7 @@
 import com.core.common.Cools;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
+import com.zy.asrs.enums.LocAreaType;
 import com.zy.asrs.enums.LocStsType;
 import com.zy.asrs.service.*;
 import com.zy.asrs.service.impl.*;
@@ -60,6 +61,8 @@
     private WaitPakinLogService waitPakinLogService;
     @Autowired
     private BasStationDetlService basStationDetlService;
+    @Autowired
+    private BasAreasService basAreasService;
 
     public ReturnT<String> start(WrkMast wrkMast) {
         // 4.鍏ュ簱瀹屾垚
@@ -75,6 +78,12 @@
     public ReturnT<String> doIn(WrkMast wrkMast) {
         Date now = new Date();
         LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
+        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_CRN.type));
+        if (Objects.isNull(basAreas)) {
+            throw new CoolException("鏁版嵁閿欒锛氬簱鍖轰笉瀛樺湪锛侊紒");
+        }
+        locMast.setAreaId(basAreas.getId());
+        locMast.setAreaName(basAreas.getName());
         try {
             if (null == locMast) {
                 // exceptionHandle("宸ヤ綔妗workNo={0}]搴撲綅鍙烽敊璇痆locNo={1}]", wrkMast.getWrkNo(),
@@ -122,7 +131,6 @@
                     }
                     // 閬嶅巻宸ヤ綔鏄庣粏锛屾洿鏂板簱瀛樻槑缁嗗拰鍏ュ簱閫氱煡妗�
                     for (WrkDetl wrkDetl : wrkDetls) {
-
                         LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl.getMatnr(),
                                 wrkDetl.getBatch(), wrkDetl.getBrand(), wrkDetl.getStandby1(), wrkDetl.getStandby2(),
                                 wrkDetl.getStandby3(), wrkDetl.getBoxType1(), wrkDetl.getBoxType2(),
@@ -233,6 +241,8 @@
                             locDetl.sync(wrkDetl);
                             locDetl.setLocNo(wrkMast.getLocNo()); // 搴撲綅鍙�
                             locDetl.setAnfme(wrkDetl.getAnfme()); // 鏁伴噺
+                            locDetl.setAreaId(locMast.getAreaId());
+                            locMast.setAreaName(locMast.getAreaName());
                             locDetl.setZpallet(wrkDetl.getZpallet()); // 鎵樼洏鏉$爜
                             locDetl.setModiTime(now);
                             locDetl.setAppeTime(now);
@@ -366,6 +376,8 @@
                             locDetl.sync(wrkDetl);
                             locDetl.setLocNo(wrkMast.getLocNo()); // 搴撲綅鍙�
                             locDetl.setAnfme(wrkDetl.getAnfme()); // 鏁伴噺
+                            locDetl.setAreaId(locMast.getAreaId());
+                            locMast.setAreaName(locMast.getAreaName());
                             locDetl.setZpallet(wrkDetl.getZpallet()); // 鎵樼洏鏉$爜
                             locDetl.setModiTime(now);
                             locDetl.setAppeTime(now);
diff --git a/src/main/resources/mapper/LocDetlMapper.xml b/src/main/resources/mapper/LocDetlMapper.xml
index f8ecfc8..9309423 100644
--- a/src/main/resources/mapper/LocDetlMapper.xml
+++ b/src/main/resources/mapper/LocDetlMapper.xml
@@ -120,22 +120,22 @@
         </choose>
     </sql>
     <sql id="batchSeqA">
-        <choose>
-            <when test="batch != null and batch != ''">
-                and a.batch = #{batch}
-            </when>
-            <otherwise>
-                and (a.batch IS NULL OR a.batch = '')
-            </otherwise>
-        </choose>
-        <choose>
-            <when test="brand != null and brand != ''">
-                and a.brand = #{brand}
-            </when>
-            <otherwise>
-                and (a.brand IS NULL OR a.brand = '')
-            </otherwise>
-        </choose>
+<!--        <choose>-->
+<!--            <when test="batch != null and batch != ''">-->
+<!--                and a.batch = #{batch}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and (a.batch IS NULL OR a.batch = '')-->
+<!--            </otherwise>-->
+<!--        </choose>-->
+<!--        <choose>-->
+<!--            <when test="brand != null and brand != ''">-->
+<!--                and a.brand = #{brand}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and (a.brand IS NULL OR a.brand = '')-->
+<!--            </otherwise>-->
+<!--        </choose>-->
         <choose>
             <when test="standby1 != null and standby1 != ''">
                 and a.standby1 = #{standby1}
@@ -144,46 +144,46 @@
                 and (a.standby1 IS NULL OR a.standby1 = '')
             </otherwise>
         </choose>
-        <choose>
-            <when test="standby2 != null and standby2 != ''">
-                and a.standby2 = #{standby2}
-            </when>
-            <otherwise>
-                and (a.standby2 IS NULL OR a.standby2 = '')
-            </otherwise>
-        </choose>
-        <choose>
-            <when test="standby3 != null and standby3 != ''">
-                and a.standby3 = #{standby3}
-            </when>
-            <otherwise>
-                and (a.standby3 IS NULL OR a.standby3 = '')
-            </otherwise>
-        </choose>
-        <choose>
-            <when test="boxType1 != null and boxType1 != ''">
-                and a.box_type1 = #{boxType1}
-            </when>
-            <otherwise>
-                and (a.box_type1 IS NULL OR a.box_type1 = '')
-            </otherwise>
-        </choose>
-        <choose>
-            <when test="boxType2 != null and boxType2 != ''">
-                and a.box_type2 = #{boxType2}
-            </when>
-            <otherwise>
-                and (a.box_type2 IS NULL OR a.box_type2 = '')
-            </otherwise>
-        </choose>
-        <choose>
-            <when test="boxType3 != null and boxType3 != ''">
-                and a.box_type3 = #{boxType3}
-            </when>
-            <otherwise>
-                and (a.box_type3 IS NULL OR a.box_type3 = '')
-            </otherwise>
-        </choose>
+<!--        <choose>-->
+<!--            <when test="standby2 != null and standby2 != ''">-->
+<!--                and a.standby2 = #{standby2}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and (a.standby2 IS NULL OR a.standby2 = '')-->
+<!--            </otherwise>-->
+<!--        </choose>-->
+<!--        <choose>-->
+<!--            <when test="standby3 != null and standby3 != ''">-->
+<!--                and a.standby3 = #{standby3}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and (a.standby3 IS NULL OR a.standby3 = '')-->
+<!--            </otherwise>-->
+<!--        </choose>-->
+<!--        <choose>-->
+<!--            <when test="boxType1 != null and boxType1 != ''">-->
+<!--                and a.box_type1 = #{boxType1}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and (a.box_type1 IS NULL OR a.box_type1 = '')-->
+<!--            </otherwise>-->
+<!--        </choose>-->
+<!--        <choose>-->
+<!--            <when test="boxType2 != null and boxType2 != ''">-->
+<!--                and a.box_type2 = #{boxType2}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and (a.box_type2 IS NULL OR a.box_type2 = '')-->
+<!--            </otherwise>-->
+<!--        </choose>-->
+<!--        <choose>-->
+<!--            <when test="boxType3 != null and boxType3 != ''">-->
+<!--                and a.box_type3 = #{boxType3}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and (a.box_type3 IS NULL OR a.box_type3 = '')-->
+<!--            </otherwise>-->
+<!--        </choose>-->
     </sql>
     <sql id="batchSeqNew">
         <choose>

--
Gitblit v1.9.1