|  | @ -5402,6 +5402,7 @@ public class StatisticsESService {
 | 
	
		
			
				|  |  |         String index_86 = "86";//设备绑定量统计指标
 | 
	
		
			
				|  |  |         String index_87 = "87";//设备使用量统计指标
 | 
	
		
			
				|  |  |         String index_88 = "88";//设备异常数据24H统计指标
 | 
	
		
			
				|  |  |         String index_96 = "96";//设备本周使用量
 | 
	
		
			
				|  |  |         //String lastDate = year + "-06-30";
 | 
	
		
			
				|  |  |         //String timeKey = elasticsearchUtil.getQuotaTime();
 | 
	
		
			
				|  |  |         String timeKey = DateUtil.getStringDateShort();//当前时间
 | 
	
	
		
			
				|  | @ -5410,12 +5411,13 @@ public class StatisticsESService {
 | 
	
		
			
				|  |  |         String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashedMap();
 | 
	
		
			
				|  |  |         DecimalFormat df = new DecimalFormat("0.00");
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         SaveModel grantSaveModel = null;
 | 
	
		
			
				|  |  |         SaveModel bindingSaveModel = null;
 | 
	
		
			
				|  |  |         List<SaveModel> startUseSaveModel = null;
 | 
	
		
			
				|  |  |         List<SaveModel> endUseSaveModel = null;
 | 
	
		
			
				|  |  | //        List<SaveModel> startUseSaveModel = null;
 | 
	
		
			
				|  |  | //        List<SaveModel> endUseSaveModel = null;
 | 
	
		
			
				|  |  |         SaveModel useSaveModel = null;
 | 
	
		
			
				|  |  |         SaveModel anomalySaveModel = null;
 | 
	
		
			
				|  |  |         String allCountSql = "";
 | 
	
		
			
				|  |  |         String anomalyCountSql = "";
 | 
	
	
		
			
				|  | @ -5436,7 +5438,8 @@ public class StatisticsESService {
 | 
	
		
			
				|  |  |                 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;
 | 
	
		
			
				|  |  |                 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 ;
 | 
	
		
			
				|  |  | //                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 ;
 | 
	
		
			
				|  |  |                 useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "1");
 | 
	
		
			
				|  |  | //                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");
 | 
	
	
		
			
				|  | @ -5449,7 +5452,8 @@ 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;
 | 
	
		
			
				|  |  |                 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 ;
 | 
	
		
			
				|  |  | //                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 ;
 | 
	
		
			
				|  |  |                 useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "2");
 | 
	
		
			
				|  |  | //                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");
 | 
	
	
		
			
				|  | @ -5463,7 +5467,8 @@ 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 ;
 | 
	
		
			
				|  |  | //                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 ;
 | 
	
		
			
				|  |  |                 useSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL);
 | 
	
		
			
				|  |  |                 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);
 | 
	
	
		
			
				|  | @ -5490,7 +5495,8 @@ public class StatisticsESService {
 | 
	
		
			
				|  |  | //        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);
 | 
	
		
			
				|  |  | //        Integer useCount = jdbcTemplate.queryForObject(useCountSql, Integer.class);
 | 
	
		
			
				|  |  |         Integer useCount = useSaveModel!=null?useSaveModel.getResult1().intValue():0;
 | 
	
		
			
				|  |  |         resultMap.put("totalUse", useCount);//本周使用量
 | 
	
		
			
				|  |  |         if (grantSaveModel.getResult1() > 0) {
 | 
	
		
			
				|  |  |             resultMap.put("totalUseRange", df.format(useCount.doubleValue() > 0.0 ? ((useCount.doubleValue()) / (grantSaveModel.getResult1() * 1.0000) * 100) : 0.0) + "%");//本周使用率
 | 
	
	
		
			
				|  | @ -5521,43 +5527,20 @@ public class StatisticsESService {
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, SaveModel> bingdingMap = new HashMap<>();
 | 
	
		
			
				|  |  |         bindingAmountList.stream().forEach(one -> {
 | 
	
		
			
				|  |  |             if ("5".equals(low_level)) {
 | 
	
		
			
				|  |  |                 bingdingMap.put(one.getTeam(), one);
 | 
	
		
			
				|  |  |             } else if ("4".equals(low_level)) {
 | 
	
		
			
				|  |  |                 bingdingMap.put(one.getHospital(), one);
 | 
	
		
			
				|  |  |             } else if ("3".equals(low_level)) {
 | 
	
		
			
				|  |  |                 bingdingMap.put(one.getTown(), one);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         //自建结果集
 | 
	
		
			
				|  |  |         resultList = getLowLevelMapKey(level, low_level, area);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = getDeviceLowLevelMapKey(level, low_level, area,allMap,bingdingMap);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (resultList != null && resultList.size() > 0) {
 | 
	
		
			
				|  |  |             Map<String, SaveModel> bingdingMap = new HashMap<>();
 | 
	
		
			
				|  |  |             bindingAmountList.stream().forEach(one -> {
 | 
	
		
			
				|  |  |                 if ("5".equals(low_level)) {
 | 
	
		
			
				|  |  |                     bingdingMap.put(one.getTeam(), one);
 | 
	
		
			
				|  |  |                 } else if ("4".equals(low_level)) {
 | 
	
		
			
				|  |  |                     bingdingMap.put(one.getHospital(), one);
 | 
	
		
			
				|  |  |                 } else if ("3".equals(low_level)) {
 | 
	
		
			
				|  |  |                     bingdingMap.put(one.getTown(), one);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |             for (Map<String, Object> reMap : resultList) {
 | 
	
		
			
				|  |  |                 reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
 | 
	
		
			
				|  |  |                 int bindingAmount = 0;
 | 
	
		
			
				|  |  |                 Integer allAmount = 0;
 | 
	
		
			
				|  |  |                 //获取绑定数量
 | 
	
		
			
				|  |  |                 if (bingdingMap != null && bingdingMap.size() > 0) {
 | 
	
		
			
				|  |  |                     SaveModel one = bingdingMap.get(reMap.get("code").toString());
 | 
	
		
			
				|  |  |                     if (one != null) {
 | 
	
		
			
				|  |  |                         bindingAmount = one.getResult2().intValue();
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (allMap != null && allMap.size() > 0) {
 | 
	
		
			
				|  |  |                     allAmount = allMap.get(reMap.get("code").toString());
 | 
	
		
			
				|  |  |                     if (allAmount == null) {
 | 
	
		
			
				|  |  |                         allAmount = 0;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 reMap.put("allNum", allAmount);
 | 
	
		
			
				|  |  |                 reMap.put("bindingNum", bindingAmount);
 | 
	
		
			
				|  |  |                 reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
 | 
	
		
			
				|  |  |                 translateTeamLeaderName(resultList);
 | 
	
	
		
			
				|  | @ -5584,6 +5567,115 @@ public class StatisticsESService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取下级统计key
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param level
 | 
	
		
			
				|  |  |      * @param lowLevel
 | 
	
		
			
				|  |  |      * @param area
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> getDeviceLowLevelMapKey(int level, String lowLevel, String area,Map<String, Integer> allMap,Map<String, SaveModel> bingdingMap) {
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         if (SaveModel.townLevel.equals(lowLevel)) {
 | 
	
		
			
				|  |  |             List<Town> towns = townDao.findByCityCode(area);
 | 
	
		
			
				|  |  |             if (towns != null) {
 | 
	
		
			
				|  |  |                 for (Town town : towns) {
 | 
	
		
			
				|  |  |                     Map<String, Object> obj = new HashMap<>();
 | 
	
		
			
				|  |  |                     obj.put("code", town.getCode());
 | 
	
		
			
				|  |  |                     obj.put("name", town.getName());
 | 
	
		
			
				|  |  |                     obj.put("amount", "0");
 | 
	
		
			
				|  |  |                     obj = deviceRateList(obj,allMap,bingdingMap);
 | 
	
		
			
				|  |  |                     resultList.add(obj);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else if (lowLevel.equals("4")) {
 | 
	
		
			
				|  |  |             List<Town> towns = new ArrayList<>();
 | 
	
		
			
				|  |  |             if (SaveModel.cityLevel.equals(level + "")) {
 | 
	
		
			
				|  |  |                 towns = townDao.findByCityCode(area);
 | 
	
		
			
				|  |  |             } else if (SaveModel.townLevel.equals(level + "")) {
 | 
	
		
			
				|  |  |                 Town town = townDao.findByCode(area);
 | 
	
		
			
				|  |  |                 if (town != null) {
 | 
	
		
			
				|  |  |                     towns.add(town);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (towns != null && towns.size() > 0) {
 | 
	
		
			
				|  |  |                 for (Town town : towns) {
 | 
	
		
			
				|  |  |                     List<Hospital> hospitals = hospitalDao.findByTownCode(town.getCode());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     for (Hospital hos : hospitals) {
 | 
	
		
			
				|  |  |                         if (hos.getCode().length() > 10) {
 | 
	
		
			
				|  |  |                             continue;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         Map<String, Object> obj = new HashMap<>();
 | 
	
		
			
				|  |  |                         obj.put("code", hos.getCode());
 | 
	
		
			
				|  |  |                         obj.put("name", hos.getName());
 | 
	
		
			
				|  |  |                         obj.put("amount", "0");
 | 
	
		
			
				|  |  |                         obj = deviceRateList(obj,allMap,bingdingMap);
 | 
	
		
			
				|  |  |                         resultList.add(obj);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else if (SaveModel.teamLevel.equals(lowLevel)) {
 | 
	
		
			
				|  |  |             List<Hospital> hospitals = new ArrayList<>();
 | 
	
		
			
				|  |  |             if (level == 2) {
 | 
	
		
			
				|  |  |                 hospitals = hospitalDao.findByCity(area);
 | 
	
		
			
				|  |  |             } else if (SaveModel.townLevel.equals(level + "")) {
 | 
	
		
			
				|  |  |                 hospitals = hospitalDao.findByTownCode(area);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 Hospital hos = hospitalDao.findByCode(area);
 | 
	
		
			
				|  |  |                 if (hos != null) {
 | 
	
		
			
				|  |  |                     hospitals.add(hos);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (hospitals != null && hospitals.size() > 0) {
 | 
	
		
			
				|  |  |                 for (Hospital hos : hospitals) {
 | 
	
		
			
				|  |  |                     if (hos.getCode().length() > 10) {
 | 
	
		
			
				|  |  |                         continue;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     List<AdminTeam> teams = adminTeamDao.findByOrgCode(hos.getCode());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     for (AdminTeam team : teams) {
 | 
	
		
			
				|  |  |                         Map<String, Object> obj = new HashMap<>();
 | 
	
		
			
				|  |  |                         obj.put("code", String.valueOf(team.getId()));
 | 
	
		
			
				|  |  |                         obj.put("name", team.getName());
 | 
	
		
			
				|  |  |                         obj.put("amount", "0");
 | 
	
		
			
				|  |  |                         obj = deviceRateList(obj,allMap,bingdingMap);
 | 
	
		
			
				|  |  |                         resultList.add(obj);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return resultList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String, Object> deviceRateList(Map<String, Object> reMap,Map<String, Integer> allMap,Map<String, SaveModel> bingdingMap){
 | 
	
		
			
				|  |  |         reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
 | 
	
		
			
				|  |  |         int bindingAmount = 0;
 | 
	
		
			
				|  |  |         Integer allAmount = 0;
 | 
	
		
			
				|  |  |         //获取绑定数量
 | 
	
		
			
				|  |  |         if (bingdingMap != null && bingdingMap.size() > 0) {
 | 
	
		
			
				|  |  |             SaveModel one = bingdingMap.get(reMap.get("code").toString());
 | 
	
		
			
				|  |  |             if (one != null) {
 | 
	
		
			
				|  |  |                 bindingAmount = one.getResult2().intValue();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (allMap != null && allMap.size() > 0) {
 | 
	
		
			
				|  |  |             allAmount = allMap.get(reMap.get("code").toString());
 | 
	
		
			
				|  |  |             if (allAmount == null) {
 | 
	
		
			
				|  |  |                 allAmount = 0;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         reMap.put("allNum", allAmount);
 | 
	
		
			
				|  |  |         reMap.put("bindingNum", bindingAmount);
 | 
	
		
			
				|  |  |         reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
 | 
	
		
			
				|  |  |         return reMap;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //i健康活动统计1.4.8版本
 | 
	
		
			
				|  |  |     public Map<String, Object> statisticsActivity(String area, int level, int sort,String lowLevel,String slaveKey1) throws Exception {
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashMap<>();
 |