|
|
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|
10
|
10
|
|
|
11
|
11
|
import java.time.LocalDate;
|
|
12
|
12
|
import java.time.LocalDateTime;
|
|
|
13
|
+import java.time.format.DateTimeFormatter;
|
|
13
|
14
|
import java.util.*;
|
|
14
|
15
|
|
|
15
|
16
|
@Service
|
|
|
@@ -18,9 +19,293 @@ public class ReportService {
|
|
18
|
19
|
|
|
19
|
20
|
private final DataReportMapper reportMapper;
|
|
20
|
21
|
private final ReportTemplateMapper templateMapper;
|
|
|
22
|
+ private final DataStatisticsService dataStatisticsService;
|
|
21
|
23
|
|
|
22
|
24
|
/**
|
|
23
|
|
- * 自动生成报表
|
|
|
25
|
+ * 生成水量汇总报表
|
|
|
26
|
+ */
|
|
|
27
|
+ public DataReport generateWaterVolumeReport(String period, String startTime, String endTime) {
|
|
|
28
|
+ DataReport report = new DataReport();
|
|
|
29
|
+ report.setReportName("水量汇总报表");
|
|
|
30
|
+ report.setReportCode("WATER-VOL-" + System.currentTimeMillis());
|
|
|
31
|
+ report.setReportType("water_volume");
|
|
|
32
|
+ report.setDataType("water_supply");
|
|
|
33
|
+ report.setArea("ALL");
|
|
|
34
|
+
|
|
|
35
|
+ try {
|
|
|
36
|
+ // 设置时间范围
|
|
|
37
|
+ LocalDate start = startTime != null ? LocalDate.parse(startTime.substring(0, 10)) : LocalDate.now().minusDays(7);
|
|
|
38
|
+ LocalDate end = endTime != null ? LocalDate.parse(endTime.substring(0, 10)) : LocalDate.now();
|
|
|
39
|
+ report.setPeriodStart(start);
|
|
|
40
|
+ report.setPeriodEnd(end);
|
|
|
41
|
+
|
|
|
42
|
+ // 获取水量汇总数据
|
|
|
43
|
+ Map<String, Object> waterVolumeData = dataStatisticsService.getWaterVolumeSummary(startTime, endTime);
|
|
|
44
|
+
|
|
|
45
|
+ Map<String, Object> content = new LinkedHashMap<>();
|
|
|
46
|
+ content.put("generatedAt", LocalDateTime.now());
|
|
|
47
|
+ content.put("period", period);
|
|
|
48
|
+ content.put("startTime", startTime);
|
|
|
49
|
+ content.put("endTime", endTime);
|
|
|
50
|
+
|
|
|
51
|
+ // 基础统计
|
|
|
52
|
+ content.put("totalWaterSupply", waterVolumeData.get("totalSupply"));
|
|
|
53
|
+ content.put("totalAreaCount", ((List<?>) waterVolumeData.get("areaSupplyStats")).size());
|
|
|
54
|
+
|
|
|
55
|
+ // 分区域供水量统计
|
|
|
56
|
+ content.put("areaWaterSupply", waterVolumeData.get("areaSupplyStats"));
|
|
|
57
|
+
|
|
|
58
|
+ // 每日趋势数据
|
|
|
59
|
+ content.put("dailyTrend", waterVolumeData.get("dailyTrend"));
|
|
|
60
|
+
|
|
|
61
|
+ // 计算平均日供水量
|
|
|
62
|
+ List<Map<String, Object>> dailyTrend = (List<Map<String, Object>>) waterVolumeData.get("dailyTrend");
|
|
|
63
|
+ if (dailyTrend != null && !dailyTrend.isEmpty()) {
|
|
|
64
|
+ double totalDailySupply = dailyTrend.stream()
|
|
|
65
|
+ .mapToDouble(day -> (double) day.getOrDefault("dailySupply", 0.0))
|
|
|
66
|
+ .sum();
|
|
|
67
|
+ double avgDailySupply = totalDailySupply / dailyTrend.size();
|
|
|
68
|
+ content.put("avgDailySupply", avgDailySupply);
|
|
|
69
|
+ }
|
|
|
70
|
+
|
|
|
71
|
+ // 生成摘要
|
|
|
72
|
+ Map<String, Object> summary = new LinkedHashMap<>();
|
|
|
73
|
+ summary.put("totalSupply", waterVolumeData.get("totalSupply"));
|
|
|
74
|
+ summary.put("avgDailySupply", content.get("avgDailySupply"));
|
|
|
75
|
+ summary.put("areaCount", ((List<?>) waterVolumeData.get("areaSupplyStats")).size());
|
|
|
76
|
+
|
|
|
77
|
+ report.setContent(content);
|
|
|
78
|
+ report.setSummary(summary);
|
|
|
79
|
+ report.setStatus("GENERATED");
|
|
|
80
|
+ report.setGeneratedBy("bot_dev1");
|
|
|
81
|
+
|
|
|
82
|
+ reportMapper.insert(report);
|
|
|
83
|
+
|
|
|
84
|
+ log.info("生成水量汇总报表成功: reportCode={}, period={}", report.getReportCode(), period);
|
|
|
85
|
+
|
|
|
86
|
+ return report;
|
|
|
87
|
+
|
|
|
88
|
+ } catch (Exception e) {
|
|
|
89
|
+ log.error("生成水量汇总报表失败: {}", e.getMessage());
|
|
|
90
|
+ throw new RuntimeException("水量汇总报表生成失败: " + e.getMessage());
|
|
|
91
|
+ }
|
|
|
92
|
+ }
|
|
|
93
|
+
|
|
|
94
|
+ /**
|
|
|
95
|
+ * 生成水质合格率报表
|
|
|
96
|
+ */
|
|
|
97
|
+ public DataReport generateWaterQualityReport(String period, String startTime, String endTime) {
|
|
|
98
|
+ DataReport report = new DataReport();
|
|
|
99
|
+ report.setReportName("水质合格率报表");
|
|
|
100
|
+ report.setReportCode("WATER-QUAL-" + System.currentTimeMillis());
|
|
|
101
|
+ report.setReportType("water_quality");
|
|
|
102
|
+ report.setDataType("water_quality");
|
|
|
103
|
+ report.setArea("ALL");
|
|
|
104
|
+
|
|
|
105
|
+ try {
|
|
|
106
|
+ // 设置时间范围
|
|
|
107
|
+ LocalDate start = startTime != null ? LocalDate.parse(startTime.substring(0, 10)) : LocalDate.now().minusDays(7);
|
|
|
108
|
+ LocalDate end = endTime != null ? LocalDate.parse(endTime.substring(0, 10)) : LocalDate.now();
|
|
|
109
|
+ report.setPeriodStart(start);
|
|
|
110
|
+ report.setPeriodEnd(end);
|
|
|
111
|
+
|
|
|
112
|
+ // 获取水质合格率数据
|
|
|
113
|
+ Map<String, Object> qualityData = dataStatisticsService.getWaterQualityRate(startTime, endTime);
|
|
|
114
|
+
|
|
|
115
|
+ Map<String, Object> content = new LinkedHashMap<>();
|
|
|
116
|
+ content.put("generatedAt", LocalDateTime.now());
|
|
|
117
|
+ content.put("period", period);
|
|
|
118
|
+ content.put("startTime", startTime);
|
|
|
119
|
+ content.put("endTime", endTime);
|
|
|
120
|
+
|
|
|
121
|
+ // 基础统计
|
|
|
122
|
+ content.put("totalTests", qualityData.get("totalTests"));
|
|
|
123
|
+ content.put("passedTests", qualityData.get("passedTests"));
|
|
|
124
|
+ content.put("passRate", qualityData.get("passRate"));
|
|
|
125
|
+
|
|
|
126
|
+ // 分区域合格率
|
|
|
127
|
+ content.put("areaQualityStats", qualityData.get("areaQualityStats"));
|
|
|
128
|
+
|
|
|
129
|
+ // 生成摘要
|
|
|
130
|
+ Map<String, Object> summary = new LinkedHashMap<>();
|
|
|
131
|
+ summary.put("totalTests", qualityData.get("totalTests"));
|
|
|
132
|
+ summary.put("passedTests", qualityData.get("passedTests"));
|
|
|
133
|
+ summary.put("passRate", qualityData.get("passRate"));
|
|
|
134
|
+ summary.put("areaCount", ((List<?>) qualityData.get("areaQualityStats")).size());
|
|
|
135
|
+
|
|
|
136
|
+ report.setContent(content);
|
|
|
137
|
+ report.setSummary(summary);
|
|
|
138
|
+ report.setStatus("GENERATED");
|
|
|
139
|
+ report.setGeneratedBy("bot_dev1");
|
|
|
140
|
+
|
|
|
141
|
+ reportMapper.insert(report);
|
|
|
142
|
+
|
|
|
143
|
+ log.info("生成水质合格率报表成功: reportCode={}, period={}", report.getReportCode(), period);
|
|
|
144
|
+
|
|
|
145
|
+ return report;
|
|
|
146
|
+
|
|
|
147
|
+ } catch (Exception e) {
|
|
|
148
|
+ log.error("生成水质合格率报表失败: {}", e.getMessage());
|
|
|
149
|
+ throw new RuntimeException("水质合格率报表生成失败: " + e.getMessage());
|
|
|
150
|
+ }
|
|
|
151
|
+ }
|
|
|
152
|
+
|
|
|
153
|
+ /**
|
|
|
154
|
+ * 生成报警统计报表
|
|
|
155
|
+ */
|
|
|
156
|
+ public DataReport generateAlarmStatisticsReport(String period, String startTime, String endTime) {
|
|
|
157
|
+ DataReport report = new DataReport();
|
|
|
158
|
+ report.setReportName("报警统计报表");
|
|
|
159
|
+ report.setReportCode("ALARM-STAT-" + System.currentTimeMillis());
|
|
|
160
|
+ report.setReportType("alarm_statistics");
|
|
|
161
|
+ report.setDataType("alarm");
|
|
|
162
|
+ report.setArea("ALL");
|
|
|
163
|
+
|
|
|
164
|
+ try {
|
|
|
165
|
+ // 设置时间范围
|
|
|
166
|
+ LocalDate start = startTime != null ? LocalDate.parse(startTime.substring(0, 10)) : LocalDate.now().minusDays(7);
|
|
|
167
|
+ LocalDate end = endTime != null ? LocalDate.parse(endTime.substring(0, 10)) : LocalDate.now();
|
|
|
168
|
+ report.setPeriodStart(start);
|
|
|
169
|
+ report.setPeriodEnd(end);
|
|
|
170
|
+
|
|
|
171
|
+ // 获取报警统计数据
|
|
|
172
|
+ Map<String, Object> alarmData = dataStatisticsService.getAlarmStatistics(startTime, endTime);
|
|
|
173
|
+
|
|
|
174
|
+ Map<String, Object> content = new LinkedHashMap<>();
|
|
|
175
|
+ content.put("generatedAt", LocalDateTime.now());
|
|
|
176
|
+ content.put("period", period);
|
|
|
177
|
+ content.put("startTime", startTime);
|
|
|
178
|
+ content.put("endTime", endTime);
|
|
|
179
|
+
|
|
|
180
|
+ // 基础统计
|
|
|
181
|
+ content.put("totalAlarms", alarmData.get("totalAlarms"));
|
|
|
182
|
+
|
|
|
183
|
+ // 按级别统计
|
|
|
184
|
+ content.put("levelStatistics", alarmData.get("levelStatistics"));
|
|
|
185
|
+
|
|
|
186
|
+ // 按区域统计
|
|
|
187
|
+ content.put("areaAlarmStats", alarmData.get("areaAlarmStats"));
|
|
|
188
|
+
|
|
|
189
|
+ // 每日趋势
|
|
|
190
|
+ content.put("dailyAlarmTrend", alarmData.get("dailyAlarmTrend"));
|
|
|
191
|
+
|
|
|
192
|
+ // 计算最严重区域
|
|
|
193
|
+ List<Map<String, Object>> areaStats = (List<Map<String, Object>>) alarmData.get("areaAlarmStats");
|
|
|
194
|
+ if (areaStats != null && !areaStats.isEmpty()) {
|
|
|
195
|
+ String worstArea = areaStats.stream()
|
|
|
196
|
+ .max(Comparator.comparingInt(area -> (int) area.get("alarmCount")))
|
|
|
197
|
+ .map(area -> (String) area.get("area"))
|
|
|
198
|
+ .orElse("N/A");
|
|
|
199
|
+ content.put("worstArea", worstArea);
|
|
|
200
|
+ }
|
|
|
201
|
+
|
|
|
202
|
+ // 生成摘要
|
|
|
203
|
+ Map<String, Object> summary = new LinkedHashMap<>();
|
|
|
204
|
+ summary.put("totalAlarms", alarmData.get("totalAlarms"));
|
|
|
205
|
+ summary.put("areaCount", areaStats != null ? areaStats.size() : 0);
|
|
|
206
|
+ summary.put("worstArea", content.get("worstArea"));
|
|
|
207
|
+
|
|
|
208
|
+ report.setContent(content);
|
|
|
209
|
+ report.setSummary(summary);
|
|
|
210
|
+ report.setStatus("GENERATED");
|
|
|
211
|
+ report.setGeneratedBy("bot_dev1");
|
|
|
212
|
+
|
|
|
213
|
+ reportMapper.insert(report);
|
|
|
214
|
+
|
|
|
215
|
+ log.info("生成报警统计报表成功: reportCode={}, period={}", report.getReportCode(), period);
|
|
|
216
|
+
|
|
|
217
|
+ return report;
|
|
|
218
|
+
|
|
|
219
|
+ } catch (Exception e) {
|
|
|
220
|
+ log.error("生成报警统计报表失败: {}", e.getMessage());
|
|
|
221
|
+ throw new RuntimeException("报警统计报表生成失败: " + e.getMessage());
|
|
|
222
|
+ }
|
|
|
223
|
+ }
|
|
|
224
|
+
|
|
|
225
|
+ /**
|
|
|
226
|
+ * 生成综合报表(包含所有类型)
|
|
|
227
|
+ */
|
|
|
228
|
+ public DataReport generateComprehensiveReport(String period, String startTime, String endTime) {
|
|
|
229
|
+ DataReport report = new DataReport();
|
|
|
230
|
+ report.setReportName("综合数据报表");
|
|
|
231
|
+ report.setReportCode("COMP-" + System.currentTimeMillis());
|
|
|
232
|
+ report.setReportType("comprehensive");
|
|
|
233
|
+ report.setDataType("all");
|
|
|
234
|
+ report.setArea("ALL");
|
|
|
235
|
+
|
|
|
236
|
+ try {
|
|
|
237
|
+ // 设置时间范围
|
|
|
238
|
+ LocalDate start = startTime != null ? LocalDate.parse(startTime.substring(0, 10)) : LocalDate.now().minusDays(7);
|
|
|
239
|
+ LocalDate end = endTime != null ? LocalDate.parse(endTime.substring(0, 10)) : LocalDate.now();
|
|
|
240
|
+ report.setPeriodStart(start);
|
|
|
241
|
+ report.setPeriodEnd(end);
|
|
|
242
|
+
|
|
|
243
|
+ // 获取各类数据
|
|
|
244
|
+ Map<String, Object> waterVolumeData = dataStatisticsService.getWaterVolumeSummary(startTime, endTime);
|
|
|
245
|
+ Map<String, Object> qualityData = dataStatisticsService.getWaterQualityRate(startTime, endTime);
|
|
|
246
|
+ Map<String, Object> alarmData = dataStatisticsService.getAlarmStatistics(startTime, endTime);
|
|
|
247
|
+
|
|
|
248
|
+ Map<String, Object> content = new LinkedHashMap<>();
|
|
|
249
|
+ content.put("generatedAt", LocalDateTime.now());
|
|
|
250
|
+ content.put("period", period);
|
|
|
251
|
+ content.put("startTime", startTime);
|
|
|
252
|
+ content.put("endTime", endTime);
|
|
|
253
|
+
|
|
|
254
|
+ // 水量汇总
|
|
|
255
|
+ Map<String, Object> waterSection = new LinkedHashMap<>();
|
|
|
256
|
+ waterSection.put("totalWaterSupply", waterVolumeData.get("totalSupply"));
|
|
|
257
|
+ waterSection.put("avgDailySupply", waterVolumeData.get("avgDailySupply"));
|
|
|
258
|
+ waterSection.put("areaWaterSupply", waterVolumeData.get("areaSupplyStats"));
|
|
|
259
|
+ content.put("waterVolumeSummary", waterSection);
|
|
|
260
|
+
|
|
|
261
|
+ // 水质分析
|
|
|
262
|
+ Map<String, Object> qualitySection = new LinkedHashMap<>();
|
|
|
263
|
+ qualitySection.put("totalTests", qualityData.get("totalTests"));
|
|
|
264
|
+ qualitySection.put("passedTests", qualityData.get("passedTests"));
|
|
|
265
|
+ qualitySection.put("passRate", qualityData.get("passRate"));
|
|
|
266
|
+ qualitySection.put("areaQualityStats", qualityData.get("areaQualityStats"));
|
|
|
267
|
+ content.put("waterQualityAnalysis", qualitySection);
|
|
|
268
|
+
|
|
|
269
|
+ // 报警统计
|
|
|
270
|
+ Map<String, Object> alarmSection = new LinkedHashMap<>();
|
|
|
271
|
+ alarmSection.put("totalAlarms", alarmData.get("totalAlarms"));
|
|
|
272
|
+ alarmSection.put("levelStatistics", alarmData.get("levelStatistics"));
|
|
|
273
|
+ alarmSection.put("areaAlarmStats", alarmData.get("areaAlarmStats"));
|
|
|
274
|
+ alarmSection.put("dailyAlarmTrend", alarmData.get("dailyAlarmTrend"));
|
|
|
275
|
+ content.put("alarmStatistics", alarmSection);
|
|
|
276
|
+
|
|
|
277
|
+ // 综合评估
|
|
|
278
|
+ Map<String, Object> assessment = new LinkedHashMap<>();
|
|
|
279
|
+ assessment.put("overallRating", calculateOverallRating(waterVolumeData, qualityData, alarmData));
|
|
|
280
|
+ assessment.put("recommendations", generateRecommendations(waterVolumeData, qualityData, alarmData));
|
|
|
281
|
+ content.put("comprehensiveAssessment", assessment);
|
|
|
282
|
+
|
|
|
283
|
+ // 生成摘要
|
|
|
284
|
+ Map<String, Object> summary = new LinkedHashMap<>();
|
|
|
285
|
+ summary.put("totalWaterSupply", waterVolumeData.get("totalSupply"));
|
|
|
286
|
+ summary.put("avgWaterQuality", qualityData.get("passRate"));
|
|
|
287
|
+ summary.put("totalAlarms", alarmData.get("totalAlarms"));
|
|
|
288
|
+ summary.put("overallRating", assessment.get("overallRating"));
|
|
|
289
|
+
|
|
|
290
|
+ report.setContent(content);
|
|
|
291
|
+ report.setSummary(summary);
|
|
|
292
|
+ report.setStatus("GENERATED");
|
|
|
293
|
+ report.setGeneratedBy("bot_dev1");
|
|
|
294
|
+
|
|
|
295
|
+ reportMapper.insert(report);
|
|
|
296
|
+
|
|
|
297
|
+ log.info("生成综合报表成功: reportCode={}, period={}", report.getReportCode(), period);
|
|
|
298
|
+
|
|
|
299
|
+ return report;
|
|
|
300
|
+
|
|
|
301
|
+ } catch (Exception e) {
|
|
|
302
|
+ log.error("生成综合报表失败: {}", e.getMessage());
|
|
|
303
|
+ throw new RuntimeException("综合报表生成失败: " + e.getMessage());
|
|
|
304
|
+ }
|
|
|
305
|
+ }
|
|
|
306
|
+
|
|
|
307
|
+ /**
|
|
|
308
|
+ * 自动生成报表(原有功能保留)
|
|
24
|
309
|
*/
|
|
25
|
310
|
public DataReport generateReport(String reportType, String period) {
|
|
26
|
311
|
DataReport report = new DataReport();
|
|
|
@@ -62,11 +347,78 @@ public class ReportService {
|
|
62
|
347
|
}
|
|
63
|
348
|
report.setContent(content.toString());
|
|
64
|
349
|
report.setStatus("GENERATED");
|
|
65
|
|
- report.setCreatedTime(LocalDateTime.now());
|
|
|
350
|
+ report.setCreatedAt(LocalDateTime.now());
|
|
66
|
351
|
|
|
67
|
352
|
reportMapper.insert(report);
|
|
68
|
353
|
return report;
|
|
69
|
354
|
}
|
|
|
355
|
+
|
|
|
356
|
+ /**
|
|
|
357
|
+ * 计算综合评分
|
|
|
358
|
+ */
|
|
|
359
|
+ private String calculateOverallRating(Map<String, Object> waterData, Map<String, Object> qualityData, Map<String, Object> alarmData) {
|
|
|
360
|
+ double waterScore = calculateWaterScore(waterData);
|
|
|
361
|
+ double qualityScore = calculateQualityScore(qualityData);
|
|
|
362
|
+ double alarmScore = calculateAlarmScore(alarmData);
|
|
|
363
|
+
|
|
|
364
|
+ double totalScore = (waterScore + qualityScore + alarmScore) / 3;
|
|
|
365
|
+
|
|
|
366
|
+ if (totalScore >= 90) return "优秀";
|
|
|
367
|
+ if (totalScore >= 80) return "良好";
|
|
|
368
|
+ if (totalScore >= 70) return "一般";
|
|
|
369
|
+ if (totalScore >= 60) return "较差";
|
|
|
370
|
+ return "差";
|
|
|
371
|
+ }
|
|
|
372
|
+
|
|
|
373
|
+ private double calculateWaterScore(Map<String, Object> waterData) {
|
|
|
374
|
+ Double totalSupply = (Double) waterData.getOrDefault("totalSupply", 0.0);
|
|
|
375
|
+ // 这里可以根据实际业务逻辑计算水量分数
|
|
|
376
|
+ return Math.min(100, totalSupply / 50000 * 100); // 假设5万为满分
|
|
|
377
|
+ }
|
|
|
378
|
+
|
|
|
379
|
+ private double calculateQualityScore(Map<String, Object> qualityData) {
|
|
|
380
|
+ String passRateStr = (String) qualityData.getOrDefault("passRate", "0%");
|
|
|
381
|
+ double passRate = Double.parseDouble(passRateStr.replace("%", ""));
|
|
|
382
|
+ return passRate; // 水质合格率直接作为分数
|
|
|
383
|
+ }
|
|
|
384
|
+
|
|
|
385
|
+ private double calculateAlarmScore(Map<String, Object> alarmData) {
|
|
|
386
|
+ Integer totalAlarms = (Integer) alarmData.getOrDefault("totalAlarms", 0);
|
|
|
387
|
+ // 报警越少分数越高
|
|
|
388
|
+ return Math.max(0, 100 - totalAlarms * 2);
|
|
|
389
|
+ }
|
|
|
390
|
+
|
|
|
391
|
+ /**
|
|
|
392
|
+ * 生成改进建议
|
|
|
393
|
+ */
|
|
|
394
|
+ private List<String> generateRecommendations(Map<String, Object> waterData, Map<String, Object> qualityData, Map<String, Object> alarmData) {
|
|
|
395
|
+ List<String> recommendations = new ArrayList<>();
|
|
|
396
|
+
|
|
|
397
|
+ // 基于水量数据的建议
|
|
|
398
|
+ Double totalSupply = (Double) waterData.getOrDefault("totalSupply", 0.0);
|
|
|
399
|
+ if (totalSupply < 30000) {
|
|
|
400
|
+ recommendations.add("建议增加供水能力,当前供水量偏低");
|
|
|
401
|
+ }
|
|
|
402
|
+
|
|
|
403
|
+ // 基于水质数据的建议
|
|
|
404
|
+ String passRateStr = (String) qualityData.getOrDefault("passRate", "0%");
|
|
|
405
|
+ double passRate = Double.parseDouble(passRateStr.replace("%", ""));
|
|
|
406
|
+ if (passRate < 95) {
|
|
|
407
|
+ recommendations.add("建议加强水质监测和处理,当前合格率偏低");
|
|
|
408
|
+ }
|
|
|
409
|
+
|
|
|
410
|
+ // 基于报警数据的建议
|
|
|
411
|
+ Integer totalAlarms = (Integer) alarmData.getOrDefault("totalAlarms", 0);
|
|
|
412
|
+ if (totalAlarms > 20) {
|
|
|
413
|
+ recommendations.add("建议检查设备状态,报警频率过高");
|
|
|
414
|
+ }
|
|
|
415
|
+
|
|
|
416
|
+ if (recommendations.isEmpty()) {
|
|
|
417
|
+ recommendations.add("运行状态良好,继续保持");
|
|
|
418
|
+ }
|
|
|
419
|
+
|
|
|
420
|
+ return recommendations;
|
|
|
421
|
+ }
|
|
70
|
422
|
|
|
71
|
423
|
/**
|
|
72
|
424
|
* 获取报表列表
|
|
|
@@ -75,7 +427,7 @@ public class ReportService {
|
|
75
|
427
|
LambdaQueryWrapper<DataReport> wrapper = new LambdaQueryWrapper<>();
|
|
76
|
428
|
if (reportType != null && !reportType.isBlank()) wrapper.eq(DataReport::getReportType, reportType);
|
|
77
|
429
|
if (status != null && !status.isBlank()) wrapper.eq(DataReport::getStatus, status);
|
|
78
|
|
- return reportMapper.selectList(wrapper.orderByDesc(DataReport::getCreatedTime));
|
|
|
430
|
+ return reportMapper.selectList(wrapper.orderByDesc(DataReport::getCreatedAt));
|
|
79
|
431
|
}
|
|
80
|
432
|
|
|
81
|
433
|
/**
|
|
|
@@ -92,9 +444,19 @@ public class ReportService {
|
|
92
|
444
|
DataReport report = reportMapper.selectById(id);
|
|
93
|
445
|
if (report == null) throw new RuntimeException("报表不存在");
|
|
94
|
446
|
report.setStatus("PUBLISHED");
|
|
95
|
|
- report.setPublishedTime(LocalDateTime.now());
|
|
|
447
|
+/* publishedTime 字段不存在,发布时间用 updatedAt 体现 */ report.setUpdatedAt(LocalDateTime.now());
|
|
96
|
448
|
reportMapper.updateById(report);
|
|
97
|
449
|
}
|
|
|
450
|
+
|
|
|
451
|
+ /**
|
|
|
452
|
+ * 获取报表ID(从报表代码)
|
|
|
453
|
+ */
|
|
|
454
|
+ public Long getReportIdByCode(String reportCode) {
|
|
|
455
|
+ LambdaQueryWrapper<DataReport> wrapper = new LambdaQueryWrapper<>();
|
|
|
456
|
+ wrapper.eq(DataReport::getReportCode, reportCode);
|
|
|
457
|
+ DataReport report = reportMapper.selectOne(wrapper);
|
|
|
458
|
+ return report != null ? report.getId() : null;
|
|
|
459
|
+ }
|
|
98
|
460
|
|
|
99
|
461
|
/**
|
|
100
|
462
|
* 模板管理
|
|
|
@@ -104,7 +466,7 @@ public class ReportService {
|
|
104
|
466
|
}
|
|
105
|
467
|
|
|
106
|
468
|
public ReportTemplate createTemplate(ReportTemplate template) {
|
|
107
|
|
- template.setCreatedTime(LocalDateTime.now());
|
|
|
469
|
+ template.setCreatedAt(LocalDateTime.now());
|
|
108
|
470
|
templateMapper.insert(template);
|
|
109
|
471
|
return template;
|
|
110
|
472
|
}
|