package com.huatek.busi.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.dto.PhotoThresholdDto;
import com.huatek.busi.service.threshold.PhotoThresholdService;
import com.huatek.busi.vo.PhotoThresholdVo;
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.ApiOperation;

/**
 * 拍照阈值
 * 
 * @author buck_guo
 * @date 2019/08/09
 */
@Api(tags = {"拍照阈值"})
@RestController
@RequestMapping("/api/PhotoThreshold")
public class PhotoThresholdController {
    protected final Logger logger = LoggerFactory.getLogger(PhotoThresholdController.class);

    @Reference(check = false)
    private PhotoThresholdService photoThresholdService;

     /**
      * 查询GIS SD6阈值查询
      * @param sensorCode
      * @return
      */
    @ApiOperation(value ="查询拍照阈值")
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERPD.MODELNAME", methodName = "TRANSFORMERPD.METHODNAME.QUERYLIST")
    @PostMapping(value="/queryPhotoThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> queryPhotoThreshold(@RequestParam(value="sensorCode")String sensorCode,@RequestParam(value="workStatus")String workStatus,@RequestParam(value="type")String type) {
        PhotoThresholdVo photoThresholdVo = photoThresholdService.queryPhotoThreshold(sensorCode,workStatus,type);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", photoThresholdVo);
    }
    
    /**
     * 新增修改变压器运行工况阈值
     * @param siteId  站点ID
     * @param mainTreeId  站点设备树ID
     * @return
     */
   @ApiOperation(value = "新增修改拍照阈值")
   @KerLog(projectName = "PROJECTNAME", modelName = "IECBASECONF.MODELNAME", methodName = "IECBASECONF.METHODNAME.ADDIECBASECONF")
   @PostMapping(value="/insertOrUpdate", produces = {"application/json;charset=utf-8"})
   public Map<String, Object> insertOrUpdate(@RequestHeader("token")String token,@RequestBody PhotoThresholdDto photoThresholdDto) {
       int count = photoThresholdService.insertOrUpdate(token,photoThresholdDto);
       logger.debug("insertOrUpdate: {}", count);
       Map<String, Object> map = ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "拍照阈值保存成功", "");
       return map;
   }
}
