package com.huatek.busi.controller;

import java.util.Map;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
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.GisSf6ThresholdDto;
import com.huatek.busi.service.gis.GisSF6ThresholdService;
import com.huatek.busi.service.gis.GisSf6PressureService;
import com.huatek.busi.vo.GisSf6ThresholdVo;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * GIS SF6阈值
 * @author buck_guo
 * @date 2019/08/08
 */
@Api(tags = {Tags.BUSI_GIS_SF6_THRESHOLD})
@Slf4j
@RestController
@RequestMapping("/api/GisSF6Threshold")
public class GisSF6ThresholdController {
    @Reference(check = false)
    private GisSF6ThresholdService gisSF6ThresholdService;
    @Reference(check = false)
    private GisSf6PressureService gisSf6PressureService;

     /**
      * 查询GIS SD6阈值查询
      * @param sensorCode
      * @return
      */
    @ApiOperation(value ="查询GIS SD6阈值查询", response = GisSf6ThresholdVo.class)
    @PostMapping(value="/queryGisSF6Threshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> queryGisSF6Threshold(@RequestParam(value="sensorCode")String sensorCode) {
        GisSf6ThresholdVo gisSF6ThresholdVo = gisSF6ThresholdService.queryGisSF6Threshold(sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", gisSF6ThresholdVo);
    }
    
    /**
     * 新增修改变压器运行工况阈值
     * @param siteId  站点ID
     * @param mainTreeId  站点设备树ID
     * @return
     */
   @ApiOperation(value = "新增修改GIS SF6阈值阈值")
   @PostMapping(value="/insertOrUpdate", produces = {"application/json;charset=utf-8"})
   public Map<String, Object> insertOrUpdate(@RequestHeader("token")String token,@RequestBody GisSf6ThresholdDto gisSf6ThresholdDto) {
       int count = gisSF6ThresholdService.insertOrUpdate(token,gisSf6ThresholdDto);
       log.debug("insertOrUpdate: {}", count);
       return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "GIS SF6阈值保存成功", "");
   }
   
   
   /**
    * 更新sf6压力值
    * @param siteId  站点ID
    * @param mainTreeId  站点设备树ID
    * @return
    */
  @ApiOperation(value = "修改GIS SF6压力")
  @PostMapping(value="/updateSF6", produces = {"application/json;charset=utf-8"})
  public Map<String, Object> updateSF6() {
      gisSf6PressureService.updateSF6();
      log.debug("updateSF6---------------------");
      return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "SF6更新成功", "");
  }
}
