From 42ce1f4b6f9df984d14e29f9d9ff188de7f3c6d7 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 07 五月 2026 09:45:33 +0800
Subject: [PATCH] #地图更新
---
src/main/java/com/zy/core/plugin/GslProcess.java | 216 +-----------------------------------------------------
1 files changed, 4 insertions(+), 212 deletions(-)
diff --git a/src/main/java/com/zy/core/plugin/GslProcess.java b/src/main/java/com/zy/core/plugin/GslProcess.java
index 3ca41cc..a946e46 100644
--- a/src/main/java/com/zy/core/plugin/GslProcess.java
+++ b/src/main/java/com/zy/core/plugin/GslProcess.java
@@ -1,24 +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.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;
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;
@@ -46,23 +33,15 @@
@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() {
- //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞跺惎鍔ㄥ叆搴�
- checkInStationHasTask();
- //璇锋眰鐢熸垚鍏ュ簱浠诲姟锛屼繚鐣欐寜绔欑偣 lane 涓茶鎻愪氦
+ //鍚姩鍏ュ簱
+ stationOperateProcessUtils.submitStationEnableInTasks(DISPATCH_INTERVAL_MS);
+ //璇锋眰鐢熸垚鍏ュ簱浠诲姟
generateStoreWrkFile();
// 鎵ц鍫嗗灈鏈轰换鍔�
@@ -81,12 +60,8 @@
stationOperateProcessUtils.submitCheckTaskToCompleteTasks(DISPATCH_INTERVAL_MS);
// 妫�娴嬪苟澶勭悊鍑哄簱鎺掑簭
stationOperateProcessUtils.submitCheckStationOutOrderTasks(MAINTENANCE_INTERVAL_MS);
-// // 鐩戞帶杈撻�佺嚎缁曞湀绔欑偣
-// stationOperateProcessUtils.submitWatchCircleStationTasks(MAINTENANCE_INTERVAL_MS);
// 妫�娴嬭緭閫佺嚎杩愯鍫靛
stationOperateProcessUtils.submitCheckStationRunBlockTasks(MAINTENANCE_INTERVAL_MS);
-// // 妫�娴嬬珯鍙扮┖闂茶秴鏃跺悗鐨勬仮澶嶅鐞�
-// stationOperateProcessUtils.submitCheckStationIdleRecoverTasks(MAINTENANCE_INTERVAL_MS);
}
@Override
@@ -94,74 +69,6 @@
InTaskApplyRequest request = StoreInTaskPolicy.super.buildApplyRequest(context);
request.getExtraParams().put("weight", context.getStationProtocol().getWeight());
return request;
- }
-
- //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞跺惎鍔ㄥ叆搴�
- 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;
- }
-
- //婊¤冻鑷姩銆佹棤鐗┿�佸伐浣滃彿0锛岀敓鎴愬叆搴撴暟鎹�
- if (stationProtocol.isAutoing()
- && stationProtocol.isLoading()
- && stationProtocol.getTaskNo() == 0
- && stationProtocol.isEnableIn()
- ) {
- 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());
- }
- redisUtil.set(RedisKeyType.GENERATE_ENABLE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 15);
- News.info("{}绔欑偣鍚姩鍏ュ簱鎴愬姛锛屾暟鎹寘:{}", stationId, JSON.toJSONString(command));
- }
- }
- }
}
private void generateStoreWrkFile() {
@@ -180,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;
}
@@ -227,82 +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;
- }
-
- String lockKey = RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId();
- Object lock = redisUtil.get(lockKey);
- 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(lockKey, "lock", 60 * 60);
- return false;
}
}
--
Gitblit v1.9.1