package com.huatek.busi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.service.BusiSubPageService;
import com.huatek.busi.service.threshold.InfraredThresholdService;
import com.huatek.busi.service.threshold.WindingThresholdService;
import com.huatek.busi.vo.BusiInfraredVo;
import com.huatek.busi.vo.BusiWindingVo;
import com.huatek.busi.vo.InfraredThresholdVo;
import com.huatek.busi.vo.WindingThresholdVo;
import com.huatek.torch.frame.log.KerLog;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 绕组测温数据
 * @author buck_guo
 * @date 2019/08/08
 */
@Api(tags = {Tags.WINDING_THRESHOLD})
@RestController
@RequestMapping("/app/WindingThreshold")
public class WindingThresholdController {
    protected final Logger logger = LoggerFactory.getLogger(WindingThresholdController.class);
    @Reference(check = false)
    private BusiSubPageService busiSubPageService;

    @Reference(check = false)
    private WindingThresholdService windingThresholdService;

    /**
     * 根据sensorCode、状态获取绕组测温阈值
     * @param sensorCode
     * @param workStatus
     * @return
     */
    @ApiOperation(value ="根据sensorCode、状态获取绕组测温阈值")
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERPD.MODELNAME", methodName = "TRANSFORMERPD.METHODNAME.QUERYLIST")
    @GetMapping(value="/findWindingThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findWindingThreshold(@RequestParam(value="sensorCode")String sensorCode,@RequestParam(value="workStatus")String workStatus) {
        WindingThresholdVo windingThresholdVo = windingThresholdService.queryWindingThreshold(sensorCode, workStatus);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", windingThresholdVo);
    }

    /**
     * 根据sensorCode获取绕组测温阈值
     * @param sensorCode
     * @return
     */
    @ApiOperation(value ="根据sensorCode获取绕组测温阈值")
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERPD.MODELNAME", methodName = "TRANSFORMERPD.METHODNAME.QUERYLIST")
    @PostMapping(value="/findWindingThresholdBySensorCode", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findWindingThresholdBySensorCode(@RequestParam(value="sensorCode")String sensorCode) {
        List<WindingThresholdVo> windingThresholdVo = windingThresholdService.queryWindingThresholdBySensorCode(sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", windingThresholdVo);
    }

    /**
     * @Title: getPdWarningInfo
     * @Description: 绕组测温告警信息
     * @createDate: Aug 2, 2019 2:22:03 PM
     * @param    warningId    告警ID
     * @param    sensorCode   传感器编码
     * @return   Map<String,Object>
     */
    @ApiOperation(value = "绕组测温告警信息", response = BusiInfraredVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warningId", value="告警ID"),
            @ApiImplicitParam(name = "sensorCode", value="传感器编码"),
            @ApiImplicitParam(name = "pdType", value="")
    })
    @GetMapping(value = "/getBusiWinding")
    public Map<String, Object> getBusiWinding(@RequestParam("warningId") String warningId,
                                               @RequestParam("sensorCode") String sensorCode, @RequestParam("eqType") String eqType) {
        BusiWindingVo vo = busiSubPageService.getBusiWinding(warningId, sensorCode,eqType);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }

}
