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.service.report.WtHealthReport3Service;
import com.gyee.frame.util.DateUtils;
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.Date;
import java.util.HashMap;
import java.util.Map;


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

	@Resource
	private WtHealthReport3Service wtHealthReport3Service;

	/**
	 * 查询健康报告主表和子表数据
	 * @param wtId
	 * @param recorddate
	 * @return
	 * @throws Exception
	 */
	@PostMapping("/healthReport")
	@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 healthReport(String wtId, String recorddate) throws Exception {

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

		if(StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate))
		{

			Date date= DateUtils.parseDate(recorddate);

			map=wtHealthReport3Service.healthReport(wtId, date);
		}

		return AjaxResult.successData(AjaxStatus.success.code, map);

	}


}
