package com.xydl.cac.old;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@Api(tags = "旧接口")
@RestController
@RequestMapping("EquipController")
public class EquipmentController {

    @Resource
    OldService service;

    /**
     * 获取设备数量
     *
     * @return
     */
    @ApiOperation(value = "获取设备数量数据")
    @GetMapping(value = "/queryEquipNum")
    public AjaxResult queryEquipNum() {
        Equipment equipment = service.queryEquipNum();
        return AjaxResult.success(equipment);
    }

//    /**
//     * 获取微气象数据（默认取主变1）
//     */
//    @ApiOperation(value = "获取微气象数据")
//    @GetMapping(value = "/queryMicroclimate")
//    public AjaxResult queryMicroclimate() {
//        // 取主变1的微气象设备id
//        Integer eqmid = 186;
//        MicroclimateVo microclimateVo = cableCirculationMapper.getMicroclimate(eqmid);
//        return AjaxResult.success(microclimateVo);
//    }
//
//    /**
//     * return:
//     * {
//     * "变压器": 1,
//     * "GIS": 2,
//     * "避雷器": 3,
//     * "开关柜": 4,
//     * "电缆": 5,
//     * "发电机": 6
//     * }
//     */
//    @ApiOperation(value = "获取变电设备类型")
//    @GetMapping(value = "/queryJg")
//    public AjaxResult queryJgEqm() {
//        List<BaseDevice> jgDevices = cableCirculationMapper.getJgDevice(1);
//        Map<String, String> jgMap = new HashMap<>();
//        for (BaseDevice device : jgDevices) {
//            jgMap.put(device.getMc(), device.getId());
//        }
//        return AjaxResult.success(jgMap);
//    }

    /**
     * 获取设备小类类型
     */
    @ApiOperation(value = "获取设备小类类型")
    @GetMapping(value = "/getLxType/{jgid}")
    public AjaxResult getLxType(@PathVariable @ApiParam(value = "变电设备id") Integer jgid) throws Exception {
        List<BaseLxDevice> lxDevices = service.getLxDevice(jgid);
        return AjaxResult.success(lxDevices);
    }

    //
//    /**
//     * 获取设备小类类型
//     */
//    @ApiOperation(value = "获取监测设备类型")
//    @GetMapping(value = "/getEqType/{jgid}/{lxid}")
//    public AjaxResult geteqType(@PathVariable @ApiParam(value = "变电设备id") Integer jgid, @PathVariable @ApiParam(value = "监测设备类型id") Integer lxid) {
//        List<BaseEqmDevice> eqTypes = equipmentMapper.getEqType(jgid,lxid);
//        return AjaxResult.success(eqTypes);
//    }

    /**
     * return
     * {
     * "lxid": "1",
     * "lmc": "1#主变"
     * },
     * {
     * "lxid": "2",
     * "lmc": "2#主变"
     * }
     */
    @ApiOperation(value = "获取设备类型(lxid)")
    @GetMapping(value = "/queryLx/{jgid}/{mtid}")
    public AjaxResult queryLxEqm(@PathVariable @ApiParam(value = "间隔id") Integer jgid, @PathVariable @ApiParam(value = "监测设备类型id") List<String> mtid) throws Exception {
        List<BaseLxDevice> lxDevices = service.getLxDevice(jgid, mtid);
        return AjaxResult.success(lxDevices);
    }

    /**
     * {
     * "id": "1",  -》eqmid(传给图表数据接口，用于获取监测设备的图表数据)
     * "name": "铁芯"
     * }
     */
    @ApiOperation(value = "获取设备id(eqmid)")
    @GetMapping(value = "/queryEqmId/{jgid}/{lxid}/{mtid}")
    public AjaxResult queryEqmId(@PathVariable @ApiParam(value = "间隔id") Integer jgid, @PathVariable @ApiParam(value = "设备类型id") Integer lxid, @PathVariable @ApiParam(value = "监测设备类型id") List<String> mtid) throws Exception {
        List<BaseEqmDevice> eqmDevice = service.getEqmDevice(jgid, lxid, mtid);
        return AjaxResult.success(eqmDevice);
    }
}
