MqDataController.java
32.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
package com.skua.modules.system.controller;
import com.skua.core.api.ISysBaseAPI;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.cache.RedisUtil;
import com.skua.core.constant.CommonConstant;
import com.skua.core.service.IPgQueryService;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.JwtUtil;
import com.skua.core.util.PasswordUtil;
import com.skua.modules.alarm.service.AlarmRecordHistoryService;
import com.skua.modules.equip.entity.SysEquipInfo;
import com.skua.modules.equip.service.IEquipInfoService;
import com.skua.modules.equip.service.ISysEquipInfoService;
import com.skua.modules.monitor.entity.SysMonthData;
import com.skua.modules.monitor.service.ISysMonthDataService;
import com.skua.modules.safe.entity.SysSafeArea;
import com.skua.modules.safe.service.ISysSafeAreaService;
import com.skua.modules.shiro.vo.DefContants;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.entity.SysUser;
import com.skua.modules.system.model.SysLoginModel;
import com.skua.modules.system.service.ISysDepartService;
import com.skua.modules.system.service.ISysFactoryInfoService;
import com.skua.modules.system.service.ISysUserService;
import com.skua.modules.system.service.impl.SysUserDepartServiceImpl;
import com.skua.modules.system.vo.*;
import com.skua.modules.system.vo.SysFactoryInfo.SysFactoryInfoVO;
import com.skua.modules.video.service.ITVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
@RestController
@RequestMapping("/3d")
@Api(tags = "鸣启数据接口")
@Slf4j
public class MqDataController {
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysBaseAPI sysBaseAPI;
@Autowired
private RedisUtil redisUtil;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
SysUserDepartServiceImpl sysUserDepartService;
@Value("${skua.factoryId}")
private String factoryId;
@Autowired
private ISysFactoryInfoService sysFactoryInfoService;
@Autowired
private ISysEquipInfoService sysEquipInfoService;
@Autowired
private AlarmRecordHistoryService alarmRecordHistoryService;
@Autowired
private ISysMonthDataService sysMonthDataService;
@Autowired
private ISysSafeAreaService sysSafeAreaService;
@Autowired
private ITVideoService tVideoService;
@Autowired
private IPgQueryService pgQueryService;
@RequestMapping(value = "/appLogin", method = RequestMethod.POST)
public Result<SysAppUserInfo> appLogin(String username,String password){
Result<SysAppUserInfo> result = new Result<SysAppUserInfo>();
//1. 校验用户是否有效
SysUser sysUser = sysUserService.getUserByName(username);
result = sysUserService.checkUserIsEffective(sysUser);
if (!result.isSuccess()) {
return result;
}
//2. 校验用户名或密码是否正确
String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
String syspassword = sysUser.getPassword();
if (!syspassword.equals(userpassword)) {
result.error500("用户名或密码错误");
return result;
}
//生成token存储redis
appUserInfo(sysUser, result);
//判断集团或者单厂登录
String userId = result.getResult().getId();
List<SysDepart> userFactoryList = sysDepartService.getUserFactoryInfo(userId);
if (userFactoryList!=null && userFactoryList.size()>0) {
SysDepart sysDepart = userFactoryList.get(0);
String orgType = sysDepart.getOrgType();
if (userFactoryList.size() > 1) {
orgType = "1";
}
SysAppUserInfo userInfo = result.getResult();
if (!orgType.isEmpty()) {
if ("1".equals(orgType)||"2".equals(orgType)) {
userInfo.setOrgType("group");
} else if ("3".equals(orgType)) {
userInfo.setOrgType("factory");
}
}
}
sysBaseAPI.addLog("用户名: " + username + ",移动端登录成功!", CommonConstant.LOG_TYPE_1, null);
return result;
}
/**
* 生成token存储redis,并将数据封装到移动端需要的用户信息对象中
*
* @param sysUser
* @param result
* @return
*/
private Result<SysAppUserInfo> appUserInfo(SysUser sysUser, Result<SysAppUserInfo> result) {
SysAppUserInfo sysAppUserInfo = new SysAppUserInfo();
String syspassword = sysUser.getPassword();
String username = sysUser.getUsername();
// 生成token
String token = JwtUtil.sign(username, syspassword);
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
// 设置超时时间
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
sysAppUserInfo.setId(sysUser.getId());
sysAppUserInfo.setLogingName(username);
sysAppUserInfo.setToken(token);
if (!StringUtils.isEmpty(sysUser.getAvatar())) {
sysAppUserInfo.setIcon(sysUser.getAvatar());
}
sysAppUserInfo.setRealName(sysUser.getRealname());
sysAppUserInfo.setSex(sysUser.getSex());
sysAppUserInfo.setBirthday(sysUser.getBirthday());
sysAppUserInfo.setEmail(sysUser.getEmail());
sysAppUserInfo.setPhone(sysUser.getPhone());
sysAppUserInfo.setFactoryId(factoryId);
// 获取用户部门信息
List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
if (departs.size() > 0) {
sysAppUserInfo.setDepart(departs.get(0).getDepartName());
} else {
sysAppUserInfo.setDepart("");
}
result.setResult(sysAppUserInfo);
result.success("登录成功");
return result;
}
/**
* 退出登录
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/logout")
public Result<Object> logout(HttpServletRequest request, HttpServletResponse response) {
//用户退出逻辑
String token = request.getHeader(DefContants.X_ACCESS_TOKEN);
if (ConvertUtils.isEmpty(token)) {
return Result.error("退出登录失败!");
}
String username = JwtUtil.getUsername(token);
SysUser sysUser = sysUserService.getUserByName(username);
if (sysUser != null) {
sysBaseAPI.addLog("用户名: " + sysUser.getRealname() + ",退出成功!", CommonConstant.LOG_TYPE_1, null);
log.info(" 用户名: " + sysUser.getRealname() + ",退出成功! ");
//清空用户Token缓存
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
//清空用户权限缓存:权限Perms和角色集合
redisUtil.del(CommonConstant.LOGIN_USER_CACHERULES_ROLE + username);
redisUtil.del(CommonConstant.LOGIN_USER_CACHERULES_PERMISSION + username);
return Result.ok("退出登录成功!");
} else {
return Result.error("无效的token");
}
}
@AutoLog(value = "厂区介绍")
@ApiOperation(value="厂区介绍", notes="厂区介绍")
@RequestMapping(value = "/intro", method = RequestMethod.GET)
public Result<Map<String,Object>> getFactoryInfo() {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
SysFactoryInfoVO factoryInfoVO = sysFactoryInfoService.getByFactoryId(factoryId);
if(factoryInfoVO!=null){
map.put("factoryInfo",factoryInfoVO.getFactoryInfo());
}else{
map.put("factoryInfo","暂无介绍");
}
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "厂区详细信息")
@ApiOperation(value="厂区详细信息", notes="厂区详细信息")
@RequestMapping(value = "/serviceProcessing", method = RequestMethod.GET)
public Result<List<ResultDataVO>> getServiceProcessing() {
Result<List<ResultDataVO>> result = new Result<>();
List<ResultDataVO> list = sysFactoryInfoService.getFactoryInfo(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "厂区生产运营")
@ApiOperation(value="厂区生产运营", notes="厂区生产运营")
@RequestMapping(value = "/productionOperation", method = RequestMethod.GET)
public Result<Map<String,Object>> getProductionData() {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
Map<String,Object> chartMap = new HashMap<>();
List<ResultDataVO> list = sysFactoryInfoService.getProductionData(factoryId);
chartMap = sysFactoryInfoService.getProductionChartMap(factoryId);
map.put("list",list);
map.put("chart",chartMap);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "厂区环境效益")
@ApiOperation(value="厂区环境效益", notes="厂区环境效益")
@RequestMapping(value = "/environment", method = RequestMethod.GET)
public Result<Map<String,Object>> getEnvironmentData() {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
Map<String,Object> chartMap = new HashMap<>();
List<ResultDataVO> list = sysFactoryInfoService.getEnvironmentData(factoryId);
chartMap = sysFactoryInfoService.getEnvironmentChartMap(factoryId);
map.put("list",list);
map.put("chart",chartMap);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "厂区实时数据总计")
@ApiOperation(value="厂区实时数据总计", notes="厂区实时数据总计")
@RequestMapping(value = "/realTimeDataTotal", method = RequestMethod.GET)
public Result<List<ResultDataVO>> getRealTimeDataTotal() {
Result<List<ResultDataVO>> result = new Result<>();
List<ResultDataVO> list = new ArrayList<>();
list = sysFactoryInfoService.getRealTimeDataTotal(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "厂区实时数据指标")
@ApiOperation(value="厂区实时数据指标", notes="厂区实时数据指标")
@RequestMapping(value = "/realTimeDataIndex", method = RequestMethod.GET)
public Result<List<ResultRealTimeDataVO>> getRealTimeDataIndex() {
Result<List<ResultRealTimeDataVO>> result = new Result<>();
List<ResultRealTimeDataVO> list = new ArrayList<>();
list = sysFactoryInfoService.getRealTimeDataIndex(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "月度数据总计")
@ApiOperation(value="月度数据总计", notes="月度数据总计")
@RequestMapping(value = "/monthlyDataTotal", method = RequestMethod.GET)
public Result<List<ResultDataVO>> getMonthlyDataTotal(String month) {
Result<List<ResultDataVO>> result = new Result<>();
List<ResultDataVO> list = new ArrayList<>();
list = sysMonthDataService.getMonthlyDataTotal(factoryId,month);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "月度污染物消减")
@ApiOperation(value="月度污染物消减", notes="月度污染物消减")
@RequestMapping(value = "/monthlyDataPollutant", method = RequestMethod.GET)
public Result<List<ResultXjlDataVO>> getMonthlyDataPollutant(String month) {
Result<List<ResultXjlDataVO>> result = new Result<>();
List<ResultXjlDataVO> list = new ArrayList<>();
list = sysMonthDataService.getMonthlyDataPollutant(factoryId,month);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "月度产泥情况")
@ApiOperation(value="月度产泥情况", notes="月度产泥情况")
@RequestMapping(value = "/monthlyDataMadeMud", method = RequestMethod.GET)
public Result<Map<String,Object>> getMonthlyDataMadeMud(String month) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysMonthDataService.getMonthlyDataMadeMud(factoryId,month);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "月度用药情况")
@ApiOperation(value="月度用药情况", notes="月度用药情况")
@RequestMapping(value = "/monthlyDataUseMedical", method = RequestMethod.GET)
public Result<Map<String,Object>> getMonthlyDataUseMedical(String month) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysMonthDataService.getMonthlyDataUseMedical(factoryId,month);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "月度用电情况")
@ApiOperation(value="月度用电情况", notes="月度用电情况")
@RequestMapping(value = "/monthlyDataUseElectricity", method = RequestMethod.GET)
public Result<Map<String,Object>> getMonthlyDataUseElectricity(String month) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysMonthDataService.getMonthlyDataUseElectricity(factoryId,month);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备详细信息")
@ApiOperation(value="设备详细信息", notes="设备详细信息")
@RequestMapping(value = "/equipmentInformation", method = RequestMethod.GET)
public Result<ResultEquipInfo> getEquipmentInformation(String deviceId) {
Result<ResultEquipInfo> result = new Result<>();
ResultEquipInfo resultEquipInfo = new ResultEquipInfo();
resultEquipInfo = sysEquipInfoService.getMonthlyDataUseElectricity(deviceId);
result.setResult(resultEquipInfo);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备状态总计")
@ApiOperation(value="设备状态总计", notes="设备状态总计")
@RequestMapping(value = "/equipmentStatusTotal", method = RequestMethod.GET)
public Result<List<Map<String,Object>>> getEquipmentStatusTotal() {
Result<List<Map<String,Object>>> result = new Result<>();
List<Map<String,Object>> list = new ArrayList<>();
list = sysEquipInfoService.getEquipmentStatusTotal(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "工艺介绍")
@ApiOperation(value="工艺介绍", notes="工艺介绍")
@RequestMapping(value = "/processIntroduction", method = RequestMethod.GET)
public Result<Map<String,Object>> getProcessIntroduction(String deviceId) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysEquipInfoService.getProcessIntroduction(deviceId);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备列表")
@ApiOperation(value="设备列表", notes="设备列表")
@RequestMapping(value = "/idList", method = RequestMethod.GET)
public Result<Map<String,Object>> getEquipidList() {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysEquipInfoService.getEquipidList(factoryId);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备详细信息")
@ApiOperation(value="设备详细信息", notes="设备详细信息")
@RequestMapping(value = "/equipmentData", method = RequestMethod.GET)
public Result<ResultEquipInfo> getEqupimentData(String deviceId) {
Result<ResultEquipInfo> result = new Result<>();
ResultEquipInfo resultEquipInfo = new ResultEquipInfo();
resultEquipInfo = sysEquipInfoService.getMonthlyDataUseElectricity(deviceId);
result.setResult(resultEquipInfo);
result.setSuccess(true);
return result;
}
@AutoLog(value = "实时数据设备状态")
@ApiOperation(value="实时数据设备状态", notes="实时数据设备状态")
@RequestMapping(value = "/realTimeDataEquipmentStatusAndWorking", method = RequestMethod.GET)
public Result<List<ResultEquipState>> getRealTimeDataEquipmentStatusAndWorking() {
Result<List<ResultEquipState>> result = new Result<>();
List<ResultEquipState> list = new ArrayList<>();
list = sysEquipInfoService.getRealTimeDataEquipmentStatusAndWorking(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "报警数据")
@ApiOperation(value="报警数据", notes="报警数据")
@RequestMapping(value = "/alarmData", method = RequestMethod.GET)
public Result<List<ResultAlarmData>> getAlarmData() {
Result<List<ResultAlarmData>> result = new Result<>();
List<ResultAlarmData> list = new ArrayList<>();
list = alarmRecordHistoryService.getAlarmData(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "进出水实时数据")
@ApiOperation(value="进出水实时数据", notes="进出水实时数据")
@RequestMapping(value = "/realTimeDataOfInAndOutWater", method = RequestMethod.GET)
public Result<List<ResultWaterData>> getRealTimeDataOfInAndOutlWater() {
Result<List<ResultWaterData>> result = new Result<>();
List<ResultWaterData> list = new ArrayList<>();
String jsFields = "BKYHWSC_JS_Tag2,BKYHWSC_JS_Tag3,BKYHWSC_JS_Tag4,BKYHWSC_JS_Tag5,BKYHWSC_JS_Tag6," +
"BKYHWSC_JS_Tag7,BKYHWSC_JS_Tag8,BKYHWSC_JS_Tag9,";
List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData(factoryId,jsFields);
ResultWaterData waterData1 = new ResultWaterData();
waterData1.setName("累计流量");
waterData1.setIn("33118358");
waterData1.setOut("32341778");
waterData1.setUnit("m³");
waterData1.setIsexceed("false");
list.add(waterData1);
ResultWaterData waterData2 = new ResultWaterData();
waterData2.setName("实时流量");
waterData2.setIn("2777");
waterData2.setOut("2803");
waterData2.setUnit("m³/h");
waterData2.setIsexceed("false");
list.add(waterData2);
ResultWaterData waterData3 = new ResultWaterData();
waterData3.setName("COD");
waterData3.setIn("244");
waterData3.setOut("8.94");
waterData3.setUnit("mg/L");
waterData3.setIsexceed("false");
list.add(waterData3);
ResultWaterData waterData4 = new ResultWaterData();
waterData4.setName("氨氮");
waterData4.setIn("32.75");
waterData4.setOut("0.05");
waterData4.setUnit("mg/L");
waterData4.setIsexceed("false");
list.add(waterData4);
ResultWaterData waterData5 = new ResultWaterData();
waterData5.setName("TP");
waterData5.setIn("3.71");
waterData5.setOut("0.06");
waterData5.setUnit("mg/L");
waterData5.setIsexceed("false");
list.add(waterData5);
ResultWaterData waterData6 = new ResultWaterData();
waterData6.setName("TN");
waterData6.setIn("42.64");
waterData6.setOut("6.44");
waterData6.setUnit("mg/L");
waterData6.setIsexceed("false");
list.add(waterData6);
ResultWaterData waterData7 = new ResultWaterData();
waterData7.setName("PH");
waterData7.setIn("6.75");
waterData7.setOut("6.71");
waterData7.setUnit("");
waterData7.setIsexceed("false");
list.add(waterData7);
ResultWaterData waterData8 = new ResultWaterData();
waterData8.setName("SS");
waterData8.setIn("110");
waterData8.setOut("0.31");
waterData8.setUnit("mg/L");
waterData8.setIsexceed("false");
list.add(waterData8);
if(monitorList.size()==1){
Map<String,Object> monitorMap = monitorList.get(0);
waterData1.setIn(monitorMap.get("BKYHWSC_JS_Tag3").toString());
waterData2.setIn(monitorMap.get("BKYHWSC_JS_Tag2").toString());
waterData3.setIn(monitorMap.get("BKYHWSC_JS_Tag4").toString());
waterData4.setIn(monitorMap.get("BKYHWSC_JS_Tag5").toString());
waterData5.setIn(monitorMap.get("BKYHWSC_JS_Tag7").toString());
waterData6.setIn(monitorMap.get("BKYHWSC_JS_Tag6").toString());
waterData7.setIn(monitorMap.get("BKYHWSC_JS_Tag8").toString());
waterData8.setIn(monitorMap.get("BKYHWSC_JS_Tag9").toString());
}
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "关键数据")
@ApiOperation(value="关键数据", notes="关键数据")
@RequestMapping(value = "/importantData", method = RequestMethod.GET)
public Result<List<Map<String,Object>>> getImportantData() {//BKYHWSC_PLC2X_Tag1
Result<List<Map<String,Object>>> result = new Result<>();
List<Map<String,Object>> list = new ArrayList<>();
String jsFields = "BKYHWSC_PLC2X_Tag2,BKYHWSC_PLC2X_Tag4," +
"BKYHWSC_PLC2X_Tag6,BKYHWSC_PLC2X_Tag8,BKYHWSC_PLC2X_Tag10,BKYHWSC_PLC2X_Tag12," +//ORP
"BKYHWSC_PLC2X_Tag14,BKYHWSC_PLC2X_Tag16,BKYHWSC_PLC2X_Tag18,BKYHWSC_PLC2X_Tag20," +
"BKYHWSC_PLC2X_Tag22,BKYHWSC_PLC2X_Tag24,BKYHWSC_PLC2X_Tag26,BKYHWSC_PLC2X_Tag28," +//MLSS
"BKYHWSC_PLC2X_Tag30,BKYHWSC_PLC2X_Tag32,BKYHWSC_PLC2X_Tag34,BKYHWSC_PLC2X_Tag36," +
"BKYHWSC_PLC2X_Tag38,BKYHWSC_PLC2X_Tag40,BKYHWSC_PLC2X_Tag42,BKYHWSC_PLC2X_Tag44,";//DO
List<Map<String, Object>> monitorList = pgQueryService.queryFactoryMonitorFromRealTimeData(factoryId,jsFields);
Map<String,Object> map1 = new HashMap<>();
map1.put("name","ORP测定仪");
map1.put("data1","-2.63");
map1.put("data2","-1.56");
map1.put("data3","-2.67");
map1.put("data4","-3.23");
map1.put("data5","-2.25");
map1.put("data6","-3.39");
map1.put("unit","mV");
Map<String,Object> map2 = new HashMap<>();
map2.put("name","MLSS测定仪");
map2.put("data1","11.23");
map2.put("data2","1225");
map2.put("data3","15.20");
map2.put("data4","7.56");
map2.put("data5","9.23");
map2.put("data6","8.32");
map2.put("data7","8.96");
map2.put("data8","7.55");
map2.put("unit","mg/L");
Map<String,Object> map3 = new HashMap<>();
map3.put("name","DO测定仪");
map3.put("data1","11.23");
map3.put("data2","12.25");
map3.put("data3","15.20");
map3.put("data4","7.56");
map3.put("data5","9.23");
map3.put("data6","8.32");
map3.put("data7","8.96");
map3.put("data8","7.55");
map3.put("unit","mg/L");
if(monitorList.size()==1){
Map<String,Object> monitorMap = monitorList.get(0);
map1.put("data1",monitorMap.get("BKYHWSC_PLC2X_Tag2").toString());
map1.put("data2",monitorMap.get("BKYHWSC_PLC2X_Tag4").toString());
map1.put("data3",monitorMap.get("BKYHWSC_PLC2X_Tag6").toString());
map1.put("data4",monitorMap.get("BKYHWSC_PLC2X_Tag8").toString());
map1.put("data5",monitorMap.get("BKYHWSC_PLC2X_Tag10").toString());
map1.put("data6",monitorMap.get("BKYHWSC_PLC2X_Tag12").toString());
map2.put("data1",monitorMap.get("BKYHWSC_PLC2X_Tag14").toString());
map2.put("data2",monitorMap.get("BKYHWSC_PLC2X_Tag16").toString());
map2.put("data3",monitorMap.get("BKYHWSC_PLC2X_Tag18").toString());
map2.put("data4",monitorMap.get("BKYHWSC_PLC2X_Tag20").toString());
map2.put("data5",monitorMap.get("BKYHWSC_PLC2X_Tag22").toString());
map2.put("data6",monitorMap.get("BKYHWSC_PLC2X_Tag24").toString());
map2.put("data7",monitorMap.get("BKYHWSC_PLC2X_Tag26").toString());
map2.put("data8",monitorMap.get("BKYHWSC_PLC2X_Tag28").toString());
map3.put("data1",monitorMap.get("BKYHWSC_PLC2X_Tag30").toString());
map3.put("data2",monitorMap.get("BKYHWSC_PLC2X_Tag32").toString());
map3.put("data3",monitorMap.get("BKYHWSC_PLC2X_Tag34").toString());
map3.put("data4",monitorMap.get("BKYHWSC_PLC2X_Tag36").toString());
map3.put("data5",monitorMap.get("BKYHWSC_PLC2X_Tag38").toString());
map3.put("data6",monitorMap.get("BKYHWSC_PLC2X_Tag40").toString());
map3.put("data7",monitorMap.get("BKYHWSC_PLC2X_Tag42").toString());
map3.put("data8",monitorMap.get("BKYHWSC_PLC2X_Tag44").toString());
}
list.add(map1);
list.add(map2);
list.add(map3);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "监控数量信息")
@ApiOperation(value="监控数量信息", notes="监控数量信息")
@RequestMapping(value = "/monitor", method = RequestMethod.GET)
public Result<Map<String,Object>> getMonitor() {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map.put("normal",87);
map.put("offLinel",0);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备状态总计")
@ApiOperation(value="设备状态总计", notes="设备状态总计")
@RequestMapping(value = "/equipStatusTotal", method = RequestMethod.GET)
public Result<Map<String,Object>> getEquipStatusTotal() {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
List<SysEquipInfo> list = sysEquipInfoService.queryEquipList();
map.put("fault",0);
map.put("run",list.size());
map.put("stop",8);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备状态")
@ApiOperation(value="设备状态", notes="设备状态")
@RequestMapping(value = "/equipmentStatus", method = RequestMethod.GET)
public Result<List<ResultEquipStatus>> getEquipmentStatus() {
Result<List<ResultEquipStatus>> result = new Result<>();
List<ResultEquipStatus> list = new ArrayList<>();
list = sysEquipInfoService.getEquipmentStatus(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备报警列表")
@ApiOperation(value="设备报警列表", notes="设备报警列表")
@RequestMapping(value = "/equipmentAlarm", method = RequestMethod.GET)
public Result<List<Map<String,Object>>> getEquipmentAlarm() {
Result<List<Map<String,Object>>> result = new Result<>();
List<Map<String,Object>> list = new ArrayList<>();
list = sysEquipInfoService.getEquipidAlarmList(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "拉去配置信息")
@ApiOperation(value="拉去配置信息", notes="拉去配置信息")
@RequestMapping(value = "/download", method = RequestMethod.GET)
public Result<SysMonthData> getConfigInfo(String month) {
Result<SysMonthData> result = new Result<>();
SysMonthData sysMonthData = new SysMonthData();
sysMonthData = sysMonthDataService.getConfigInfo(factoryId,month);
result.setResult(sysMonthData);
result.setSuccess(true);
return result;
}
@AutoLog(value = "月度数据信息添加")
@ApiOperation(value="月度数据信息添加", notes="月度数据信息添加")
@PostMapping(value = "/upload")
public Result<SysMonthData> addConfigInfo(@RequestBody SysMonthData sysMonthData) {
Result<SysMonthData> result = new Result<SysMonthData>();
try {
SysMonthData bean = sysMonthDataService.getConfigInfo(factoryId,sysMonthData.getMonth());
sysMonthData.setFactoryId(factoryId);
if(bean != null){
//修改
sysMonthData.setId(bean.getId());
sysMonthDataService.updateById(sysMonthData);
}else{
sysMonthDataService.save(sysMonthData);
}
result.success("添加成功!");
result.setResult(sysMonthData);
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
}
return result;
}
@AutoLog(value = "获取安全区域列表")
@ApiOperation(value="获取安全区域列表", notes="获取安全区域列表")
@GetMapping(value = "/getSafeList")
public Result<List<Map<String,Object>>> getSafeList() {
Result<List<Map<String,Object>>> result = new Result<>();
List<Map<String,Object>> list = new ArrayList<>();
list = sysSafeAreaService.getSafeList(factoryId);
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "获取安全区域信息")
@ApiOperation(value="获取安全区域信息", notes="获取安全区域信息")
@GetMapping(value = "/getSafeInfo")
public Result<SysSafeArea> getSafeInfo(String structId) {
Result<SysSafeArea> result = new Result<>();
SysSafeArea sysSafeArea = new SysSafeArea();
sysSafeArea = sysSafeAreaService.getSafeInfo(factoryId,structId);
result.setResult(sysSafeArea);
result.setSuccess(true);
return result;
}
@AutoLog(value = "获取摄像头列表")
@ApiOperation(value="获取摄像头列表", notes="获取摄像头列表")
@GetMapping(value = "/getVideoList")
public Result<Map<String,Object>> getVideoList(String structId) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = tVideoService.getVideoList(factoryId,structId);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "监测数据接口")
@GetMapping(value = "/monitorData")
public Result<Map<String,Object>> getMonitorData(String equipId) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysFactoryInfoService.getMonitorData(factoryId,equipId);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "实时数据历史信息")
@GetMapping(value = "/monitorHistory")
public Result<Map<String,Object>> getMonitorHistory(String type,String montorId) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysFactoryInfoService.getMonitorHistory(factoryId, type, montorId);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "电子看板数据接口")
@GetMapping(value = "/digitalSignageInfo")
public Result<Map<String,Object>> getDigitalSignageInfo(String structId) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysMonthDataService.getDigitalSignageInfo(factoryId,structId);
result.setResult(map);
result.setSuccess(true);
return result;
}
@AutoLog(value = "电子看板数据接口")
@GetMapping(value = "/digitalSignageData")
public Result<Map<String,Object>> getDigitalSignageData(String structId) {
Result<Map<String,Object>> result = new Result<>();
Map<String,Object> map = new HashMap<>();
map = sysMonthDataService.getDigitalSignageData(factoryId,structId);
result.setResult(map);
result.setSuccess(true);
return result;
}
}