package com.nbclass.szxgl.controller.mobile;

import com.alibaba.fastjson.JSONObject;
import com.nbclass.system.controller.BaseController;
import com.nbclass.szxgl.service.GraphicStatisticsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 图表统计数据
 * 
 * @author Leon
 * @datetime 2019年5月21日 下午2:07:17
 */
@Controller
@RequestMapping("/mobile/api/graphic")
public class GraphicStatisticsController extends BaseController {

	@Resource
	private GraphicStatisticsService service;

	/**
	 * 获取区域项目数量统计数据 - 饼图
	 * 
	 * @param starttime
	 * @param endtime
	 */
	@RequestMapping("/getProjectNumDataByPie")
	@ResponseBody
	public JSONObject getProjectNumDataByPie(String starttime, String endtime) {
		if (StringUtils.isNotBlank(starttime) && starttime.length() < 11)
			starttime = starttime.trim() + " 00:00:00";
		if (StringUtils.isNotBlank(endtime) && endtime.length() < 11)
			endtime = endtime.trim() + " 23:59:59";
		JSONObject obj = service.getProjectNumDataByPie(starttime, endtime);
		return obj;
	}

	/**
	 * 获取区域项目数量统计数据 - 折线图
	 * 
	 * @param starttime
	 * @param endtime
	 */
	@RequestMapping("/getProjectNumDataByLine")
	@ResponseBody
	public JSONObject getProjectNumDataByLine(String starttime, String endtime) {
		if (StringUtils.isNotBlank(starttime) && starttime.length() < 11)
			starttime = starttime.trim() + " 00:00:00";
		if (StringUtils.isNotBlank(endtime) && endtime.length() < 11)
			endtime = endtime.trim() + " 23:59:59";
		JSONObject obj = service.getProjectNumDataByLine(starttime, endtime);
		return obj;
	}

	/**
	 * 获得个人项目数量统计
	 * 
	 * @param starttime
	 * @param endtime
	 */
	@RequestMapping("/queryPersonProject")
	@ResponseBody
	public JSONObject queryPersonProject(String starttime, String endtime,String deptId,String userId) {
		if (StringUtils.isNotBlank(starttime) && starttime.length() < 11)
			starttime = starttime.trim() + " 00:00:00";
		if (StringUtils.isNotBlank(endtime) && endtime.length() < 11)
			endtime = endtime.trim() + " 23:59:59";
		JSONObject obj = service.queryPersonProject(starttime, endtime,deptId,userId);
		return obj;
	}

	/**
	 * 获得月报表--折线图
	 * 
	 * @param year
	 * @param deptId
	 */
	@RequestMapping("/queryMonthProjectLine")
	@ResponseBody
	public JSONObject queryMonthProjectLine(String year, String deptId) {
		JSONObject obj = service.queryMonthProjectLine(year, deptId);
		return obj;
	}
   /**
    * 获得公司部门列表
    */
	@RequestMapping("/queryDepartmentLable")
	@ResponseBody
	public JSONObject queryDepartmentLable() {
		JSONObject obj = service.queryDepartmentLable();
		return obj;
	}

}
