| 
					
				 | 
			
			
				@ -540,7 +540,7 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //离线的设备数 超过6小时未受理的预警数  超6小时未响应服务(审核照料发起6小时未接单) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sqltmp = " select count(distinct pd.device_sn) total ,pd.device_type from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where (dev.contact_status=0 or dev.contact_status is null ) and pd.user "+userfilter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where dev.contact_status=0  and pd.user "+userfilter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sqltmp += " group by pd.device_type "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> offlineDevices = jdbcTemplate.queryForList(sqltmp);//离线设备 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count = 0l; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -826,6 +826,9 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer streetOldTotal = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer streetOldOff = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer streetOldOn = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer doctorON = 0; //医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer doctorOff = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer doctorTotal = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //儿童注册人数 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1011,8 +1014,24 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        olderFamilyBinding = jdbcTemplate.queryForObject(sql2,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorSqlTotal = "SELECT count(d.id) AS count, if(d.openid is null,0,1) online FROM base_doctor d WHERE  d.del = 1 AND d.doctor_level = 1 AND d.id NOT IN " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_doctor') GROUP BY openid "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> doctorCountList = jdbcTemplate.queryForList(doctorSqlTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> dcm : doctorCountList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer num = Integer.valueOf(dcm.get("count").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer online = Integer.valueOf(dcm.get("online").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (0==online){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorOff+=num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (1==online){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorON+=num; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        doctorTotal = doctorOff + doctorON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //helper 社工,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板 olderFamily老人家属  street 街道老人二次导入朝辉街道 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //helper4助老员 unSignOlder社区老人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //helper4助老员 unSignOlder社区老人 doctor 医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("olderTotal", olderTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("olderOn", olderOn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("olderOff", olderOff); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1026,6 +1045,10 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("unSignOlderOff", unSignOlderOff); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("unSignOlderOn", unSignOlderOn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("doctorTotal",doctorTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("doctorOn",doctorON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("doctorOff",doctorOff); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("helperTotal", helperTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("helperOff", helperOff); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("helperOn", helperOn); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2461,6 +2484,37 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop getCareServerList(String name,String idCard,String area,Integer status,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        page = page>0?page-1:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String olderFilter = " 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)  = life.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child')  ) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String pageSql = " order by life.create_time desc limit "+page*pageSize+","+pageSize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String headSql = "SELECT life.id,life.number,life.patient,life.patient_name patientName,life.patient_phone patientPhone,life.hospital,life.hospital_name hospitalName,CAST(DATE_FORMAT(life.create_time,'%Y-%m-%d %H:%i:%S') as char) createTime,de.name serviceName,p.idcard,p.residential_area residentialArea,o.mobile hospitalMobile,life.status,p.photo "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String countSql = "SELECT count(*) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String tableSql = " FROM base_life_care_order life left join base_life_care_fee_detail de on life.id = de.order_id left join base_patient p on life.patient = p.id left join base_org o on life.hospital = o.code where 1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(name)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tableSql += " and p.name like '%"+name+"%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(idCard)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tableSql += " and p.idcard like '%"+idCard+"%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(area)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tableSql += " and p.residential_area like '%"+area+"%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(status == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //tableSql += " and life.status in (1,2,3) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tableSql += " and life.status = "+status + " "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(headSql + tableSql + olderFilter+pageSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count = jdbcTemplate.queryForObject(countSql + tableSql + olderFilter, Long.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *获取老人服务情况(助老服务、紧急救助、医生服务 项目数量) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3166,14 +3220,21 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "  YEAR ( now()) - YEAR (substring( p.idcard, 7, 8 )) WHEN LENGTH( p.idcard )= 15 THEN " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "  YEAR ( now()) - YEAR (STR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " END AS age, p.mobile AS mobile, p.address AS address, t.`name` AS orgName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName  FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " base_patient p,base_service_package_sign_record sr,base_service_package_record r,base_service_package_item i,base_service_package pack,base_team t,base_team_member tm,base_doctor d  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS socialWorkerName" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ",GROUP_CONCAT( DISTINCT h.doctor_name SEPARATOR ',' ) AS helperName" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ",GROUP_CONCAT( DISTINCT pd.doctor_name SEPARATOR ',' ) AS doctorName  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " FROM base_patient p " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " left join base_patient_helper h on h.patient = p.id and h.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " left join base_patient_doctor pd on pd.patient = p.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ",base_service_package_sign_record sr,base_service_package_record r," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " base_service_package_item i,base_service_package pack,base_team t,base_team_member tm,base_doctor d  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " 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 i.del = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " AND p.del = 1  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " AND sr.`status` = 1  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " AND CONVERT ( sr.patient USING utf8 ) = p.id  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " AND r.team_code = t.id  " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3189,9 +3250,13 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "  WHEN LENGTH( p.idcard )= 15 THEN " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "  YEAR (now()) - YEAR (STR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " END AS age, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " p.mobile AS mobile,p.address AS address, p.residential_area AS orgName,'' AS doctorName  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " p.mobile AS mobile,p.address AS address, p.residential_area AS orgName,'' AS socialWorkerName" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " ,GROUP_CONCAT( DISTINCT h.doctor_name SEPARATOR ',' ) AS helperName  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " ,GROUP_CONCAT( DISTINCT pd.doctor_name SEPARATOR ',' ) AS doctorName  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user`  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user`" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " left join base_patient_helper h on h.patient = p.id and h.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " left join base_patient_doctor pd on pd.patient = p.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " WHERE p.sign_status = 0 AND p.del = 1 AND d.del = 0 AND p.archive_type = 1 " + nameSql+idcardSql+orgNameSql2+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " <testUserSql>  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " GROUP BY p.idcard  "; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3213,7 +3278,7 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        page = (page - 1) * size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String testUserSql = "AND p.id NOT IN (SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user') AND dict_code IS NOT NULL ) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += "  ORDER BY id limit " + page + "," + size + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += "  ORDER BY id DESC limit " + page + "," + size + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql = sql.replace("<testUserSql>",testUserSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3648,8 +3713,8 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(name)) nameSql = " AND p.name LIKE '%" + name + "%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(deviceSn)) deviceSnSql = " AND pd.device_sn = '" + deviceSn + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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' OR dict_name ='jkzl_helper' OR dict_name= 'jkzl_olderRelative' OR dict_name ='jkzl_user') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filter="AND pd.USER NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_user' OR dict_name = 'jkzl_older' ) AND dict_code IS NOT NULL ) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*String sqltmp = " SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' OR dict_name ='jkzl_helper' OR dict_name= 'jkzl_olderRelative' OR dict_name ='jkzl_user') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(listtmp.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes")); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3657,46 +3722,58 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                orgCodes = orgCodes.replaceAll(",","','"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                filter = " and p.id not in ('"+orgCodes+"') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        page = page>0?page-1:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceSql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("jk".equals(type)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            categoryCodeSql = " AND ( pd.category_code = 1 OR pd.category_code = 2 )"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            categoryCodeSql = " AND pd.device_type = 0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(categoryCode)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCodeSql = " AND pd.category_code = '" + categoryCode + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceSql = "SELECT DISTINCT  p.id AS patient, pd.id as id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,'健康设备' AS deviceType,p.`name`," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " p.mobile,p.phone,dd.photo,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceSql = "SELECT p.id AS patient,pd.id AS id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,dd.photo,'健康设备' AS deviceType,p.`name`,p.mobile,p.phone,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " pd.del = 0 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql = "SELECT count(DISTINCT pd.id) FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " pd.del = 0 " +filter+ nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1    " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql = "SELECT count(pd.id) FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN base_patient p ON pd.USER = p.id  AND pd.del = 0  AND p.del = 1  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("af".equals(type) || StringUtils.isBlank(type)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            categoryCodeSql = " AND pd.category_code > 2 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            categoryCodeSql = " AND pd.device_type = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(categoryCode)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                categoryCodeSql = " AND pd.category_code = '" + categoryCode + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceSql = " SELECT DISTINCT  p.id AS patient,pd.id AS id ,pd.device_name AS deviceName,pd.device_sn AS deviceSn,'安防设备' AS deviceType,p.`name`,p.mobile,p.phone,dd.photo,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceSql = "SELECT p.id AS patient,pd.id AS id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,dd.photo,'安防设备' AS deviceType,p.`name`,p.mobile,p.phone,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " pd.del = 0 " +filter+nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1    " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql = "SELECT count(pd.id) FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " INNER JOIN base_patient p ON pd.USER = p.id  AND pd.del = 0  AND p.del = 1  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalSql = " SELECT count(DISTINCT pd.id) FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " pd.del = 0 " +filter+nameSql + deviceSnSql + categoryCodeSql + contactStatusSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        deviceSql += " GROUP BY id LIMIT " + page*size + "," + size + " "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        deviceSql += " GROUP BY pd.id LIMIT " + page*size + "," + size + " "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> deviceList = jdbcTemplate.queryForList(deviceSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> list = jdbcTemplate.queryForList(totalSql, String.class); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3756,7 +3833,7 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //离线设备数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String offLineDeviceSql="select count(distinct pd.device_sn) total from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                 INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                where (dev.contact_status=0 or dev.contact_status is null ) and pd.device_type = "+type+"  AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                where dev.contact_status=0  and pd.device_type = "+type+"  AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceTotalSql = "SELECT count(DISTINCT device_code) FROM wlyy_devices WHERE (device_code IS NOT NULL OR device_code <> '') AND device_type = "+type+""; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3776,6 +3853,8 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                where pd.device_type = "+type+"  AND EXISTS(SELECT 1 FROM device_data_push_log pl WHERE pl.device_sn = pd.device_sn "+deviceCategorySql+" AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= pl.create_time ) AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备类型总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceCodeTotalSql ="SELECT count(DISTINCT device_code) FROM wlyy_devices WHERE (device_code IS NOT NULL OR device_code <> '') AND category_code = '"+deviceCategory+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Integer> total = jdbcTemplate.queryForList(typeTotalSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("typeTotal",total.get(0)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -3786,9 +3865,10 @@ public class StatisticsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        total = jdbcTemplate.queryForList(lineDeviceSql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("lineDevice",total.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        total = jdbcTemplate.queryForList(sevenDayUseSql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer deviceCodeTotal = jdbcTemplate.queryForObject(deviceCodeTotalSql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Float num = 0F; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (total.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            num= (float)total.get(0)/(float)Integer.parseInt(jsonObject.get("deviceTotal").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            num= (float)total.get(0)/(float)deviceCodeTotal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonObject.put("sevenDayUse",num*100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jsonObject; 
			 |