燕山石化溯源三维电子沙盘-【后端】-服务
6
13693261870
2023-07-29 4b4a150626f7943ee0811d7c3c718be0abe68b23
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
package com.yssh.controller;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
 
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yssh.service.WarningAnalyseService;
import com.yssh.utils.Result;
 
import javax.annotation.Resource;
import java.util.Date;
 
@Api(tags = "告警分析")
@RequestMapping("/warning")
@RestController
@SuppressWarnings("rawtypes")
public class WarningAnalyseController {
    @Resource
    private WarningAnalyseService warningService;
 
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "获取实时报警", notes = "获取实时报警分析数据")
    @GetMapping("/runAlarm")
    public Result alarmAnalyse(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.getRunTimeAlarmAnalyse(null == date ? new Date() : date));
    }
 
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "获取实时预警", notes = "获取实时预警分析数据")
    @GetMapping("/runWarning")
    public Result warningAnalyse(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.getRunTimeWarningAnalyse(null == date ? new Date() : date));
    }
 
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "本月预警报警统计", notes = "本月预警报警统计,返回参数alarmNumber对应值为本月报警数据量,参数warningNumber对应值为本月预警数据量")
    @GetMapping("/monthCount")
    public Result thisMonthCount(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.monthCount(null == date ? new Date() : date));
    }
 
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "一周预警报警数量变化趋势", notes = "一周预警报警数量变化趋势,返回参数alarmDayCount为一周每日报警统计数量列表,参数warningDayCount为一周每日预警统计数量列表")
    @GetMapping("/everydayCount")
    public Result everydayCount(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.everydayCount(null == date ? new Date() : date));
    }
 
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "三小时监测站点数据变化趋势", notes = "返回值为三小时监测站点监测数据,返回值为map集合,其中key为站点名称,value为list集合,保存每天监测数值数据")
    @GetMapping("/locationDataChange")
    public Result locationDataChange(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.select3Hours(null == date ? new Date() : date));
    }
 
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "获取本月监测大数据站点最大值TOP10", notes = "获取本月监测大数据站点最大值TOP10数量列表")
    @GetMapping("/monthTop10")
    public Result monthTop10() {
        return Result.OK(warningService.selectMonthTop10());
    }
 
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "根据时间获取报警和预警信息", notes = "根据时间获取报警和预警信息")
    @GetMapping("/getAlarmAndWarnByTime")
    public Result getAlarmAndWarnByTime(
            @RequestParam(value = "begin") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date begin,
            @RequestParam(value = "end") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date end) {
        if (null == begin || null == end) {
            return Result.error(null);
        }
        if (begin.getTime() > end.getTime()) {
            Date tmp = begin;
            begin = end;
            end = tmp;
        }
 
        return Result.OK(warningService.getAlarmAndWarnByTime(begin, end));
    }
}