From 73a8fcbaaec22b972c7f52d9477271a246d17926 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 27 四月 2026 10:57:41 +0800
Subject: [PATCH] feat: add guarded auto tune apply and rollback service

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

diff --git a/src/main/java/com/zy/core/plugin/GslProcess.java b/src/main/java/com/zy/core/plugin/GslProcess.java
index f8cf213..6d9edb7 100644
--- a/src/main/java/com/zy/core/plugin/GslProcess.java
+++ b/src/main/java/com/zy/core/plugin/GslProcess.java
@@ -1,23 +1,11 @@
 package com.zy.core.plugin;
 
-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.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;
 import com.zy.core.cache.SlaveConnection;
-import com.zy.core.dispatch.StationCommandDispatcher;
-import com.zy.core.enums.RedisKeyType;
 import com.zy.core.enums.SlaveType;
-import com.zy.core.enums.StationCommandType;
-import com.zy.core.enums.WrkIoType;
 import com.zy.core.model.StationObjModel;
-import com.zy.core.model.command.StationCommand;
 import com.zy.core.model.protocol.StationProtocol;
 import com.zy.core.plugin.api.MainProcessPluginApi;
 import com.zy.core.plugin.store.InTaskApplyRequest;
@@ -45,17 +33,9 @@
     @Autowired
     private StationOperateProcessUtils stationOperateProcessUtils;
     @Autowired
-    private CommonService commonService;
-    @Autowired
     private BasDevpService basDevpService;
     @Autowired
-    private RedisUtil redisUtil;
-    @Autowired
-    private WrkLastnoService wrkLastnoService;
-    @Autowired
     private StoreInTaskGenerationService storeInTaskGenerationService;
-    @Autowired
-    private StationCommandDispatcher stationCommandDispatcher;
 
     @Override
     public void run() {
@@ -107,46 +87,7 @@
             List<StationObjModel> barcodeStations = getBarcodeStations(basDevp);
             for (StationObjModel stationObjModel : barcodeStations) {
                 Integer stationId = stationObjModel == null ? null : stationObjModel.getStationId();
-                if (stationId == null) {
-                    continue;
-                }
-                if (!stationMap.containsKey(stationId)) {
-                    continue;
-                }
-                if (!handleErrorStationBack(basDevp, stationThread, stationObjModel, stationMap.get(stationId))) {
-                    continue;
-                }
-
-                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()) {
+                if (stationId == null || !stationMap.containsKey(stationId)) {
                     continue;
                 }
 
@@ -154,81 +95,6 @@
                         () -> storeInTaskGenerationService.generate(this, basDevp, stationObjModel));
             }
         }
-    }
-
-    private boolean handleErrorStationBack(BasDevp basDevp,
-                                           StationThread stationThread,
-                                           StationObjModel stationObjModel,
-                                           StationProtocol stationProtocol) {
-        if (stationProtocol == null) {
-            return false;
-        }
-
-        if (!stationProtocol.isAutoing()) {
-            return false;
-        }
-
-        if (!stationProtocol.isLoading()) {
-            return false;
-        }
-
-        if (stationProtocol.getError() <= 0) {
-            return true;//绔欑偣鏃犳晠闅�
-        }
-
-        if (!stationProtocol.isInBarcodeError()) {
-            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={}",
-                    basDevp == null ? null : basDevp.getDevpNo(),
-                    stationProtocol.getStationId());
-            return false;
-        }
-
-        // 褰撳墠绔欑偣宸茬粡鎸傜潃閫�鍥炵洰鏍囨椂锛屼笉鍐嶉噸澶嶇敓鎴愭柊鐨勯��鍥炲伐浣滃彿銆�
-        if (stationProtocol.getTaskNo() != null
-                && stationProtocol.getTaskNo() > 0
-                && backStation.getStationId().equals(stationProtocol.getTargetStaNo())) {
-            return false;
-        }
-
-        Object lock = redisUtil.get(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId());
-        if (lock != null) {
-            return false;
-        }
-
-        StationCommand command = stationThread.getCommand(StationCommandType.MOVE,
-                commonService.getWorkNo(WrkIoType.STATION_BACK.id),
-                stationObjModel.getStationId(),
-                backStation.getStationId(), 0);
-        if (command == null) {
-            News.taskInfo(stationProtocol.getTaskNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", stationProtocol.getTaskNo());
-            return false;
-        }
-        stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "gsl-process", "station-back");
-        News.info("{}鎵爜绔欏紓甯革紝宸查��鍥炶嚦{},鏉$爜绔欑姸鎬侊細{}", stationProtocol.getTaskNo(), backStation.getStationId(), JSON.toJSONString(stationProtocol));
-        redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(), "lock", 60 * 60);
-        return false;
     }
 
 }

--
Gitblit v1.9.1