| 
					
				 | 
			
			
				@ -17,6 +17,7 @@ import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/*** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * @ClassName: OnlineContactService 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -133,7 +134,7 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray doctorResult = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray patientResult = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctors = imUtil.getSessionListByType(patient,"0","1","2",null,null,"1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patients = imUtil.getSessionListByType(patient,"0","1","2",null,null,"2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patients = imUtil.getSessionListByType(patient,"0","100","2",null,null,"2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray doctorArr = JSON.parseArray(doctors); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray patientArr = JSON.parseArray(patients); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (doctorArr.size()==0){//取签约医生其中一个 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -164,42 +165,48 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorResult.add(tmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientArr.size()==0){//取家属 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray families = familyMemberService.membersWithOnLineFlag(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (families.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject tmp = families.getJSONObject(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject tmpObj = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmpObj.put("name",tmp.getString("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmpObj.put("unread_count","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmpObj.put("avatar",tmp.getString("photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmpObj.put("userType","2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmpObj.put("patientId",tmp.get("id")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                tmpObj.put("relationName",tmp.get("familyRelationName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientResult.add(tmpObj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject tmp = patientArr.getJSONObject(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (int i=0;i<participantsTimeArray.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject tmpObj = participantsTimeArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String id =  tmpObj.getString("id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!id.equals(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmp.put("avatar",tmp.getString("photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmp.put("patientId",id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String sql = " select family_relation from base_patient_family_member where " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            " patient = '"+patient+"' and family_member='"+id+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            " and (del=1 or del is null) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(relations.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("relationName",familyMemberService.relations.get(relations.get(0))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("relationName","其他"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray families = familyMemberService.membersWithOnLineFlag(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (families.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> familyIds = families.stream().map(item->((JSONObject)item).getString("id")).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(patientArr.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject tmp = patientArr.getJSONObject(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i=0;i<participantsTimeArray.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject tmpObj = participantsTimeArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String id =  tmpObj.getString("id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!id.equals(patient)&&familyIds.contains(id)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("avatar",tmp.getString("photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("patientId",id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String sql = " select family_relation from base_patient_family_member where " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                " patient = '"+patient+"' and family_member='"+id+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                " and (del=1 or del is null) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if(relations.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            tmp.put("relationName",familyMemberService.relations.get(relations.get(0))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            tmp.put("relationName","其他"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        patientResult.add(tmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientResult.add(tmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (patientResult.size()==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (families.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject tmp = families.getJSONObject(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject tmpObj = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmpObj.put("name",tmp.getString("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmpObj.put("unread_count","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmpObj.put("avatar",tmp.getString("photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmpObj.put("userType","2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmpObj.put("patientId",tmp.get("id")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmpObj.put("relationName",tmp.get("familyRelationName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientResult.add(tmpObj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("doctors",doctorResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("patients",patientResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 |