From 58137d4f560dc16900ea99e0a7a07080b7751e5f Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期一, 20 十一月 2023 20:17:47 +0800
Subject: [PATCH] Merge branch 'tzskasrs' of http://47.97.1.152:5880/r/zy-asrs into tzskasrs

---
 src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java |   94 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 64 insertions(+), 30 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java b/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java
index ef79460..b22bdd1 100644
--- a/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/AgvWrkMastHandler.java
@@ -3,15 +3,15 @@
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
-import com.zy.asrs.entity.AgvLocDetl;
-import com.zy.asrs.entity.AgvWaitPakin;
-import com.zy.asrs.entity.AgvWrkDetl;
-import com.zy.asrs.entity.AgvWrkMast;
+import com.core.exception.CoolException;
+import com.zy.asrs.entity.*;
 import com.zy.asrs.service.*;
 import com.zy.asrs.task.AbstractHandler;
 import com.zy.asrs.task.core.ReturnT;
+import lombok.Synchronized;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -23,24 +23,29 @@
 @Service
 public class AgvWrkMastHandler extends AbstractHandler<String> {
 
+    @Value("${agvBasDev.maxWorkNum}")
+    private int maxWrokNum;
+
     @Autowired
-    AgvWrkMastService agvWrkMastService;
+    private AgvWrkMastService agvWrkMastService;
     @Autowired
-    AgvLocMastService agvLocMastService;
+    private AgvLocMastService agvLocMastService;
     @Autowired
-    AgvLocDetlService agvLocDetlService;
+    private AgvLocDetlService agvLocDetlService;
     @Autowired
-    AgvWrkMastLogService agvWrkMastLogService;
+    private AgvWrkMastLogService agvWrkMastLogService;
     @Autowired
-    AgvWrkDetlService agvWrkDetlService;
+    private AgvWrkDetlService agvWrkDetlService;
     @Autowired
-    AgvWrkDetlLogService agvWrkDetlLogService;
+    private AgvWrkDetlLogService agvWrkDetlLogService;
     @Autowired
-    AgvWaitPakinService agvWaitPakinService;
+    private AgvWaitPakinService agvWaitPakinService;
     @Autowired
-    AgvWaitPakinLogService agvWaitPakinLogService;
+    private AgvWaitPakinLogService agvWaitPakinLogService;
     @Autowired
-    OrderService orderService;
+    private OrderService orderService;
+    @Autowired
+    private AgvBasDevpService agvBasDevpService;
 
     @Transactional
     public ReturnT<String> completedPutWayWrk(AgvWrkMast agvWrkMast) {
@@ -53,10 +58,10 @@
         agvWrkMastService.updateById(agvWrkMast);
         if(agvWrkMast.getIoType() == 10){
             // 绌烘澘鍏ュ簱 璁剧疆搴撲綅鐘舵�佷负D.绌烘《/绌烘爤鏉�
-            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D");
+            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D",agvWrkMast.getBarcode());
         }else{
             //淇敼鐩爣搴撲綅鐘舵�佷负F.鍦ㄥ簱
-            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"F");
+            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"F",agvWrkMast.getBarcode());
         }
         //鐢熸垚AGV宸ヤ綔鍘嗗彶妗�
         agvWrkMastLogService.save(agvWrkMast);
@@ -78,8 +83,14 @@
             //鏇存柊搴撳瓨鏄庣粏
             agvLocDetlService.updateStock(agvWrkMast.getSourceLocNo(),agvWrkMast.getLocNo());
             //淇敼婧愬簱浣嶇姸鎬佷负O
-            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O");
+            agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","");
         }
+
+        //鍒犻櫎AGV宸ヤ綔妗�
+        agvWrkMastService.deleteById(wrkNo);
+        //鍒犻櫎AGV宸ヤ綔鏄庣粏妗�
+        agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",wrkNo));
+
         if(!isJSON(orderNo)){
             //妫�鏌ヨ鍗曟槸鍚﹀凡瀹屾垚
             orderService.checkComplete(orderNo);
@@ -90,11 +101,6 @@
                 orderService.checkComplete(o);
             });
         }
-
-        //鍒犻櫎AGV宸ヤ綔妗�
-        agvWrkMastService.deleteById(wrkNo);
-        //鍒犻櫎AGV宸ヤ綔鏄庣粏妗�
-        agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",wrkNo));
 
         return SUCCESS;
     }
@@ -108,7 +114,7 @@
         agvWrkMast.setWrkSts(207L);
         agvWrkMastService.updateById(agvWrkMast);
         //淇敼婧愬簱浣嶇姸鎬佷负O
-        agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O");
+        agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","");
         if(agvWrkMast.getIoType() == 101){
             //鏇存柊鐩爣搴撲綅鏄庣粏 101.鍑哄簱 鍒犻櫎婧愬簱浣嶅簱瀛樻槑缁�
             agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",agvWrkMast.getSourceLocNo()));
@@ -138,12 +144,25 @@
     @Transactional
     public ReturnT<String> startPutWayWrk(List<AgvWrkMast> agvWrkMastList) throws IOException {
 
-        int startWwrkCode = agvWrkMastService.startWrk(agvWrkMastList,"putaway");
+        //涓嬪彂浠诲姟
+        int startWrkCode = agvWrkMastService.startWrk(agvWrkMastList,"putaway");
+        if(startWrkCode != 0){
+            throw new CoolException("浠诲姟涓嬪彂澶辫触");
+        }
 
-        int code = agvWrkMastService.containerMove(agvWrkMastList);
+        //涓嬪彂瀹瑰櫒鍏ュ満鎸囦护 锛堢紦瀛樿揣鏋讹級
+        int code = agvWrkMastService.containerMoveIn(agvWrkMastList);
 
         if(code == 0){
-            agvWrkMastList.forEach(agvWrkMast -> {
+            for(AgvWrkMast agvWrkMast : agvWrkMastList){
+                //涓嬪彂瀹瑰櫒杈惧埌閫氱煡 锛堣緭閫佺嚎锛�
+                if("Y".equals(agvWrkMast.getMk())){
+                    int containerArrivedCode = agvWrkMastService.containerArrived(agvWrkMast);
+                    if(containerArrivedCode != 0){
+                        log.error("瀹瑰櫒鍒拌揪鎸囦护涓嬪彂澶辫触");
+                        continue;
+                    }
+                }
                 //202.RCS鍙栬揣涓�
                 agvWrkMast.setWrkSts(202L);
                 agvWrkMastService.updateById(agvWrkMast);
@@ -151,13 +170,9 @@
                     //淇敼AGV鍏ュ簱閫氱煡妗g姸鎬佸叆鍑虹姸鎬佷负Y
                     agvWaitPakinService.updateIoStatus(agvWrkMast.getWrkNo(),"Y");
                 }
-
-            });
-            //agvWrkMastService.updateBatchById(agvWrkMastList);
-
+            }
             return SUCCESS;
         }
-
         return FAIL;
     }
 
@@ -178,6 +193,25 @@
         return FAIL;
     }
 
+    @Synchronized
+    @Transactional
+    public ReturnT<String> dealWatiWrk(List<AgvWrkMast> agvWrkMastList) throws IOException {
+
+        agvWrkMastList.forEach(agvWrkMast -> {
+            //鏌ヨ璇ョ珯鐐规墍鏈夋殏瀛樹綅鍦ㄥ伐浣滄。涓嚭鐜扮殑娆℃暟
+            List<Map<String, Object>> devNoMaps = agvBasDevpService.selectDevNoAndNumBystationCode(agvWrkMast.getLocNo());
+            //鍙栫涓�涓殏瀛樹綅锛屽苟鏌ヨ鍏舵鏁颁笌閰嶇疆鐨勬鏁板仛姣旇緝
+            Map<String, Object> devNoMap = devNoMaps.get(0);
+            if((int)devNoMap.get("num") < maxWrokNum){
+                agvWrkMast.setLocNo(devNoMap.get("dev_no").toString());
+                agvWrkMastService.updateById(agvWrkMast);
+                log.info("after锛�" + devNoMap.toString()  +  ", wrkNo:" + agvWrkMast.getWrkNo() + ", locNo: " + agvWrkMast.getLocNo());
+            }
+        });
+
+        return SUCCESS;
+    }
+
     private String getOrderNoByWrkNo(int wrkNo){
         AgvWrkDetl agvWrkDetl = agvWrkDetlService.selectOne(new EntityWrapper<AgvWrkDetl>().eq("wrk_no", wrkNo));
         if(Cools.isEmpty(agvWrkDetl)){

--
Gitblit v1.9.1