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.service.BusiSubPageService;
import com.huatek.busi.service.threshold.TransformerOilThresholdService;
import com.huatek.busi.vo.TransformerOilThresholdVo;
import com.huatek.busi.vo.warning.BusiOilVo;
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;

/**
 * App 油色谱报警及阈值
 * @author buck_guo
 * @date 2019/08/20
 */
@Api(tags = {Tags.OIL_WARNNNING_THRESHOLD})
@RestController
@RequestMapping("/app/oilWarnigAndThreshold")
public class OilWarnigAndThresholdController {


    @Reference(check = false)
    private BusiSubPageService busiSubPageService;
    @Reference(check = false)
    private TransformerOilThresholdService transformerOilThresholdService;
    /**
     * @Title: getOilWarnigInfo
     * @Description: 油色谱告警信息
     * @createDate: Aug 2, 2019 2:22:03 PM
     * @param    warningId    告警ID
     * @param    sensorCode   传感器编码
     * @return   Map<String,Object>
     */
    @ApiOperation(value = "油色谱告警信息 ", response = BusiOilVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warningId", value="告警ID"),
            @ApiImplicitParam(name = "sensorCode", value="传感器编码")
    })
    @GetMapping(value = "/getOilWarnigInfo")
    public Map<String, Object> getOilWarnigInfo(@RequestParam("warningId") String warningId,
                                                @RequestParam("sensorCode") String sensorCode) {
        BusiOilVo vo = busiSubPageService.getOilWarnigInfo(warningId, sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }

    @ApiOperation(value = Tags.BUSI_YSP_SENSOR_THRESHOLD)
    @ApiImplicitParam(name = "sensorCode", value = "sensorCode")
    @GetMapping(value = "/findOilThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findOilThreshold(@RequestParam("sensorCode") String sensorCode) {
        TransformerOilThresholdVo info = transformerOilThresholdService.getBySensorCode(sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", info);
    }
}
