AlarmAnalysisController.java 8.8 KB
package com.skua.modules.controller;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.skua.modules.alarmtmp.service.AlarmRecordHistoryService;
import com.skua.modules.alarmtmp.vo.AlarmRecordHistoryVO;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.util.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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;

/**
 * @Description 报警分析控制层
 * @Date 2020-12-16 17:08
 * @Param
 * @return
 **/
@Slf4j
@RestController
@RequestMapping("/alarm/analysis")
@Api(tags = "报警分析页面")
public class AlarmAnalysisController {


    @Autowired
    private AlarmRecordHistoryService alarmRecordHistoryService;

    /**
     * 重要报警排序列表 (type 1 出水水质 2重要设备)
     */
    @AutoLog(value = "重要报警排序列表查询")
    @ApiOperation(value = "重要报警排序列表查询", notes = "重要报警排序列表查询")
    @GetMapping(value = "/getAlarmImportantList")
    public Result<List<Map<String, Object>>> getAlarmImportantList(String time, String type) {

        Result<List<Map<String, Object>>> result = new Result<>();
        List<Map<String, Object>> data = Lists.newArrayList();
        if (StringUtils.isBlank(time)) {
            //time = DateUtils.getLastMonthOfMonth(DateUtils.getDate("yyyy-MM"));
            time = DateUtils.getDate("yyyy-MM");
        }
        data = alarmRecordHistoryService.getAlarmImportantList(time, type);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }


    @AutoLog(value = "数据断线列表查询")
    @ApiOperation(value = "数据断线列表查询", notes = "数据断线列表查询")
    @GetMapping(value = "/getOffLineList")
    public Result<Map<String, Object>> getOffLineList(String time) {

        Result<Map<String, Object>> result = new Result<>();
        Map<String, Object> data = Maps.newHashMap();
        if (StringUtils.isBlank(time)) {
            time = DateUtils.getDate("yyyy-MM");
        }
        data = alarmRecordHistoryService.getOffLineList(time);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }


    @AutoLog(value = "报警类型分析查询")
    @ApiOperation(value = "报警类型分析查询", notes = "报警类型分析查询")
    @GetMapping(value = "/getAlarmTypeAnalysis")
    public Result<Map<String, Object>> getAlarmTypeAnalysis(String time) {

        Result<Map<String, Object>> result = new Result<>();
        if (StringUtils.isBlank(time)) {
            time = DateUtils.getDate("yyyy-MM");
        }
        Map<String, Object> data = alarmRecordHistoryService.getAlarmTypeAnalysis(time);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }


    @AutoLog(value = "水质报警列表查询")
    @ApiOperation(value = "水质报警列表查询", notes = "水质报警列表查询")
    @GetMapping(value = "/getWaterAlarmList")
    public Result<List<Map<String, Object>>> getWaterAlarmList(String time) {

        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isBlank(time)) {
            time = DateUtils.getDate("yyyy-MM");
        }
        List<Map<String, Object>> data = alarmRecordHistoryService.getWaterAlarmList(time);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }

    @AutoLog(value = "过程仪表报警列表查询")
    @ApiOperation(value = "过程仪表报警列表查询", notes = "过程仪表报警列表查询")
    @GetMapping(value = "/getProcessAlarmList")
    public Result<List<Map<String, Object>>> getProcessAlarmList(String time) {

        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isBlank(time)) {
            time = DateUtils.getDate("yyyy-MM");
        }
        List<Map<String, Object>> data = alarmRecordHistoryService.getProcessAlarmList(time);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }


    @AutoLog(value = "水量报警列表查询")
    @ApiOperation(value = "水量报警列表查询", notes = "水量报警列表查询")
    @GetMapping(value = "/getWaterCountAlarmList")
    public Result<List<Map<String, Object>>> getWaterCountAlarmList(String time) {

        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isBlank(time)) {
            time = DateUtils.getDate("yyyy-MM");
        }
        List<Map<String, Object>> data = alarmRecordHistoryService.getWaterCountAlarmList(time);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }

    @AutoLog(value = "设备报警查询")
    @ApiOperation(value = "设备报警查询", notes = "设备报警查询")
    @GetMapping(value = "/getEquipAlarm")
    public Result<Map<String, Object>> getEquipAlarm(String time) {

        Result<Map<String, Object>> result = new Result<>();
        if (StringUtils.isBlank(time)) {
            time = DateUtils.getDate("yyyy-MM");
        }
        Map<String, Object> data = alarmRecordHistoryService.getEquipAlarm(time);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }

    @AutoLog(value = "质量报警列表查询")
    @ApiOperation(value = "质量报警列表查询", notes = "质量报警列表查询")
    @GetMapping(value = "/getQualityAlarmList")
    public Result<List<Map<String, Object>>> getQualityAlarmList(String time) {

        Result<List<Map<String, Object>>> result = new Result<>();
        if (StringUtils.isBlank(time)) {
            time = DateUtils.getDate("yyyy-MM");
            //time = DateUtils.getLastMonthOfMonth(DateUtils.getDate("yyyy-MM"));
        }
        List<Map<String, Object>> data = alarmRecordHistoryService.getQualityAlarmList(time);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }

    @AutoLog(value = "APP报警列表查询")
    @ApiOperation(value = "APP报警列表查询", notes = "APP报警列表查询")
    @GetMapping(value = "/getAppWaterAlarmList")
    public Result<Map<String, Object>> getAppWaterAlarmList(AlarmRecordHistoryVO alarmRecordHistoryVO) {

        Result<Map<String, Object>> result = new Result<>();
        Map<String, Object> data = alarmRecordHistoryService.getAppWaterAlarmList(alarmRecordHistoryVO);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }

    @AutoLog(value = "APP报警详情查询")
    @ApiOperation(value = "APP报警详情查询", notes = "APP报警详情查询")
    @GetMapping(value = "/getAppWaterAlarmDetail")
    public Result<Map<String, Object>> getAppWaterAlarmDetail(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                              AlarmRecordHistoryVO alarmRecordHistoryVO) {

        Result<Map<String, Object>> result = new Result<>();
        Map<String, Object> data = alarmRecordHistoryService.getAppWaterAlarmDetail(alarmRecordHistoryVO,pageNo,pageSize);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }

    @AutoLog(value = "APP报警等级次数查询")
    @ApiOperation(value = "APP报警等级次数查询", notes = "APP报警等级次数查询")
    @GetMapping(value = "/getAppWaterAlarmCount")
    public Result<Map<String, Object>> getAppWaterAlarmCount(AlarmRecordHistoryVO alarmRecordHistoryVO) {

        Result< Map<String, Object>> result = new Result<>();
        Map<String, Object> data = alarmRecordHistoryService.getAppWaterAlarmCount(alarmRecordHistoryVO);
        result.setResult(data);
        result.setSuccess(true);
        return result;

    }

    @AutoLog(value = "web趋势")
    @ApiOperation(value = "web趋势", notes = "web趋势")
    @GetMapping(value = "/getSZTreadWeb")
    public Result<Map<String, Object>> getSZTreadWeb(String departId, String timeType, String startTime, String endTime,String id) {
        Result<Map<String, Object>> result = new Result<>();
        Map<String, Object> data = alarmRecordHistoryService.getSZTreadWeb(departId, timeType, startTime,endTime,id);
        result.setResult(data);
        result.setSuccess(true);
        return result;
    }
}