package com.huatek.busi.controller;

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.PathVariable;
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.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.dto.TransformerRunStatusThresholdDto;
import com.huatek.busi.service.transformer.TransformerRunStatusThresholdService;
import com.huatek.busi.vo.TransformerRunStatusThresholdVo;
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/07
 */
@Api(tags = {Tags.TRANSFORMERRUNSTATUSTHRESHOLD})
@RestController
@RequestMapping("/api/TransformerRunStatusThreshold")
public class TransformerRunStatusThresholdController {

    protected final Logger logger = LoggerFactory.getLogger(TransformerRunStatusThresholdController.class);

    @Reference(check = false)
    private TransformerRunStatusThresholdService transformerRunStatusThresholdService;


     /**
      * 查询变压器运行工况阈值
      * @param siteId  站点ID
      * @param mainTreeId  站点设备树ID
      * @return
      */
    @ApiOperation(value = "变压器运行工况阈值查询")
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERPD.MODELNAME", methodName = "TRANSFORMERPD.METHODNAME.QUERYLIST")
    @GetMapping(value="/queryTransformerRunStatusThreshold/{siteId}/{mainTreeId}/{workStatus}", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> queryRunStatusThreshold(@PathVariable(value="siteId")String siteId,@PathVariable(value="mainTreeId")String mainTreeId,@PathVariable(value="workStatus")String workStatus) {
        TransformerRunStatusThresholdVo transformerPds = transformerRunStatusThresholdService.queryRunStatusThreshold(siteId,mainTreeId,workStatus);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", transformerPds);
    }
    
    /**
     * 新增修改变压器运行工况阈值
     * @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 TransformerRunStatusThresholdDto transformerRunStatusThresholdDto) {
       int count = transformerRunStatusThresholdService.insertOrUpdate(token,transformerRunStatusThresholdDto);
       logger.debug("insertOrUpdate: {}", count);
       Map<String, Object> map = ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "保存阈值成功", "");
       return map;
   }
}
