From 90aea4830974e3687222aa266952923d59aa088f Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期五, 19 十二月 2025 17:19:52 +0800
Subject: [PATCH] bug修复

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |   79 ++++++++++++++++++++++-----------------
 1 files changed, 44 insertions(+), 35 deletions(-)

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 582a0ea..c3db773 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1741,7 +1741,7 @@
                     throw new CoolException("鏁版嵁閿欒锛岀珯鐐逛笉瀛樺湪锛侊紒");
                 }
                 station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
-                station.setBarcode(null);
+                station.setBarcode("");
                 if (!basStationService.updateById(station)) {
                     throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
                 }
@@ -1786,7 +1786,7 @@
         }
 
         station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
-        station.setBarcode(null);
+        station.setBarcode("");
         if (!basStationService.updateById(station)) {
             throw new CoolException("绔欑偣鐘舵�佷慨鏀瑰け璐�!");
         }
@@ -2381,11 +2381,6 @@
      */
     @Transactional(rollbackFor = Exception.class)
     public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
-        List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
-        if (Objects.isNull(pakins) || pakins.isEmpty()) {
-            throw new CoolException("缁勬墭淇℃伅涓嶅瓨鍦紒锛�");
-        }
-
         List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode));
         if (!tasks.isEmpty()) {
             throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
@@ -2416,32 +2411,39 @@
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
 
-        for (WaitPakin pakin : pakins) {
-            TaskDetl wrkDetl = new TaskDetl();
-            BeanUtils.copyProperties(pakin, wrkDetl);
-            wrkDetl.setId(null).setWrkNo(workNo)
-                    .setIoTime(new Date())
-                    .setOrderNo(pakin.getOrderNo())
-                    .setAnfme(pakin.getAnfme())
-                    .setZpallet(pakin.getZpallet())
-                    .setBatch(pakin.getBatch())
-                    .setMatnr(pakin.getMatnr())
-                    .setMaktx(pakin.getMaktx())
-                    .setAppeUser(userId)
-                    .setUnit(pakin.getUnit())
-                    .setModel(pakin.getModel())
-                    .setAppeTime(new Date())
-                    .setModiUser(userId);
-            if (!taskDetlService.insert(wrkDetl)) {
-                throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+        if (!type.equals("agv_back")) {
+            List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+            if (Objects.isNull(pakins) || pakins.isEmpty()) {
+                throw new CoolException("缁勬墭淇℃伅涓嶅瓨鍦紒锛�");
             }
 
-        }
+            for (WaitPakin pakin : pakins) {
+                TaskDetl wrkDetl = new TaskDetl();
+                BeanUtils.copyProperties(pakin, wrkDetl);
+                wrkDetl.setId(null).setWrkNo(workNo)
+                        .setIoTime(new Date())
+                        .setOrderNo(pakin.getOrderNo())
+                        .setAnfme(pakin.getAnfme())
+                        .setZpallet(pakin.getZpallet())
+                        .setBatch(pakin.getBatch())
+                        .setMatnr(pakin.getMatnr())
+                        .setMaktx(pakin.getMaktx())
+                        .setAppeUser(userId)
+                        .setUnit(pakin.getUnit())
+                        .setModel(pakin.getModel())
+                        .setAppeTime(new Date())
+                        .setModiUser(userId);
+                if (!taskDetlService.insert(wrkDetl)) {
+                    throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+                }
 
-        for (WaitPakin pakin : pakins) {
-            pakin.setIoStatus("Y");
-            if (!waitPakinService.updateById(pakin)) {
-                throw new CoolException("鏇存柊缁勬墭淇℃伅澶辫触");
+            }
+
+            for (WaitPakin pakin : pakins) {
+                pakin.setIoStatus("Y");
+                if (!waitPakinService.updateById(pakin)) {
+                    throw new CoolException("鏇存柊缁勬墭淇℃伅澶辫触");
+                }
             }
         }
 
@@ -2463,9 +2465,9 @@
             throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
         }
 
-        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type) || station.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) {
             station.setLocSts("R"); // S.鍏ュ簱棰勭害
-//            station.setBarcode(barcode);
+            station.setBarcode(barcode);
             station.setModiTime(new Date());
             station.setModiUser(userId);
             if (!basStationService.updateById(station)) {
@@ -2531,7 +2533,7 @@
     }
 
     /**
-     * 鍛煎彨AGV杩斿洖
+     * 鍛煎彨AGV绌哄彴杞﹁繑鍥�
      * @author Ryan
      * @date 2025/9/24
      * @param callAgvBackParam
@@ -2550,9 +2552,16 @@
         if (Objects.isNull(locCache)) {
             return R.error("鏈煡璇㈠埌鍙敤搴撲綅");
         }
-        
+
+        // 淇敼鐩爣绔欑偣淇℃伅
+        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", callAgvBackParam.getOrgSite()));
+        if (Objects.isNull(station)) {
+            throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
+        }
+
         try {
-            generateAgvTask("agv", locCache, callAgvBackParam.getOrgSite(), callAgvBackParam.getBarcode(), userId);
+            //绌哄彴杞﹀洖搴�
+            generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId);
         } catch (Exception e) {
             e.printStackTrace();
             return R.error(e.getMessage());

--
Gitblit v1.9.1