From bf4e43c1fd1a361029e7cb51daac378fa5ee3617 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 20 三月 2026 18:44:13 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/domain/path/StationPathProfileConfig.java   |    2 +
 src/main/webapp/views/stationPathPolicy/stationPathPolicy.html        |    4 +
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java       |   45 ++++++++++++++--------
 src/main/webapp/static/js/stationPathPolicy/stationPathPolicy.js      |   14 +++++++
 src/main/resources/sql/20260313_create_station_path_policy_tables.sql |    2 
 5 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/zy/asrs/domain/path/StationPathProfileConfig.java b/src/main/java/com/zy/asrs/domain/path/StationPathProfileConfig.java
index 48265c7..4314abf 100644
--- a/src/main/java/com/zy/asrs/domain/path/StationPathProfileConfig.java
+++ b/src/main/java/com/zy/asrs/domain/path/StationPathProfileConfig.java
@@ -26,6 +26,7 @@
     private Double s2DeadlockWeight = 8.0d;
     private Double s2RunBlockWeight = 10.0d;
     private Double s2LoopLoadWeight = 12.0d;
+    private Double circleMaxLoadLimit = 80.0d;
 
     private Double stationPathLenWeightPercent = 50.0d;
     private Double stationPathCongWeightPercent = 50.0d;
@@ -56,6 +57,7 @@
         if (source.s2DeadlockWeight != null) this.s2DeadlockWeight = source.s2DeadlockWeight;
         if (source.s2RunBlockWeight != null) this.s2RunBlockWeight = source.s2RunBlockWeight;
         if (source.s2LoopLoadWeight != null) this.s2LoopLoadWeight = source.s2LoopLoadWeight;
+        if (source.circleMaxLoadLimit != null) this.circleMaxLoadLimit = source.circleMaxLoadLimit;
         if (source.stationPathLenWeightPercent != null) this.stationPathLenWeightPercent = source.stationPathLenWeightPercent;
         if (source.stationPathCongWeightPercent != null) this.stationPathCongWeightPercent = source.stationPathCongWeightPercent;
         if (source.stationPathPassOtherOutStationWeightPercent != null) this.stationPathPassOtherOutStationWeightPercent = source.stationPathPassOtherOutStationWeightPercent;
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index 1224d5d..05e0599 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -7,6 +7,7 @@
 import com.core.common.Cools;
 import com.core.exception.CoolException;
 import com.zy.asrs.domain.enums.NotifyMsgType;
+import com.zy.asrs.domain.path.StationPathResolvedPolicy;
 import com.zy.asrs.domain.vo.StationCycleCapacityVo;
 import com.zy.asrs.domain.vo.StationCycleLoopVo;
 import com.zy.asrs.entity.*;
@@ -57,13 +58,15 @@
     private BasStationService basStationService;
     @Autowired
     private StationCycleCapacityService stationCycleCapacityService;
+    @Autowired
+    private StationPathPolicyService stationPathPolicyService;
 
     //鎵ц杈撻�佺珯鐐瑰叆搴撲换鍔�
     public synchronized void stationInExecute() {
         try {
-            DispatchLimitConfig limitConfig = getDispatchLimitConfig();
+            DispatchLimitConfig baseLimitConfig = getDispatchLimitConfig(null, null);
             int[] currentStationTaskCountRef = new int[]{countCurrentStationTask()};
-            LoadGuardState loadGuardState = buildLoadGuardState(limitConfig);
+            LoadGuardState loadGuardState = buildLoadGuardState(baseLimitConfig);
 
             List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<>());
             for (BasDevp basDevp : basDevps) {
@@ -119,6 +122,7 @@
                             continue;
                         }
 
+                        DispatchLimitConfig limitConfig = getDispatchLimitConfig(stationProtocol.getStationId(), targetStationId);
                         LoopHitResult loopHitResult = findPathLoopHit(limitConfig, stationProtocol.getStationId(), targetStationId, loadGuardState);
 
                         if (isDispatchBlocked(limitConfig, currentStationTaskCountRef[0], loadGuardState, loopHitResult.isThroughLoop())) {
@@ -154,9 +158,9 @@
     //鎵ц鍫嗗灈鏈鸿緭閫佺珯鐐瑰嚭搴撲换鍔�
     public synchronized void crnStationOutExecute() {
         try {
-            DispatchLimitConfig limitConfig = getDispatchLimitConfig();
+            DispatchLimitConfig baseLimitConfig = getDispatchLimitConfig(null, null);
             int[] currentStationTaskCountRef = new int[]{countCurrentStationTask()};
-            LoadGuardState loadGuardState = buildLoadGuardState(limitConfig);
+            LoadGuardState loadGuardState = buildLoadGuardState(baseLimitConfig);
 
             List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>()
                     .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
@@ -200,6 +204,7 @@
                             true
                     );
 
+                    DispatchLimitConfig limitConfig = getDispatchLimitConfig(stationProtocol.getStationId(), moveStaNo);
                     LoopHitResult loopHitResult = findPathLoopHit(limitConfig, stationProtocol.getStationId(), moveStaNo, loadGuardState);
 
                     if (isDispatchBlocked(limitConfig, currentStationTaskCountRef[0], loadGuardState, loopHitResult.isThroughLoop())) {
@@ -1000,23 +1005,31 @@
         redisUtil.expire(RedisKeyType.STATION_CYCLE_LOAD_RESERVE.key, LOOP_LOAD_RESERVE_EXPIRE_SECONDS);
     }
 
-    private DispatchLimitConfig getDispatchLimitConfig() {
+    private DispatchLimitConfig getDispatchLimitConfig(Integer startStationId, Integer endStationId) {
         DispatchLimitConfig config = new DispatchLimitConfig();
         Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
-        if (!(systemConfigMapObj instanceof Map)) {
-            return config;
+        if (systemConfigMapObj instanceof Map) {
+            Map<?, ?> systemConfigMap = (Map<?, ?>) systemConfigMapObj;
+            config.circleMaxLoadLimit = parseLoadLimit(getConfigValue(systemConfigMap, "circleMaxLoadLimit"), config.circleMaxLoadLimit);
+            String loopModeValue = getConfigValue(systemConfigMap, "circleLoopModeEnable");
+            if (isBlank(loopModeValue)) {
+                loopModeValue = getConfigValue(systemConfigMap, "circleModeEnable");
+            }
+            if (isBlank(loopModeValue)) {
+                loopModeValue = getConfigValue(systemConfigMap, "isCircleMode");
+            }
+            config.loopModeEnable = parseBoolean(loopModeValue, config.loopModeEnable);
         }
-        Map<?, ?> systemConfigMap = (Map<?, ?>) systemConfigMapObj;
 
-        config.circleMaxLoadLimit = parseLoadLimit(getConfigValue(systemConfigMap, "circleMaxLoadLimit"), config.circleMaxLoadLimit);
-        String loopModeValue = getConfigValue(systemConfigMap, "circleLoopModeEnable");
-        if (isBlank(loopModeValue)) {
-            loopModeValue = getConfigValue(systemConfigMap, "circleModeEnable");
+        if (stationPathPolicyService != null && startStationId != null && endStationId != null) {
+            try {
+                StationPathResolvedPolicy resolvedPolicy = stationPathPolicyService.resolvePolicy(startStationId, endStationId);
+                if (resolvedPolicy != null && resolvedPolicy.getProfileConfig() != null) {
+                    config.circleMaxLoadLimit = parseLoadLimit(String.valueOf(resolvedPolicy.getProfileConfig().getCircleMaxLoadLimit()), config.circleMaxLoadLimit);
+                }
+            } catch (Exception ignore) {
+            }
         }
-        if (isBlank(loopModeValue)) {
-            loopModeValue = getConfigValue(systemConfigMap, "isCircleMode");
-        }
-        config.loopModeEnable = parseBoolean(loopModeValue, config.loopModeEnable);
 
         return config;
     }
diff --git a/src/main/resources/sql/20260313_create_station_path_policy_tables.sql b/src/main/resources/sql/20260313_create_station_path_policy_tables.sql
index 080be0c..8e6d622 100644
--- a/src/main/resources/sql/20260313_create_station_path_policy_tables.sql
+++ b/src/main/resources/sql/20260313_create_station_path_policy_tables.sql
@@ -45,7 +45,7 @@
   100,
   1,
   1,
-  '{"calcMaxDepth":120,"calcMaxPaths":500,"calcMaxCost":300,"s1TopK":5,"s1LenWeight":1.0,"s1TurnWeight":3.0,"s1LiftWeight":8.0,"s1SoftDeviationWeight":4.0,"s1MaxLenRatio":1.15,"s1MaxTurnDiff":1,"s2BusyWeight":2.0,"s2QueueWeight":2.5,"s2WaitWeight":1.5,"s2DeadlockWeight":8.0,"s2RunBlockWeight":10.0,"s2LoopLoadWeight":12.0,"stationPathLenWeightPercent":50.0,"stationPathCongWeightPercent":50.0,"stationPathPassOtherOutStationWeightPercent":100.0,"stationPathPassOtherOutStationForceSkip":false}',
+  '{"calcMaxDepth":120,"calcMaxPaths":500,"calcMaxCost":300,"s1TopK":5,"s1LenWeight":1.0,"s1TurnWeight":3.0,"s1LiftWeight":8.0,"s1SoftDeviationWeight":4.0,"s1MaxLenRatio":1.15,"s1MaxTurnDiff":1,"s2BusyWeight":2.0,"s2QueueWeight":2.5,"s2WaitWeight":1.5,"s2DeadlockWeight":8.0,"s2RunBlockWeight":10.0,"s2LoopLoadWeight":12.0,"circleMaxLoadLimit":80.0,"stationPathLenWeightPercent":50.0,"stationPathCongWeightPercent":50.0,"stationPathPassOtherOutStationWeightPercent":100.0,"stationPathPassOtherOutStationForceSkip":false}',
   '榛樿妯℃澘'
 FROM dual
 WHERE NOT EXISTS (
diff --git a/src/main/webapp/static/js/stationPathPolicy/stationPathPolicy.js b/src/main/webapp/static/js/stationPathPolicy/stationPathPolicy.js
index e3c04c2..89632e9 100644
--- a/src/main/webapp/static/js/stationPathPolicy/stationPathPolicy.js
+++ b/src/main/webapp/static/js/stationPathPolicy/stationPathPolicy.js
@@ -16,6 +16,7 @@
         s2DeadlockWeight: 8.0,
         s2RunBlockWeight: 10.0,
         s2LoopLoadWeight: 12.0,
+        circleMaxLoadLimit: 80.0,
         stationPathLenWeightPercent: 50,
         stationPathCongWeightPercent: 50,
         stationPathPassOtherOutStationWeightPercent: 100,
@@ -1156,9 +1157,11 @@
         },
         normalizeProfile: function (raw) {
             var config = Object.assign({}, this.defaultProfileConfig(), this.parseJson(raw.configJson) || raw.config || {})
+            config.circleMaxLoadLimit = this.toNumberSafe(config.circleMaxLoadLimit)
             config.stationPathLenWeightPercent = this.toNumberSafe(config.stationPathLenWeightPercent)
             config.stationPathCongWeightPercent = this.toNumberSafe(config.stationPathCongWeightPercent)
             config.stationPathPassOtherOutStationWeightPercent = this.toNumberSafe(config.stationPathPassOtherOutStationWeightPercent)
+            config.circleMaxLoadLimit = config.circleMaxLoadLimit == null ? 80 : config.circleMaxLoadLimit
             config.stationPathLenWeightPercent = config.stationPathLenWeightPercent == null ? 50 : config.stationPathLenWeightPercent
             config.stationPathCongWeightPercent = config.stationPathCongWeightPercent == null ? 50 : config.stationPathCongWeightPercent
             config.stationPathPassOtherOutStationWeightPercent = config.stationPathPassOtherOutStationWeightPercent == null ? 100 : config.stationPathPassOtherOutStationWeightPercent
@@ -1209,6 +1212,7 @@
         },
         sanitizeProfileForSave: function (item) {
             var config = Object.assign({}, item.config || {})
+            config.circleMaxLoadLimit = this.toNumberSafe(config.circleMaxLoadLimit) == null ? 80 : this.toNumberSafe(config.circleMaxLoadLimit)
             config.stationPathLenWeightPercent = this.toNumberSafe(config.stationPathLenWeightPercent) == null ? 50 : this.toNumberSafe(config.stationPathLenWeightPercent)
             config.stationPathCongWeightPercent = this.toNumberSafe(config.stationPathCongWeightPercent) == null ? 50 : this.toNumberSafe(config.stationPathCongWeightPercent)
             config.stationPathPassOtherOutStationWeightPercent = this.toNumberSafe(config.stationPathPassOtherOutStationWeightPercent) == null ? 100 : this.toNumberSafe(config.stationPathPassOtherOutStationWeightPercent)
@@ -1306,6 +1310,16 @@
             var num = Number(value)
             return isNaN(num) ? null : num
         },
+        displayLoadLimitPercent: function (value) {
+            var num = this.toNumberSafe(value)
+            if (num == null) {
+                num = 80
+            }
+            if (num <= 1) {
+                num = num * 100
+            }
+            return num.toFixed(1) + '%'
+        },
         notNull: function (value) {
             return value != null
         },
diff --git a/src/main/webapp/views/stationPathPolicy/stationPathPolicy.html b/src/main/webapp/views/stationPathPolicy/stationPathPolicy.html
index 7c24dfe..791f61c 100644
--- a/src/main/webapp/views/stationPathPolicy/stationPathPolicy.html
+++ b/src/main/webapp/views/stationPathPolicy/stationPathPolicy.html
@@ -846,7 +846,8 @@
                             <div class="entity-desc">
                                 S1: 闀垮害(s1LenWeight) {{ item.config.s1LenWeight }} / 鎷愮偣(s1TurnWeight) {{ item.config.s1TurnWeight }} / 椤跺崌(s1LiftWeight) {{ item.config.s1LiftWeight }}<br>
                                 S2: 鎷ュ牭(s2BusyWeight) {{ item.config.s2BusyWeight }} / 鎺掗槦(s2QueueWeight) {{ item.config.s2QueueWeight }} / 绛夊緟(s2WaitWeight) {{ item.config.s2WaitWeight }} / 姝婚攣(s2DeadlockWeight) {{ item.config.s2DeadlockWeight }} / 鍫靛(s2RunBlockWeight) {{ item.config.s2RunBlockWeight }} / 鐜嚎(s2LoopLoadWeight) {{ item.config.s2LoopLoadWeight }}<br>
-                                骞宠 : 闀垮害(stationPathLenWeightPercent) {{ item.config.stationPathLenWeightPercent }}% / 鎵胯浇(stationPathCongWeightPercent) {{ item.config.stationPathCongWeightPercent }}% / 浠栧嚭鎯╃綒(stationPathPassOtherOutStationWeightPercent) {{ item.config.stationPathPassOtherOutStationWeightPercent }} / 寮鸿烦(stationPathPassOtherOutStationForceSkip) {{ item.config.stationPathPassOtherOutStationForceSkip ? '鏄�' : '鍚�' }}
+                                骞宠 : 闀垮害(stationPathLenWeightPercent) {{ item.config.stationPathLenWeightPercent }}% / 鎵胯浇(stationPathCongWeightPercent) {{ item.config.stationPathCongWeightPercent }}% / 浠栧嚭鎯╃綒(stationPathPassOtherOutStationWeightPercent) {{ item.config.stationPathPassOtherOutStationWeightPercent }} / 寮鸿烦(stationPathPassOtherOutStationForceSkip) {{ item.config.stationPathPassOtherOutStationForceSkip ? '鏄�' : '鍚�' }}<br>
+                                鎵ц: 鐜嚎绂佸彂闃堝��(circleMaxLoadLimit) {{ displayLoadLimitPercent(item.config.circleMaxLoadLimit) }}
                             </div>
                             <div class="entity-actions">
                                 <el-button size="mini" @click.stop="openProfileDialog(item)">缂栬緫</el-button>
@@ -1084,6 +1085,7 @@
                         <el-form-item label="姝婚攣椋庨櫓鏉冮噸(s2DeadlockWeight)"><el-input-number v-model="profileForm.config.s2DeadlockWeight" :min="0" :step="0.5" style="width: 100%;"></el-input-number></el-form-item>
                         <el-form-item label="鍫靛鏉冮噸(s2RunBlockWeight)"><el-input-number v-model="profileForm.config.s2RunBlockWeight" :min="0" :step="0.5" style="width: 100%;"></el-input-number></el-form-item>
                         <el-form-item label="鐜嚎璐熻浇鏉冮噸(s2LoopLoadWeight)"><el-input-number v-model="profileForm.config.s2LoopLoadWeight" :min="0" :step="0.5" style="width: 100%;"></el-input-number></el-form-item>
+                        <el-form-item label="鐜嚎绂佸彂闃堝��(circleMaxLoadLimit, %)"><el-input-number v-model="profileForm.config.circleMaxLoadLimit" :min="0" :max="100" :step="5" style="width: 100%;"></el-input-number></el-form-item>
                     </div>
                 </div>
             </el-form>

--
Gitblit v1.9.1