| 
					
				 | 
			
			
				@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.PatientDeviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.patient.CarePatientService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.role.RoleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.CommonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.ConstantUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.vo.NumVo; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -83,6 +84,8 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String esType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private CarePatientService carePatientService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RoleService roleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static final String defalutArea = "330100"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1368,23 +1371,27 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 管理端首页老人接入情况,关联家属 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param area 权限范围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param level 1省2市3区县4机构5团队6医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject olderBindingDeviceStatus(String area) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject olderBindingDeviceStatus(String area,String level) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filter = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (listtmp.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgCodes = orgCodes.replaceAll(",", "','"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filter = " not in ('" + orgCodes + "')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select count(id) from base_patient  where del=1 and archive_type=1 and id " + filter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String olderFilter = roleService.getOlderRoleSQL(area,level); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String filter = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (listtmp.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            orgCodes = orgCodes.replaceAll(",", "','"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            filter = " not in ('" + orgCodes + "')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select count(p.id) from base_patient p  where p.del=1 and p.archive_type=1 " + olderFilter.replace("{patient}","p.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer olderCount = jdbcTemplate.queryForObject(sql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql = " select count(DISTINCT p.id) from base_patient p INNER JOIN wlyy_patient_device pd on p.id = pd.user and p.archive_type=1 and pd.del=0 where p.del=1 and p.id " + filter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql = " select count(DISTINCT p.id) from base_patient p INNER JOIN wlyy_patient_device pd on p.id = pd.user and p.archive_type=1 and pd.del=0 where p.del=1  "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                olderFilter.replace("{patient}","p.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer bindingCount = jdbcTemplate.queryForObject(sql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //老人接入情况 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("olderCount", olderCount); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1393,18 +1400,13 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //关联家属 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlfamily = "SELECT COUNT(DISTINCT p.id)  FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "base_patient p INNER JOIN base_service_package_sign_record sr " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "on p.id = sr.patient and sr.`status`=1 and  p.id not in " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older') " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ",(SELECT DISTINCT fm.family_member from base_patient_family_member fm,base_patient p1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "base_patient p , (SELECT DISTINCT fm.family_member from base_patient_family_member fm,base_patient p1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE p1.id = fm.patient and p1.archive_type = '3') f1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE p.del = 1 and p.archive_type =1 and p.id = f1.family_member "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE p.del = 1 and p.archive_type =1 and p.id = f1.family_member "+olderFilter.replace("{patient}","p.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlSign = "SELECT COUNT(DISTINCT p.id) FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "base_patient p INNER JOIN base_service_package_sign_record sr " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "on p.id = sr.patient and sr.`status`=1 and  p.id not in " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older') " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE p.del = 1 and p.archive_type =1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "base_patient p "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE p.del = 1 and p.archive_type =1 "+olderFilter.replace("{patient}","p.id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer familyOlderCount = jdbcTemplate.queryForObject(sqlfamily, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer familySignCount = jdbcTemplate.queryForObject(sqlSign, Integer.class); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1416,18 +1418,18 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 管理端安防监护新增分析 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 管理端首页安防预警统计分析 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject statisticsSecurityOlder(String endDate, String area, int level, String type) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject res = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String areaLevel = "4"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        areaLevel = "4"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, areaLevel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, null, null, "-2,0,1" ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("index_" + 46 + "_total", saveModel.getResult2().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(type)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //周/月 增量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String start = statisticsUtilService.calStart(endDate, type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevel0(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, areaLevel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevels(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, null,null,"-2,0,1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("index_" + 46 + "_add", saveModelAdd.getResult2().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray addDetail = new JSONArray(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1435,16 +1437,25 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //周/月 增量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String start = statisticsUtilService.calStart(endDate, type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SaveModel> saveModelAdds = elasticsearchUtil.findDateQuotaLevelList(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, null,null,"3", null, null, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SaveModel> saveModelAdds = elasticsearchUtil.findDateQuotaLevelList(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, null,null,"3", null, "-2,0,1" ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SaveModel saveModelTmp : saveModelAdds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                SaveModel saveMode2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, "3", null, null, saveModelTmp.getSlaveKey3()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                SaveModel saveMode2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, "3", null, "-2,0,1", saveModelTmp.getSlaveKey3()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("total", saveMode2.getResult2().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("num", saveModelTmp.getResult2().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("code", saveModelTmp.getSlaveKey3()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("name", saveModelTmp.getSlaveKey3Name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                addDetail.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SaveModel saveMode2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "53", SaveModel.timeLevel_DDL, null, null, "-2,0,1" ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SaveModel saveModelTmp = elasticsearchUtil.findOneDateQuotaLevels(start, endDate, area, level, "53", SaveModel.timeLevel_ZL, null, null, "-2,0,1" ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("total", saveMode2.getResult2().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("num", saveModelTmp.getResult2().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("code", "jjhj"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("name", "紧急呼叫"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            addDetail.add(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            System.out.println("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("index_add_detail", addDetail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return res; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2386,7 +2397,7 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop<List<Map<String,Object>>> getOlderTeamListWithPage(Integer page,Integer size) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop<List<Map<String,Object>>> getOlderTeamListWithPage(String area,String level,Integer page,Integer size) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> teamList  = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        page = page>0?page-1:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select count(distinct org.code) from " + 
			 |