package com.usky.alarm.controller.web;


import com.aliyuncs.exceptions.ClientException;
import com.usky.alarm.domain.BaseAlarm;
import com.usky.alarm.service.BaseAlarmService;
import com.usky.alarm.service.BaseAlarmStatisticService;
import com.usky.common.core.bean.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 告警统计表 前端控制器
 * </p>
 *
 * @author han
 * @since 2023-11-24
 */
@RestController
@RequestMapping("/baseAlarmStatistic")
public class BaseAlarmStatisticController {
    @Autowired
    private BaseAlarmStatisticService baseAlarmStatisticService;

    @GetMapping("/add")
    public ApiResult<Void> add(@RequestParam(value = "alarmId") Integer alarmId) throws ClientException {
        baseAlarmStatisticService.baseAlarmStatisticTask(alarmId);
        return ApiResult.success();
    }

    /**
     * 综合云图-告警及隐患折线图接口
     *
     * @param deptId 部门ID
     * @param dateType 时间类型
     * @return
     */
    @GetMapping("/alarmStatistic")
    public ApiResult<List<Map<String,Object>>> alarmStatistic(@RequestParam(value = "deptId", required = false) Integer deptId,
                                                              @RequestParam(value = "dateType", required = false) Integer dateType){
        return ApiResult.success(baseAlarmStatisticService.alarmStatistic(deptId,dateType));
    }
}

