| | |
| | | |
| | | 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.AutoTuneTargetType; |
| | | import com.zy.ai.domain.autotune.AutoTuneTaskSnapshot; |
| | | import com.zy.ai.service.AutoTuneSnapshotService; |
| | | import com.zy.ai.service.FlowTopologySnapshotService; |
| | |
| | | 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(resolveDynamicMaxSource(rule)); |
| | | item.setNote(resolveRuleNote(rule)); |
| | | result.add(item); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private String resolveDynamicMaxSource(AutoTuneRuleDefinition.Rule rule) { |
| | | if (!AutoTuneTargetType.STATION.equals(rule.getTargetType())) { |
| | | return null; |
| | | } |
| | | if (!"outTaskLimit".equals(rule.getTargetKey())) { |
| | | return null; |
| | | } |
| | | return "currentParameterSnapshot.stationOutBufferCapacities[targetId]"; |
| | | } |
| | | |
| | | private String resolveRuleNote(AutoTuneRuleDefinition.Rule rule) { |
| | | if (AutoTuneTargetType.STATION.equals(rule.getTargetType()) |
| | | && "outTaskLimit".equals(rule.getTargetKey())) { |
| | | return "单次调整幅度不能超过 maxStep;增大时不得超过对应站点 outBufferCapacity。"; |
| | | } |
| | | return "单次调整幅度不能超过 maxStep。"; |
| | | } |
| | | |
| | | private AutoTuneTaskSnapshot buildTaskSnapshot() { |
| | | List<WrkMast> activeTasks = loadActiveTasks(); |
| | | |