package com.huatek.busi.controller;

import java.util.Map;

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 com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.entity.BusiTemperPoint;
import com.huatek.busi.service.BusiSubPageService;
import com.huatek.busi.service.temperature.BusiTemperPointService;
import com.huatek.busi.vo.BusiTemperPointVo;
import com.huatek.busi.vo.warning.BusiWcgVo;
import com.huatek.frame.base.util.BeanUtils;
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.TEMPER_WARNNING_THRESHOLD})
@RestController
@RequestMapping("/app/TemperWarnningAndThreshold")
public class TemperWarnigAndThresholdController {
    @Reference(check = false)
    private BusiSubPageService busiSubPageService;

    @Reference(check = false)
    private BusiTemperPointService busiTemperPointService;
    /**
     * @Title: getCwgInfo
     * @Description:测温柜告警信息
     * @createDate: Aug 15, 2019 2:17:53 PM
     * @param warningId
     *            告警ID
     * @param sensorCode
     *            传感器编码
     * @return Map<String,Object>
     */
    @ApiOperation(value = "测温柜告警信息", response = BusiWcgVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warningId", value = "告警ID"),
            @ApiImplicitParam(name = "sensorCode", value = "传感器编码")
    })
    @GetMapping(value = "/getCwgInfo")
    public Map<String, Object> getCwgInfo(@RequestParam("warningId") String warningId,
                                          @RequestParam("sensorCode") String sensorCode) {
        BusiWcgVo vo = busiSubPageService.getCwgInfo(warningId, sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }

    /**
     * 查询测温点阈值查询
     *
     * @param sensorCode
     * @return
     */
    @ApiOperation(value = "查询测温点阈值查询", response = BusiTemperPointVo.class)
    @GetMapping(value = "/findCWThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findCWThreshold(@RequestParam(value = "sensorCode") String sensorCode) {
        BusiTemperPoint busiTemperPoint = busiTemperPointService.findSensorBySensorCode(sensorCode);
        BusiTemperPointVo busiTemperPointVo = new BusiTemperPointVo();
        BeanUtils.copyPropertiesWithIgnoreNull(busiTemperPoint, busiTemperPointVo);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", busiTemperPointVo);
    }
}
