|
@ -1,10 +1,19 @@
|
|
|
package com.yihu.wlyy.web.statistic;
|
|
|
|
|
|
import com.yihu.wlyy.service.app.statisticsES.StatisticsESService;
|
|
|
import com.yihu.wlyy.util.Constant;
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
/**
|
|
|
* Created by chenweida on 2017/10/13.
|
|
@ -12,5 +21,339 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
|
|
|
@Api(description = "ES统计查询")
|
|
|
public class EsStatisticsController {
|
|
|
public class EsStatisticsController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
StatisticsESService statisticsESService;
|
|
|
|
|
|
/**
|
|
|
* 指标按间隔统计 增量
|
|
|
* 按年度统计是根据前端传的 startDate
|
|
|
*
|
|
|
* @param startDate 起始日期
|
|
|
* @param endDate 结束时间
|
|
|
* @param interval 时间间隔
|
|
|
* @param area 区域或机构
|
|
|
* @param level 级别
|
|
|
* @param index 指标 3 4 5 27
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/interval")
|
|
|
@ResponseBody
|
|
|
public String indexInterval(@RequestParam(required = true) String startDate,
|
|
|
@RequestParam(required = true) String endDate,
|
|
|
@RequestParam(required = true) String interval,
|
|
|
@RequestParam(required = true) String area,
|
|
|
@RequestParam(required = true) int level,
|
|
|
@RequestParam(required = true) String index,
|
|
|
@RequestParam(required = false) String level2_type) {
|
|
|
String tag = "";
|
|
|
try {
|
|
|
String[] indexes = index.split(",");
|
|
|
JSONObject result = new JSONObject();
|
|
|
if (index != null) {
|
|
|
for (String idx : indexes) {
|
|
|
result.put("index_" + idx, statisticsESService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx, level2_type));
|
|
|
// result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, Integer.parseInt(interval), area, level, idx, level2_type));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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(@RequestParam(required = true) String startDate,
|
|
|
@RequestParam(required = true) String endDate,
|
|
|
@RequestParam(required = true) String area,
|
|
|
@RequestParam(required = true) int level,
|
|
|
@RequestParam(required = true) String index,
|
|
|
@RequestParam(required = false) String year) {
|
|
|
try {
|
|
|
String[] indexes = index.split(",");
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
for (String idx : indexes) {
|
|
|
// result.put("index_" + idx, statisticsService.getIntervalIncrement(startDate, endDate, area, level, idx));
|
|
|
result.put("index_" + idx, statisticsESService.getIntervalIncrement(startDate, endDate, area, level, idx));
|
|
|
}
|
|
|
|
|
|
return write(200, "查询成功", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 指标截止日期累积量 增量的累加接口
|
|
|
*
|
|
|
* @param startDate 开始时间
|
|
|
* @param endDate 结束时间 1
|
|
|
* @param area 父code
|
|
|
* @param level 等级 1 团队,2 机构,3 区,4 市
|
|
|
* @param index 指标代码 3 4 5 27
|
|
|
* @param level2_type 指标代码 例如性别 1 男 2 女 不传就返回男和女的总和
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/total")
|
|
|
@ResponseBody
|
|
|
public String getIndexTotal(
|
|
|
@RequestParam(required = true) String startDate,
|
|
|
@RequestParam(required = true) String endDate,
|
|
|
@RequestParam(required = true) String area,
|
|
|
@RequestParam(required = true) int level,
|
|
|
@RequestParam(required = true) String index,
|
|
|
@RequestParam(required = false) String level2_type) {
|
|
|
try {
|
|
|
String[] indexes = index.split(",");
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
for (String idx : indexes) {
|
|
|
// result.put("index_" + idx, statisticsService.getTotalAmount(startDate, endDate, area, level, idx, level2_type));
|
|
|
result.put("index_" + idx, statisticsESService.getTotalAmount(startDate, endDate, area, level, idx, level2_type));
|
|
|
}
|
|
|
|
|
|
return write(200, "查询成功", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 指标截止日期 增量
|
|
|
* (如:待预约量)
|
|
|
*
|
|
|
* @param endDate 结束时间
|
|
|
* @param area 父code
|
|
|
* @param level 等级 1 团队,2 机构,3 区,4 市
|
|
|
* @param index 指标代码
|
|
|
* @param sort 排序 1倒叙 2是 正序
|
|
|
* @param lowLevel
|
|
|
* @param level2_type 指标代码 例如性别 1 男 2 女 不传就返回男和女的总和
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/lowlevel_total")
|
|
|
@ResponseBody
|
|
|
public String getIndexLowLevelTotal(@RequestParam(required = true) String endDate,
|
|
|
@RequestParam(required = true) String area,
|
|
|
@RequestParam(required = true) int level,
|
|
|
@RequestParam(required = true) String index,
|
|
|
@RequestParam(required = true) int sort,
|
|
|
@RequestParam(required = false) String lowLevel,
|
|
|
@RequestParam(required = false) String level2_type,
|
|
|
@RequestParam(required = false) String year) {
|
|
|
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, level2_type, year));
|
|
|
result.put("index_" + idx, statisticsESService.getLowLevelTotalDetail(endDate, area, level, idx, sort, lowLevel, level2_type, year));
|
|
|
}
|
|
|
|
|
|
return write(200, "查询成功", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 指标截止日期累积量 增量
|
|
|
* 根据2个ID合并指标
|
|
|
*
|
|
|
* @param endDate
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index 3,22
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/lowlevel_total_mesh")
|
|
|
@ResponseBody
|
|
|
public String getIndexLowLevelTotalMesh(@RequestParam(required = true) String endDate, // 2007-10-02
|
|
|
@RequestParam(required = true) String area,//区域 350205
|
|
|
@RequestParam(required = true) int level,//等级
|
|
|
@RequestParam(required = true) String index,//指标code
|
|
|
@RequestParam(required = true) int sort,//1是倒叙 0是正序
|
|
|
@RequestParam(required = false) String lowLevel,
|
|
|
@RequestParam(required = false) String year) {
|
|
|
try {
|
|
|
String[] indexes = index.split(",");
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONArray jsonArray = statisticsESService.getLowLevelTotalDetail(endDate, area, level, index, sort, lowLevel, null, year);
|
|
|
result.put("index_" + indexes[0], jsonArray);
|
|
|
return write(200, "查询成功", "data", result);
|
|
|
} catch (Exception e)
|
|
|
|
|
|
{
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 指标期间 增长量
|
|
|
* 如果是查找去年的 前端根据endDate来查看 2016年度 就传 2017-6-30
|
|
|
*
|
|
|
* @param endDate
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index 6 7 8 15 16
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/leveltwo_increment")
|
|
|
@ResponseBody
|
|
|
public String getIndexLevelTwoIncrement(
|
|
|
@RequestParam(required = true) String endDate,
|
|
|
@RequestParam(required = true) String area,
|
|
|
@RequestParam(required = true) int level,
|
|
|
@RequestParam(required = true) String index) {
|
|
|
try {
|
|
|
String[] indexes = index.split(",");
|
|
|
JSONObject result = new JSONObject();
|
|
|
for (String idx : indexes) {
|
|
|
// result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(endDate, area, level, idx));
|
|
|
result.put("index_" + idx, statisticsESService.getIndexLevelTwototal(endDate, area, level, idx));
|
|
|
}
|
|
|
return write(200, "查询成功", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取签约率、签约完成率 续签率
|
|
|
* t
|
|
|
*
|
|
|
* @param endDate 截止日期
|
|
|
* @param area 区域
|
|
|
* @param level 区域级别 4:城市 3:区 2:社区 1:团队
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/sign_info")
|
|
|
@ResponseBody
|
|
|
public String getAreaSignInfo(@RequestParam(required = true) String endDate,
|
|
|
@RequestParam(required = true) String area,
|
|
|
@RequestParam(required = true) int level,
|
|
|
@RequestParam(required = false) String lowCode,
|
|
|
@RequestParam(required = false) String year
|
|
|
) {
|
|
|
try {
|
|
|
JSONObject result = new JSONObject();
|
|
|
//year没传默认是今年
|
|
|
if(org.springframework.util.StringUtils.isEmpty(year)){
|
|
|
year= Constant.getNowYear();
|
|
|
}
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(lowCode)) {
|
|
|
// long sign = statisticsAllService.getIndexTotal(endDate, area, level, "13");
|
|
|
// long weiJf = statisticsAllService.getWeiJiaoFei(endDate, area, level);
|
|
|
// JSONObject jo = statisticsService.getRenewPercent(level + "", area, Constant.getNowYear());
|
|
|
// JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level,year);
|
|
|
// JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level,year);
|
|
|
|
|
|
long sign = statisticsESService.getIndexTotal(endDate, area, level, "13","2");
|
|
|
long weiJf = statisticsESService.getWeiJiaoFei(endDate, area, level);
|
|
|
JSONObject jo = statisticsESService.getRenewPercent(level + "", area, Constant.getNowYear());
|
|
|
JSONObject signRate = statisticsESService.getSignRate(endDate, area, level,year);
|
|
|
JSONObject signTaskRate = statisticsESService.getSignTaskRate(endDate, area, level,year);
|
|
|
|
|
|
result.put("sign", sign);
|
|
|
result.put("expenses", weiJf);
|
|
|
result.put("signRate", signRate);
|
|
|
result.put("signTaskRate", signTaskRate);
|
|
|
result.put("renew", jo.get("thisYearRenew") + "/" + jo.get("yesterYearSign"));//去年的签约量
|
|
|
result.put("renewRange", jo.get("renewRange"));//续签率 50.00%
|
|
|
} else {
|
|
|
//如果年度不是当前年度 就根据endDate 找到那个年度的最后一天的数据
|
|
|
if(!Constant.getNowYear().equals(year)){
|
|
|
endDate=(Integer.valueOf(year)+1)+"-06-30";
|
|
|
}
|
|
|
// result = statisticsAllService.getGroupInfo(endDate, lowCode, area, level,year);
|
|
|
result = statisticsESService.getGroupInfo(endDate, lowCode, area, level,year);
|
|
|
}
|
|
|
|
|
|
return write(200, "查询成功", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取三级指标增量 到达量
|
|
|
*
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @return
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 指标按间隔统计 到达量
|
|
|
*
|
|
|
* @param startDate 起始日期
|
|
|
* @param endDate 结束时间
|
|
|
* @param interval 时间间隔
|
|
|
* @param area 区域或机构
|
|
|
* @param level 级别
|
|
|
* @param index 指标 除了增量的指标都会调用
|
|
|
* @param lowCode 子维度
|
|
|
* @param year 查询年份
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/interval_total")
|
|
|
@ResponseBody
|
|
|
public String indexIntervalTotal(@RequestParam(required = true) String startDate,
|
|
|
@RequestParam(required = true) String endDate,
|
|
|
@RequestParam(required = true) int interval,
|
|
|
@RequestParam(required = true) String area,
|
|
|
@RequestParam(required = true) int level,
|
|
|
@RequestParam(required = true) String index,
|
|
|
@RequestParam(required = false) String lowCode,
|
|
|
@RequestParam(required = false) String year) {
|
|
|
try {
|
|
|
String[] indexes = index.split(",");
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
if (index != null) {
|
|
|
for (String idx : indexes) {
|
|
|
if(org.springframework.util.StringUtils.isEmpty(year)){
|
|
|
year=Constant.getNowYear();
|
|
|
}
|
|
|
// JSONObject json = statisticsAllService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode,year);
|
|
|
JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode,year);
|
|
|
result.put("index_" + idx, json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
return write(200, "查询成功!", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败!");
|
|
|
}
|
|
|
}
|
|
|
}
|