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);
|
}
|
}
|