package com.huatek.busi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant;
import com.huatek.busi.entity.*;
import com.huatek.busi.service.*;
import com.huatek.busi.vo.EquipmentOnlineRateVo;
import com.huatek.busi.vo.EquipmentTemperatureCacheVo;
import com.huatek.busi.vo.SensiorIdExportVo;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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:mitchell
 */
@Api(tags = {ApiConstant.Tags.BUSI_EQUIPMENT_ONLINERATE})
@RestController
@RequestMapping("/api/equipmentOnlineRate")
public class EquipmentOnlineController {

    @Reference(check = false)
    TransformerNumberService transformerNumberService;

    @Reference(check = false)
    GisNumberService gisNumberService;

    @Reference(check = false)
    CableNumberService cableNumberService;

    @Reference(check = false)
    ArresterNumberService arresterNumberService;

    @Reference(check = false)
    CubicleNumberService cubicleNumberService;

    /**
     * 查询所有设备外挂装置和在线率
     */
    @ApiOperation(value = "查询所有设备外挂装置和在线率")
    @GetMapping(value="/selectSumSensorNumber")
    public Map<String, Object> selectSumSensorNumber () {
        EquipmentSumSensorCache sum = transformerNumberService.findSumSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", sum);
    }



    /**
     * 查询变压器总外挂装置和在线率
     */
    @ApiOperation(value = "查询变压器总外挂装置和在线率")
    @GetMapping(value="/selectSumTransformerSensorNumber")
    public Map<String, Object> selectSumTransformerSensorNumber () {
       EquipmentSumSensorCache transformerSensorNumber = transformerNumberService.findSumTransformerSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", transformerSensorNumber);
    }
    /**
     * 查询变压器总外挂装置和在线率
     */
    @ApiOperation(value = "查询设备信息详情")
    @GetMapping(value="/selectSumTransformerSensorInfo")
    public Map<String, Object> selectSumTransformerSensorInfo (@RequestParam String flag,@RequestParam String type) {
        List<EquipmentTemperatureCacheVo> transformerSensorNumber = transformerNumberService.selectSumTransformerSensorInfo(flag,type);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", transformerSensorNumber);
    }

    /**
     * 查询变压器外挂装置和在线率
     */
    @ApiOperation(value = "查询变压器外挂装置和在线率")
    @GetMapping(value="/selectTransformerSensorNumber")
    public Map<String, Object> selectTransformerSensorNumber (@RequestParam String mainEquipmentId) {
        List<EquipmentSensorCache> list = transformerNumberService.findTransformerSensorNumber(mainEquipmentId);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", list);
    }

    /**
     * 查询Gis外挂装置和在线率
     */
    @ApiOperation(value = "查询Gis外挂装置和在线率")
    @GetMapping(value="/selectGisSensorNumber")
    public Map<String, Object> selectGisSensorNumber (@RequestParam String mainEquipmentId) {
        List<EquipmentSensorCache> list = gisNumberService.findGisSensorNumber(mainEquipmentId);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", list);
    }

    /**
     * 查询Gis总外挂装置和在线率
     */
    @ApiOperation(value = "查询Gis外挂装置和在线率")
    @GetMapping(value="/selectSumGisSensorNumber")
    public Map<String, Object> selectSumGisSensorNumber () {
        EquipmentSumSensorCache gis = gisNumberService.findSumGisSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", gis);
    }



    /**
     * 查询电缆外挂装置和在线率
     */
    @ApiOperation(value = "查询电缆外挂装置和在线率")
    @GetMapping(value="/selectCableSensorNumber")
    public Map<String, Object> selectCableSensorNumber (@RequestParam String mainEquipmentId) {
        List<EquipmentSensorCache> list = cableNumberService.findCableSensorNumber(mainEquipmentId);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", list);
    }


    /**
     * 查询总电缆外挂装置和在线率
     */
    @ApiOperation(value = "查询总电缆外挂装置和在线率")
    @GetMapping(value="/selectSumCableSensorNumber")
    public Map<String, Object> selectSumCableSensorNumber () {
        EquipmentSumSensorCache cable = cableNumberService.findSumCableSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", cable);
    }


    /**
     * 查询避雷器外挂装置和在线率
     */
    @ApiOperation(value = "查询避雷器外挂装置和在线率")
    @GetMapping(value="/selectArresterSensorNumber")
    public Map<String, Object> selectArresterSensorNumber (@RequestParam String mainEquipmentId) {
        List<EquipmentSensorCache> list = arresterNumberService.findArresterSensorNumber(mainEquipmentId);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", list);
    }


    /**
     * 查询总避雷器外挂装置和在线率
     */
    @ApiOperation(value = "查询总避雷器外挂装置和在线率")
    @GetMapping(value="/selectSumArresterSensorNumber")
    public Map<String, Object> selectSumArresterSensorNumber () {
       EquipmentSumSensorCache arrester = arresterNumberService.findSumArresterSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", arrester);
    }



    /**
     * 查询开关柜外挂装置和在线率
     */
    @ApiOperation(value = "查询开关柜外挂装置和在线率")
    @GetMapping(value="/selectCubicleSensorNumber")
    public Map<String, Object> selectCubicleSensorNumber (@RequestParam String mainEquipmentId) {
        List<EquipmentSensorCache> list = cubicleNumberService.findCubicleSensorNumber(mainEquipmentId);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", list);
    }


    /**
     * 查询总开关柜外挂装置和在线率
     */
    @ApiOperation(value = "查询总开关柜外挂装置和在线率")
    @GetMapping(value="/selectSumCubicleSensorNumber")
    public Map<String, Object> selectSumCubicleSensorNumber () {
        EquipmentSumSensorCache cubicle = cubicleNumberService.findSumCubicleSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", cubicle);
    }

    /**
     * 查询所有设备外挂装置和在线率
     */
    @ApiOperation(value = "获取所有设备外挂装置数量以及在线率")
    @GetMapping(value="/getAllDeviceSensorNumber")
    public Map<String, Object> getAllDeviceSensorNumber () {
        Map<String, EquipmentSumSensorCache> map = transformerNumberService.getAllDeviceSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", map);
    }

    @ApiOperation(value = "获取关键装置数量以及在线率")
    @GetMapping(value = "/getMajorDeviceSensorNumber")
    public Map<String, Object> getMajorDeviceSensorNumber() {
        Map<String, EquipmentOnlineRateVo> map = transformerNumberService.getMajorDeviceSensorNumber();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", map);
    }

}
