From 2919f41969fd7e93d58be899263833f017acd929 Mon Sep 17 00:00:00 2001
From: Administrator <XS@163.COM>
Date: 星期一, 27 四月 2026 11:53:05 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java | 139 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 123 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index 288f8c8..78d5cd9 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -117,18 +117,50 @@
}
public void submitStationInTasks(MainProcessLane lane, long minIntervalMs) {
- // 鍏ュ簱涓嬪彂渚濊禆鍗曡疆鍏变韩鐨勬壙杞介鍗犵姸鎬侊紝蹇呴』鏁翠綋涓茶锛岄伩鍏嶅涓珯鐐瑰苟鍙戞椂鍚屾椂閫氳繃瀹归噺妫�鏌ャ��
mainProcessTaskSubmitter.submitSerialTask(
- MainProcessLane.STATION,
- "stationInExecute",
+ MainProcessLane.STATION_SCAN,
+ "submitStationInTasks",
minIntervalMs,
new Runnable() {
@Override
public void run() {
- stationInExecute();
+ submitStationInTasksInternal(lane, minIntervalMs);
}
}
);
+ }
+
+ private void submitStationInTasksInternal(MainProcessLane lane, long minIntervalMs) {
+ List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>());
+ for (final BasDevp basDevp : basDevps) {
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
+ if (stationThread == null) {
+ continue;
+ }
+ Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
+ if (stationMap == null || stationMap.isEmpty()) {
+ continue;
+ }
+ List<StationObjModel> list = basDevp.getBarcodeStationList$();
+ for (final StationObjModel stationObjModel : list) {
+ Integer stationId = stationObjModel == null ? null : stationObjModel.getStationId();
+ if (stationId == null || !stationMap.containsKey(stationId)) {
+ continue;
+ }
+ mainProcessTaskSubmitter.submitKeyedSerialTask(
+ lane,
+ stationId,
+ "stationInExecute",
+ minIntervalMs,
+ new Runnable() {
+ @Override
+ public void run() {
+ stationInExecute(basDevp, stationObjModel);
+ }
+ }
+ );
+ }
+ }
}
public void submitCrnStationOutTasks(long minIntervalMs) {
@@ -136,18 +168,39 @@
}
public void submitCrnStationOutTasks(MainProcessLane lane, long minIntervalMs) {
- // 鍑哄簱绔欑偣涓嬪彂鍚屾牱浼氶鍗犺緭閫佺嚎/鐜嚎瀹归噺锛屼笌 stationInExecute 鍏辩敤 STATION lane 涓茶銆�
mainProcessTaskSubmitter.submitSerialTask(
- MainProcessLane.STATION,
- "crnStationOutExecute",
+ MainProcessLane.STATION_SCAN,
+ "submitCrnStationOutTasks",
minIntervalMs,
new Runnable() {
@Override
public void run() {
- crnStationOutExecute();
+ submitCrnStationOutTasksInternal(lane, minIntervalMs);
}
}
);
+ }
+
+ private void submitCrnStationOutTasksInternal(MainProcessLane lane, long minIntervalMs) {
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
+ .isNotNull("crn_no")
+ );
+ for (final WrkMast wrkMast : wrkMasts) {
+ Integer laneKey = getCrnStationOutLaneKey(wrkMast);
+ mainProcessTaskSubmitter.submitKeyedSerialTask(
+ lane,
+ laneKey,
+ "crnStationOutExecute",
+ minIntervalMs,
+ new Runnable() {
+ @Override
+ public void run() {
+ crnStationOutExecute(wrkMast);
+ }
+ }
+ );
+ }
}
public void submitDualCrnStationOutTasks(long minIntervalMs) {
@@ -214,10 +267,7 @@
private void submitStationOutExecuteFinishTasksInternal(MainProcessLane lane, long minIntervalMs) {
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
for (final WrkMast wrkMast : wrkMasts) {
- Integer laneKey = wrkMast == null ? null : wrkMast.getStaNo();
- if (laneKey == null) {
- laneKey = wrkMast == null ? null : wrkMast.getWrkNo();
- }
+ Integer laneKey = wrkMast == null ? null : wrkMast.getWrkNo();
mainProcessTaskSubmitter.submitKeyedSerialTask(
lane,
laneKey,
@@ -254,10 +304,7 @@
private void submitCheckTaskToCompleteTasksInternal(MainProcessLane lane, long minIntervalMs) {
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN_COMPLETE.sts));
for (final WrkMast wrkMast : wrkMasts) {
- Integer laneKey = wrkMast == null ? null : wrkMast.getStaNo();
- if (laneKey == null) {
- laneKey = wrkMast == null ? null : wrkMast.getWrkNo();
- }
+ Integer laneKey = wrkMast == null ? null : wrkMast.getWrkNo();
mainProcessTaskSubmitter.submitKeyedSerialTask(
lane,
laneKey,
@@ -460,14 +507,25 @@
.eq("io_type", WrkIoType.IN.id)
);
if (wrkMast == null) {
+ logDebugLimited("station_in_wait_wrk_" + stationId + "_" + stationProtocol.getTaskNo(), 3,
+ "[WCS Debug][鏉$爜绔欏叆搴揮 鏉$爜绔欏凡鏈夌珯鐐逛换鍔″彿浣嗘湭鎵惧埌鍏ュ簱宸ヤ綔妗o紝绛夊緟浠诲姟鐢熸垚銆俿tationId={}锛宻tationTaskNo={}锛宐arcode={}锛宨sLoading={}锛宨sAutoing={}",
+ stationId, stationProtocol.getTaskNo(), stationProtocol.getBarcode(),
+ stationProtocol.isLoading(), stationProtocol.isAutoing());
return false;
}
if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
+ logDebugLimited("station_in_already_run_" + wrkMast.getWrkNo(), 5,
+ "[WCS Debug][鏉$爜绔欏叆搴揮 鍏ュ簱宸ヤ綔妗e凡澶勪簬璁惧涓婅蛋鐘舵�侊紝绛夊緟杈撻�佺嚎/PLC鐘舵�佹帹杩涖�俿tationId={}锛寃rkNo={}锛宐arcode={}锛宭ocNo={}锛寃rkSts={}",
+ stationId, wrkMast.getWrkNo(), stationProtocol.getBarcode(),
+ wrkMast.getLocNo(), wrkMast.getWrkSts());
return false;
}
String locNo = wrkMast.getLocNo();
+ News.info("[WCS Debug][鏉$爜绔欏叆搴揮 鍑嗗鍖归厤鍏ュ簱鐩爣绔欍�俿tationId={}锛宻tationTaskNo={}锛寃rkNo={}锛宐arcode={}锛宭ocNo={}锛寃rkSts={}",
+ stationId, stationProtocol.getTaskNo(), wrkMast.getWrkNo(),
+ stationProtocol.getBarcode(), locNo, wrkMast.getWrkSts());
FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
if (findCrnNoResult == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鏈尮閰嶅埌鍫嗗灈鏈�", wrkMast.getWrkNo());
@@ -483,10 +541,18 @@
LoopHitResult loopHitResult = findPathLoopHit(limitConfig, stationProtocol.getStationId(), targetStationId, loadGuardState);
if (isDispatchBlocked(limitConfig, currentStationTaskCountRef[0], loadGuardState, loopHitResult.isThroughLoop())) {
+ logDebugLimited("station_in_dispatch_blocked_" + wrkMast.getWrkNo(), 3,
+ "[WCS Debug][鏉$爜绔欏叆搴揮 鍏ュ簱杈撻�佸懡浠ゆ殏缂擄紝涓嬪彂瀹归噺/鐜嚎璐熻浇鍙楅檺銆俿tationId={}锛宼argetStationId={}锛寃rkNo={}锛宑urrentStationTaskCount={}锛宼hroughLoop={}锛宭oopNo={}锛宧itStationId={}",
+ stationId, targetStationId, wrkMast.getWrkNo(), currentStationTaskCountRef[0],
+ loopHitResult.isThroughLoop(), loopHitResult.getLoopNo(), loopHitResult.getHitStationId());
return true;
}
+ long commandStartMs = System.currentTimeMillis();
StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, targetStationId, 0);
+ News.info("[WCS Debug][鏉$爜绔欏叆搴揮 鑾峰彇鍏ュ簱杈撻�佸懡浠ゅ畬鎴愩�俿tationId={}锛宼argetStationId={}锛寃rkNo={}锛宑ostMs={}锛宑ommand={}",
+ stationId, targetStationId, wrkMast.getWrkNo(),
+ System.currentTimeMillis() - commandStartMs, JSON.toJSONString(command));
if (command == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", wrkMast.getWrkNo());
return false;
@@ -500,6 +566,9 @@
if (wrkMastService.updateById(wrkMast)) {
MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
News.info("杈撻�佺珯鐐瑰叆搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command));
+ News.info("[WCS Debug][鏉$爜绔欏叆搴揮 鍏ュ簱杈撻�佸懡浠ゅ凡鍏ラ槦銆俿tationId={}锛宼argetStationId={}锛寃rkNo={}锛宐arcode={}锛宭ocNo={}锛宒eviceNo={}",
+ stationId, targetStationId, wrkMast.getWrkNo(), stationProtocol.getBarcode(),
+ locNo, basDevp.getDevpNo());
redisUtil.set(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId, "lock", 5);
loadGuardState.reserveLoopTask(loopHitResult.getLoopNo());
saveLoopLoadReserve(wrkMast.getWrkNo(), loopHitResult);
@@ -529,6 +598,30 @@
} catch (Exception e) {
e.printStackTrace();
}
+ }
+
+ private Integer getCrnStationOutLaneKey(WrkMast wrkMast) {
+ if (wrkMast == null) {
+ return null;
+ }
+ Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
+ if (infoObj != null) {
+ try {
+ StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
+ if (stationObjModel != null && stationObjModel.getStationId() != null) {
+ return stationObjModel.getStationId();
+ }
+ } catch (Exception e) {
+ News.error("[WCS Debug][绔欑偣鍑哄簱] 瑙f瀽鍑哄簱缂撳瓨绔欑偣澶辫触锛屽伐浣滃彿={}锛宑ache={}", wrkMast.getWrkNo(), infoObj);
+ }
+ }
+ if (wrkMast.getSourceStaNo() != null) {
+ return wrkMast.getSourceStaNo();
+ }
+ if (wrkMast.getStaNo() != null) {
+ return wrkMast.getStaNo();
+ }
+ return wrkMast.getWrkNo();
}
public void crnStationOutExecute(WrkMast wrkMast) {
@@ -1482,6 +1575,20 @@
redisUtil.expire(RedisKeyType.STATION_CYCLE_LOAD_RESERVE.key, LOOP_LOAD_RESERVE_EXPIRE_SECONDS);
}
+ private void logDebugLimited(String lockKey, int seconds, String format, Object... arguments) {
+ String redisKey = RedisKeyType.LOG_LIMIT.key + "wcs_debug_" + lockKey;
+ try {
+ Object lock = redisUtil.get(redisKey);
+ if (lock != null) {
+ return;
+ }
+ redisUtil.set(redisKey, "lock", seconds);
+ } catch (Exception e) {
+ // 璇婃柇鏃ュ織涓嶈兘褰卞搷涓绘祦绋嬨��
+ }
+ News.info(format, arguments);
+ }
+
private DispatchLimitConfig getDispatchLimitConfig() {
DispatchLimitConfig config = new DispatchLimitConfig();
Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
--
Gitblit v1.9.1