package com.huatek.busi.controller;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.service.BusiSubPageService;
import com.huatek.busi.service.threshold.InfraredThresholdService;
import com.huatek.busi.vo.BusiInfraredVo;
import com.huatek.busi.vo.InfraredThresholdVo;
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;

/**
 * 红外热成像数据
 * @author buck_guo
 * @date 2019/08/08
 */
@Api(tags = {Tags.INFRARED_THRESHOLD})
@RestController
@RequestMapping("/app/InfraredThreshold")
public class InfraredThresholdController {
    protected final Logger logger = LoggerFactory.getLogger(InfraredThresholdController.class);
    @Reference(check = false)
    private BusiSubPageService busiSubPageService;

    @Reference(check = false)
    private InfraredThresholdService infraredThresholdService;

    /**
     * 根据sensorCode、状态获取红外热成像阈值
     * @param sensorCode
     * @param workStatus
     * @return
     */
    @ApiOperation(value ="根据sensorCode、状态获取红外热成像阈值")
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERPD.MODELNAME", methodName = "TRANSFORMERPD.METHODNAME.QUERYLIST")
    @GetMapping(value="/findInfraredThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findInfraredThreshold(@RequestParam(value="sensorCode")String sensorCode,@RequestParam(value="workStatus")String workStatus) {
        InfraredThresholdVo infraredThresholdVo = infraredThresholdService.queryInfraredThreshold(sensorCode, workStatus);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", infraredThresholdVo);
    }

    /**
     * 根据sensorCode获取红外热成像阈值
     * @param sensorCode
     * @return
     */
    @ApiOperation(value ="根据sensorCode获取红外热成像阈值")
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERPD.MODELNAME", methodName = "TRANSFORMERPD.METHODNAME.QUERYLIST")
    @PostMapping(value="/findInfraredThresholdBySensorCode", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findInfraredThresholdBySensorCode(@RequestParam(value="sensorCode")String sensorCode) {
        List<InfraredThresholdVo> infraredThresholdVo = infraredThresholdService.queryInfraredThresholdBySensorCode(sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", infraredThresholdVo);
    }

    /**
     * @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 = "/getBusiInfrared")
    public Map<String, Object> getBusiInfrared(@RequestParam("warningId") String warningId,
                                               @RequestParam("sensorCode") String sensorCode, @RequestParam("eqType") String eqType) {
        BusiInfraredVo vo = busiSubPageService.getBusiInfrared(warningId, sensorCode,eqType);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }
}
