From 3e28500e76ffd71b7da90f40d1f3126c00a0e5f0 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 13 四月 2026 14:49:41 +0800
Subject: [PATCH] #站点运行优化
---
src/main/java/com/zy/core/plugin/store/StoreInTaskGenerationService.java | 142 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 138 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/zy/core/plugin/store/StoreInTaskGenerationService.java b/src/main/java/com/zy/core/plugin/store/StoreInTaskGenerationService.java
index fc921fa..0939a56 100644
--- a/src/main/java/com/zy/core/plugin/store/StoreInTaskGenerationService.java
+++ b/src/main/java/com/zy/core/plugin/store/StoreInTaskGenerationService.java
@@ -13,9 +13,14 @@
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
+import com.zy.core.dispatch.StationCommandDispatchResult;
+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.task.MainProcessLane;
import com.zy.core.task.MainProcessTaskSubmitter;
@@ -31,7 +36,9 @@
@Service
public class StoreInTaskGenerationService {
private static final int APPLY_IN_TASK_TIMEOUT_SECONDS = 5;
+ private static final int APPLY_FAIL_STATION_BACK_LOCK_SECONDS = 30;
+ @Autowired
private WrkMastService wrkMastService;
@Autowired
private StationOperateProcessUtils stationOperateProcessUtils;
@@ -43,6 +50,8 @@
private CommonService commonService;
@Autowired
private MainProcessTaskSubmitter mainProcessTaskSubmitter;
+ @Autowired
+ private StationCommandDispatcher stationCommandDispatcher;
/**
* 淇濈暀褰撳墠鎸夌珯鐐� lane 骞跺彂鐨勮兘鍔涳紝鍚屾椂鐢ㄤ竴涓畝鍗曡鏁伴伩鍏嶅苟鍙戠敓鎴愭妸绔欑偣浠诲姟鏁伴《绌夸笂闄愩��
@@ -101,9 +110,51 @@
return;
}
- long count = wrkMastService.count(new QueryWrapper<WrkMast>().eq("barcode", context.getStationProtocol().getBarcode()));
+ StationProtocol stationProtocol = context.getStationProtocol();
+ if (stationProtocol == null) {
+ return;
+ }
+
+ if (!stationProtocol.isAutoing()) {
+ return;
+ }
+
+ if (!stationProtocol.isLoading()) {
+ return;
+ }
+
+ if (!stationProtocol.isInEnable()) {
+ return;
+ }
+
+ if (stationProtocol.getTaskNo() == 0) {
+ return;
+ }
+
+ if (Cools.isEmpty(stationProtocol.getBarcode())) {
+ return;
+ }
+
+ if (stationProtocol.getError() > 0) {
+ return;
+ }
+
+ if (stationProtocol.isInBarcodeError()) {
+ return;
+ }
+
+ if (!stationProtocol.getIoMode().equals(1)) {
+ policy.setSystemWarning(context, "褰撳墠绔欑偣涓嶅浜庡叆搴撴ā寮�");
+ return;
+ }
+
+ String barcode = context.getStationProtocol().getBarcode();
+ long count = wrkMastService.count(new QueryWrapper<WrkMast>().eq("barcode", barcode));
if (count > 0) {
- policy.setSystemWarning(context, "绯荤粺浠诲姟宸插瓨鍦�");
+ Object tipsLimit = redisUtil.get(RedisKeyType.GENERATE_IN_TASK_SUCCESS_REPEAT_WARNING_TIPS_LIMIT.key + barcode);
+ if (tipsLimit == null) {
+ policy.setSystemWarning(context, "绯荤粺浠诲姟宸插瓨鍦�");
+ }
return;
}
@@ -176,6 +227,7 @@
WrkMast wrkMast = commonService.createInTask(taskParam);
policy.afterTaskCreated(context, wrkMast);
policy.clearSystemWarning(context);
+ redisUtil.set(RedisKeyType.GENERATE_IN_TASK_SUCCESS_REPEAT_WARNING_TIPS_LIMIT.key + wrkMast.getBarcode(), "lock", 30);
} catch (Exception e) {
News.error("澶勭悊WMS鍏ュ簱鍝嶅簲寮傚父锛宐arcode={}锛宻tationId={}", request.getBarcode(),
request.getSourceStaNo(), e);
@@ -190,10 +242,92 @@
result.setResponse(response);
result.setMessage(message);
- News.error("WMS鍏ュ簱璇锋眰澶辫触锛宐arcode={}锛宻tationId={}锛宺esponse={}",
- request.getBarcode(), request.getSourceStaNo(), policy.buildFailureMessage(result));
+ News.error("WMS鍏ュ簱璇锋眰澶辫触锛宐arcode={}锛宻tationId={}锛宺esponse={}锛學CS鍝嶅簲={}",
+ request.getBarcode(), request.getSourceStaNo(), result.getResponse(), result.getMessage());
redisUtil.set(policy.getGenerateLockKey(context), "lock", policy.getRetryLockSeconds(context));
policy.onApplyFailed(context, result);
+ triggerStationBackOnApplyFailed(context, request, result);
+ }
+
+ /**
+ * WMS 鐢宠鍏ュ簱澶辫触鍚庯紝璐х墿浠嶅仠鐣欏湪鎵爜绔欙紝姝ゆ椂琛ュ彂閫�鍥炲埌鍏ュ簱绔欑殑杈撻�佸懡浠わ紝閬垮厤璐х墿闀挎湡婊炵暀銆�
+ */
+ private void triggerStationBackOnApplyFailed(StoreInTaskContext context,
+ InTaskApplyRequest request,
+ InTaskApplyResult result) {
+ if (context == null || context.getStationThread() == null || context.getStationObjModel() == null) {
+ return;
+ }
+
+ StationProtocol stationProtocol = context.getStationProtocol();
+ if (stationProtocol == null || stationProtocol.getStationId() == null) {
+ return;
+ }
+
+ StationObjModel backStation = context.getStationObjModel().getBackStation();
+ if (backStation == null || backStation.getStationId() == null) {
+ News.warn("WMS鍏ュ簱澶辫触鍚庢棤娉曢��鍥炲叆搴撶珯锛岄��鍥炵珯鏈厤缃�俠arcode={}锛宻tationId={}",
+ request == null ? null : request.getBarcode(), stationProtocol.getStationId());
+ return;
+ }
+
+ Integer currentStationId = stationProtocol.getStationId();
+ Integer backStationId = backStation.getStationId();
+ if (backStationId.equals(currentStationId)) {
+ return;
+ }
+
+ if (stationProtocol.getTaskNo() != null
+ && stationProtocol.getTaskNo() > 0
+ && backStationId.equals(stationProtocol.getTargetStaNo())) {
+ return;
+ }
+
+ String lockKey = RedisKeyType.GENERATE_STATION_BACK_LIMIT.key
+ + currentStationId + "_" + stationProtocol.getTaskNo();
+ if (redisUtil.get(lockKey) != null) {
+ return;
+ }
+
+ Integer stationBackTaskNo = commonService.getWorkNo(WrkIoType.STATION_BACK.id);
+ StationCommand command = context.getStationThread().getCommand(
+ StationCommandType.MOVE,
+ stationBackTaskNo,
+ currentStationId,
+ backStationId,
+ 0
+ );
+ if (command == null) {
+ News.warn("WMS鍏ュ簱澶辫触鍚庣敓鎴愰��鍥炲叆搴撶珯鍛戒护澶辫触銆俠arcode={}锛宻tationId={}锛宐ackStationId={}锛寃arning={}",
+ request == null ? null : request.getBarcode(),
+ currentStationId,
+ backStationId,
+ result == null ? null : result.getMessage());
+ return;
+ }
+
+ StationCommandDispatchResult dispatchResult = stationCommandDispatcher.dispatch(
+ context.getBasDevp().getDevpNo(),
+ command,
+ "store-in-task-generation",
+ "apply-failed-station-back"
+ );
+ if (!dispatchResult.isAccepted()) {
+ News.warn("WMS鍏ュ簱澶辫触鍚庨��鍥炲叆搴撶珯鍛戒护鍏ラ槦澶辫触銆俠arcode={}锛宻tationId={}锛宐ackStationId={}锛宺eason={}锛寃arning={}",
+ request == null ? null : request.getBarcode(),
+ currentStationId,
+ backStationId,
+ dispatchResult.getReason(),
+ result == null ? null : result.getMessage());
+ return;
+ }
+
+ redisUtil.set(lockKey, "lock", APPLY_FAIL_STATION_BACK_LOCK_SECONDS);
+ News.warn("WMS鍏ュ簱澶辫触锛屽凡瑙﹀彂璐х墿閫�鍥炲叆搴撶珯銆俠arcode={}锛宻tationId={}锛宐ackStationId={}锛寃arning={}",
+ request == null ? null : request.getBarcode(),
+ currentStationId,
+ backStationId,
+ result == null ? null : result.getMessage());
}
private HashMap<String, String> getSystemConfigMap() {
--
Gitblit v1.9.1