package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.influx.core.InfluxDbUtils;
import com.usky.fire.service.AlarmDetectorService;
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.Map;

/**
 * <p>
 * 独立式无线探测器告警 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-08-08
 */
@RestController
@RequestMapping("/alarmDetector")
public class AlarmDetectorController {

    @Autowired
    private AlarmDetectorService alarmDetectorService;

    @Autowired
    private InfluxDbUtils influxDbUtils;

    /**
     * 物联网数据查询-左上实时数据查询
     *
     * @param field      字段名称
     * @param deviceCode 单位编号
     * @return
     */
    @GetMapping("leftData")
    public ApiResult<Map<String, Object>> leftData(@RequestParam(value = "field") String field,
                                                   @RequestParam(value = "deviceCode") String deviceCode) {
        return ApiResult.success(alarmDetectorService.leftData(field, deviceCode));
    }


    /**
     * 物联网数据查询-右上侧统计图
     *
     * @param field     字段名称
     * @param deviceCode 单位编号
     * @return
     */
    @GetMapping("statisticalChartData")
    public ApiResult<Map<String, Object>> statisticalChartData(@RequestParam(value = "field") String field,
                                                               @RequestParam(value = "deviceCode") String deviceCode) {
        return ApiResult.success(alarmDetectorService.statisticalChartData(field, deviceCode));
    }


}

