|
@ -906,7 +906,12 @@ public class StatisticsESService {
|
|
|
json.put("data", jsonArray);
|
|
|
return json;
|
|
|
} else if (interval == 2) {
|
|
|
JSONArray jsonArray = weekTotalStatistics(startDate, endDate, area, level, index, lowCode, timelevel);
|
|
|
JSONArray jsonArray = null;
|
|
|
if("90".equals(index)){
|
|
|
jsonArray = weekTotalStatistics_90(startDate, endDate, area, level, index, lowCode, timelevel);
|
|
|
}else {
|
|
|
jsonArray = weekTotalStatistics(startDate, endDate, area, level, index, lowCode, timelevel);
|
|
|
}
|
|
|
json.put("data", jsonArray);
|
|
|
return json;
|
|
|
} else if (interval == 3) {
|
|
@ -1016,6 +1021,7 @@ public class StatisticsESService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 按周统计 折线图
|
|
|
*
|
|
@ -1041,7 +1047,7 @@ public class StatisticsESService {
|
|
|
//因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
|
|
|
Calendar temp = Calendar.getInstance();
|
|
|
temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
|
|
|
temp.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
// temp.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
end.setTime(temp.getTime());
|
|
|
// 起始日期为周几
|
|
|
int week = start.get(Calendar.DAY_OF_WEEK);
|
|
@ -1090,6 +1096,8 @@ public class StatisticsESService {
|
|
|
// 结果集
|
|
|
Map<String, JSONObject> countResult = new HashMap<>();
|
|
|
|
|
|
// Date dd = df.parse();
|
|
|
|
|
|
// 算出每个查询周期
|
|
|
for (int j = 0; j < days.size() - 1; j++) {
|
|
|
String startStr = "";
|
|
@ -1109,6 +1117,14 @@ public class StatisticsESService {
|
|
|
range.put("range", endStr);
|
|
|
range.put("amount", 0);
|
|
|
countResult.put(endStr, range);
|
|
|
|
|
|
|
|
|
// if(!DateUtil.getSundayOfThisDate(new Date()).equals(df.format(new Date()))){
|
|
|
// JSONObject range2 = new JSONObject();
|
|
|
// range2.put("range", endDate);
|
|
|
// range2.put("amount", 0);
|
|
|
// countResult.put(df.format(new Date()), range2);
|
|
|
// };
|
|
|
}
|
|
|
|
|
|
if (startDate.equals(df.format(new Date()))) {
|
|
@ -1135,10 +1151,173 @@ public class StatisticsESService {
|
|
|
range = df.format(saveModel.getQuotaDate());
|
|
|
}
|
|
|
JSONObject json = countResult.get(range);
|
|
|
//因为上述时间集提前一天 但是前端是显示当前时间,所以这里给调整回去
|
|
|
if (range.equals(df.format(temp.getTime()))) {
|
|
|
json.put("range", endDate);
|
|
|
// //因为上述时间集提前一天 但是前端是显示当前时间,所以这里给调整回去
|
|
|
// if (range.equals(df.format(temp.getTime()))) {
|
|
|
// json.put("range", endDate);
|
|
|
// }
|
|
|
if (json != null) {
|
|
|
long amount = saveModel.getResult2().longValue();
|
|
|
json.put("amount", amount);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<JSONObject> result = new ArrayList<>(countResult.values());
|
|
|
|
|
|
// 排序
|
|
|
result.sort(new Comparator<JSONObject>() {
|
|
|
@Override
|
|
|
public int compare(JSONObject o1, JSONObject o2) {
|
|
|
if (o1.getString("range").compareTo(o2.getString("range")) > 0) {
|
|
|
return 1;
|
|
|
} else if (o1.getString("range").compareTo(o2.getString("range")) < 0) {
|
|
|
return -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return new JSONArray(result);
|
|
|
} else {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按周统计 折线图 90指标,es统计生成数据规则是按周去重
|
|
|
*
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param lowCode
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private JSONArray weekTotalStatistics_90(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel) throws Exception {
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
// 起始日期
|
|
|
Calendar start = Calendar.getInstance();
|
|
|
start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
|
|
|
// 第一个统计周期结束日期
|
|
|
String firstEnd = "";
|
|
|
// 结束日期
|
|
|
Calendar end = Calendar.getInstance();
|
|
|
//因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
|
|
|
Calendar temp = Calendar.getInstance();
|
|
|
temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
|
|
|
// temp.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
end.setTime(temp.getTime());
|
|
|
// 起始日期为周几
|
|
|
int week = start.get(Calendar.DAY_OF_WEEK);
|
|
|
int incre = 7 - week + 1;
|
|
|
|
|
|
// 日期集合
|
|
|
List<Calendar> days = new ArrayList<>();
|
|
|
days.add(start);
|
|
|
boolean flag = true;
|
|
|
int i = 0;
|
|
|
|
|
|
if (startDate.compareTo(endDate) == 0) {
|
|
|
flag = false;
|
|
|
days.add(end);
|
|
|
firstEnd = df.format(end.getTime());
|
|
|
}
|
|
|
|
|
|
// 计算统计日期
|
|
|
while (flag) {
|
|
|
Calendar next = Calendar.getInstance();
|
|
|
next.setTime(days.get(days.size() - 1).getTime());
|
|
|
|
|
|
if (i == 0) {
|
|
|
if (incre != 7) {
|
|
|
next.add(Calendar.DATE, incre);
|
|
|
}
|
|
|
} else {
|
|
|
next.add(Calendar.DATE, 7);
|
|
|
}
|
|
|
if (next.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))) {
|
|
|
days.add(next);
|
|
|
if (i == 0) {
|
|
|
firstEnd = df.format(next.getTime());
|
|
|
}
|
|
|
} else {
|
|
|
days.add(end);
|
|
|
flag = false;
|
|
|
if (i == 0) {
|
|
|
firstEnd = df.format(end.getTime());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
// 结果集
|
|
|
Map<String, JSONObject> countResult = new HashMap<>();
|
|
|
|
|
|
|
|
|
// 算出每个查询周期
|
|
|
for (int j = 0; j < days.size() - 1; j++) {
|
|
|
String startStr = "";
|
|
|
String endStr = df.format(days.get(j + 1).getTime());
|
|
|
|
|
|
// 起始、截止日期
|
|
|
if (j == 0) {
|
|
|
startStr = df.format(days.get(j).getTime());
|
|
|
} else {
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
cal.setTime(days.get(j).getTime());
|
|
|
cal.add(Calendar.DATE, 1);
|
|
|
startStr = df.format(cal.getTime());
|
|
|
}
|
|
|
|
|
|
JSONObject range = new JSONObject();
|
|
|
range.put("range", endStr);
|
|
|
range.put("amount", 0);
|
|
|
countResult.put(endStr, range);
|
|
|
|
|
|
|
|
|
// if(!DateUtil.getSundayOfThisDate(df.parse(endDate)).equals(df.parse(endDate))){
|
|
|
// JSONObject range2 = countResult.get(DateUtil.getSundayOfThisDate(df.parse(endDate)));
|
|
|
// range2.put("range",endDate);
|
|
|
//// countResult.put(df.format(new Date()), range2);
|
|
|
// };
|
|
|
}
|
|
|
|
|
|
if (startDate.equals(df.format(new Date()))) {
|
|
|
Calendar preDate = Calendar.getInstance();
|
|
|
preDate.setTime(df.parse(endDate));
|
|
|
preDate.add(Calendar.DATE, -1);
|
|
|
|
|
|
startDate = df.format(preDate.getTime());
|
|
|
}
|
|
|
|
|
|
|
|
|
List<SaveModel> saveModels = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(lowCode)) {
|
|
|
saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, DateUtil.getSundayOfThisDate(df.parse(endDate)), area, level, index, timelevel, SaveModel.interval_day, lowCode);
|
|
|
} else {
|
|
|
saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, DateUtil.getSundayOfThisDate(df.parse(endDate)), area, level, index, timelevel, SaveModel.interval_day);
|
|
|
}
|
|
|
|
|
|
if (saveModels != null) {
|
|
|
// 计算结果
|
|
|
for (SaveModel saveModel : saveModels) {
|
|
|
String range = "";
|
|
|
if (saveModel.getQuotaDate() != null) {
|
|
|
range = df.format(saveModel.getQuotaDate());
|
|
|
|
|
|
}
|
|
|
JSONObject json = countResult.get(range);
|
|
|
if(range.equals(DateUtil.getSundayOfThisDate(df.parse(endDate)))){
|
|
|
json = countResult.get(endDate);
|
|
|
}
|
|
|
// //因为上述时间集提前一天 但是前端是显示当前时间,所以这里给调整回去
|
|
|
// if (range.equals(df.format(temp.getTime()))) {
|
|
|
// json.put("range", endDate);
|
|
|
// }
|
|
|
if (json != null) {
|
|
|
long amount = saveModel.getResult2().longValue();
|
|
|
json.put("amount", amount);
|
|
@ -5429,7 +5608,7 @@ public class StatisticsESService {
|
|
|
areaCondition = " and d.area like '" + area.substring(0, 4) + "%' ";
|
|
|
// areaCondition2 = " and t.org_code like '" + area.substring(0, 2) + "%' ";
|
|
|
}
|
|
|
String activitySql = "select count(1) from wlyy_health_bank.wlyy_health_bank_activity d where d.status=1 " + areaCondition;
|
|
|
String activitySql = "select count(1) from wlyy_health_bank.wlyy_health_bank_activity d where 1=1 " + areaCondition;
|
|
|
Integer activityCount = jdbcTemplate.queryForObject(activitySql, Integer.class);//发布活动数
|
|
|
|
|
|
|
|
@ -5481,7 +5660,7 @@ public class StatisticsESService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取活动信息
|
|
|
* 获取活动的信息
|
|
|
*
|
|
|
* @param id
|
|
|
* @param area
|
|
@ -5500,7 +5679,7 @@ public class StatisticsESService {
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
|
condition += " and a.id='" + id+"'";
|
|
|
}
|
|
|
String sql = " select * from wlyy_health_bank.wlyy_health_bank_activity a where a.status=1 " + condition;
|
|
|
String sql = " select * from wlyy_health_bank.wlyy_health_bank_activity a where 1=1 " + condition;
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
@ -5515,11 +5694,11 @@ public class StatisticsESService {
|
|
|
// Map<String, Object> resultMap = new HashedMap();//返回的结果
|
|
|
List<SaveModel> allAmountList = null;//签约已缴费人数列表
|
|
|
List<SaveModel> applyAmountList = null;//报名人数列表
|
|
|
allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_all, SaveModel.timeLevel_DDL, "", low_level);
|
|
|
if (StringUtils.isNotEmpty(slaveKey1)) {
|
|
|
allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_all, SaveModel.timeLevel_DDL, slaveKey1, "", low_level);
|
|
|
// allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_all, SaveModel.timeLevel_DDL, null, "", low_level);
|
|
|
applyAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_part, SaveModel.timeLevel_DDL, slaveKey1, "", low_level);
|
|
|
} else {
|
|
|
allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_all, SaveModel.timeLevel_DDL, "", low_level);
|
|
|
applyAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_part, SaveModel.timeLevel_DDL, "", low_level);
|
|
|
}
|
|
|
Map<String, Integer> allMap = new HashMap<>(); //签约人数的的列表转map
|
|
@ -5745,4 +5924,5 @@ public class StatisticsESService {
|
|
|
JSONArray rsJs = new JSONArray(rs);
|
|
|
return rsJs;
|
|
|
}*/
|
|
|
|
|
|
}
|