package com.huatek.busi.controller;

import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.dto.TransformerIcgeThresholdDto;
import com.huatek.busi.service.BusiSubPageService;
import com.huatek.busi.service.threshold.TransformerIcgeThresholdService;
import com.huatek.busi.vo.TransformerIcgeThresholdVo;
import com.huatek.busi.vo.warning.BusiIcgeVo;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 铁芯夹件
 * @author buck_guo
 * @date 2019/08/20
 */
@Api(tags = {Tags.BUSI_TXJJ_SENSOR_THRESHOLD})
@RestController
@RequestMapping("/app/IcgeWarnningAndThreshold")
public class IcgeWarnningAndThresholdController {

    @Reference(check = false)
    private TransformerIcgeThresholdService transformerIcgeThresholdService;

    @Reference(check = false)
    private BusiSubPageService busiSubPageService;

    /**
     * @Title: getIcgeWarningInfo
     * @Description: 铁芯接地信息
     * @createDate: Aug 2, 2019 2:22:03 PM
     * @param    warningId    告警ID
     * @param    sensorCode   传感器编码
     * @return   Map<String,Object>
     */
    @ApiOperation(value = "铁芯夹件信息", response = BusiIcgeVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warningId", value="告警ID"),
            @ApiImplicitParam(name = "sensorCode", value="传感器编码")
    })
    @GetMapping(value = "/getIcgeWarningInfo")
    public Map<String, Object> getIcgeWarningInfo(@RequestParam("warningId") String warningId,
                                                  @RequestParam("sensorCode") String sensorCode) {
        BusiIcgeVo vo = busiSubPageService.getIcgeWarningInfo(warningId, sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }

    /**
     * 根据sensorCode、runstate获取变压器铁芯夹件传感器阈值详情
     * @param id id
     * @return map map
     */
    @ApiOperation(value = Tags.BUSI_TXJJ_SENSOR_THRESHOLD_INFO)
    @PostMapping(value = "/findTransformerIcgeThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object>
    findTransformerIcgeThreshold(@RequestParam("sensorCode") String sensorCode,@RequestParam("runState") String runState) {

        TransformerIcgeThresholdDto transformerIcgeThresholdDto = new TransformerIcgeThresholdDto();
        transformerIcgeThresholdDto.setSensorCode(sensorCode);
        transformerIcgeThresholdDto.setRunState(runState);
        TransformerIcgeThresholdVo vo =
                transformerIcgeThresholdService.getTransformerIcgeThresholdVo(transformerIcgeThresholdDto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }

    /**
     * 根据sensorCode获取变压器铁芯夹件传感器阈值详情
     * @param id id
     * @return map map
     */
    @ApiOperation(value = Tags.BUSI_TXJJ_SENSOR_THRESHOLD_INFO_SENSORCODE)
    @GetMapping(value = "/findTransformerIcgeThresholdBySensorCode", produces = {"application/json;charset=utf-8"})
    public Map<String, Object>
    findTransformerIcgeThresholdBySensorCode(@RequestParam("sensorCode") String sensorCode) {

        TransformerIcgeThresholdDto transformerIcgeThresholdDto = new TransformerIcgeThresholdDto();
        transformerIcgeThresholdDto.setSensorCode(sensorCode);
        List<TransformerIcgeThresholdVo> vo =
                transformerIcgeThresholdService.getTransformerIcgeThresholdVoList(transformerIcgeThresholdDto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }
}
