package com.securitycontrol.screen.controller;

import com.securitycontrol.common.core.web.controller.BaseController;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.core.web.page.TableDataInfo;
import com.securitycontrol.common.log.annotation.Log;
import com.securitycontrol.common.log.enums.OperationType;
import com.securitycontrol.entity.screen.dto.TowerAssInspectDto;
import com.securitycontrol.entity.screen.vo.AlarmMgeVo;
import com.securitycontrol.entity.screen.vo.TowerAssInspectVo;
import com.securitycontrol.screen.service.TowerAssInspectService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lsun
 * 组塔检测
 */
@RestController
@RequestMapping("/largeScreen/towerAssInspect/")
@Slf4j
public class TowerAssInspectController extends BaseController {

    @Resource(name = "TowerAssInspectService")
    private TowerAssInspectService service;

    /**
     * 设备列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "设备列表")
    @GetMapping("getDeviceList")
    @Log(title = "组塔检测", menu = "组塔检测->设备列表", grade = OperationType.QUERY_BUSINESS, details = "查询设备列表", type = "业务日志")
    public AjaxResult getDeviceList(TowerAssInspectDto dto) {
        return service.getDeviceList(dto);
    }

    /**
     * 实时检测
     * @param dto
     * @return
     */
    @ApiOperation(value = "实时检测")
    @GetMapping("getRealTimeDetection")
    @Log(title = "组塔检测", menu = "组塔检测->实时检测", grade = OperationType.QUERY_BUSINESS, details = "查询实时检测", type = "业务日志")
    public AjaxResult getRealTimeDetection(TowerAssInspectDto dto) {
        return service.getRealTimeDetection(dto);
    }

    /**
     * 当日检测变化趋势
     * @param dto
     * @return
     */
    @ApiOperation(value = "当日检测变化趋势")
    @GetMapping("getTrend")
    @Log(title = "组塔检测", menu = "组塔检测->当日检测变化趋势", grade = OperationType.QUERY_BUSINESS, details = "查询当日检测变化趋势", type = "业务日志")
    public AjaxResult getTrend(TowerAssInspectDto dto) {
        return service.getTrend(dto);
    }

    @ApiOperation(value = "实时告警")
    @GetMapping("getRealTimeAlarmList")
    @Log(title = "实时告警", menu = "告警管理->实时告警", grade = OperationType.QUERY_BUSINESS, details = "查询实时告警列表", type = "业务日志")
    public TableDataInfo getRealTimeAlarmList(TowerAssInspectDto dto) {
        try{
            startLayPage();
            List<TowerAssInspectVo> list = service.getRealTimeAlarmList(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

    @ApiOperation(value = "历史记录")
    @GetMapping("getHistoryList")
    @Log(title = "历史记录", menu = "告警管理->历史记录", grade = OperationType.QUERY_BUSINESS, details = "查询历史记录列表", type = "业务日志")
    public TableDataInfo getHistoryList(TowerAssInspectDto dto) {
        try{
            startLayPage();
            List<TowerAssInspectVo> list = service.getHistoryList(dto);
            return getDataTableLayui(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBadLayui(new ArrayList<>(),"请求出错了");
        }
    }

}
