| 
					
				 | 
			
			
				@ -10,7 +10,6 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.im.util.ImUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -40,10 +39,9 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ServicePackageService servicePackageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao patientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorDao doctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getOnLineObj(String patient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject obj = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String zlySql = "SELECT  doc.* from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor doc \n" + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -133,41 +131,24 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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","100","2",null,null,"2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray doctorArr = JSON.parseArray(doctors); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray patientArr = JSON.parseArray(patients); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (doctorArr.size()==0){//取签约医生其中一个 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          List<Map<String,Object>> signDoctors =  servicePackageService.getServerDoctorAll(patient,null,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          if (signDoctors.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              Map<String,Object> tmp = signDoctors.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              JSONObject tmpObj = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              tmpObj.put("name",tmp.get("doctorName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              tmpObj.put("unread_count","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              tmpObj.put("avatar",tmp.get("photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              tmpObj.put("userType","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              tmpObj.put("doctorId",tmp.get("doctor")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              tmpObj.put("doctorLevel",tmp.get("doctorLevel")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              tmpObj.put("relationName",null==tmp.get("doctorLevel")?"":"1".equals(tmp.get("doctorLevel").toString())?"社区医生":"助老员"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              doctorResult.add(tmpObj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject tmp = doctorArr.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("doctorId",id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BaseDoctorDO doctorDO = doctorDao.findById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmp.put("doctorLevel",doctorDO.getLevel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    tmp.put("relationName","助老员"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorResult.add(tmp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //医生默认取签约第一个 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> signDoctors =  servicePackageService.getServerDoctorAll(patient,null,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (signDoctors.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> tmp = signDoctors.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject tmpObj = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpObj.put("name",tmp.get("doctorName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpObj.put("unread_count","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpObj.put("avatar",tmp.get("photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpObj.put("userType","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpObj.put("doctorId",tmp.get("doctor")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmp.put("doctorLevel",tmp.get("doctorLevel")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            tmpObj.put("relationName","助老员"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorResult.add(tmpObj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray families = familyMemberService.membersWithOnLineFlag(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (families.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> familyIds = families.stream().map(item->((JSONObject)item).getString("id")).collect(Collectors.toList()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -177,10 +158,6 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i=0;i<participantsTimeArray.size();i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject tmpObj = participantsTimeArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String id =  tmpObj.getString("id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    BasePatientDO patientDO = patientDao.findById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (patientDO.getArchiveType()==3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!id.equals(patient)&&familyIds.contains(id)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("avatar",tmp.getString("photo")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tmp.put("patientId",id); 
			 |