package com.gyee.frame.controller.report;

import com.gyee.frame.common.base.BaseController;
import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.model.auto.Recommenmain;
import com.gyee.frame.model.auto.Wobugeq;
import com.gyee.frame.model.auto.WtTragetReportChart;
import com.gyee.frame.service.report.WtHealthReportMonthService;
import com.gyee.frame.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Controller
@RequestMapping("/reportmonth")
@Api(value = "月度健康报告",tags =  "月度健康报告")
public class WtHealthReportMonthController extends BaseController {
	private static Logger logger = LoggerFactory.getLogger(WtHealthReportMonthController.class);

	@Resource
	private WtHealthReportMonthService wtHealthReportMonthService;



	/**
	 * 查询健康包括部件健康指数的历史图表
	 * @param wtId
	 * @param partId
	 * zk	主控
	 * clx	齿轮箱
	 * fdj	发电机
	 * bj	变桨
	 * @param recorddate
	 * @return
	 */
	@PostMapping("/healthReportChart")
	@ResponseBody
	@ApiOperation(value = "查询健康包括部件健康指数的历史图表", notes = "查询健康包括部件健康指数的历史图表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "partId", value = "部件编号 zk:主控,clx:齿轮箱,fdj:发电机,bj:变桨", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

	public AjaxResult healthReportChart(String wtId,String partId, String recorddate)  {

		List<WtTragetReportChart> vos=new ArrayList<>();

		if(StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate))
		{
			vos=wtHealthReportMonthService.healthReportChart(wtId,partId, recorddate);
		}



		if (null!=vos) {
			return AjaxResult.successData(AjaxStatus.success.code, vos);
		} else {
			return AjaxResult.successData(AjaxStatus.success.code, vos);
		}

	}


	/**
	 * 查询生产系统月度风机检修情况
	 * @param wtId
	 * @param recorddate
	 * @return
	 */
	@PostMapping("/getWobugeqList")
	@ResponseBody
	@ApiOperation(value = "查询生产系统月度风机检修情况", notes = "查询生产系统月度风机检修情况")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

	public AjaxResult getWobugeqList(String wtId, String recorddate)  {

		List<Wobugeq> vos=new ArrayList<>();

		if(StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate))
		{
			vos=wtHealthReportMonthService.getWobugeqList(wtId, recorddate);
		}

		if (null!=vos) {
			return AjaxResult.successData(AjaxStatus.success.code, vos);
		} else {
			return AjaxResult.successData(AjaxStatus.success.code, vos);
		}

	}


	/**
	 * 查询推荐月度风机检修情况
	 * @param wtId
	 * @param recorddate
	 * @return
	 */
	@PostMapping("/getRecommenmainList")
	@ResponseBody
	@ApiOperation(value = "查询推荐月度风机检修情况", notes = "查询推荐月度风机检修情况")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

	public AjaxResult getRecommenmainList(String wtId, String recorddate)  {

		List<Recommenmain> vos=new ArrayList<>();

		if(StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate))
		{
			vos=wtHealthReportMonthService.getRecommenmainList(wtId, recorddate);
		}



		if (null!=vos) {
			return AjaxResult.successData(AjaxStatus.success.code, vos);
		} else {
			return AjaxResult.successData(AjaxStatus.success.code, vos);
		}

	}


	/**
	 * 获得风机月度等级评估数据
	 * @param wtId
	 * @param recorddate
	 * @return
	 *
	 * map.put(" wid ", po); 等级评估对象
	 * map.put("vos",vos); 等级评估雷达图数据
	 */
	@PostMapping("/gamonthlistByWtId")
	@ResponseBody
	@ApiOperation(value = "获得风机月度等级评估数据", notes = "获得风机月度等级评估数据")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

	public AjaxResult gamonthlistByWtId(String wtId, String recorddate)  {

		Map<String,Object> map=new HashMap<>();

		if(StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate))
		{
			map=wtHealthReportMonthService.gamonthlistByWtId(wtId, recorddate);
		}



		if (null!=map) {
			return AjaxResult.successData(AjaxStatus.success.code, map);
		} else {
			return AjaxResult.successData(AjaxStatus.success.code, map);
		}

	}


}
