| | |
| | | |
| | | 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; |
| | |
| | | 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() { |
| | |
| | | )); |
| | | 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)); |
| | |
| | | } |
| | | } |
| | | |
| | | 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() { |
| | |
| | | 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)) { |