|
@ -793,6 +793,18 @@ public class StatisticsESService {
|
|
|
return filesize + "%";
|
|
|
}
|
|
|
|
|
|
public Double getRange2(int first, int second, int i) {
|
|
|
if (second == 0 && first > 0) {
|
|
|
return 1.0;
|
|
|
} else if (second == 0 && first == 0) {
|
|
|
return 0.0;
|
|
|
}
|
|
|
Double size = (first * 100.0) / second;
|
|
|
// DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
|
|
|
// String filesize = df.format(size);
|
|
|
return size;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计65以上人群数据
|
|
|
*
|
|
@ -5182,7 +5194,8 @@ public class StatisticsESService {
|
|
|
//String lastDate = year + "-06-30";
|
|
|
//String timeKey = elasticsearchUtil.getQuotaTime();
|
|
|
String timeKey = DateUtil.getStringDateShort();//当前时间
|
|
|
String mondayTime = DateUtil.getMondayOfThisDate(new Date());//本周一开始时间
|
|
|
String currentTime = DateUtil.getStringDate();
|
|
|
String mondayTime = DateUtil.getMondayOfThisDate(new Date())+" 00:00:00";//本周一开始时间
|
|
|
String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
|
|
|
Map<String, Object> resultMap = new HashedMap();
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
@ -5195,24 +5208,26 @@ public class StatisticsESService {
|
|
|
SaveModel anomalySaveModel = null;
|
|
|
String allCountSql = "";
|
|
|
String anomalyCountSql = "";
|
|
|
String useCountSql = "";
|
|
|
List<SaveModel> allAmountList = null;//发放量列表
|
|
|
List<SaveModel> bindingAmountList = null;//绑定量列表
|
|
|
String areaCondition = "";
|
|
|
if (SaveModel.OrgLevel.equals(level + "")) {
|
|
|
areaCondition = " and d.grant_org_code like '" + area + "' ";
|
|
|
} else if (SaveModel.townLevel.equals(level + "")) {
|
|
|
areaCondition = " and d.grant_org_code like '" + area.substring(0, 4) + "%' ";
|
|
|
areaCondition = " and d.grant_org_code like '" + area.substring(0, 6) + "%' ";
|
|
|
} else if (SaveModel.cityLevel.equals(level + "")) {
|
|
|
areaCondition = " and d.grant_org_code like '" + area.substring(0, 2) + "%' ";
|
|
|
areaCondition = " and d.grant_org_code like '" + area.substring(0, 4) + "%' ";
|
|
|
}
|
|
|
|
|
|
//SELECT DISTINCT p.device_sn as healthProblem,"team" as team FROM device.wlyy_patient_health_index p WHERE p.type IN (1, 2) and p.del=1
|
|
|
switch (deviceType) {
|
|
|
case "1": {
|
|
|
grantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer");
|
|
|
bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer");
|
|
|
allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血压%' " + areaCondition;
|
|
|
startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
|
|
|
endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
|
|
|
useCountSql = "SELECT COUNT(DISTINCT p.device_sn) FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=1 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
|
|
|
// startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
|
|
|
// endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
|
|
|
anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "hemopiezometer");
|
|
|
anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
|
|
|
allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
|
|
@ -5223,8 +5238,9 @@ public class StatisticsESService {
|
|
|
grantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer");
|
|
|
bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer");
|
|
|
allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血糖%' " + areaCondition;
|
|
|
startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
|
|
|
endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
|
|
|
useCountSql = "SELECT COUNT(DISTINCT p.device_sn) FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=2 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
|
|
|
// startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
|
|
|
// endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
|
|
|
anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "glucometer");
|
|
|
anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
|
|
|
allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
|
|
@ -5236,9 +5252,10 @@ public class StatisticsESService {
|
|
|
bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_86, SaveModel.timeLevel_DDL);
|
|
|
anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_88, SaveModel.timeLevel_DDL);
|
|
|
allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 " + areaCondition;
|
|
|
useCountSql = "SELECT COUNT(DISTINCT p.device_sn) FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
|
|
|
anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.status=1 and i.del=1 " + areaCondition;
|
|
|
startUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
|
|
|
endUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
|
|
|
// startUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
|
|
|
// endUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
|
|
|
allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "", low_level);
|
|
|
bindingAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "", low_level);
|
|
|
|
|
@ -5259,12 +5276,13 @@ public class StatisticsESService {
|
|
|
resultMap.put("totalGrantRange", 0.0 + "%");//发放率
|
|
|
resultMap.put("totalBindingRange", 0.0 + "%");//绑定率
|
|
|
}
|
|
|
Double startTotalUseAccount = startUseSaveModel.size() > 0 ? startUseSaveModel.get(0).getResult1() : 0.0;
|
|
|
Double endTotalUseAccount = endUseSaveModel.size() > 0 ? endUseSaveModel.get(0).getResult1() : 0.0;
|
|
|
Double totalUseAccount = endTotalUseAccount-startTotalUseAccount;
|
|
|
resultMap.put("totalUse", endTotalUseAccount-startTotalUseAccount);//本周使用量
|
|
|
// Double startTotalUseAccount = startUseSaveModel.size() > 0 ? startUseSaveModel.get(0).getResult1() : 0.0;
|
|
|
// Double endTotalUseAccount = endUseSaveModel.size() > 0 ? endUseSaveModel.get(0).getResult1() : 0.0;
|
|
|
// Double totalUseAccount = endTotalUseAccount-startTotalUseAccount;
|
|
|
Integer useCount = jdbcTemplate.queryForObject(useCountSql, Integer.class);
|
|
|
resultMap.put("totalUse", useCount);//本周使用量
|
|
|
if (grantSaveModel.getResult1() > 0) {
|
|
|
resultMap.put("totalUseRange", df.format(totalUseAccount > 0.0 ? ((totalUseAccount) / (grantSaveModel.getResult1() * 1.0000) * 100) : 0.0) + "%");//本周使用率
|
|
|
resultMap.put("totalUseRange", df.format(useCount.doubleValue() > 0.0 ? ((useCount.doubleValue()) / (grantSaveModel.getResult1() * 1.0000) * 100) : 0.0) + "%");//本周使用率
|
|
|
} else {
|
|
|
resultMap.put("totalUseRange", 0.0 + "%");//本周使用率
|
|
|
}
|
|
@ -5362,53 +5380,64 @@ public class StatisticsESService {
|
|
|
String index_91 = "91";//健康银行全部活动报名数(人)
|
|
|
String index_1 = "1";//签约已缴费指标(总人数按签约人数计算)
|
|
|
String index_92 = "92";//健康银行活动参与数(人次)
|
|
|
String index_93 = "93";//健康银行活动获取积分数(人次)
|
|
|
String timeKey = DateUtil.getStringDateShort();//当前时间
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
String areaCondition = "";
|
|
|
String areaCondition2 = "";
|
|
|
//发布活动数
|
|
|
|
|
|
if (SaveModel.OrgLevel.equals(level + "")) {
|
|
|
areaCondition = " and d.area like '" + area + "' ";
|
|
|
areaCondition2 = " and t.org_code like '" + area + "' ";
|
|
|
// areaCondition2 = " and t.org_code like '" + area + "' ";
|
|
|
} else if (SaveModel.townLevel.equals(level + "")) {
|
|
|
areaCondition = " and d.area like '" + area.substring(0, 4) + "%' ";
|
|
|
areaCondition2 = " and t.org_code like '" + area.substring(0, 4) + "%' ";
|
|
|
areaCondition = " and d.area like '" + area.substring(0, 6) + "%' ";
|
|
|
// areaCondition2 = " and t.org_code like '" + area.substring(0, 4) + "%' ";
|
|
|
} else if (SaveModel.cityLevel.equals(level + "")) {
|
|
|
areaCondition = " and d.area like '" + area.substring(0, 2) + "%' ";
|
|
|
areaCondition2 = " and t.org_code like '" + area.substring(0, 2) + "%' ";
|
|
|
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_activity d where d.status=1 " + areaCondition;
|
|
|
String activitySql = "select count(1) from wlyy_health_bank.wlyy_health_bank_activity d where d.status=1 " + areaCondition;
|
|
|
Integer activityCount = jdbcTemplate.queryForObject(activitySql, Integer.class);//发布活动数
|
|
|
|
|
|
|
|
|
SaveModel activitySaveModel = null;//活动报名人次总量
|
|
|
SaveModel participantSaveModel = null;//活动参与人次总量
|
|
|
SaveModel creditsSaveModel = null;//活动获取积分人次总量
|
|
|
if(StringUtils.isNotEmpty(slaveKey1)){
|
|
|
activitySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_89, SaveModel.timeLevel_DDL,slaveKey1);
|
|
|
participantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_92, SaveModel.timeLevel_DDL,slaveKey1);
|
|
|
activitySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_89, SaveModel.timeLevel_DDL,slaveKey1);//活动报名人次总量
|
|
|
participantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_92, SaveModel.timeLevel_DDL,slaveKey1);//活动参与人次总量
|
|
|
creditsSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_93, SaveModel.timeLevel_DDL,slaveKey1);//活动获取积分人次总量
|
|
|
resultMap = applyList(index_1,index_89,area,level, sort,lowLevel,slaveKey1,resultMap);//列表
|
|
|
}else{
|
|
|
activitySaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_89, SaveModel.timeLevel_DDL);
|
|
|
participantSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_92, SaveModel.timeLevel_DDL);
|
|
|
activitySaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_89, SaveModel.timeLevel_DDL);//活动报名人次总量
|
|
|
participantSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_92, SaveModel.timeLevel_DDL);//活动参与人次总量
|
|
|
creditsSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_93, SaveModel.timeLevel_DDL);//活动获取积分人次总量
|
|
|
resultMap = applyList(index_1,index_91,area,level, sort,lowLevel,slaveKey1,resultMap);//列表
|
|
|
}
|
|
|
|
|
|
Double applyCount = activitySaveModel!=null?activitySaveModel.getResult1():0.0;//报名数
|
|
|
Double participantCount = participantSaveModel!=null?participantSaveModel.getResult1():0.0;//已参与
|
|
|
Double creditsCount = creditsSaveModel!=null?creditsSaveModel.getResult1():0.0;//以获取积分人数(人次)
|
|
|
|
|
|
if(!StringUtils.isNotEmpty(slaveKey1)){
|
|
|
resultMap.put("activityCount",activityCount);//发布活动数
|
|
|
resultMap.put("participantCount",participantSaveModel!=null?participantSaveModel.getResult1().intValue():0);//参与活动人数
|
|
|
resultMap.put("applyCount",applyCount);//(报名数)参与活动人数
|
|
|
}else{
|
|
|
String dayStart = DateUtil.dateToStrLong(new Date(DateUtil.getDayStartTime(new Date()).getTime()));
|
|
|
String currentTime = DateUtil.getStringDate();
|
|
|
String sql = " select count(1) from health_bank.wlyy_health_bank_active_record r join wlyy.wlyy_admin_team t on r.team_id=t.id where r.create_time>='"+dayStart+"' and r.create_time<='"+currentTime+"' r.activity_id='"+slaveKey1+"' "+areaCondition2;
|
|
|
Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
resultMap.put("dayActiveCount",count!=null?count.intValue():0);//今日活跃量
|
|
|
resultMap.put("activityPatient",activitySaveModel.getResult1().intValue());//单个活动报名人数
|
|
|
// String dayStart = DateUtil.dateToStrLong(new Date(DateUtil.getDayStartTime(new Date()).getTime()));
|
|
|
// String currentTime = DateUtil.getStringDate();
|
|
|
// String sql = " select count(1) from health_bank.wlyy_health_bank_active_record r join wlyy.wlyy_admin_team t on r.team_id=t.id where r.create_time>='"+dayStart+"' and r.create_time<='"+currentTime+"' r.activity_id='"+slaveKey1+"' "+areaCondition2;
|
|
|
// Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
// resultMap.put("dayActiveCount",count!=null?count.intValue():0);//今日活跃量
|
|
|
resultMap.put("participantCount",participantCount.intValue());//单个活动参与人数
|
|
|
resultMap.put("applyCount",applyCount.intValue());//单个活动报名人数
|
|
|
}
|
|
|
|
|
|
|
|
|
//居民活跃统计
|
|
|
resultMap.put("activityPatientRange","80%");//已报名
|
|
|
resultMap.put("participantRange","60%");//已参与
|
|
|
resultMap.put("expiryRange","20%");//已兑奖
|
|
|
// resultMap.put("activityPatientRange",df.format(participantCount > 0.0 ? ((participantCount) / (allCount * 1.0000) * 100) : 0.0) + "%");//已报名
|
|
|
resultMap.put("participantRange",df.format(participantCount > 0.0 ? ((participantCount) / (applyCount * 1.0000) * 100) : 0.0) + "%");//已参与
|
|
|
resultMap.put("creditsRange",df.format(creditsCount > 0.0 ? ((creditsCount) / (applyCount * 1.0000) * 100) : 0.0) + "%");//已获取积分
|
|
|
resultMap.put("expiryRange","0%");//已兑奖
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
@ -5425,14 +5454,14 @@ public class StatisticsESService {
|
|
|
if (SaveModel.OrgLevel.equals(level + "")) {
|
|
|
condition = " and a.area like '" + area + "' ";
|
|
|
} else if (SaveModel.townLevel.equals(level + "")) {
|
|
|
condition = " and a.area like '" + area.substring(0, 4) + "%' ";
|
|
|
condition = " and a.area like '" + area.substring(0, 6) + "%' ";
|
|
|
} else if (SaveModel.cityLevel.equals(level + "")) {
|
|
|
condition = " and a.area like '" + area.substring(0, 2) + "%' ";
|
|
|
condition = " and a.area like '" + area.substring(0, 4) + "%' ";
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
|
condition += " and a.id=" + id;
|
|
|
condition += " and a.id='" + id+"'";
|
|
|
}
|
|
|
String sql = " select * from 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 a.status=1 " + condition;
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
@ -5501,25 +5530,30 @@ public class StatisticsESService {
|
|
|
}
|
|
|
reMap.put("allNum", allAmount);
|
|
|
reMap.put("applyNum", applyAmount);
|
|
|
reMap.put("rate", getRange(applyAmount, allAmount, 2));//参与率是 报名数/签约数
|
|
|
reMap.put("rate", getRange2(applyAmount, allAmount, 2));//参与率是 报名数/签约数
|
|
|
if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
|
|
|
translateTeamLeaderName(resultList);
|
|
|
}
|
|
|
//对结果进行排序
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
int map1value = (int) o1.get("allNum");
|
|
|
int map2value = (int) o2.get("allNum");
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//对结果进行排序
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
double map1value = (double) o1.get("rate");
|
|
|
double map2value = (double) o2.get("rate");
|
|
|
|
|
|
if (map1value - map2value > 0.0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
|
|
|
for(Map<String, Object> one:resultList){
|
|
|
one.put("rate",df.format(one.get("rate"))+"%");
|
|
|
}
|
|
|
resultMap.put("list", resultList);
|
|
|
return resultMap;
|