#
Junjie
9 天以前 dc3f9cc91759823ce59486f19b138be4b296a0f1
src/main/java/com/zy/ai/service/impl/AutoTuneSnapshotServiceImpl.java
@@ -2,6 +2,8 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zy.ai.domain.autotune.AutoTuneParameterSnapshot;
import com.zy.ai.domain.autotune.AutoTuneRuleDefinition;
import com.zy.ai.domain.autotune.AutoTuneRuleSnapshotItem;
import com.zy.ai.domain.autotune.AutoTuneSnapshot;
import com.zy.ai.domain.autotune.AutoTuneStationRuntimeItem;
import com.zy.ai.domain.autotune.AutoTuneTaskSnapshot;
@@ -86,8 +88,27 @@
        snapshot.setCycleLoadSnapshot(buildCycleLoadSnapshot());
        snapshot.setFlowTopologySnapshot(flowTopologySnapshotService.buildSnapshot(stationRuntimeSnapshot));
        snapshot.setCurrentParameterSnapshot(buildCurrentParameterSnapshot());
        snapshot.setRuleSnapshot(buildRuleSnapshot());
        snapshot.setSnapshotTime(new Date());
        return snapshot;
    }
    List<AutoTuneRuleSnapshotItem> buildRuleSnapshot() {
        List<AutoTuneRuleSnapshotItem> result = new ArrayList<>();
        for (AutoTuneRuleDefinition.Rule rule : AutoTuneRuleDefinition.rules().values()) {
            AutoTuneRuleSnapshotItem item = new AutoTuneRuleSnapshotItem();
            item.setTargetType(rule.getTargetType().getCode());
            item.setTargetKey(rule.getTargetKey());
            item.setMinValue(rule.getMinValue());
            item.setMaxValue(rule.getMaxValue());
            item.setMaxStep(rule.getMaxStep());
            item.setCooldownMinutes(rule.getCooldownMinutes());
            item.setDynamicMaxValue(rule.isDynamicMaxValue());
            item.setDynamicMaxSource(rule.getDynamicMaxSource());
            item.setNote(rule.getNote());
            result.add(item);
        }
        return result;
    }
    private AutoTuneTaskSnapshot buildTaskSnapshot() {
@@ -224,7 +245,9 @@
        ));
        List<BasCrnp> crnList = loadCrnList();
        List<BasDualCrnp> dualCrnList = loadDualCrnList();
        snapshot.setStationOutTaskLimits(loadStationOutTaskLimits());
        List<BasStation> outStationList = loadOutStationList();
        snapshot.setStationOutTaskLimits(buildStationOutTaskLimitMap(outStationList));
        snapshot.setStationOutBufferCapacities(buildStationOutBufferCapacityMap(outStationList));
        snapshot.setCrnMaxOutTask(buildCrnMaxOutTask(crnList));
        snapshot.setCrnMaxInTask(buildCrnMaxInTask(crnList));
        snapshot.setDualCrnMaxOutTask(buildDualCrnMaxOutTask(dualCrnList));
@@ -247,19 +270,18 @@
        }
    }
    private Map<String, Integer> loadStationOutTaskLimits() {
        Map<String, Integer> result = new LinkedHashMap<>();
    private List<BasStation> loadOutStationList() {
        if (basStationService == null) {
            return result;
            return Collections.emptyList();
        }
        Set<Integer> outStationIds = loadOutStationIds();
        if (outStationIds.isEmpty()) {
            return result;
            return Collections.emptyList();
        }
        QueryWrapper<BasStation> wrapper = new QueryWrapper<>();
        wrapper.in("station_id", outStationIds);
        wrapper.orderByAsc("station_id");
        return buildStationOutTaskLimitMap(basStationService.list(wrapper));
        return safeList(basStationService.list(wrapper));
    }
    private Set<Integer> loadOutStationIds() {
@@ -295,6 +317,16 @@
        return result;
    }
    Map<String, Integer> buildStationOutBufferCapacityMap(List<BasStation> stationList) {
        Map<String, Integer> result = new LinkedHashMap<>();
        for (BasStation station : safeList(stationList)) {
            if (station != null && station.getStationId() != null) {
                result.put(String.valueOf(station.getStationId()), station.getOutBufferCapacity());
            }
        }
        return result;
    }
    private Map<String, Integer> buildCrnMaxOutTask(List<BasCrnp> crnList) {
        Map<String, Integer> result = new LinkedHashMap<>();
        for (BasCrnp crn : safeList(crnList)) {