|
@ -1,12 +1,15 @@
|
|
package com.yihu.jw.care.service.patient;
|
|
package com.yihu.jw.care.service.patient;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
|
|
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.json.JSONArray;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@ -28,6 +31,10 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
@Autowired
|
|
@Autowired
|
|
private ImUtil imUtil;
|
|
private ImUtil imUtil;
|
|
|
|
@Autowired
|
|
|
|
private PatientFamilyMemberService familyMemberService;
|
|
|
|
@Autowired
|
|
|
|
private ServicePackageService servicePackageService;
|
|
|
|
|
|
public JSONObject getOnLineObj(String patient){
|
|
public JSONObject getOnLineObj(String patient){
|
|
JSONObject obj = new JSONObject();
|
|
JSONObject obj = new JSONObject();
|
|
@ -121,4 +128,81 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
|
|
return obj;
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public JSONObject getContactFirst(String patient){
|
|
|
|
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","1","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);
|
|
|
|
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("relationName","助老员");
|
|
|
|
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);
|
|
|
|
tmp.put("relationName","助老员");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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","其他");
|
|
|
|
}
|
|
|
|
patientResult.add(tmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.put("doctors",doctorResult);
|
|
|
|
result.put("patients",patientResult);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|