From 37efb9725fcbcf921534d032ad2aa4ce2aaa7fde Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 11 四月 2026 10:23:28 +0800
Subject: [PATCH] #入库异常

---
 src/main/java/com/zy/core/plugin/GslProcess.java |   97 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 79 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/zy/core/plugin/GslProcess.java b/src/main/java/com/zy/core/plugin/GslProcess.java
index 0e16ea5..3ca41cc 100644
--- a/src/main/java/com/zy/core/plugin/GslProcess.java
+++ b/src/main/java/com/zy/core/plugin/GslProcess.java
@@ -3,9 +3,11 @@
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.core.common.Cools;
+import com.zy.asrs.entity.WrkLastno;
 import com.zy.asrs.utils.Utils;
 import com.zy.asrs.entity.BasDevp;
 import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.service.WrkLastnoService;
 import com.zy.common.service.CommonService;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
@@ -49,6 +51,8 @@
     private BasDevpService basDevpService;
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private WrkLastnoService wrkLastnoService;
     @Autowired
     private StoreInTaskGenerationService storeInTaskGenerationService;
     @Autowired
@@ -126,7 +130,29 @@
                         && stationProtocol.getTaskNo() == 0
                         && stationProtocol.isEnableIn()
                 ) {
-                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, commonService.getWorkNo(WrkIoType.ENABLE_IN.id), stationId, entity.getBarcodeStation().getStationId(), 0);
+                    if (stationProtocol.getIoMode() != 1) {
+                        continue;//涓嶅睘浜庡叆搴撴ā寮�
+                    }
+
+                    //鍚姩鍏ュ簱锛屽垹闄ゆ潯鐮佺珯閫�鍥為檺鍒�
+                    Integer backStationId = entity.getBarcodeStation().getStationId();
+                    String lockKey = RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + backStationId;
+                    if (redisUtil.hasKey(lockKey)) {
+                        StationProtocol backStationProtocol = stationMap.get(backStationId);
+                        if (backStationProtocol == null) {
+                            continue;
+                        }
+
+                        if (backStationProtocol.isAutoing()
+                                && !backStationProtocol.isLoading()
+                                && stationProtocol.getTaskNo() == 0
+                        ) {
+                            //鏉$爜绔欒嚜鍔ㄣ�佹棤鐗┿�佸伐浣滃彿0銆傚垹闄ゆ潯鐮佺珯閫�鍥為檺鍒�
+                            redisUtil.del(lockKey);
+                        }
+                    }
+
+                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, commonService.getWorkNo(WrkIoType.ENABLE_IN.id), stationId, backStationId, 0);
                     stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "gsl-process", "enable-in");
                     if (entity.getBarcodeStation() != null && entity.getBarcodeStation().getStationId() != null) {
                         Utils.precomputeInTaskEnableRow(entity.getBarcodeStation().getStationId());
@@ -163,23 +189,44 @@
                 if (!handleErrorStationBack(basDevp, stationThread, stationObjModel, stationMap.get(stationId))) {
                     continue;
                 }
-                if (!canRequestStoreIn(stationMap.get(stationId))) {
+
+                StationProtocol stationProtocol = stationMap.get(stationId);
+                if (stationProtocol == null) {
                     continue;
                 }
+
+                if (!stationProtocol.isAutoing()) {
+                    continue;
+                }
+
+                if (!stationProtocol.isLoading()) {
+                    continue;
+                }
+
+                if (!stationProtocol.isInEnable()) {
+                    continue;
+                }
+
+                if (stationProtocol.getTaskNo() == 0) {
+                    continue;
+                }
+
+                if (Cools.isEmpty(stationProtocol.getBarcode())) {
+                    continue;
+                }
+
+                if (stationProtocol.getError() > 0) {
+                    continue;
+                }
+
+                if (stationProtocol.isInBarcodeError()) {
+                    continue;
+                }
+
                 storeInTaskGenerationService.submitGenerateStoreTask(this, basDevp, stationObjModel, DISPATCH_INTERVAL_MS,
                         () -> storeInTaskGenerationService.generate(this, basDevp, stationObjModel));
             }
         }
-    }
-
-    private boolean canRequestStoreIn(StationProtocol stationProtocol) {
-        return stationProtocol != null
-                && stationProtocol.getError() <= 0
-                && stationProtocol.isAutoing()
-                && stationProtocol.isLoading()
-                && stationProtocol.isInEnable()
-                && stationProtocol.getTaskNo() > 0
-                && !Cools.isEmpty(stationProtocol.getBarcode());
     }
 
     private boolean handleErrorStationBack(BasDevp basDevp,
@@ -206,6 +253,23 @@
             return true;//绔欑偣鏃犲紓甯�
         }
 
+        WrkLastno stationBackTaskRange = wrkLastnoService.getById(WrkIoType.STATION_BACK.id);
+        Integer currentTaskNo = stationProtocol.getTaskNo();
+        if (currentTaskNo != null
+                && currentTaskNo > 0
+                && stationBackTaskRange != null
+                && stationBackTaskRange.getsNo() != null
+                && stationBackTaskRange.geteNo() != null
+                && currentTaskNo >= stationBackTaskRange.getsNo()
+                && currentTaskNo <= stationBackTaskRange.geteNo()) {
+            News.info("鏉$爜绔欏凡澶勪簬閫�鍥炲伐浣滃彿鑼冨洿锛岃烦杩囬噸澶嶇敓鎴愰��鍥炲懡浠ゃ�俿tationId={}锛宼askNo={}锛宺ange=[{}, {}]",
+                    stationProtocol.getStationId(),
+                    currentTaskNo,
+                    stationBackTaskRange.getsNo(),
+                    stationBackTaskRange.geteNo());
+            return false;
+        }
+
         StationObjModel backStation = stationObjModel.getBackStation();
         if (backStation == null || backStation.getStationId() == null) {
             News.warn("鏉$爜绔欓��鍥炲け璐ワ紝閫�鍥炵珯鏈厤缃�俤eviceNo={}锛宻tationId={}",
@@ -221,10 +285,7 @@
             return false;
         }
 
-        Integer lockTaskNo = stationProtocol.getTaskNo();
-        String lockKey = (lockTaskNo != null && lockTaskNo > 0)
-                ? RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + lockTaskNo
-                : RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + "station_" + stationProtocol.getStationId();
+        String lockKey = RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId();
         Object lock = redisUtil.get(lockKey);
         if (lock != null) {
             return false;
@@ -239,8 +300,8 @@
             return false;
         }
         stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "gsl-process", "station-back");
-        News.taskInfo(stationProtocol.getTaskNo(), "鎵爜寮傚父锛屽凡閫�鍥炶嚦{}", backStation.getStationId());
-        redisUtil.set(lockKey, "lock", 10);
+        News.info("{}鎵爜绔欏紓甯革紝宸查��鍥炶嚦{},鏉$爜绔欑姸鎬侊細{}", stationProtocol.getTaskNo(), backStation.getStationId(), JSON.toJSONString(stationProtocol));
+        redisUtil.set(lockKey, "lock", 60 * 60);
         return false;
     }
 

--
Gitblit v1.9.1