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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.dto.BusiOutlineTransformerExperimentDataDto;
import com.huatek.busi.entity.BusiOutlineTransformerExperimentData;
import com.huatek.busi.service.BusiOutlineTransformerExperimentDataService;
import com.huatek.busi.vo.BusiOutlineTransformerExperimentDataVo;
import com.huatek.torch.frame.log.KerLog;
import com.huatek.torch.frame.permission.KerPermission;
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 walker_wang
 * @date Jul 4, 2019 4:53:56 PM
 */
@Api(tags = { Tags.BUSI_OUTLINE_THRESHOLD })
@RestController
@RequestMapping("/api/BusiOutlineTransformerExperimentData")
public class BusiOutlineTransformerExperimentDataController {

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

	@Reference(check = false)
	private BusiOutlineTransformerExperimentDataService busiOutlineTransformerExperimentDataService;

	/**
	 * 离线数据--变压器试验数据 分页列表
	 *
	 * @param busiOutlineTransformerExperimentDataDto
	 *            离线数据--变压器试验数据Dto
	 * @return map map
	 */
	@ApiOperation(value = "变压器试验数据查询")
	@KerLog(projectName = "PROJECTNAME", modelName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.MODELNAME", methodName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.METHODNAME.QUERYLIST")
	@PostMapping(value = "/queryList", produces = { "application/json;charset=utf-8" })
    public Map<String, Object>
        queryList(@RequestBody BusiOutlineTransformerExperimentDataDto busiOutlineTransformerExperimentDataDto) {
        PageInfo<BusiOutlineTransformerExperimentDataVo> pageInfo = busiOutlineTransformerExperimentDataService
            .findBusiOutlineTransformerExperimentDataPage(busiOutlineTransformerExperimentDataDto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, pageInfo.getTotal(), "", pageInfo.getList());
    }

	/**
	 * 添加 离线数据--变压器试验数据
	 *
	 * @param token
	 *            the token
	 * @param busiOutlineTransformerExperimentDataDto
	 *            离线数据--变压器试验数据Dto
	 * @return map map
	 */
	@ApiOperation(value = "变压器试验数据添加")
	@KerLog(projectName = "PROJECTNAME", modelName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.MODELNAME", methodName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.METHODNAME.ADDBUSIOUTLINETRANSFORMEREXPERIMENTDATA")
	@PostMapping(value = "/addBusiOutlineTransformerExperimentData", produces = { "application/json;charset=utf-8" })
//	@KerValid
//	@KerPermission("")
	public Map<String, Object> addBusiOutlineTransformerExperimentData(String token,
			@RequestBody BusiOutlineTransformerExperimentDataDto busiOutlineTransformerExperimentDataDto) {
		busiOutlineTransformerExperimentDataService.addBusiOutlineTransformerExperimentData(token, busiOutlineTransformerExperimentDataDto);
		Map<String, Object> map = ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
		return map;
	}

	/**
	 * 通过id查找 离线数据--变压器试验数据
	 *
	 * @param id
	 *            id
	 * @return map map
	 */
	@ApiOperation(value = "通过id查找 离线数据")
	@KerLog(projectName = "PROJECTNAME", modelName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.MODELNAME", methodName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.METHODNAME.FINDBUSIOUTLINETRANSFORMEREXPERIMENTDATA")
	@GetMapping(value = "/findBusiOutlineTransformerExperimentData/{id}", produces = {
			"application/json;charset=utf-8" })
	@KerPermission("")
	public Map<String, Object> findBusiOutlineTransformerExperimentData(@PathVariable(value = "id") String id) {
		BusiOutlineTransformerExperimentData busiOutlineTransformerExperimentData = busiOutlineTransformerExperimentDataService.findBusiOutlineTransformerExperimentData(id);
		return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", busiOutlineTransformerExperimentData);
	}

	/**
	 * 修改 离线数据--变压器试验数据
	 *
	 * @param token
	 *            the token
	 * @param busiOutlineTransformerExperimentDataDto
	 *            离线数据--变压器试验数据Dto
	 * @return the map
	 */
	@ApiOperation(value = "修改 离线数据")
	@KerLog(projectName = "PROJECTNAME", modelName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.MODELNAME", methodName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.METHODNAME.UPDATEBUSIOUTLINETRANSFORMEREXPERIMENTDATA")
	@PostMapping(value = "/updateBusiOutlineTransformerExperimentData", produces = { "application/json;charset=utf-8" })
	@KerPermission("")
	public Map<String, Object> updateBusiOutlineTransformerExperimentData(String token,
			@RequestBody BusiOutlineTransformerExperimentDataDto busiOutlineTransformerExperimentDataDto) {
		int count = busiOutlineTransformerExperimentDataService.updateBusiOutlineTransformerExperimentData(token,
				busiOutlineTransformerExperimentDataDto);
		logger.debug("updateBusiOutlineTransformerExperimentData: {}", count);
		Map<String, Object> map = ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
		return map;
	}

	/**
	 * 删除 离线数据--变压器试验数据
	 * 
	 * @param token
	 * @param ids
	 * @return
	 */
	@ApiOperation(value = "删除 离线数据")
	@KerLog(projectName = "PROJECTNAME", modelName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.MODELNAME", methodName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.METHODNAME.DELETEBUSIOUTLINETRANSFORMEREXPERIMENTDATA")
	@PostMapping(value = "/deleteBusiOutlineTransformerExperimentData", produces = { "application/json;charset=utf-8" })
//	@KerPermission("")
	public Map<String, Object> deleteBusiOutlineTransformerExperimentData(String token, @RequestBody String[] ids) {
		busiOutlineTransformerExperimentDataService.deleteBusiOutlineTransformerExperimentData(ids);
		Map<String, Object> map = ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
		return map;
	}
	
	/**
	 * 查找例行试验
	 * @param equipmentId
	 * @param siteId
	 * @return
	 */
	@ApiOperation(value = "查找例行试验")
	@KerLog(projectName = "PROJECTNAME", modelName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.MODELNAME", methodName = "BUSIOUTLINETRANSFORMEREXPERIMENTDATA.METHODNAME.FINDBUSIOUTLINEDATABYEQUIP")
	@GetMapping(value = "/findBusiOutlineTransformerExperimentData", produces = {
			"application/json;charset=utf-8" })
//	@KerPermission("")
	public Map<String, Object> findBusiOutlineDataByEquip(@PathVariable(value = "equipmentId") String equipmentId, @PathVariable(value = "siteId") String siteId) {
		BusiOutlineTransformerExperimentData busiOutlineTransformerExperimentData = busiOutlineTransformerExperimentDataService.findBusiOutlineDataByEquip(equipmentId, siteId);
		return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", busiOutlineTransformerExperimentData);
	}

}