#
Junjie
2026-04-27 b83bc2ee89d5826b3ab5fe42ac3af5972360b55c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.zy.ai.domain.autotune;
 
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
 
public final class AutoTuneRuleDefinition {
 
    private static final Map<String, Rule> RULE_MAP = buildRuleMap();
 
    private AutoTuneRuleDefinition() {
    }
 
    public static Rule findRule(String targetType, String targetKey) {
        if (targetType == null || targetKey == null) {
            return null;
        }
        return RULE_MAP.get(buildKey(targetType.trim(), targetKey.trim()));
    }
 
    public static Map<String, Rule> rules() {
        return RULE_MAP;
    }
 
    private static Map<String, Rule> buildRuleMap() {
        LinkedHashMap<String, Rule> ruleMap = new LinkedHashMap<>();
        add(ruleMap, AutoTuneTargetType.SYS_CONFIG, "aiAutoTuneIntervalMinutes", 5, 60, 5, 30, false);
        add(ruleMap, AutoTuneTargetType.SYS_CONFIG, "conveyorStationTaskLimit", 5, 200, 5, 20, false);
        add(ruleMap, AutoTuneTargetType.SYS_CONFIG, "crnOutBatchRunningLimit", 1, 20, 3, 20, false);
        add(ruleMap, AutoTuneTargetType.STATION, "outTaskLimit", 0, null, 3, 10, true);
        add(ruleMap, AutoTuneTargetType.CRN, "maxOutTask", 0, 10, 3, 10, false);
        add(ruleMap, AutoTuneTargetType.CRN, "maxInTask", 0, 10, 3, 10, false);
        add(ruleMap, AutoTuneTargetType.DUAL_CRN, "maxOutTask", 0, 10, 3, 10, false);
        add(ruleMap, AutoTuneTargetType.DUAL_CRN, "maxInTask", 0, 10, 3, 10, false);
        return Collections.unmodifiableMap(ruleMap);
    }
 
    private static void add(LinkedHashMap<String, Rule> ruleMap,
                            AutoTuneTargetType targetType,
                            String targetKey,
                            Integer minValue,
                            Integer maxValue,
                            int maxStep,
                            int cooldownMinutes,
                            boolean dynamicMaxValue) {
        Rule rule = new Rule(targetType, targetKey, minValue, maxValue, maxStep, cooldownMinutes, dynamicMaxValue);
        ruleMap.put(buildKey(targetType.getCode(), targetKey), rule);
    }
 
    private static String buildKey(String targetType, String targetKey) {
        return targetType + ":" + targetKey;
    }
 
    public static final class Rule {
        private final AutoTuneTargetType targetType;
        private final String targetKey;
        private final Integer minValue;
        private final Integer maxValue;
        private final int maxStep;
        private final int cooldownMinutes;
        private final boolean dynamicMaxValue;
 
        private Rule(AutoTuneTargetType targetType,
                     String targetKey,
                     Integer minValue,
                     Integer maxValue,
                     int maxStep,
                     int cooldownMinutes,
                     boolean dynamicMaxValue) {
            this.targetType = targetType;
            this.targetKey = targetKey;
            this.minValue = minValue;
            this.maxValue = maxValue;
            this.maxStep = maxStep;
            this.cooldownMinutes = cooldownMinutes;
            this.dynamicMaxValue = dynamicMaxValue;
        }
 
        public AutoTuneTargetType getTargetType() {
            return targetType;
        }
 
        public String getTargetKey() {
            return targetKey;
        }
 
        public Integer getMinValue() {
            return minValue;
        }
 
        public Integer getMaxValue() {
            return maxValue;
        }
 
        public int getMaxStep() {
            return maxStep;
        }
 
        public int getCooldownMinutes() {
            return cooldownMinutes;
        }
 
        public boolean isDynamicMaxValue() {
            return dynamicMaxValue;
        }
    }
}