package com.blueland.bpm.manage.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.blueland.bpm.common.base.BaseSpringController;
import com.blueland.bpm.manage.countAnalysis.service.IndexService;
/**
 * @作者     dsl
 * @创建时间  2020年2月5日
 * @说明     流程首页
 */
@Controller
@RequestMapping(value = "/sys/index")
public class IndexController extends BaseSpringController{
	@Autowired
	private IndexService indexService;
	/** 
	 * 流程统计
	 **/
	@RequestMapping(value = "/porcessStatistics")
	public ModelAndView porcessStatistics(HttpServletRequest request) throws Exception{
		//所有接入应用
		int allApp =  indexService.getAppCount();
		//流程定义总数
		int procDefKeyCount = indexService.getProcDefKeyCount();
		//流程执行情况
		Map<String,Object>  processLogCount= indexService.getProcessLogCount();
		ModelAndView modelAndView = new ModelAndView("/processReport/index");
		
		modelAndView.addObject("allApp", allApp);
		modelAndView.addObject("procDefKeyCount", procDefKeyCount);
		modelAndView.addObject("error", processLogCount.get("ERROR"));
		modelAndView.addObject("info", processLogCount.get("INFO"));
		return modelAndView;
	}
	/**
	 * 流程运行情况
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/statisticsProcessByTime")
	@ResponseBody
	public List<Map<String, Object>> statisticsProcessByTime(HttpServletRequest request) throws Exception{
		return indexService.getAllFlowDatas();
	}
	/**
	 * 流程监控top
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getProcessMonitorTop")
	@ResponseBody
	public Map<String, Object> getProcessMonitorTop(HttpServletRequest request) throws Exception{
		return indexService.getProcessMonitorTop();
	}
	/**
	 * 系统负载数据
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getSysLoadData")
	@ResponseBody
	public Map<String, Object> getSysLoadData(HttpServletRequest request) throws Exception{
		return indexService.getSysLoadData();
	}
}
