|  | @ -791,11 +791,11 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject platformPeople(String area,Integer level) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         boolean b = StringUtils.isNotBlank(area) && 5 == level;
 | 
	
		
			
				|  |  |         boolean areaFilterFlag = StringUtils.isNotBlank(area) && 5 == level;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String areaFilter = " ";
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         Integer olderTotal = 0;
 | 
	
		
			
				|  |  |         Integer olderTotal = 0; //已照护老人
 | 
	
		
			
				|  |  |         Integer childTotal = 0;
 | 
	
		
			
				|  |  |         Integer helperTotal = 0;
 | 
	
		
			
				|  |  |         Integer teacherTotal = 0;
 | 
	
	
		
			
				|  | @ -816,7 +816,7 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |         Integer helper4On=0;
 | 
	
		
			
				|  |  |         Integer helper4Off=0;
 | 
	
		
			
				|  |  |         Integer helper4Total=0;
 | 
	
		
			
				|  |  |         Integer unSignOlderTotal=0;
 | 
	
		
			
				|  |  |         Integer unSignOlderTotal=0; //需招呼老人
 | 
	
		
			
				|  |  |         Integer unSignOlderOff=0;
 | 
	
		
			
				|  |  |         Integer unSignOlderOn=0;
 | 
	
		
			
				|  |  |         Integer streetOldTotal = 0;
 | 
	
	
		
			
				|  | @ -852,17 +852,19 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |         if (listOldtmp.size() > 0) {
 | 
	
		
			
				|  |  |             String orgCodes = String.valueOf(listOldtmp.get(0).get("orgCodes"));
 | 
	
		
			
				|  |  |             orgCodes = orgCodes.replaceAll(",", "','");
 | 
	
		
			
				|  |  |             oldFilter = " and a.id not in ('" + orgCodes + "')";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (b){
 | 
	
		
			
				|  |  |             areaFilter = " 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+"') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE  a.archive_type = 1 AND a.sign_status = 1 AND a.del =1 " +
 | 
	
		
			
				|  |  |                 " and del='1' "+areaFilter+" " + oldFilter + " GROUP BY online";
 | 
	
		
			
				|  |  |             oldFilter = " and a.id not in ('" + orgCodes + "') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql1 = " SELECT COUNT(distinct a.id) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a " +
 | 
	
		
			
				|  |  |                 " WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' " +oldFilter+
 | 
	
		
			
				|  |  |                 "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 "+(areaFilterFlag?" and r.team_code='"+area+"' ":" ")+" ) " +
 | 
	
		
			
				|  |  |                 "UNION ALL " +
 | 
	
		
			
				|  |  |                 "SELECT COUNT(distinct a.id) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a where a.archive_type = 1 " +
 | 
	
		
			
				|  |  |                 " and a.sign_status=0 and register='1' and a.del = '1' "+(areaFilterFlag?" and a.saas_id='"+area+"' ":"")+" " +oldFilter+
 | 
	
		
			
				|  |  |                 "and EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) GROUP BY on_line ";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
 | 
	
		
			
				|  |  |         for (Map<String, Object> map : list1) {
 | 
	
		
			
				|  |  |             Integer num = Integer.valueOf(map.get("c").toString());
 | 
	
	
		
			
				|  | @ -876,14 +878,14 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |         olderTotal = olderOff + olderOn;
 | 
	
		
			
				|  |  |         childTotal = childOff + childOn;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 社区老人
 | 
	
		
			
				|  |  |         // 需招呼老人
 | 
	
		
			
				|  |  |         String unSignOldAreaSql ="";
 | 
	
		
			
				|  |  |         if (b) {
 | 
	
		
			
				|  |  |         if (areaFilterFlag) {
 | 
	
		
			
				|  |  |             unSignOldAreaSql = " AND saas_id = '"+area+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and a.register = 1 and (sign_status=0 or sign_status is null ) " +
 | 
	
		
			
				|  |  |                 " and del='1' " + oldFilter + unSignOldAreaSql + " GROUP BY online";
 | 
	
		
			
				|  |  |                 " and del='1' and not EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) " + oldFilter + unSignOldAreaSql + " GROUP BY online";
 | 
	
		
			
				|  |  |         list1 = jdbcTemplate.queryForList(sql1);
 | 
	
		
			
				|  |  |         for (Map<String, Object> map : list1) {
 | 
	
		
			
				|  |  |             Integer num = Integer.valueOf(map.get("c").toString());
 | 
	
	
		
			
				|  | @ -915,7 +917,7 @@ public class StatisticsService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //社工和教师注册人数
 | 
	
		
			
				|  |  |         if (b){
 | 
	
		
			
				|  |  |         if (areaFilterFlag){
 | 
	
		
			
				|  |  |             areaFilter = " and EXISTS ( select 1 from base_team_member mem where mem.doctor_code = a.id " +
 | 
	
		
			
				|  |  |                     " and mem.team_code='"+area+"' and mem.del=1 )  ";
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -965,7 +967,7 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |             orgCodes = orgCodes.replaceAll(",", "','");
 | 
	
		
			
				|  |  |             olderRelativeFilter = " and t2.id not in ('" + orgCodes + "') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (b){
 | 
	
		
			
				|  |  |         if (areaFilterFlag){
 | 
	
		
			
				|  |  |             //有社区只查询该社区老人的家属列表
 | 
	
		
			
				|  |  |             areaFilter = " 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 " +
 | 
	
	
		
			
				|  | @ -993,7 +995,7 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         olderFamilyTotal = olderFamilyOff+olderFamilyOn;
 | 
	
		
			
				|  |  |         //家属绑定老人数量
 | 
	
		
			
				|  |  |         if (b){
 | 
	
		
			
				|  |  |         if (areaFilterFlag){
 | 
	
		
			
				|  |  |             areaFilter = " 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 " +
 | 
	
	
		
			
				|  | @ -2580,13 +2582,18 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |                 orgCodes = orgCodes.replaceAll(",","','");
 | 
	
		
			
				|  |  |                 filter = " and a.id not in ('"+orgCodes+"')";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' ";
 | 
	
		
			
				|  |  |             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='"+teamId+"' ) "+filter;
 | 
	
		
			
				|  |  |             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);
 | 
	
		
			
				|  |  |             map.put("oldTotal",count);
 | 
	
		
			
				|  |  |             map.put("oldTotal",count);//照护老人
 | 
	
		
			
				|  |  |             //照护老人数量
 | 
	
		
			
				|  |  |             filter = "";
 | 
	
		
			
				|  |  |             sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
 | 
	
	
		
			
				|  | @ -2677,14 +2684,18 @@ public class StatisticsService {
 | 
	
		
			
				|  |  |             if(listtmp.size()>0){
 | 
	
		
			
				|  |  |                 String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
 | 
	
		
			
				|  |  |                 orgCodes = orgCodes.replaceAll(",","','");
 | 
	
		
			
				|  |  |                 filter = " and a.id not in ('"+orgCodes+"')";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             sql = "SELECT count(distinct a.id) from base_patient a  WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' ";
 | 
	
		
			
				|  |  |             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='"+teamId+"') or " +
 | 
	
		
			
				|  |  |                     " (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) and a.register='1' and  a.saas_id = '"+teamId+"' )) "+filter;
 | 
	
		
			
				|  |  |                 filter = " and a.id not in ('"+orgCodes+"') ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             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);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             map.put("oldTotal",count);//照护老人数量
 |