| 
					
				 | 
			
			
				@ -892,7 +892,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查找签约老人 + 名单800 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param residentialArea 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param residentialArea 小区名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type 2已照护老人(签约+已绑定设备) , 8 需招呼老人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param limit 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -902,13 +903,26 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE a.archive_type = 1 and a.del = '1'   "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("2".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and a.sign_status=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(area)&&5==level){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and ((a.sign_status=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='"+area+"')" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) and a.saas_id='"+area+"' ))) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+=" and (a.sign_status=1 or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0))) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("8".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and a.register='1' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("8".equals(type)){//需招呼老人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and a.register='1' and not EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(area)&&5==level){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.isNotBlank(area)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql+= " and a.saas_id = '"+area+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //if(openid is null,0,1) onlineWx,IFNULL(a.on_line,0) onlinePad 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtil.isBlank(name)){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -917,23 +931,6 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtil.isBlank(residentialArea)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+= " and residential_area = '"+residentialArea+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(area)&&5==level){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " 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='"+area+"')  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " OR (a.saas_id = '"+area+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(name)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+= " and a.name like '%"+name+"%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(residentialArea)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+= " and a.residential_area = '"+residentialArea+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql +=" )"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += filter1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex,a.ykt_id,online,signStatus "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " ORDER BY online desc,a.ykt_id desc,signStatus desc"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -984,10 +981,24 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT count(DISTINCT a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("2".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and a.sign_status=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(area)&&5==level){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and ((a.sign_status=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='"+area+"')" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        " or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) and a.saas_id='"+area+"' ))) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+=" and (a.sign_status=1 or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0))) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("8".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and a.register='1' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("8".equals(type)){//需招呼老人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and a.register='1' and not EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(area)&&5==level){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.isNotBlank(area)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql+= " and a.saas_id = '"+area+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtil.isBlank(name)){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -996,21 +1007,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtil.isBlank(residentialArea)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+= " and residential_area = '"+residentialArea+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(area)&&5==level){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " 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='"+area+"' )  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += "OR (a.saas_id = '"+area+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(name)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+= " and a.name like '%"+name+"%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(residentialArea)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+= " and a.residential_area = '"+residentialArea+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql +=" )"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += filter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return jdbcTemplate.queryForObject(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 |