zxl
2026-03-25 0b39edb68acc67ed01fbfe5d31bfa776a1b17de1
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
package com.tievd.jyz.controller;
 
import cn.hutool.core.date.DateUtil;
import com.tievd.cube.commons.annotations.DictApi;
import com.tievd.cube.commons.base.Result;
import com.tievd.cube.commons.utils.SystemContextUtil;
import com.tievd.cube.modules.system.model.LoginUser;
import com.tievd.jyz.dto.AlarmStatDTO;
import com.tievd.jyz.entity.vo.AlarmEventVO;
import com.tievd.jyz.entity.vo.AlarmOverviewVO;
import com.tievd.jyz.entity.vo.OrgAlarmCountVO;
import com.tievd.jyz.entity.vo.PartitionAlarmStatVO;
import com.tievd.jyz.service.AlarmDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;
import java.util.Map;
 
/** 告警大屏
 * @author yang'zhi'shui
 */
@Slf4j
@DictApi
@RestController
@RequestMapping("/jyz/alarmData")
public class AlarmDataController {
 
    @Autowired
    private AlarmDataService alarmDataService;
 
    /**
     * 告警概况查询
     */
    @GetMapping("/overview")
    public Result<?> overview() {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        AlarmOverviewVO overviewVO = alarmDataService.overview(DateUtil.today(), currentLoginUser.getOrgCode());
        return Result.ok(overviewVO);
    }
 
    /**
     * 近一周告警量统计-加油站
     */
    @GetMapping("/alarmStat")
    public Result<?> alarmStat() {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        Map<String, List> result = alarmDataService.alarmStat(7, DateUtil.today(), currentLoginUser.getOrgCode());
        return Result.ok(result);
    }
 
    /**
     * 告警量统计-片区
     */
    @GetMapping("/regionAlarmStat")
    public Result<?> regionAlarmStat(@RequestParam(defaultValue = "10") Integer limit) {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        List<AlarmStatDTO> result = alarmDataService.regionAlarmStat(DateUtil.today(), currentLoginUser.getOrgCode(), limit);
        return Result.ok(result);
    }
 
    /**
     * 告警类型统计
     * @param freq 0表示当天 1表示当月
     */
    @GetMapping("/alarmTypeStat")
    public Result<?> alarmTypeStat(@RequestParam(defaultValue = "0") Integer freq) {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        Map<String, List> result = alarmDataService.alarmTypeStat(freq, currentLoginUser.getOrgCode());
        return Result.ok(result);
    }
 
    /**
     * 最新告警
     * @param limit 查询条数
     */
    @GetMapping("/latestAlarm")
    public Result<?> latestAlarm(@RequestParam(defaultValue = "10") Integer limit) {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        List<AlarmEventVO> result = alarmDataService.latestAlarm(DateUtil.today(), currentLoginUser.getOrgCode(), limit);
        return Result.ok(result);
    }
 
    /**
     * 设备在线统计
     * @param type 0表示终端设备 1表示网关设备
     */
    @GetMapping("/deviceStatusStat")
    public Result<?> deviceStatusStat(@RequestParam(defaultValue = "0") Integer type) {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        Map<String, List> result = alarmDataService.deviceStatusStat(currentLoginUser.getOrgCode(), type);
        return Result.ok(result);
    }
 
    /**
     * 告警趋势统计
     */
    @GetMapping("/alarmTrendStat")
    public Result<?> alarmTrendStat() {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        Map<String, List> result = alarmDataService.alarmTrendStat(7, DateUtil.today(), currentLoginUser.getOrgCode());
        return Result.ok(result);
    }
 
    /**
     * 告警数排行 按机构
     * @param freq 0表示当天 1表示当月*
     */
    @GetMapping("/alarmRanking")
    public Result<?> alarmRanking(@RequestParam(defaultValue = "3") Integer limit,
                                  @RequestParam(defaultValue = "0") Integer freq) {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        List<OrgAlarmCountVO> result = alarmDataService.alarmRanking(currentLoginUser.getOrgCode(), freq, limit);
        return Result.ok(result);
    }
 
    /**
     * 大屏
     */
    @GetMapping("/partitionAlarmStat")
    public Result<?> partitionAlarmStat() {
        LoginUser currentLoginUser = SystemContextUtil.currentLoginUser();
        Map<String, PartitionAlarmStatVO> result = alarmDataService.partitionAlarmStat(DateUtil.today(), currentLoginUser.getOrgCode());
        return Result.ok(result);
    }
}