package com.gyee.frame.service.report;

import com.gyee.frame.model.auto.WtReportMain;
import com.gyee.frame.model.auto.WtReportSub;
import com.gyee.frame.model.auto.WtTragetReportChart;
import com.gyee.frame.service.WtReportMainService;
import com.gyee.frame.service.WtReportSubService;
import com.gyee.frame.service.WtTragetReportChartService;
import com.gyee.frame.util.DateUtils;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * 线路 LineService
 * @Title: LineService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2019-12-31 14:58:09  
 **/
@Service
public class WtHealthReportService{
	@Resource
	private WtReportMainService wtReportMainService;
	@Resource
	private WtReportSubService wtReportSubService;
	@Resource
	private WtTragetReportChartService wtTragetReportChartService;




	/**
	 * 查询健康报告主表和子表数据
	 * @param wtId
	 * @param recorddate
	 * @return
	 */
	public Map<String,Object> healthReport(String wtId, String recorddate) {

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

		if(StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate))
		{
			Date date= DateUtils.parseStrtoDate(recorddate);

			List<WtReportMain> wtrmls=wtReportMainService.healthReport(wtId,date);

			if(!wtrmls.isEmpty())
			{
				WtReportMain wtrm=wtrmls.get(0);
				map.put("main",wtrm);
				List<WtReportSub>  wtrmsubls=wtReportSubService.findWtReportSubList(wtrm.getId());

				map.put("sub",wtrmsubls);

			}
		}

		return map;
	}

	/**
	 * 查询健康包括部件健康指数的历史图表
	 * @param wtId
	 * @param partId
	 * @param recorddate
	 * @return
	 */
	public List<WtTragetReportChart> healthReportChart(String wtId,String partId, String recorddate)  {

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

		if(StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate))
		{
			Date date= DateUtils.parseStrtoDate(recorddate);

			vos=wtTragetReportChartService.healthReportChart(wtId,partId,date);
		}

		return vos;
	}

	/**
	 * 通过查询条件获得健康报告主表信息
	 * @param wpId
	 * @param wtId
	 * @param beginDate
	 * @param endDate
	 * @return
	 */
	public List<WtReportMain> getReportList(String wpId,String wtId, Date beginDate,Date endDate)
	{
		List<WtReportMain> wtrmls=new ArrayList<>();
		if( StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate))
		{
			 wtrmls=wtReportMainService.getReportList(wpId,wtId, beginDate, endDate);

		}

		return wtrmls;
	}
}
