|
|
@@ -4,15 +4,44 @@ import com.water.bi.service.DataVisualizationService;
|
|
4
|
4
|
import com.water.bi.entity.BIDashboard;
|
|
5
|
5
|
import com.water.bi.entity.DataVisualization;
|
|
6
|
6
|
import org.springframework.stereotype.Service;
|
|
|
7
|
+import org.springframework.web.socket.TextMessage;
|
|
|
8
|
+import org.springframework.web.socket.WebSocketSession;
|
|
|
9
|
+import org.springframework.web.socket.handler.TextWebSocketHandler;
|
|
|
10
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
11
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
7
|
12
|
import java.util.*;
|
|
|
13
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
8
|
14
|
import java.util.stream.Collectors;
|
|
9
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
15
|
+import java.time.LocalDateTime;
|
|
|
16
|
+import java.time.format.DateTimeFormatter;
|
|
10
|
17
|
|
|
11
|
18
|
/**
|
|
12
|
19
|
* 数据可视化服务实现
|
|
13
|
20
|
*/
|
|
14
|
21
|
@Service
|
|
15
|
22
|
public class DataVisualizationServiceImpl implements DataVisualizationService {
|
|
|
23
|
+
|
|
|
24
|
+ @Autowired
|
|
|
25
|
+ private BISupersetMetabaseService biSupersetMetabaseService;
|
|
|
26
|
+
|
|
|
27
|
+ // WebSocket相关配置
|
|
|
28
|
+ private final Map<String, WebSocketSession> sessions = new ConcurrentHashMap<>();
|
|
|
29
|
+ private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
30
|
+ private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
31
|
+
|
|
|
32
|
+ // 实时数据缓存
|
|
|
33
|
+ private final Map<String, Object> realTimeData = new ConcurrentHashMap<>();
|
|
|
34
|
+
|
|
|
35
|
+ // 模拟实时数据生成器
|
|
|
36
|
+ private final Thread dataGeneratorThread;
|
|
|
37
|
+ private volatile boolean running = true;
|
|
|
38
|
+
|
|
|
39
|
+ public DataVisualizationServiceImpl() {
|
|
|
40
|
+ // 启动实时数据生成线程
|
|
|
41
|
+ this.dataGeneratorThread = new Thread(this::generateRealTimeData);
|
|
|
42
|
+ this.dataGeneratorThread.setDaemon(true);
|
|
|
43
|
+ this.dataGeneratorThread.start();
|
|
|
44
|
+ }
|
|
16
|
45
|
|
|
17
|
46
|
@Override
|
|
18
|
47
|
public Long createDashboard(BIDashboard dashboard) {
|
|
|
@@ -58,6 +87,404 @@ public class DataVisualizationServiceImpl implements DataVisualizationService {
|
|
58
|
87
|
screen.setCreateTime(new Date());
|
|
59
|
88
|
return screen.getId();
|
|
60
|
89
|
}
|
|
|
90
|
+
|
|
|
91
|
+ /**
|
|
|
92
|
+ * WebSocket处理器 - 处理实时数据连接
|
|
|
93
|
+ */
|
|
|
94
|
+ @Service
|
|
|
95
|
+ public static class WebSocketDataHandler extends TextWebSocketHandler {
|
|
|
96
|
+ @Autowired
|
|
|
97
|
+ private DataVisualizationServiceImpl dataVisualizationService;
|
|
|
98
|
+
|
|
|
99
|
+ @Override
|
|
|
100
|
+ public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
|
|
101
|
+ String sessionId = session.getId();
|
|
|
102
|
+ dataVisualizationService.sessions.put(sessionId, session);
|
|
|
103
|
+
|
|
|
104
|
+ // 发送当前状态数据
|
|
|
105
|
+ Map<String, Object> statusData = new HashMap<>();
|
|
|
106
|
+ statusData.put("type", "connection-status");
|
|
|
107
|
+ statusData.put("status", "connected");
|
|
|
108
|
+ statusData.put("timestamp", LocalDateTime.now().format(formatter));
|
|
|
109
|
+
|
|
|
110
|
+ session.sendMessage(new TextMessage(objectMapper.writeValueAsString(statusData)));
|
|
|
111
|
+ }
|
|
|
112
|
+
|
|
|
113
|
+ @Override
|
|
|
114
|
+ public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
|
|
115
|
+ String payload = message.getPayload();
|
|
|
116
|
+ Map<String, Object> request = objectMapper.readValue(payload, Map.class);
|
|
|
117
|
+
|
|
|
118
|
+ String type = (String) request.get("type");
|
|
|
119
|
+
|
|
|
120
|
+ if ("subscribe".equals(type)) {
|
|
|
121
|
+ // 处理数据订阅
|
|
|
122
|
+ List<String> channels = (List<String>) request.get("channels");
|
|
|
123
|
+ Map<String, Object> response = new HashMap<>();
|
|
|
124
|
+ response.put("type", "subscription-confirmed");
|
|
|
125
|
+ response.put("channels", channels);
|
|
|
126
|
+ response.put("timestamp", LocalDateTime.now().format(formatter));
|
|
|
127
|
+
|
|
|
128
|
+ session.sendMessage(new TextMessage(objectMapper.writeValueAsString(response)));
|
|
|
129
|
+ } else if ("get-kpi".equals(type)) {
|
|
|
130
|
+ // 返回KPI数据
|
|
|
131
|
+ Map<String, Object> kpiData = dataVisualizationService.getCurrentKPIData();
|
|
|
132
|
+ kpiData.put("type", "kpi-update");
|
|
|
133
|
+
|
|
|
134
|
+ session.sendMessage(new TextMessage(objectMapper.writeValueAsString(kpiData)));
|
|
|
135
|
+ }
|
|
|
136
|
+ }
|
|
|
137
|
+
|
|
|
138
|
+ @Override
|
|
|
139
|
+ public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
|
|
140
|
+ String sessionId = session.getId();
|
|
|
141
|
+ dataVisualizationService.sessions.remove(sessionId);
|
|
|
142
|
+ }
|
|
|
143
|
+ }
|
|
|
144
|
+
|
|
|
145
|
+ /**
|
|
|
146
|
+ * 获取当前KPI数据
|
|
|
147
|
+ */
|
|
|
148
|
+ public Map<String, Object> getCurrentKPIData() {
|
|
|
149
|
+ Map<String, Object> kpiData = new HashMap<>();
|
|
|
150
|
+
|
|
|
151
|
+ // 模拟实时KPI数据
|
|
|
152
|
+ kpiData.put("supplyTotal", 12580 + (int)(Math.random() * 1000 - 500));
|
|
|
153
|
+ kpiData.put("waterOutput", 11230 + (int)(Math.random() * 800 - 400));
|
|
|
154
|
+ kpiData.put("productionLossRate", 10.8 + (Math.random() - 0.5) * 2);
|
|
|
155
|
+ kpiData.put("productionLossTrend", (Math.random() - 0.5) * 4);
|
|
|
156
|
+ kpiData.put("revenueAmount", 85.2 + (Math.random() - 0.5) * 10);
|
|
|
157
|
+ kpiData.put("waterQualityScore", 98.5 + (Math.random() - 0.5) * 3);
|
|
|
158
|
+ kpiData.put("waterQualityTrend", (Math.random() - 0.5) * 2);
|
|
|
159
|
+ kpiData.put("alarmCount", 3 + (int)(Math.random() * 5 - 2));
|
|
|
160
|
+ kpiData.put("alarmTrend", -15.8 + (Math.random() - 0.5) * 10);
|
|
|
161
|
+
|
|
|
162
|
+ return kpiData;
|
|
|
163
|
+ }
|
|
|
164
|
+
|
|
|
165
|
+ /**
|
|
|
166
|
+ * 推送实时数据到所有连接的WebSocket客户端
|
|
|
167
|
+ */
|
|
|
168
|
+ public void broadcastRealTimeData(String channel, Object data) {
|
|
|
169
|
+ Map<String, Object> message = new HashMap<>();
|
|
|
170
|
+ message.put("type", channel);
|
|
|
171
|
+ message.put("data", data);
|
|
|
172
|
+ message.put("timestamp", LocalDateTime.now().format(formatter));
|
|
|
173
|
+
|
|
|
174
|
+ String jsonMessage;
|
|
|
175
|
+ try {
|
|
|
176
|
+ jsonMessage = objectMapper.writeValueAsString(message);
|
|
|
177
|
+ } catch (Exception e) {
|
|
|
178
|
+ System.err.println("JSON序列化错误: " + e.getMessage());
|
|
|
179
|
+ return;
|
|
|
180
|
+ }
|
|
|
181
|
+
|
|
|
182
|
+ sessions.forEach((sessionId, session) -> {
|
|
|
183
|
+ try {
|
|
|
184
|
+ if (session.isOpen()) {
|
|
|
185
|
+ session.sendMessage(new TextMessage(jsonMessage));
|
|
|
186
|
+ }
|
|
|
187
|
+ } catch (Exception e) {
|
|
|
188
|
+ System.err.println("发送WebSocket消息失败: " + e.getMessage());
|
|
|
189
|
+ }
|
|
|
190
|
+ });
|
|
|
191
|
+ }
|
|
|
192
|
+
|
|
|
193
|
+ /**
|
|
|
194
|
+ * 生成实时数据
|
|
|
195
|
+ */
|
|
|
196
|
+ private void generateRealTimeData() {
|
|
|
197
|
+ while (running) {
|
|
|
198
|
+ try {
|
|
|
199
|
+ // 生成供水趋势数据
|
|
|
200
|
+ Map<String, Object> supplyTrendData = generateSupplyTrendData();
|
|
|
201
|
+ realTimeData.put("supply-trend", supplyTrendData);
|
|
|
202
|
+ broadcastRealTimeData("supply-trend", supplyTrendData);
|
|
|
203
|
+
|
|
|
204
|
+ // 生成水质数据
|
|
|
205
|
+ Map<String, Object> waterQualityData = generateWaterQualityData();
|
|
|
206
|
+ realTimeData.put("water-quality", waterQualityData);
|
|
|
207
|
+ broadcastRealTimeData("water-quality", waterQualityData);
|
|
|
208
|
+
|
|
|
209
|
+ // 生成实时报警
|
|
|
210
|
+ List<Map<String, Object>> alarmData = generateRealtimeAlarms();
|
|
|
211
|
+ realTimeData.put("realtime-alarm", alarmData);
|
|
|
212
|
+ broadcastRealTimeData("realtime-alarm", alarmData);
|
|
|
213
|
+
|
|
|
214
|
+ // 生成设备状态数据
|
|
|
215
|
+ Map<String, Object> deviceStatusData = generateDeviceStatusData();
|
|
|
216
|
+ realTimeData.put("device-status", deviceStatusData);
|
|
|
217
|
+ broadcastRealTimeData("device-status", deviceStatusData);
|
|
|
218
|
+
|
|
|
219
|
+ // 生成营收数据
|
|
|
220
|
+ Map<String, Object> revenueData = generateRevenueData();
|
|
|
221
|
+ realTimeData.put("revenue-data", revenueData);
|
|
|
222
|
+ broadcastRealTimeData("revenue-data", revenueData);
|
|
|
223
|
+
|
|
|
224
|
+ // 生成能耗数据
|
|
|
225
|
+ Map<String, Object> energyData = generateEnergyData();
|
|
|
226
|
+ realTimeData.put("energy-data", energyData);
|
|
|
227
|
+ broadcastRealTimeData("energy-data", energyData);
|
|
|
228
|
+
|
|
|
229
|
+ // 每5秒更新一次
|
|
|
230
|
+ Thread.sleep(5000);
|
|
|
231
|
+ } catch (Exception e) {
|
|
|
232
|
+ System.err.println("实时数据生成错误: " + e.getMessage());
|
|
|
233
|
+ try {
|
|
|
234
|
+ Thread.sleep(10000);
|
|
|
235
|
+ } catch (InterruptedException ie) {
|
|
|
236
|
+ break;
|
|
|
237
|
+ }
|
|
|
238
|
+ }
|
|
|
239
|
+ }
|
|
|
240
|
+ }
|
|
|
241
|
+
|
|
|
242
|
+ /**
|
|
|
243
|
+ * 生成供水趋势数据
|
|
|
244
|
+ */
|
|
|
245
|
+ private Map<String, Object> generateSupplyTrendData() {
|
|
|
246
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
247
|
+ List<Integer> inflow = new ArrayList<>();
|
|
|
248
|
+ List<Integer> outflow = new ArrayList<>();
|
|
|
249
|
+
|
|
|
250
|
+ for (int i = 0; i < 6; i++) {
|
|
|
251
|
+ inflow.add(400 + (int)(Math.random() * 200 - 100));
|
|
|
252
|
+ outflow.add(380 + (int)(Math.random() * 180 - 90));
|
|
|
253
|
+ }
|
|
|
254
|
+
|
|
|
255
|
+ data.put("inflow", inflow);
|
|
|
256
|
+ data.put("outflow", outflow);
|
|
|
257
|
+ data.put("timestamp", LocalDateTime.now().format(formatter));
|
|
|
258
|
+
|
|
|
259
|
+ return data;
|
|
|
260
|
+ }
|
|
|
261
|
+
|
|
|
262
|
+ /**
|
|
|
263
|
+ * 生成水质数据
|
|
|
264
|
+ */
|
|
|
265
|
+ private Map<String, Object> generateWaterQualityData() {
|
|
|
266
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
267
|
+ List<Double> currentValues = Arrays.asList(
|
|
|
268
|
+ 1.2 + (Math.random() - 0.5) * 0.2, // 浊度
|
|
|
269
|
+ 7.2 + (Math.random() - 0.5) * 0.1, // pH值
|
|
|
270
|
+ 0.3 + (Math.random() - 0.5) * 0.05, // 余氯
|
|
|
271
|
+ 25 + (Math.random() - 0.5) * 5, // 菌落
|
|
|
272
|
+ 3 + (Math.random() - 0.5) * 0.5, // 色度
|
|
|
273
|
+ 1 + (Math.random() - 0.5) * 0.2 // 嗅味
|
|
|
274
|
+ );
|
|
|
275
|
+
|
|
|
276
|
+ data.put("currentValues", currentValues);
|
|
|
277
|
+ data.put("timestamp", LocalDateTime.now().format(formatter));
|
|
|
278
|
+
|
|
|
279
|
+ return data;
|
|
|
280
|
+ }
|
|
|
281
|
+
|
|
|
282
|
+ /**
|
|
|
283
|
+ * 生成实时报警数据
|
|
|
284
|
+ */
|
|
|
285
|
+ private List<Map<String, Object>> generateRealtimeAlarms() {
|
|
|
286
|
+ List<Map<String, Object>> alarms = new ArrayList<>();
|
|
|
287
|
+
|
|
|
288
|
+ // 随机生成1-3条新报警
|
|
|
289
|
+ int alarmCount = 1 + (int)(Math.random() * 3);
|
|
|
290
|
+
|
|
|
291
|
+ for (int i = 0; i < alarmCount; i++) {
|
|
|
292
|
+ Map<String, Object> alarm = new HashMap<>();
|
|
|
293
|
+ alarm.put("id", System.currentTimeMillis() + i);
|
|
|
294
|
+ alarm.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
|
|
295
|
+
|
|
|
296
|
+ String[] types = {"压力报警", "水质报警", "设备报警", "流量报警", "漏损报警"};
|
|
|
297
|
+ String[] locations = {"精芒片区", "一体化水厂", "托里片区", "八家户片区", "大镇阿合其"};
|
|
|
298
|
+ String[] titles = {"压力异常波动", "浊度超标", "泵站设备异常", "流量异常", "管网漏损"};
|
|
|
299
|
+ String[] levels = {"info", "warning", "danger"};
|
|
|
300
|
+ String[] statuses = {"处理中", "监控中", "紧急处理", "已恢复"};
|
|
|
301
|
+
|
|
|
302
|
+ alarm.put("type", types[(int)(Math.random() * types.length)]);
|
|
|
303
|
+ alarm.put("location", locations[(int)(Math.random() * locations.length)]);
|
|
|
304
|
+ alarm.put("title", titles[(int)(Math.random() * titles.length)]);
|
|
|
305
|
+ alarm.put("level", levels[(int)(Math.random() * levels.length)]);
|
|
|
306
|
+ alarm.put("status", statuses[(int)(Math.random() * statuses.length)]);
|
|
|
307
|
+
|
|
|
308
|
+ alarms.add(alarm);
|
|
|
309
|
+ }
|
|
|
310
|
+
|
|
|
311
|
+ return alarms;
|
|
|
312
|
+ }
|
|
|
313
|
+
|
|
|
314
|
+ /**
|
|
|
315
|
+ * 生成设备状态数据
|
|
|
316
|
+ */
|
|
|
317
|
+ private Map<String, Object> generateDeviceStatusData() {
|
|
|
318
|
+ Map<String, Object> data = new ArrayList<>();
|
|
|
319
|
+
|
|
|
320
|
+ // 模拟设备状态数据
|
|
|
321
|
+ Map<String, Object> status1 = new HashMap<>();
|
|
|
322
|
+ status1.put("name", "正常运行");
|
|
|
323
|
+ status1.put("value", 142);
|
|
|
324
|
+ status1.put("itemStyle", Map.of("color", "#67c23a"));
|
|
|
325
|
+
|
|
|
326
|
+ Map<String, Object> status2 = new HashMap<>();
|
|
|
327
|
+ status2.put("name", "维护中");
|
|
|
328
|
+ status2.put("value", 10 + (int)(Math.random() * 5));
|
|
|
329
|
+ status2.put("itemStyle", Map.of("color", "#e6a23c"));
|
|
|
330
|
+
|
|
|
331
|
+ Map<String, Object> status3 = new HashMap<>();
|
|
|
332
|
+ status3.put("name", "故障");
|
|
|
333
|
+ status3.put("value", 2 + (int)(Math.random() * 5));
|
|
|
334
|
+ status3.put("itemStyle", Map.of("color", "#f56c6c"));
|
|
|
335
|
+
|
|
|
336
|
+ Map<String, Object> status4 = new HashMap<>();
|
|
|
337
|
+ status4.put("name", "离线");
|
|
|
338
|
+ status4.put("value", 15 + (int)(Math.random() * 10));
|
|
|
339
|
+ status4.put("itemStyle", Map.of("color", "#909399"));
|
|
|
340
|
+
|
|
|
341
|
+ data.add(status1);
|
|
|
342
|
+ data.add(status2);
|
|
|
343
|
+ data.add(status3);
|
|
|
344
|
+ data.add(status4);
|
|
|
345
|
+
|
|
|
346
|
+ return data;
|
|
|
347
|
+ }
|
|
|
348
|
+
|
|
|
349
|
+ /**
|
|
|
350
|
+ * 生成营收数据
|
|
|
351
|
+ */
|
|
|
352
|
+ private Map<String, Object> generateRevenueData() {
|
|
|
353
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
354
|
+ List<Double> monthlyRevenue = new ArrayList<>();
|
|
|
355
|
+
|
|
|
356
|
+ // 生成6个月的营收数据
|
|
|
357
|
+ for (int i = 0; i < 6; i++) {
|
|
|
358
|
+ monthlyRevenue.add(800 + Math.random() * 400);
|
|
|
359
|
+ }
|
|
|
360
|
+
|
|
|
361
|
+ data.put("monthlyRevenue", monthlyRevenue);
|
|
|
362
|
+ data.put("timestamp", LocalDateTime.now().format(formatter));
|
|
|
363
|
+
|
|
|
364
|
+ return data;
|
|
|
365
|
+ }
|
|
|
366
|
+
|
|
|
367
|
+ /**
|
|
|
368
|
+ * 生成能耗数据
|
|
|
369
|
+ */
|
|
|
370
|
+ private Map<String, Object> generateEnergyData() {
|
|
|
371
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
372
|
+ List<Integer> hourlyEnergy = new ArrayList<>();
|
|
|
373
|
+
|
|
|
374
|
+ // 生成24小时的能耗数据
|
|
|
375
|
+ for (int i = 0; i < 24; i++) {
|
|
|
376
|
+ int base = 100;
|
|
|
377
|
+ if (i >= 6 && i <= 22) {
|
|
|
378
|
+ base = 150 + (int)(Math.random() * 50);
|
|
|
379
|
+ } else {
|
|
|
380
|
+ base = 50 + (int)(Math.random() * 30);
|
|
|
381
|
+ }
|
|
|
382
|
+ hourlyEnergy.add(base);
|
|
|
383
|
+ }
|
|
|
384
|
+
|
|
|
385
|
+ data.put("hourlyEnergy", hourlyEnergy);
|
|
|
386
|
+ data.put("timestamp", LocalDateTime.now().format(formatter));
|
|
|
387
|
+
|
|
|
388
|
+ return data;
|
|
|
389
|
+ }
|
|
|
390
|
+
|
|
|
391
|
+ /**
|
|
|
392
|
+ * 获取实时数据缓存
|
|
|
393
|
+ */
|
|
|
394
|
+ public Map<String, Object> getRealTimeData() {
|
|
|
395
|
+ return new HashMap<>(realTimeData);
|
|
|
396
|
+ }
|
|
|
397
|
+
|
|
|
398
|
+ /**
|
|
|
399
|
+ * 获取当前报警统计
|
|
|
400
|
+ */
|
|
|
401
|
+ public Map<String, Object> getAlarmStatistics() {
|
|
|
402
|
+ Map<String, Object> stats = new HashMap<>();
|
|
|
403
|
+
|
|
|
404
|
+ // 统计报警数量
|
|
|
405
|
+ List<Map<String, Object>> alarms = (List<Map<String, Object>>) realTimeData.get("realtime-alarm");
|
|
|
406
|
+ if (alarms != null) {
|
|
|
407
|
+ long urgent = alarms.stream().filter(a -> "danger".equals(a.get("level"))).count();
|
|
|
408
|
+ long warning = alarms.stream().filter(a -> "warning".equals(a.get("level"))).count();
|
|
|
409
|
+ long info = alarms.stream().filter(a -> "info".equals(a.get("level"))).count();
|
|
|
410
|
+
|
|
|
411
|
+ stats.put("urgent", urgent);
|
|
|
412
|
+ stats.put("warning", warning);
|
|
|
413
|
+ stats.put("info", info);
|
|
|
414
|
+ stats.put("total", alarms.size());
|
|
|
415
|
+ }
|
|
|
416
|
+
|
|
|
417
|
+ return stats;
|
|
|
418
|
+ }
|
|
|
419
|
+
|
|
|
420
|
+ /**
|
|
|
421
|
+ * 获取供水专题大屏数据
|
|
|
422
|
+ */
|
|
|
423
|
+ public Map<String, Object> getWaterSupplyScreenData() {
|
|
|
424
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
425
|
+
|
|
|
426
|
+ // 核心KPI指标
|
|
|
427
|
+ data.put("coreKPIs", getCurrentKPIData());
|
|
|
428
|
+
|
|
|
429
|
+ // 水源数据
|
|
|
430
|
+ List<Map<String, Object>> waterSources = new ArrayList<>();
|
|
|
431
|
+ String[] sourceNames = {"地表水源A", "地下水源B", "引黄调水", "水库备用"};
|
|
|
432
|
+ String[] statuses = {"normal", "warning", "normal", "normal"};
|
|
|
433
|
+
|
|
|
434
|
+ for (int i = 0; i < sourceNames.length; i++) {
|
|
|
435
|
+ Map<String, Object> source = new HashMap<>();
|
|
|
436
|
+ source.put("id", i + 1);
|
|
|
437
|
+ source.put("name", sourceNames[i]);
|
|
|
438
|
+ source.put("status", statuses[i]);
|
|
|
439
|
+ source.put("currentFlow", 300 + (int)(Math.random() * 200));
|
|
|
440
|
+ source.put("targetFlow", 300 + (int)(Math.random() * 200));
|
|
|
441
|
+ source.put("currentPressure", 350 + (int)(Math.random() * 100));
|
|
|
442
|
+ source.put("minPressure", 300);
|
|
|
443
|
+ source.put("maxPressure", 500);
|
|
|
444
|
+ source.put("qualityScore", 90 + (int)(Math.random() * 10));
|
|
|
445
|
+ waterSources.add(source);
|
|
|
446
|
+ }
|
|
|
447
|
+ data.put("waterSources", waterSources);
|
|
|
448
|
+
|
|
|
449
|
+ // GIS地图数据
|
|
|
450
|
+ Map<String, Object> mapData = new HashMap<>();
|
|
|
451
|
+ mapData.put("pipelineTotalLength", 245 + (int)(Math.random() * 20));
|
|
|
452
|
+ mapData.put("monitoringPoints", 326 + (int)(Math.random() * 50));
|
|
|
453
|
+ mapData.put("coveragePopulation", 85 + (int)(Math.random() * 10));
|
|
|
454
|
+ mapData.put("coverageAreas", 6);
|
|
|
455
|
+ data.put("mapData", mapData);
|
|
|
456
|
+
|
|
|
457
|
+ // 运营统计
|
|
|
458
|
+ Map<String, Object> operationStats = new HashMap<>();
|
|
|
459
|
+ operationStats.put("designCapacity", 150000);
|
|
|
460
|
+ operationStats.put("actualCapacity", 138000 + (int)(Math.random() * 10000 - 5000));
|
|
|
461
|
+ operationStats.put("avgDailySupply", 125000 + (int)(Math.random() * 10000 - 5000));
|
|
|
462
|
+ operationStats.put("waterQualityIndex", 96.5 + (Math.random() - 0.5) * 2);
|
|
|
463
|
+ operationStats.put("complianceRate", 98.2 + (Math.random() - 0.5) * 1);
|
|
|
464
|
+ operationStats.put("complaintRate", 0.3 + (Math.random() - 0.5) * 0.1);
|
|
|
465
|
+ operationStats.put("productionLossRate", 10.8 + (Math.random() - 0.5) * 2);
|
|
|
466
|
+ operationStats.put("leakageRate", 5.8 + (Math.random() - 0.5) * 1);
|
|
|
467
|
+ operationStats.put("equipmentIntegrityRate", 95.6 + (Math.random() - 0.5) * 2);
|
|
|
468
|
+ data.put("operationStats", operationStats);
|
|
|
469
|
+
|
|
|
470
|
+ // 营收数据
|
|
|
471
|
+ Map<String, Object> revenueData = new HashMap<>();
|
|
|
472
|
+ revenueData.put("todayRevenue", 8.52 + (Math.random() - 0.5) * 1);
|
|
|
473
|
+ revenueData.put("monthlyRevenue", 255.6 + (Math.random() - 0.5) * 20);
|
|
|
474
|
+ data.put("revenueData", revenueData);
|
|
|
475
|
+
|
|
|
476
|
+ return data;
|
|
|
477
|
+ }
|
|
|
478
|
+
|
|
|
479
|
+ /**
|
|
|
480
|
+ * 停止数据生成线程
|
|
|
481
|
+ */
|
|
|
482
|
+ public void shutdown() {
|
|
|
483
|
+ running = false;
|
|
|
484
|
+ if (dataGeneratorThread != null) {
|
|
|
485
|
+ dataGeneratorThread.interrupt();
|
|
|
486
|
+ }
|
|
|
487
|
+ }
|
|
61
|
488
|
|
|
62
|
489
|
@Override
|
|
63
|
490
|
public List<DataVisualization> listSpecialScreens() {
|