From dc3f9cc91759823ce59486f19b138be4b296a0f1 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 28 四月 2026 09:43:28 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/plugin/XiaosongProcess.java |  116 ---------------------------------------------------------
 1 files changed, 1 insertions(+), 115 deletions(-)

diff --git a/src/main/java/com/zy/core/plugin/XiaosongProcess.java b/src/main/java/com/zy/core/plugin/XiaosongProcess.java
index e01aeb4..74a2eee 100644
--- a/src/main/java/com/zy/core/plugin/XiaosongProcess.java
+++ b/src/main/java/com/zy/core/plugin/XiaosongProcess.java
@@ -1,22 +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.utils.Utils;
 import com.zy.asrs.entity.BasDevp;
 import com.zy.asrs.service.BasDevpService;
-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.StoreInTaskGenerationService;
@@ -42,22 +31,16 @@
     @Autowired
     private StationOperateProcessUtils stationOperateProcessUtils;
     @Autowired
-    private CommonService commonService;
-    @Autowired
     private BasDevpService basDevpService;
-    @Autowired
-    private RedisUtil redisUtil;
     @Autowired
     private DualCrnOperateProcessUtils dualCrnOperateProcessUtils;
     @Autowired
     private StoreInTaskGenerationService storeInTaskGenerationService;
-    @Autowired
-    private StationCommandDispatcher stationCommandDispatcher;
 
     @Override
     public void run() {
         //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞跺惎鍔ㄥ叆搴�
-        checkInStationHasTask();
+        stationOperateProcessUtils.submitStationEnableInTasks(DISPATCH_INTERVAL_MS);
         //璇锋眰鐢熸垚鍏ュ簱浠诲姟
         generateStoreWrkFile();
 
@@ -108,107 +91,10 @@
                     continue;
                 }
 
-                StationProtocol stationProtocol = stationMap.get(stationId);
-                if (!canSubmitGenerateStoreTask(basDevp, stationThread, stationObjModel, stationProtocol)) {
-                    continue;
-                }
-
                 storeInTaskGenerationService.submitGenerateStoreTask(this, basDevp, stationObjModel, 0L,
                         () -> storeInTaskGenerationService.generate(this, basDevp, stationObjModel));
             }
         }
-    }
-
-    //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞跺惎鍔ㄥ叆搴�
-    private synchronized void checkInStationHasTask() {
-        List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<>());
-        for (BasDevp basDevp : basDevps) {
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if(stationThread == null){
-                continue;
-            }
-
-            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
-
-            List<StationObjModel> list = basDevp.getInStationList$();
-            for (StationObjModel entity : list) {
-                Integer stationId = entity.getStationId();
-                if(!stationMap.containsKey(stationId)){
-                    continue;
-                }
-
-                StationProtocol stationProtocol = stationMap.get(stationId);
-                if (stationProtocol == null) {
-                    continue;
-                }
-
-                Object lock = redisUtil.get(RedisKeyType.GENERATE_ENABLE_IN_STATION_DATA_LIMIT.key + stationId);
-                if(lock != null){
-                    continue;
-                }
-
-                if (stationProtocol.isAutoing()
-                        && stationProtocol.isLoading()
-                        && stationProtocol.getTaskNo() == 0
-                        && stationProtocol.isEnableIn()
-                ) {
-                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, commonService.getWorkNo(WrkIoType.ENABLE_IN.id), stationId, entity.getBarcodeStation().getStationId(), 0);
-                    stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "xiaosong-process", "enable-in");
-                    if (entity.getBarcodeStation() != null && entity.getBarcodeStation().getStationId() != null) {
-                        Utils.precomputeInTaskEnableRow(entity.getBarcodeStation().getStationId());
-                    }
-                    redisUtil.set(RedisKeyType.GENERATE_ENABLE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 15);
-                    News.info("{}绔欑偣鍚姩鍏ュ簱鎴愬姛锛屾暟鎹寘:{}", stationId, JSON.toJSONString(command));
-                }
-            }
-        }
-    }
-
-    private boolean canSubmitGenerateStoreTask(BasDevp basDevp,
-                                               StationThread stationThread,
-                                               StationObjModel stationObjModel,
-                                               StationProtocol stationProtocol) {
-        if (!handleErrorStationBack(basDevp, stationThread, stationObjModel, stationProtocol)) {
-            return false;
-        }
-        return canRequestStoreIn(stationProtocol);
-    }
-
-    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,
-                                           StationThread stationThread,
-                                           StationObjModel stationObjModel,
-                                           StationProtocol stationProtocol) {
-        if (stationProtocol.getError() <= 0) {
-            return true;
-        }
-
-        Object lock = redisUtil.get(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getTaskNo());
-        if (lock != null) {
-            return false;
-        }
-        StationObjModel backStation = stationObjModel.getBackStation();
-        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, "xiaosong-process", "station-back");
-        News.taskInfo(stationProtocol.getTaskNo(), "{}鎵爜寮傚父锛屽凡閫�鍥炶嚦{}", backStation.getStationId());
-        redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getTaskNo(), "lock", 10);
-        return false;
     }
 
 }

--
Gitblit v1.9.1