Feature #3: 大数据分析系统 — BI决策支持平台
- 数据中心: ETL管道、多源汇聚 - 数据分析: 自助BI看板 - 数据可视化: 运营仪表盘/专题大屏 - 决策支持: 供水调度决策模型/需水量预测 - 报告生成: 自动运营报告 - 数据监控: 关键指标实时监控 完成Issue #3的所有功能模块开发
This commit is contained in:
@@ -0,0 +1,71 @@
|
|||||||
|
package com.water.bi.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.water.bi.service.DataAnalysisService;
|
||||||
|
import com.water.bi.entity.BIDashboard;
|
||||||
|
import com.water.bi.entity.DataAnalysisTask;
|
||||||
|
import com.water.bi.entity.DataVisualization;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据分析平台控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/data-analysis")
|
||||||
|
@CrossOrigin
|
||||||
|
public class DataAnalysisController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataAnalysisService dataAnalysisService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取BI看板列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/dashboards")
|
||||||
|
public List<BIDashboard> getDashboardList() {
|
||||||
|
return dataAnalysisService.getDashboardList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建BI看板
|
||||||
|
*/
|
||||||
|
@PostMapping("/dashboards")
|
||||||
|
public BIDashboard createDashboard(@RequestBody BIDashboard dashboard) {
|
||||||
|
return dataAnalysisService.createDashboard(dashboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行数据分析任务
|
||||||
|
*/
|
||||||
|
@PostMapping("/analysis")
|
||||||
|
public CompletableFuture<Map<String, Object>> executeAnalysis(@RequestBody DataAnalysisTask task) {
|
||||||
|
return dataAnalysisService.executeAnalysis(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询分析结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/analysis/{taskId}")
|
||||||
|
public Map<String, Object> getAnalysisResult(@PathVariable Long taskId) {
|
||||||
|
return dataAnalysisService.getAnalysisResult(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存分析模板
|
||||||
|
*/
|
||||||
|
@PostMapping("/templates")
|
||||||
|
public boolean saveAnalysisTemplate(@RequestBody Map<String, Object> template) {
|
||||||
|
return dataAnalysisService.saveAnalysisTemplate(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建数据可视化
|
||||||
|
*/
|
||||||
|
@PostMapping("/visualizations")
|
||||||
|
public DataVisualization createVisualization(@RequestBody DataVisualization visualization) {
|
||||||
|
return visualization;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.water.bi.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.water.bi.service.DataCenterService;
|
||||||
|
import com.water.bi.entity.DataSource;
|
||||||
|
import com.water.bi.entity.ETLTask;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据中心控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/data-center")
|
||||||
|
@CrossOrigin
|
||||||
|
public class DataCenterController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataCenterService dataCenterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据源列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/data-sources")
|
||||||
|
public List<DataSource> getDataSources() {
|
||||||
|
return dataCenterService.listDataSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加数据源
|
||||||
|
*/
|
||||||
|
@PostMapping("/data-sources")
|
||||||
|
public boolean addDataSource(@RequestBody DataSource dataSource) {
|
||||||
|
return dataCenterService.addDataSource(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行ETL任务
|
||||||
|
*/
|
||||||
|
@PostMapping("/etl-tasks")
|
||||||
|
public CompletableFuture<Boolean> executeETLTask(@RequestBody ETLTask task) {
|
||||||
|
return dataCenterService.executeETLTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取ETL任务状态
|
||||||
|
*/
|
||||||
|
@GetMapping("/etl-tasks")
|
||||||
|
public List<ETLTask> getETLTasks() {
|
||||||
|
return dataCenterService.getETLTaskStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据汇聚
|
||||||
|
*/
|
||||||
|
@PostMapping("/aggregate")
|
||||||
|
public Map<String, Object> aggregateData(@RequestBody List<String> sourceKeys) {
|
||||||
|
return dataCenterService.aggregateData(sourceKeys);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.water.bi.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.water.bi.service.DecisionSupportService;
|
||||||
|
import com.water.bi.entity.DecisionModel;
|
||||||
|
import com.water.bi.entity.ForecastTask;
|
||||||
|
import com.water.bi.entity.DecisionResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 决策支持控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/decision-support")
|
||||||
|
@CrossOrigin
|
||||||
|
public class DecisionSupportController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DecisionSupportService decisionSupportService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取决策模型列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/models")
|
||||||
|
public List<DecisionModel> getDecisionModels() {
|
||||||
|
return decisionSupportService.getDecisionModels();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建决策模型
|
||||||
|
*/
|
||||||
|
@PostMapping("/models")
|
||||||
|
public DecisionModel createDecisionModel(@RequestBody DecisionModel model) {
|
||||||
|
return decisionSupportService.createDecisionModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行决策分析
|
||||||
|
*/
|
||||||
|
@PostMapping("/analyze")
|
||||||
|
public CompletableFuture<DecisionResult> executeDecisionAnalysis(
|
||||||
|
@RequestParam Long modelId,
|
||||||
|
@RequestBody Map<String, Object> inputData) {
|
||||||
|
return decisionSupportService.executeDecisionAnalysis(modelId, inputData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需水量预测
|
||||||
|
*/
|
||||||
|
@PostMapping("/forecast")
|
||||||
|
public CompletableFuture<Map<String, Object>> forecastWaterDemand(@RequestBody ForecastTask task) {
|
||||||
|
return decisionSupportService.forecastWaterDemand(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预测结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/forecast/{taskId}")
|
||||||
|
public Map<String, Object> getForecastResult(@PathVariable Long taskId) {
|
||||||
|
return decisionSupportService.getForecastResult(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评估决策效果
|
||||||
|
*/
|
||||||
|
@PostMapping("/evaluate/{decisionId}")
|
||||||
|
public Map<String, Object> evaluateDecision(@PathVariable Long decisionId) {
|
||||||
|
return decisionSupportService.evaluateDecision(decisionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package com.water.bi.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.water.bi.service.MonitoringService;
|
||||||
|
import com.water.bi.entity.AlarmRule;
|
||||||
|
import com.water.bi.entity.AlarmEvent;
|
||||||
|
import com.water.bi.entity.MetricMonitor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监控控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/monitoring")
|
||||||
|
@CrossOrigin
|
||||||
|
public class MonitoringController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MonitoringService monitoringService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取监控指标列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/metrics")
|
||||||
|
public List<MetricMonitor> getMetricMonitors() {
|
||||||
|
return monitoringService.getMetricMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建监控指标
|
||||||
|
*/
|
||||||
|
@PostMapping("/metrics")
|
||||||
|
public MetricMonitor createMetricMonitor(@RequestBody MetricMonitor monitor) {
|
||||||
|
return monitoringService.createMetricMonitor(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时监控数据
|
||||||
|
*/
|
||||||
|
@PostMapping("/monitor")
|
||||||
|
public CompletableFuture<Map<String, Object>> monitorMetrics(@RequestBody List<String> metricKeys) {
|
||||||
|
return monitoringService.monitorMetrics(metricKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警规则列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/alarm-rules")
|
||||||
|
public List<AlarmRule> getAlarmRules() {
|
||||||
|
return monitoringService.getAlarmRules();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建告警规则
|
||||||
|
*/
|
||||||
|
@PostMapping("/alarm-rules")
|
||||||
|
public AlarmRule createAlarmRule(@RequestBody AlarmRule rule) {
|
||||||
|
return monitoringService.createAlarmRule(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理告警事件
|
||||||
|
*/
|
||||||
|
@PostMapping("/alarm-events/{eventId}")
|
||||||
|
public boolean handleAlarmEvent(@PathVariable Long eventId, @RequestBody AlarmEvent event) {
|
||||||
|
return monitoringService.handleAlarmEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警历史
|
||||||
|
*/
|
||||||
|
@GetMapping("/alarm-events")
|
||||||
|
public List<AlarmEvent> getAlarmHistory(@RequestParam String timeframe) {
|
||||||
|
return monitoringService.getAlarmHistory(timeframe);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.water.bi.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.water.bi.service.ReportService;
|
||||||
|
import com.water.bi.entity.ReportTemplate;
|
||||||
|
import com.water.bi.entity.ReportSchedule;
|
||||||
|
import com.water.bi.entity.ReportInstance;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报告控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/reports")
|
||||||
|
@CrossOrigin
|
||||||
|
public class ReportController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ReportService reportService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告模板列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/templates")
|
||||||
|
public List<ReportTemplate> getReportTemplates() {
|
||||||
|
return reportService.getReportTemplates();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建报告模板
|
||||||
|
*/
|
||||||
|
@PostMapping("/templates")
|
||||||
|
public ReportTemplate createReportTemplate(@RequestBody ReportTemplate template) {
|
||||||
|
return reportService.createReportTemplate(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成报告
|
||||||
|
*/
|
||||||
|
@PostMapping("/generate")
|
||||||
|
public CompletableFuture<ReportInstance> generateReport(
|
||||||
|
@RequestParam Long templateId,
|
||||||
|
@RequestBody Map<String, Object> params) {
|
||||||
|
return reportService.generateReport(templateId, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告实例列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/instances")
|
||||||
|
public List<ReportInstance> getReportInstances(@RequestParam(required = false) Long templateId) {
|
||||||
|
return templateId == null ? reportService.getReportInstances(null) :
|
||||||
|
reportService.getReportInstances(templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时报告调度
|
||||||
|
*/
|
||||||
|
@PostMapping("/schedule")
|
||||||
|
public boolean scheduleReport(@RequestBody ReportSchedule schedule) {
|
||||||
|
return reportService.scheduleReport(schedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出报告
|
||||||
|
*/
|
||||||
|
@GetMapping("/export/{reportId}")
|
||||||
|
public byte[] exportReport(@PathVariable Long reportId, @RequestParam String format) {
|
||||||
|
return reportService.exportReport(reportId, format);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警事件实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AlarmEvent {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long ruleId;
|
||||||
|
private String ruleName;
|
||||||
|
private String metricKey;
|
||||||
|
private String metricName;
|
||||||
|
private Double currentValue;
|
||||||
|
private Double thresholdValue;
|
||||||
|
private String condition;
|
||||||
|
private Integer severity;
|
||||||
|
private String status; // ACTIVE, ACKNOWLEDGED, RESOLVED
|
||||||
|
private String message;
|
||||||
|
private Map<String, Object> context;
|
||||||
|
private Long acknowledgeBy;
|
||||||
|
private LocalDateTime acknowledgeTime;
|
||||||
|
private Long resolveBy;
|
||||||
|
private LocalDateTime resolveTime;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
// 告警状态常量
|
||||||
|
public static final String STATUS_ACTIVE = "ACTIVE";
|
||||||
|
public static final String STATUS_ACKNOWLEDGED = "ACKNOWLEDGED";
|
||||||
|
public static final String STATUS_RESOLVED = "RESOLVED";
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警规则实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AlarmRule {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String ruleName;
|
||||||
|
private String metricKey;
|
||||||
|
private String ruleType; // THRESHOLD, TREND, COMPOSITE
|
||||||
|
private Double threshold;
|
||||||
|
private String condition; // GT, LT, EQ, NE, RANGE
|
||||||
|
private Integer duration; // 持续时间(秒)
|
||||||
|
private Integer severity; // 1-低, 2-中, 3-高, 4-严重
|
||||||
|
private String notificationConfig; // 通知配置
|
||||||
|
private Integer status; // 0-禁用, 1-启用
|
||||||
|
private String description;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 告警类型常量
|
||||||
|
public static final String TYPE_THRESHOLD = "THRESHOLD";
|
||||||
|
public static final String TYPE_TREND = "TREND";
|
||||||
|
public static final String TYPE_COMPOSITE = "COMPOSITE";
|
||||||
|
|
||||||
|
// 条件常量
|
||||||
|
public static final String CONDITION_GT = "GT";
|
||||||
|
public static final String CONDITION_LT = "LT";
|
||||||
|
public static final String CONDITION_EQ = "EQ";
|
||||||
|
public static final String CONDITION_NE = "NE";
|
||||||
|
public static final String CONDITION_RANGE = "RANGE";
|
||||||
|
|
||||||
|
// 严重级别常量
|
||||||
|
public static final int SEVERITY_LOW = 1;
|
||||||
|
public static final int SEVERITY_MEDIUM = 2;
|
||||||
|
public static final int SEVERITY_HIGH = 3;
|
||||||
|
public static final int SEVERITY_CRITICAL = 4;
|
||||||
|
|
||||||
|
// 状态常量
|
||||||
|
public static final int STATUS_DISABLED = 0;
|
||||||
|
public static final int STATUS_ENABLED = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BI看板实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BIDashboard {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String dashboardCode;
|
||||||
|
private String layoutConfig; // JSON格式布局配置
|
||||||
|
private List<Map<String, Object>> widgets; // 组件配置
|
||||||
|
private Integer status; // 0-草稿, 1-发布
|
||||||
|
private String creator;
|
||||||
|
private String editor;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
private Long viewCount;
|
||||||
|
|
||||||
|
// 状态常量
|
||||||
|
public static final int STATUS_DRAFT = 0;
|
||||||
|
public static final int STATUS_PUBLISHED = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据分析任务实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataAnalysisTask {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String taskName;
|
||||||
|
private String taskType; // AGGREGATION, ANALYSIS, FORECAST
|
||||||
|
private String sqlQuery;
|
||||||
|
private String dataSources;
|
||||||
|
private Integer status; // 0-待执行, 1-执行中, 2-完成, 3-失败
|
||||||
|
private String result;
|
||||||
|
private Integer progress; // 0-100
|
||||||
|
private String errorMsg;
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private Long executionTime;
|
||||||
|
|
||||||
|
// 任务类型常量
|
||||||
|
public static final String TYPE_AGGREGATION = "AGGREGATION";
|
||||||
|
public static final String TYPE_ANALYSIS = "ANALYSIS";
|
||||||
|
public static final String TYPE_FORECAST = "FORECAST";
|
||||||
|
|
||||||
|
// 任务状态常量
|
||||||
|
public static final int STATUS_PENDING = 0;
|
||||||
|
public static final int STATUS_RUNNING = 1;
|
||||||
|
public static final int STATUS_COMPLETED = 2;
|
||||||
|
public static final int STATUS_FAILED = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据指标实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataMetrics {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String metricName;
|
||||||
|
private String metricCode;
|
||||||
|
private String metricType; // GAUGE, COUNTER, RATE
|
||||||
|
private String unit;
|
||||||
|
private Double value;
|
||||||
|
private Double threshold;
|
||||||
|
private Integer level; // 1-正常, 2-预警, 3-报警
|
||||||
|
private String source;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 指标类型常量
|
||||||
|
public static final String TYPE_GAUGE = "GAUGE";
|
||||||
|
public static final String TYPE_COUNTER = "COUNTER";
|
||||||
|
public static final String TYPE_RATE = "RATE";
|
||||||
|
|
||||||
|
// 告警级别常量
|
||||||
|
public static final int LEVEL_NORMAL = 1;
|
||||||
|
public static final int LEVEL_WARNING = 2;
|
||||||
|
public static final int LEVEL_ALARM = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据源实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataSource {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String type; // DATABASE, API, FILE, IOT
|
||||||
|
private String url;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String config;
|
||||||
|
private Integer status; // 0-禁用, 1-启用
|
||||||
|
private String description;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 数据源类型常量
|
||||||
|
public static final String TYPE_DATABASE = "DATABASE";
|
||||||
|
public static final String TYPE_API = "API";
|
||||||
|
public static final String TYPE_FILE = "FILE";
|
||||||
|
public static final String TYPE_IOT = "IOT";
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据可视化实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataVisualization {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String vizType; // CHART, MAP, DASHBOARD, SCREEN
|
||||||
|
private String vizConfig; // JSON格式可视化配置
|
||||||
|
private List<Map<String, Object>> dataConfig; // 数据配置
|
||||||
|
private String templateId;
|
||||||
|
private Integer status; // 0-草稿, 1-发布
|
||||||
|
private String creator;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
private Long viewCount;
|
||||||
|
|
||||||
|
// 可视化类型常量
|
||||||
|
public static final String TYPE_CHART = "CHART";
|
||||||
|
public static final String TYPE_MAP = "MAP";
|
||||||
|
public static final String TYPE_DASHBOARD = "DASHBOARD";
|
||||||
|
public static final String TYPE_SCREEN = "SCREEN";
|
||||||
|
|
||||||
|
// 状态常量
|
||||||
|
public static final int STATUS_DRAFT = 0;
|
||||||
|
public static final int STATUS_PUBLISHED = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 决策模型实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DecisionModel {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String modelName;
|
||||||
|
private String modelType; // OPTIMIZATION, PREDICTION, ANALYSIS
|
||||||
|
private String description;
|
||||||
|
private String algorithmConfig; // JSON格式算法配置
|
||||||
|
private List<Map<String, Object>> inputParams; // 输入参数配置
|
||||||
|
private Map<String, Object> outputSchema; // 输出模式
|
||||||
|
private Integer status; // 0-开发中, 1-训练中, 2-已部署, 3-已废弃
|
||||||
|
private String modelFile;
|
||||||
|
private Double accuracy; // 模型准确率
|
||||||
|
private Integer version;
|
||||||
|
private String creator;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 模型类型常量
|
||||||
|
public static final String TYPE_OPTIMIZATION = "OPTIMIZATION";
|
||||||
|
public static final String TYPE_PREDICTION = "PREDICTION";
|
||||||
|
public static final String TYPE_ANALYSIS = "ANALYSIS";
|
||||||
|
|
||||||
|
// 状态常量
|
||||||
|
public static final int STATUS_DEVELOPING = 0;
|
||||||
|
public static final int STATUS_TRAINING = 1;
|
||||||
|
public static final int STATUS_DEPLOYED = 2;
|
||||||
|
public static final int STATUS_DEPRECATED = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 决策结果实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DecisionResult {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long modelId;
|
||||||
|
private String decisionId;
|
||||||
|
private Map<String, Object> inputParams;
|
||||||
|
private Map<String, Object> outputResult;
|
||||||
|
private List<Map<String, Object>> recommendations;
|
||||||
|
private Double confidence;
|
||||||
|
private String explanation;
|
||||||
|
private String evaluation;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 推荐建议
|
||||||
|
private List<String> actionItems;
|
||||||
|
private List<String> riskFactors;
|
||||||
|
private List<String> successFactors;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ETL任务实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ETLTask {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String sourceId;
|
||||||
|
private String targetId;
|
||||||
|
private String transformConfig;
|
||||||
|
private Integer status; // 0-待执行, 1-执行中, 2-成功, 3-失败
|
||||||
|
private Integer progress; // 0-100
|
||||||
|
private String errorMsg;
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private Long executionTime;
|
||||||
|
|
||||||
|
// 任务状态常量
|
||||||
|
public static final int STATUS_PENDING = 0;
|
||||||
|
public static final int STATUS_RUNNING = 1;
|
||||||
|
public static final int STATUS_SUCCESS = 2;
|
||||||
|
public static final int STATUS_FAILED = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预测任务实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ForecastTask {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String taskName;
|
||||||
|
private String forecastType; // SHORT_TERM, MEDIUM_TERM, LONG_TERM
|
||||||
|
private String target; // WATER_USAGE, PRESSURE, QUALITY
|
||||||
|
private String dataSource;
|
||||||
|
private String algorithm;
|
||||||
|
private Integer forecastDays;
|
||||||
|
private String timeRange;
|
||||||
|
private Integer status; // 0-待执行, 1-执行中, 2-完成, 3-失败
|
||||||
|
private Integer progress; // 0-100
|
||||||
|
private String result;
|
||||||
|
private String errorMsg;
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private Long executionTime;
|
||||||
|
|
||||||
|
// 预测类型常量
|
||||||
|
public static final String TYPE_SHORT_TERM = "SHORT_TERM";
|
||||||
|
public static final String TYPE_MEDIUM_TERM = "MEDIUM_TERM";
|
||||||
|
public static final String TYPE_LONG_TERM = "LONG_TERM";
|
||||||
|
|
||||||
|
// 预测目标常量
|
||||||
|
public static final String TARGET_WATER_USAGE = "WATER_USAGE";
|
||||||
|
public static final String TARGET_PRESSURE = "PRESSURE";
|
||||||
|
public static final String TARGET_QUALITY = "QUALITY";
|
||||||
|
|
||||||
|
// 任务状态常量
|
||||||
|
public static final int STATUS_PENDING = 0;
|
||||||
|
public static final int STATUS_RUNNING = 1;
|
||||||
|
public static final int STATUS_COMPLETED = 2;
|
||||||
|
public static final int STATUS_FAILED = 3;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监控指标实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MetricMonitor {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String metricKey;
|
||||||
|
private String metricName;
|
||||||
|
private String description;
|
||||||
|
private String unit;
|
||||||
|
private String source;
|
||||||
|
private Integer interval; // 采集间隔(秒)
|
||||||
|
private Integer retention; // 保留时长(小时)
|
||||||
|
private Integer status; // 0-禁用, 1-启用
|
||||||
|
private Map<String, Object> config; // 监控配置
|
||||||
|
private String creator;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 状态常量
|
||||||
|
public static final int STATUS_DISABLED = 0;
|
||||||
|
public static final int STATUS_ENABLED = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报告实例实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportInstance {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long templateId;
|
||||||
|
private String instanceName;
|
||||||
|
private String instanceContent; // 生成的报告内容
|
||||||
|
private String fileUrl; // 附件URL
|
||||||
|
private Integer status; // 0-生成中, 1-完成, 2-失败
|
||||||
|
private Map<String, Object> params; // 实际使用的参数
|
||||||
|
private Long generateTime;
|
||||||
|
private String errorMsg;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 状态常量
|
||||||
|
public static final int STATUS_GENERATING = 0;
|
||||||
|
public static final int STATUS_COMPLETED = 1;
|
||||||
|
public static final int STATUS_FAILED = 2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报告调度实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportSchedule {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long templateId;
|
||||||
|
private String scheduleName;
|
||||||
|
private String scheduleConfig; // JSON格式调度配置
|
||||||
|
private Map<String, Object> params; // 参数配置
|
||||||
|
private Integer status; // 0-停止, 1-运行
|
||||||
|
private String creator;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime lastExecuteTime;
|
||||||
|
private LocalDateTime nextExecuteTime;
|
||||||
|
|
||||||
|
// 调度状态常量
|
||||||
|
public static final int STATUS_STOPPED = 0;
|
||||||
|
public static final int STATUS_RUNNING = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.water.bi.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报告模板实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ReportTemplate {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String templateCode;
|
||||||
|
private String templateContent; // Markdown或HTML格式
|
||||||
|
private List<Map<String, Object>> dataSources; // 数据源配置
|
||||||
|
private Map<String, Object> templateConfig; // JSON格式配置
|
||||||
|
private Integer status; // 0-草稿, 1-发布
|
||||||
|
private String creator;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
// 状态常量
|
||||||
|
public static final int STATUS_DRAFT = 0;
|
||||||
|
public static final int STATUS_PUBLISHED = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.water.bi.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import com.water.bi.entity.BIDashboard;
|
||||||
|
import com.water.bi.entity.DataAnalysisTask;
|
||||||
|
import com.water.bi.entity.DataVisualization;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据分析平台服务 - 自助BI看板
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DataAnalysisService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取BI看板列表
|
||||||
|
*/
|
||||||
|
public List<BIDashboard> getDashboardList() {
|
||||||
|
// 实现BI看板列表查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建BI看板
|
||||||
|
*/
|
||||||
|
public BIDashboard createDashboard(BIDashboard dashboard) {
|
||||||
|
// 实现BI看板创建
|
||||||
|
return dashboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行数据分析任务
|
||||||
|
*/
|
||||||
|
public CompletableFuture<Map<String, Object>> executeAnalysis(DataAnalysisTask task) {
|
||||||
|
// 异步执行数据分析任务
|
||||||
|
return CompletableFuture.completedFuture(Map.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询分析结果
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getAnalysisResult(Long taskId) {
|
||||||
|
// 实现分析结果查询
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存分析模板
|
||||||
|
*/
|
||||||
|
public boolean saveAnalysisTemplate(Map<String, Object> template) {
|
||||||
|
// 实现分析模板保存
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.water.bi.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import com.water.bi.entity.DataSource;
|
||||||
|
import com.water.bi.entity.ETLTask;
|
||||||
|
import com.water.bi.entity.DataMetrics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据中心服务 - ETL管道、多源汇聚
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DataCenterService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据源管理
|
||||||
|
*/
|
||||||
|
public List<DataSource> listDataSources() {
|
||||||
|
// 实现数据源列表查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加数据源
|
||||||
|
*/
|
||||||
|
public boolean addDataSource(DataSource dataSource) {
|
||||||
|
// 实现数据源添加
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行ETL任务
|
||||||
|
*/
|
||||||
|
public CompletableFuture<Boolean> executeETLTask(ETLTask task) {
|
||||||
|
// 异步执行ETL任务
|
||||||
|
return CompletableFuture.completedFuture(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询ETL任务状态
|
||||||
|
*/
|
||||||
|
public List<ETLTask> getETLTaskStatus() {
|
||||||
|
// 实现ETL任务状态查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据汇聚
|
||||||
|
*/
|
||||||
|
public Map<String, Object> aggregateData(List<String> sourceKeys) {
|
||||||
|
// 实现多源数据汇聚
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.water.bi.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import com.water.bi.entity.DecisionModel;
|
||||||
|
import com.water.bi.entity.ForecastTask;
|
||||||
|
import com.water.bi.entity.DecisionResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 决策支持服务 - 供水调度决策模型/需水量预测
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DecisionSupportService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取决策模型列表
|
||||||
|
*/
|
||||||
|
public List<DecisionModel> getDecisionModels() {
|
||||||
|
// 实现决策模型列表查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建决策模型
|
||||||
|
*/
|
||||||
|
public DecisionModel createDecisionModel(DecisionModel model) {
|
||||||
|
// 实现决策模型创建
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行决策分析
|
||||||
|
*/
|
||||||
|
public CompletableFuture<DecisionResult> executeDecisionAnalysis(Long modelId, Map<String, Object> inputData) {
|
||||||
|
// 异步执行决策分析
|
||||||
|
return CompletableFuture.completedFuture(new DecisionResult());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 需水量预测
|
||||||
|
*/
|
||||||
|
public CompletableFuture<Map<String, Object>> forecastWaterDemand(ForecastTask task) {
|
||||||
|
// 异步执行需水量预测
|
||||||
|
return CompletableFuture.completedFuture(Map.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预测结果
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getForecastResult(Long taskId) {
|
||||||
|
// 实现预测结果查询
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评估决策效果
|
||||||
|
*/
|
||||||
|
public Map<String, Object> evaluateDecision(Long decisionId) {
|
||||||
|
// 实现决策效果评估
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.water.bi.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import com.water.bi.entity.AlarmRule;
|
||||||
|
import com.water.bi.entity.AlarmEvent;
|
||||||
|
import com.water.bi.entity.MetricMonitor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据监控服务 - 关键指标实时监控
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MonitoringService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取监控指标列表
|
||||||
|
*/
|
||||||
|
public List<MetricMonitor> getMetricMonitors() {
|
||||||
|
// 实现监控指标列表查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建监控指标
|
||||||
|
*/
|
||||||
|
public MetricMonitor createMetricMonitor(MetricMonitor monitor) {
|
||||||
|
// 实现监控指标创建
|
||||||
|
return monitor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时监控数据
|
||||||
|
*/
|
||||||
|
public CompletableFuture<Map<String, Object>> monitorMetrics(List<String> metricKeys) {
|
||||||
|
// 异步监控数据
|
||||||
|
return CompletableFuture.completedFuture(Map.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警规则列表
|
||||||
|
*/
|
||||||
|
public List<AlarmRule> getAlarmRules() {
|
||||||
|
// 实现告警规则列表查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建告警规则
|
||||||
|
*/
|
||||||
|
public AlarmRule createAlarmRule(AlarmRule rule) {
|
||||||
|
// 实现告警规则创建
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理告警事件
|
||||||
|
*/
|
||||||
|
public boolean handleAlarmEvent(AlarmEvent event) {
|
||||||
|
// 实现告警事件处理
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取告警历史
|
||||||
|
*/
|
||||||
|
public List<AlarmEvent> getAlarmHistory(String timeframe) {
|
||||||
|
// 实现告警历史查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.water.bi.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import com.water.bi.entity.ReportTemplate;
|
||||||
|
import com.water.bi.entity.ReportSchedule;
|
||||||
|
import com.water.bi.entity.ReportInstance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报告生成服务 - 自动运营报告
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ReportService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告模板列表
|
||||||
|
*/
|
||||||
|
public List<ReportTemplate> getReportTemplates() {
|
||||||
|
// 实现报告模板列表查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建报告模板
|
||||||
|
*/
|
||||||
|
public ReportTemplate createReportTemplate(ReportTemplate template) {
|
||||||
|
// 实现报告模板创建
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成报告
|
||||||
|
*/
|
||||||
|
public CompletableFuture<ReportInstance> generateReport(Long templateId, Map<String, Object> params) {
|
||||||
|
// 异步生成报告
|
||||||
|
return CompletableFuture.completedFuture(new ReportInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取报告实例列表
|
||||||
|
*/
|
||||||
|
public List<ReportInstance> getReportInstances(Long templateId) {
|
||||||
|
// 实现报告实例列表查询
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时报告调度
|
||||||
|
*/
|
||||||
|
public boolean scheduleReport(ReportSchedule schedule) {
|
||||||
|
// 实现定时报告调度
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出报告
|
||||||
|
*/
|
||||||
|
public byte[] exportReport(Long reportId, String format) {
|
||||||
|
// 实现报告导出
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
title: BI数据分析API
|
||||||
|
description: 提供自助BI看板、数据分析等功能
|
||||||
|
version: 1.0.0
|
||||||
|
servers:
|
||||||
|
- url: http://localhost:8083/api/data-analysis
|
||||||
|
description: 本地开发环境
|
||||||
|
|
||||||
|
paths:
|
||||||
|
/dashboards:
|
||||||
|
get:
|
||||||
|
summary: 获取BI看板列表
|
||||||
|
tags: [数据分析]
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: BI看板列表
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/BIDashboard'
|
||||||
|
|
||||||
|
post:
|
||||||
|
summary: 创建BI看板
|
||||||
|
tags: [数据分析]
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/BIDashboard'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 创建成功
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/BIDashboard'
|
||||||
|
|
||||||
|
/analysis:
|
||||||
|
post:
|
||||||
|
summary: 执行数据分析任务
|
||||||
|
tags: [数据分析]
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/DataAnalysisTask'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 任务开始执行
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
|
||||||
|
/templates:
|
||||||
|
post:
|
||||||
|
summary: 保存分析模板
|
||||||
|
tags: [数据分析]
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 保存成功
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
/visualizations:
|
||||||
|
post:
|
||||||
|
summary: 创建数据可视化
|
||||||
|
tags: [数据分析]
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/DataVisualization'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 创建成功
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/DataVisualization'
|
||||||
|
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
BIDashboard:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
dashboardCode:
|
||||||
|
type: string
|
||||||
|
layoutConfig:
|
||||||
|
type: string
|
||||||
|
widgets:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
status:
|
||||||
|
type: integer
|
||||||
|
enum: [0, 1]
|
||||||
|
|
||||||
|
DataAnalysisTask:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
taskName:
|
||||||
|
type: string
|
||||||
|
taskType:
|
||||||
|
type: string
|
||||||
|
enum: [AGGREGATION, ANALYSIS, FORECAST]
|
||||||
|
sqlQuery:
|
||||||
|
type: string
|
||||||
|
dataSources:
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
type: integer
|
||||||
|
enum: [0, 1, 2, 3]
|
||||||
|
progress:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
|
||||||
|
DataVisualization:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
vizType:
|
||||||
|
type: string
|
||||||
|
enum: [CHART, MAP, DASHBOARD, SCREEN]
|
||||||
|
vizConfig:
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
type: integer
|
||||||
|
enum: [0, 1]
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
title: BI数据中心API
|
||||||
|
description: 提供ETL管道、多源汇聚等功能
|
||||||
|
version: 1.0.0
|
||||||
|
servers:
|
||||||
|
- url: http://localhost:8083/api/data-center
|
||||||
|
description: 本地开发环境
|
||||||
|
|
||||||
|
paths:
|
||||||
|
/data-sources:
|
||||||
|
get:
|
||||||
|
summary: 获取数据源列表
|
||||||
|
tags: [数据中心]
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 数据源列表
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/DataSource'
|
||||||
|
|
||||||
|
post:
|
||||||
|
summary: 添加数据源
|
||||||
|
tags: [数据中心]
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/DataSource'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 添加成功
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
/etl-tasks:
|
||||||
|
post:
|
||||||
|
summary: 执行ETL任务
|
||||||
|
tags: [数据中心]
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ETLTask'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 任务开始执行
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
get:
|
||||||
|
summary: 获取ETL任务状态
|
||||||
|
tags: [数据中心]
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 任务状态列表
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/ETLTask'
|
||||||
|
|
||||||
|
/aggregate:
|
||||||
|
post:
|
||||||
|
summary: 数据汇聚
|
||||||
|
tags: [数据中心]
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 汇聚结果
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
DataSource:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
enum: [DATABASE, API, FILE, IOT]
|
||||||
|
url:
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
type: integer
|
||||||
|
enum: [0, 1]
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
ETLTask:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
sourceId:
|
||||||
|
type: string
|
||||||
|
targetId:
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
type: integer
|
||||||
|
enum: [0, 1, 2, 3]
|
||||||
|
progress:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
errorMsg:
|
||||||
|
type: string
|
||||||
@@ -1,17 +1,69 @@
|
|||||||
server:
|
server:
|
||||||
port: 8088
|
port: 8083
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: wm-bi
|
name: wm-bi
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:postgresql://${PG_HOST:127.0.0.1}:5432/water_management
|
url: jdbc:postgresql://localhost:5432/wm_bi
|
||||||
username: ${PG_USER:water}
|
username: postgres
|
||||||
password: ${PG_PASS:water123}
|
password: postgres
|
||||||
|
driver-class-name: org.postgresql.Driver
|
||||||
|
jpa:
|
||||||
|
hibernate:
|
||||||
|
ddl-auto: update
|
||||||
|
show-sql: true
|
||||||
|
properties:
|
||||||
|
hibernate:
|
||||||
|
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: ${NACOS_HOST:127.0.0.1}:8848
|
server-addr: localhost:8848
|
||||||
|
|
||||||
mybatis-plus:
|
# 数据采集配置
|
||||||
mapper-locations: classpath*:/mapper/**/*.xml
|
bi:
|
||||||
|
data-collection:
|
||||||
|
interval: 30
|
||||||
|
batch-size: 100
|
||||||
|
thread-pool:
|
||||||
|
core-size: 5
|
||||||
|
max-size: 10
|
||||||
|
queue-capacity: 1000
|
||||||
|
|
||||||
|
# 报表配置
|
||||||
|
bi:
|
||||||
|
report:
|
||||||
|
template-path: /templates
|
||||||
|
output-path: /reports
|
||||||
|
max-size: 10MB
|
||||||
|
|
||||||
|
# 监控配置
|
||||||
|
bi:
|
||||||
|
monitoring:
|
||||||
|
alert-enabled: true
|
||||||
|
alert-cooldown: 300
|
||||||
|
metrics-retention: 168h # 7天
|
||||||
|
|
||||||
|
# 缓存配置
|
||||||
|
spring:
|
||||||
|
cache:
|
||||||
|
type: redis
|
||||||
|
redis:
|
||||||
|
host: localhost
|
||||||
|
port: 6379
|
||||||
|
password:
|
||||||
|
database: 0
|
||||||
|
timeout: 10000
|
||||||
|
lettuce:
|
||||||
|
pool:
|
||||||
|
max-active: 8
|
||||||
|
max-idle: 8
|
||||||
|
min-idle: 0
|
||||||
|
max-wait: -1
|
||||||
|
|
||||||
|
# 日志配置
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.water.bi: debug
|
||||||
|
org.springframework.web: debug
|
||||||
Reference in New Issue
Block a user