123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- package com.yihu.wlyy.web.statistic;
- import com.yihu.wlyy.service.app.statistics.StatisticsService;
- import com.yihu.wlyy.web.BaseController;
- import io.swagger.annotations.Api;
- import org.json.JSONArray;
- import org.json.JSONObject;
- 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;
- /**
- * Created by lyr on 2016/08/16.
- */
- @Controller
- @RequestMapping(value = "/statistics")
- @Api(description = "统计")
- public class StatisticsController extends BaseController {
- @Autowired
- StatisticsService statisticsService;
- /**
- * 指标按间隔统计
- *
- * @param startDate 起始日期
- * @param endDate 结束时间
- * @param interval 时间间隔
- * @param area 区域或机构
- * @param level 级别
- * @param index 指标
- * @return
- */
- @RequestMapping(value = "/interval")
- @ResponseBody
- public String indexInterval(String startDate, String endDate, int interval, String area, int level, String index) {
- String tag = "";
- try {
- String[] indexes = index.split(",");
- JSONObject result = new JSONObject();
- if (index != null) {
- for (String idx : indexes) {
- result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx));
- }
- }
- return write(200, "查询成功!", "data", result);
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, tag + "查询失败!");
- }
- }
- /**
- * 指标期间增长量
- *
- * @param startDate
- * @param endDate
- * @param area
- * @param level
- * @param index
- * @return
- */
- @RequestMapping("/increment")
- @ResponseBody
- public String getIndexIncrement(String startDate, String endDate, String area, int level, String index) {
- try {
- String[] indexes = index.split(",");
- JSONObject result = new JSONObject();
- for (String idx : indexes) {
- result.put("index_" + idx, statisticsService.getIntervalIncrement(startDate, endDate, area, level, idx));
- }
- return write(200, "查询成功", "data", result);
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "查询失败");
- }
- }
- /**
- * 指标截止日期累积量
- *
- * @param endDate
- * @param area
- * @param level
- * @param index
- * @return
- */
- @RequestMapping("/total")
- @ResponseBody
- public String getIndexTotal(String endDate, String area, int level, String index) {
- try {
- String[] indexes = index.split(",");
- JSONObject result = new JSONObject();
- for (String idx : indexes) {
- result.put("index_" + idx, statisticsService.getTotalAmount(endDate, area, level, idx));
- }
- return write(200, "查询成功", "data", result);
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "查询失败");
- }
- }
- /**
- * 指标期间增长量
- *
- * @param startDate
- * @param endDate
- * @param area
- * @param level
- * @param index
- * @return
- */
- @RequestMapping("/lowlevel_increment")
- @ResponseBody
- public String getIndexLowLevelIncrement(String startDate, String endDate, String area, int level, String index, int sort,String lowLevel) {
- try {
- String[] indexes = index.split(",");
- JSONObject result = new JSONObject();
- for (String idx : indexes) {
- result.put("index_" + idx, statisticsService.getLowLevelIncrementDetail(startDate, endDate, area, level, idx, sort,lowLevel));
- }
- return write(200, "查询成功", "data", result);
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "查询失败");
- }
- }
- /**
- * 指标截止日期累积量
- *
- * @param endDate
- * @param area
- * @param level
- * @param index
- * @return
- */
- @RequestMapping("/lowlevel_total")
- @ResponseBody
- public String getIndexLowLevelTotal(String endDate, String area, int level, String index, int sort, String lowLevel) {
- try {
- String[] indexes = index.split(",");
- JSONObject result = new JSONObject();
- for (String idx : indexes) {
- result.put("index_" + idx, statisticsService.getLowLevelTotalDetail(endDate, area, level, idx, sort, lowLevel));
- }
- return write(200, "查询成功", "data", result);
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "查询失败");
- }
- }
- /**
- * 指标期间增长量
- *
- * @param startDate
- * @param endDate
- * @param area
- * @param level
- * @param index
- * @return
- */
- @RequestMapping("/leveltwo_increment")
- @ResponseBody
- public String getIndexLevelTwoIncrement(String startDate, String endDate, String area, int level, String index) {
- try {
- String[] indexes = index.split(",");
- JSONObject result = new JSONObject();
- for (String idx : indexes) {
- result.put("index_" + idx, statisticsService.getLevelTwoIndexIncrement(startDate, endDate, area, level, idx));
- }
- return write(200, "查询成功", "data", result);
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "查询失败");
- }
- }
- /**
- * 获取签约率、签约完成率
- *
- * @param endDate 截止日期
- * @param area 区域
- * @param level 区域级别 4:城市 3:区 2:社区 1:团队
- * @param type 1:签约率 2:签约完成率
- * @return
- */
- @RequestMapping(value = "/rate")
- @ResponseBody
- public String getAreaRate(String endDate, String area, int level, String type) {
- try {
- JSONObject result = null;
- if (type.equals("1")) {
- result = statisticsService.getSignRate(endDate,area,level);
- } else {
- result = statisticsService.getSignTaskRate(endDate,area,level);
- }
- return write(200, "查询成功", "data", result);
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "查询失败");
- }
- }
- /**
- * 获取三级指标增量
- *
- * @param startDate
- * @param endDate
- * @param area
- * @param level
- * @return
- */
- @RequestMapping(value = "/sixfive_statistics")
- @ResponseBody
- public String getSixFiveStatistics(String startDate, String endDate, String area, int level){
- try{
- JSONArray result = statisticsService.getSixFiveStatistics(startDate,endDate,area,level);
- return write(200,"查询成功","data",result);
- }catch (Exception e){
- e.printStackTrace();
- return error(-1,"查询失败");
- }
- }
- }
|