| 
					
				 | 
			
			
				@ -864,10 +864,20 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Integer> integers = jdbcTemplate.queryForList(totalList, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("oldTotal",integers.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //照护老人总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String zhTotalList = "SELECT COUNT(id) FROM base_patient where archive_type = 1 AND del = 1 AND id NOT IN(SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE  dict_name = 'jkzl_older'  and dict_code is not null) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //String zhTotalList = "SELECT COUNT(id) FROM base_patient where archive_type = 1 AND del = 1 AND id NOT IN(SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE  dict_name = 'jkzl_older'  and dict_code is not null) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String zhTotalList = " SELECT ((SELECT COUNT(distinct p.id) FROM base_patient p  WHERE p.sign_status = 1 AND p.del = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "              and p.id not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') ) +(SELECT COUNT(distinct p.id) FROM base_patient p INNER JOIN " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "              wlyy_patient_device d ON p.id = d.`user` WHERE p.sign_status = 0 AND p.del = 1  AND d.del = 0 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "              and p.id not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child'))) total"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceSql ="SELECT COUNT(id) AS total, COUNT(IF(device_type = 0,device_type,NULL)) AS jk,COUNT(IF(device_type = 1,device_type,NULL)) AS af FROM wlyy_devices where 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备总数  随着版本更新修改逻辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //String deviceSql ="SELECT COUNT(id) AS total, COUNT(IF(device_type = 0,device_type,NULL)) AS jk,COUNT(IF(device_type = 1,device_type,NULL)) AS af FROM wlyy_devices where 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String healthEquipmentSql = "SELECT COUNT(1) FROM wlyy_patient_device WHERE del = 0 AND (category_code = 1 OR category_code = 2)";   //健康设备 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer healthEquipmentNum = jdbcTemplate.queryForObject(healthEquipmentSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String securityEquipmentSql = "SELECT COUNT(1) FROM wlyy_patient_device WHERE del = 0 AND category_code > 2";   //安防设备 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer securityEquipmentNum = jdbcTemplate.queryForObject(securityEquipmentSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //医疗机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //养老机构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //日照中心 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -875,12 +885,17 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //助老员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //医护人员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //社工 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String zlSql = "SELECT COUNT(IF(doctor_level = 1,doctor_level,null)) AS yh,COUNT(IF(doctor_level = 2,doctor_level,null)) AS sg,COUNT(IF(doctor_level = 4,doctor_level,null)) AS zly FROM base_doctor WHERE id NOT IN(SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_user' or dict_name = 'jkzl_helper') and dict_code is not null) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //String zlSql = "SELECT COUNT(IF(doctor_level = 1,doctor_level,null)) AS yh,COUNT(IF(doctor_level = 2,doctor_level,null)) AS sg,COUNT(IF(doctor_level = 4,doctor_level,null)) AS zly FROM base_doctor WHERE id NOT IN(SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_user' or dict_name = 'jkzl_helper') and dict_code is not null) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String zlSql = "SELECT COUNT(a.id) total,a.doctor_level " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   and a.doctor_level is not null and h.org_code not in ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   ) GROUP BY a.doctor_level;"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(endDate)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhTotalList += " and create_time <= '"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orgSql += " and create_time <= '"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zlSql += " and create_time <= '"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //zhTotalList += " and create_time <= '"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //orgSql += " and create_time <= '"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //zlSql += " and create_time <= '"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        integers = jdbcTemplate.queryForList(zhTotalList,Integer.class); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -888,10 +903,10 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //照护率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("zh_rate", (Float.parseFloat(res.get("zh_oldTotal").toString()) / Float.parseFloat(res.get("oldTotal").toString()) * 100) + "%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> deviceList = jdbcTemplate.queryForList(deviceSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("deviceTotal",deviceList.get(0).get("total")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("deviceJkTotal",deviceList.get(0).get("jk")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("deviceAfTotal",deviceList.get(0).get("af")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //List<Map<String, Object>> deviceList = jdbcTemplate.queryForList(deviceSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("deviceTotal",healthEquipmentNum+securityEquipmentNum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("deviceJkTotal",healthEquipmentNum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("deviceAfTotal",securityEquipmentNum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> orgList = jdbcTemplate.queryForList(orgSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("yanglao",orgList.get(0).get("yangl")); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -899,9 +914,20 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("rz",orgList.get(0).get("rz")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> maps = jdbcTemplate.queryForList(zlSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("yh",maps.get(0).get("yh")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("sg",maps.get(0).get("sg")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("zly",maps.get(0).get("zly")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> map : maps) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            switch (Integer.parseInt(map.get("doctor_level").toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 1 : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res.put("yh",Integer.parseInt(map.get("total").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 2 : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res.put("sg",Integer.parseInt(map.get("total").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                case 4 : 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res.put("zly",Integer.parseInt(map.get("total").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = statisticsService.cloudCareForTheElderly(endDate, defalutArea, defalutLevel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        res.put("label",jsonArray); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -985,15 +1011,18 @@ public class WlyygcStatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = a.id and r.team_code='"+teamId+"' ) "+filter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = "SELECT count( DISTINCT a.id ) FROM base_patient a LEFT JOIN  base_service_package_record pr ON pr.patient = a.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN base_service_package_sign_record sr ON sr.id = pr.sign_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " a.archive_type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND a.sign_status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND pr.team_code = '"+teamId+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " AND sr.`status` = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count =  jdbcTemplate.queryForObject(sql+filter,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = " select sum(total) from ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "SELECT count(distinct a.id) total from base_patient a  WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "and EXISTS ( select 1 from " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = a.id and r.team_code='"+teamId+"') " +filter+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " UNION ALL " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "SELECT count(distinct a.id) total from base_patient a where a.archive_type = 1 and a.sign_status=0 and register='1' and a.del = '1' and a.saas_id='"+teamId+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "and EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) " + filter+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " )A "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            count =  jdbcTemplate.queryForObject(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //count =  jdbcTemplate.queryForObject(sql+filter,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("oldTotal",count);//照护老人数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return  teamList; 
			 |