|
@ -35,17 +35,23 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springside.modules.persistence.DynamicSpecifications;
|
|
import org.springside.modules.persistence.DynamicSpecifications;
|
|
import org.springside.modules.persistence.SearchFilter;
|
|
import org.springside.modules.persistence.SearchFilter;
|
|
import org.springside.modules.persistence.SearchFilter.Operator;
|
|
import org.springside.modules.persistence.SearchFilter.Operator;
|
|
@ -553,18 +559,18 @@ public class ConsultTeamService extends ConsultService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public void reply(List<ConsultTeamLog> logs, String patient) throws Exception {
|
|
public void reply(List<ConsultTeamLog> logs, String patient) throws Exception {
|
|
ConsultTeam consultTeam = consultTeamDao.findByConsult(logs.get(0).getConsult());
|
|
|
|
WlyyTalkGroup wlyyTalkGroup = talkGroupService.findConsultTalkGroupByType(logs.get(0).getConsult(), 2);
|
|
|
|
for (ConsultTeamLog log : logs) {
|
|
|
|
reply(log, patient, null, log.getType());
|
|
|
|
//判断当前咨询是否创建讨论租
|
|
|
|
if (wlyyTalkGroup != null) {
|
|
|
|
sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType() + "", log.getContent());
|
|
|
|
} else {
|
|
|
|
//推送给IM
|
|
|
|
sendIM(patient, consultTeam.getDoctor(), log.getChatType() + "", log.getContent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//ConsultTeam consultTeam = consultTeamDao.findByConsult(logs.get(0).getConsult());
|
|
|
|
//WlyyTalkGroup wlyyTalkGroup = talkGroupService.findConsultTalkGroupByType(logs.get(0).getConsult(), 2);
|
|
|
|
//for (ConsultTeamLog log : logs) {
|
|
|
|
// reply(log, patient, null, log.getType());
|
|
|
|
// //判断当前咨询是否创建讨论租
|
|
|
|
// if (wlyyTalkGroup != null) {
|
|
|
|
// sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType() + "", log.getContent());
|
|
|
|
// } else {
|
|
|
|
// //推送给IM
|
|
|
|
// sendIM(patient, consultTeam.getDoctor(), log.getChatType() + "", log.getContent());
|
|
|
|
// }
|
|
|
|
//}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -622,6 +628,7 @@ public class ConsultTeamService extends ConsultService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public int addTeamConsult(ConsultTeam ct, String patient) throws Exception {
|
|
public int addTeamConsult(ConsultTeam ct, String patient) throws Exception {
|
|
|
|
JSONObject users = new JSONObject();
|
|
// 咨询三师
|
|
// 咨询三师
|
|
if (ct.getType() == 1) {
|
|
if (ct.getType() == 1) {
|
|
// 查询三师签约信息
|
|
// 查询三师签约信息
|
|
@ -633,15 +640,21 @@ public class ConsultTeamService extends ConsultService {
|
|
ct.setTeam(sc.getTeamCode());
|
|
ct.setTeam(sc.getTeamCode());
|
|
// 设置健康管理师,三师咨询默认给健康管理师处理
|
|
// 设置健康管理师,三师咨询默认给健康管理师处理
|
|
//查找病人所在的团队
|
|
//查找病人所在的团队
|
|
DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
|
|
|
|
|
|
DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
|
|
//得到团队的健康管理师
|
|
//得到团队的健康管理师
|
|
DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
|
|
|
|
|
|
|
|
if (doctorTeamMember == null) {
|
|
|
|
doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
|
|
|
|
|
|
DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
|
|
|
|
DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
|
|
|
|
if (doctorTeamMemberHealthy == null) {
|
|
|
|
ct.setDoctor(doctorTeamMember.getMemberCode());
|
|
|
|
if(doctorTeamMember!=null){
|
|
|
|
users.put(doctorTeamMember.getMemberCode(),1);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(),0);
|
|
|
|
ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
|
|
}
|
|
}
|
|
// 设置家庭医生
|
|
// 设置家庭医生
|
|
ct.setDoctor(doctorTeamMember.getMemberCode());
|
|
|
|
|
|
|
|
ct.setAdminTeamId(sc.getAdminTeamId());
|
|
ct.setAdminTeamId(sc.getAdminTeamId());
|
|
} else if (ct.getType() == 2) {
|
|
} else if (ct.getType() == 2) {
|
|
// 咨询家庭医生
|
|
// 咨询家庭医生
|
|
@ -654,14 +667,19 @@ public class ConsultTeamService extends ConsultService {
|
|
//查找病人所在的团队
|
|
//查找病人所在的团队
|
|
DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
|
|
DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
|
|
//得到团队的健康管理师
|
|
//得到团队的健康管理师
|
|
DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
|
|
|
|
|
|
|
|
if (doctorTeamMember == null) {
|
|
|
|
doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
|
|
|
|
|
|
DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
|
|
|
|
DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
|
|
|
|
if (doctorTeamMemberHealthy == null) {
|
|
|
|
ct.setDoctor(doctorTeamMember.getMemberCode());
|
|
|
|
if(doctorTeamMember!=null){
|
|
|
|
users.put(doctorTeamMember.getMemberCode(),1);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(),0);
|
|
|
|
ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
|
|
}
|
|
}
|
|
|
|
|
|
// 设置家庭医生
|
|
// 设置家庭医生
|
|
ct.setDoctor(doctorTeamMember.getMemberCode());
|
|
|
|
|
|
|
|
ct.setAdminTeamId(sf.getAdminTeamId());
|
|
ct.setAdminTeamId(sf.getAdminTeamId());
|
|
}
|
|
}
|
|
// 设置患者信息
|
|
// 设置患者信息
|
|
@ -697,23 +715,21 @@ public class ConsultTeamService extends ConsultService {
|
|
cd.setTo(ct.getDoctor());
|
|
cd.setTo(ct.getDoctor());
|
|
// 添加医生咨询日志
|
|
// 添加医生咨询日志
|
|
String content = addLogs(ct);
|
|
String content = addLogs(ct);
|
|
//推送给IM文字消息
|
|
|
|
String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
|
JSONObject jo = new JSONObject(returnJson);
|
|
|
|
if (jo.has("startId")) {
|
|
|
|
//设置消息ID
|
|
|
|
ct.setStartMsgId(jo.getInt("startId"));
|
|
|
|
//推送给IM图片
|
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
|
String[] images = ct.getImages().split(",");
|
|
|
|
for (String image : images) {
|
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//推送给IM去创建议题,取得成员消息
|
|
|
|
|
|
|
|
DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
|
|
|
|
JSONObject messages = new JSONObject();
|
|
|
|
messages.put("description",consult.getSymptoms());
|
|
|
|
messages.put("title",consult.getTitle());
|
|
|
|
messages.put("img",consult.getImages());
|
|
|
|
messages.put("senderId",patient);
|
|
|
|
messages.put("senderName",tempPatient.getName());
|
|
|
|
users.put(patient,0);
|
|
|
|
JSONObject obj = createTopics(patient,consult.getCode(),"咨询问题:"+consult.getSymptoms(),users,messages);
|
|
|
|
if(obj==null){
|
|
|
|
throw new RuntimeException("IM消息结束异常!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ct.setStartMsgId(obj.get("id").toString());
|
|
consultTeamDao.save(ct);
|
|
consultTeamDao.save(ct);
|
|
consultDao.save(consult);
|
|
consultDao.save(consult);
|
|
consultTeamDoctorDao.save(cd);
|
|
consultTeamDoctorDao.save(cd);
|
|
@ -724,21 +740,85 @@ public class ConsultTeamService extends ConsultService {
|
|
* 发送消息给IM
|
|
* 发送消息给IM
|
|
*
|
|
*
|
|
* @param from 来自
|
|
* @param from 来自
|
|
* @param to
|
|
|
|
* @param contentType 1文字 2图片消息
|
|
* @param contentType 1文字 2图片消息
|
|
* @param content 内容
|
|
* @param content 内容
|
|
*/
|
|
*/
|
|
private String sendIM(String from, String to, String contentType, String content) {
|
|
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/pm";
|
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
|
params.add(new BasicNameValuePair("from", from));
|
|
|
|
params.add(new BasicNameValuePair("to", to));
|
|
|
|
params.add(new BasicNameValuePair("contentType", contentType));
|
|
|
|
params.add(new BasicNameValuePair("content", content));
|
|
|
|
String response = HttpClientUtil.post(imAddr, params, "UTF-8");
|
|
|
|
|
|
private String sendIM(String from,String fromName, String sessionId, String contentType, String content) {
|
|
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "/api/v2/sessions/"+sessionId+"/messages";
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
params.put("sender_id", from);
|
|
|
|
params.put("sender_name", fromName);
|
|
|
|
params.put("content_type", contentType);
|
|
|
|
params.put("content", content);
|
|
|
|
params.put("sessionId", sessionId);;
|
|
|
|
String response = HttpClientUtil.postBody(imAddr, params);
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 创建议题
|
|
|
|
*
|
|
|
|
* @param topicId 议题ID
|
|
|
|
* @param topicName 议题名称
|
|
|
|
* @param participants 成员
|
|
|
|
*/
|
|
|
|
private JSONObject createTopics(String sessionId, String topicId,String topicName, JSONObject participants,JSONObject messages) {
|
|
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/topics";
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
params.put("topicId", topicId);
|
|
|
|
params.put("topicName", topicName);
|
|
|
|
params.put("participants", participants.toString());
|
|
|
|
params.put("messages", messages.toString());
|
|
|
|
params.put("sessionId", sessionId);;
|
|
|
|
String ret = HttpClientUtil.postBody(imAddr,params);
|
|
|
|
JSONObject obj = null;
|
|
|
|
try{
|
|
|
|
obj = new JSONObject(ret);
|
|
|
|
}catch (Exception e){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 结束议题
|
|
|
|
*
|
|
|
|
* @param topicId 议题ID
|
|
|
|
* @param endUser 结束人
|
|
|
|
* @param endUserName 结束人名字
|
|
|
|
* @param sessionId 会话ID
|
|
|
|
*/
|
|
|
|
private JSONObject endTopics(String sessionId,String endUser, String endUserName,String topicId) {
|
|
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/topics/"+topicId+"/ended";
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
params.put("session_id", sessionId);
|
|
|
|
params.put("end_user", endUser);
|
|
|
|
params.put("end_user_name",endUserName);
|
|
|
|
params.put("topic_id", topicId);
|
|
|
|
String ret = HttpClientUtil.postBody(imAddr,params);
|
|
|
|
JSONObject obj = null;
|
|
|
|
try{
|
|
|
|
obj = new JSONObject(ret);
|
|
|
|
}catch (Exception e){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 议题邀请人员
|
|
|
|
* @param user 结束人名字
|
|
|
|
* @param sessionId 会话ID
|
|
|
|
*/
|
|
|
|
private void updateTopicUser(String sessionId,String user) {
|
|
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/participants/"+user;
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
params.put("user", user+":"+0);
|
|
|
|
HttpClientUtil.putBody(imAddr,params);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送消息给IM
|
|
* 发送消息给IM
|
|
*
|
|
*
|
|
@ -896,38 +976,24 @@ public class ConsultTeamService extends ConsultService {
|
|
public int finish(String consult, String endOperator, int endType) throws Exception {
|
|
public int finish(String consult, String endOperator, int endType) throws Exception {
|
|
|
|
|
|
ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
|
|
ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
|
|
String name = "";
|
|
|
|
String returnJson = "";
|
|
|
|
|
|
String endName = "";
|
|
|
|
String endId = "";
|
|
//推送给IM文字消息
|
|
//推送给IM文字消息
|
|
if (endType == 1) {
|
|
if (endType == 1) {
|
|
Patient p = patientDao.findByCode(endOperator);
|
|
Patient p = patientDao.findByCode(endOperator);
|
|
name = p.getName();
|
|
|
|
returnJson = sendIM(consultTeam.getPatient(), consultTeam.getDoctor(), "7", name + "结束了本次咨询");
|
|
|
|
|
|
endName = p.getName();
|
|
|
|
endId = p.getCode();
|
|
} else {
|
|
} else {
|
|
Doctor d = doctorDao.findByCode(endOperator);
|
|
Doctor d = doctorDao.findByCode(endOperator);
|
|
name = d.getName();
|
|
|
|
returnJson = sendIM(consultTeam.getDoctor(), consultTeam.getPatient(), "7", name + "结束了本次咨询");
|
|
|
|
|
|
endId = d.getCode();
|
|
|
|
endName = d.getName();
|
|
}
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(returnJson)) {
|
|
|
|
throw new Exception("send consult finished IM message failed");
|
|
|
|
} else {
|
|
|
|
JSONObject jo = new JSONObject(returnJson); //设置消息ID
|
|
|
|
consultTeam.setEndMsgId(jo.getInt("startId"));
|
|
|
|
consultTeam.setEndOperator(endOperator);
|
|
|
|
consultTeam.setEndType(endType);
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject group = talkGroupService.findConsultTalkGroup(consultTeam.getConsult());
|
|
|
|
|
|
|
|
if (group != null) {
|
|
|
|
String json = sendGroupIM(endOperator, group.getString("code"), "7", name + "结束了本次咨询");
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(json)) {
|
|
|
|
throw new Exception("send consult finished IM message failed");
|
|
|
|
}
|
|
|
|
|
|
JSONObject obj = endTopics(consultTeam.getPatient(),endId,endName,consultTeam.getConsult());
|
|
|
|
if(obj==null){
|
|
|
|
throw new RuntimeException("IM消息结束异常!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
consultTeam.setType(endType);
|
|
|
|
consultTeam.setEndMsgId(obj.get("id").toString());
|
|
return consultTeamDao.updateStatusByConsult(consult);
|
|
return consultTeamDao.updateStatusByConsult(consult);
|
|
}
|
|
}
|
|
|
|
|
|
@ -1129,6 +1195,7 @@ public class ConsultTeamService extends ConsultService {
|
|
public void addFamousTeamConsult(ConsultTeam ct, String uid, String type) throws Exception {
|
|
public void addFamousTeamConsult(ConsultTeam ct, String uid, String type) throws Exception {
|
|
// 设置患者信息
|
|
// 设置患者信息
|
|
ct.setPatient(uid);
|
|
ct.setPatient(uid);
|
|
|
|
JSONObject messages = new JSONObject();
|
|
if ("1".equals(type)) {
|
|
if ("1".equals(type)) {
|
|
// 查询患者信息
|
|
// 查询患者信息
|
|
Patient tempPatient = patientDao.findByCode(uid);
|
|
Patient tempPatient = patientDao.findByCode(uid);
|
|
@ -1140,6 +1207,11 @@ public class ConsultTeamService extends ConsultService {
|
|
ct.setSex(tempPatient.getSex());
|
|
ct.setSex(tempPatient.getSex());
|
|
// 设置患者头像
|
|
// 设置患者头像
|
|
ct.setPhoto(tempPatient.getPhoto());
|
|
ct.setPhoto(tempPatient.getPhoto());
|
|
|
|
|
|
|
|
messages.put("senderId",tempPatient.getCode());
|
|
|
|
|
|
|
|
messages.put("senderName",tempPatient.getName());
|
|
|
|
|
|
} else if ("2".equals(type)) {
|
|
} else if ("2".equals(type)) {
|
|
Doctor doctorTemp = doctorDao.findByCode(uid);
|
|
Doctor doctorTemp = doctorDao.findByCode(uid);
|
|
// 设置医生姓名
|
|
// 设置医生姓名
|
|
@ -1172,20 +1244,19 @@ public class ConsultTeamService extends ConsultService {
|
|
// 添加医生咨询日志
|
|
// 添加医生咨询日志
|
|
String content = addLogs(ct);
|
|
String content = addLogs(ct);
|
|
//推送给IM文字消息
|
|
//推送给IM文字消息
|
|
String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
|
;
|
|
|
|
JSONObject jo = new JSONObject(returnJson);
|
|
|
|
//设置消息ID
|
|
|
|
ct.setStartMsgId(jo.getInt("startId"));
|
|
|
|
//推送给IM图片
|
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
|
String[] images = ct.getImages().split(",");
|
|
|
|
for (String image : images) {
|
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put(ct.getPatient(),0);
|
|
|
|
jsonObject.put(ct.getDoctor(),0);
|
|
|
|
|
|
|
|
messages.put("description",consult.getSymptoms());
|
|
|
|
messages.put("title",consult.getTitle());
|
|
|
|
messages.put("img",consult.getImages());
|
|
|
|
JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),consult.getSymptoms(),jsonObject,messages);
|
|
|
|
if(obj==null){
|
|
|
|
throw new RuntimeException("im消息创建异常!");
|
|
}
|
|
}
|
|
|
|
//设置消息ID
|
|
|
|
ct.setStartMsgId(obj.get("id").toString());
|
|
consultTeamDao.save(ct); // 保存医生咨询信息
|
|
consultTeamDao.save(ct); // 保存医生咨询信息
|
|
consultTeamDoctorDao.save(cd);
|
|
consultTeamDoctorDao.save(cd);
|
|
consultDao.save(consult);
|
|
consultDao.save(consult);
|
|
@ -1286,36 +1357,31 @@ public class ConsultTeamService extends ConsultService {
|
|
// 添加医生咨询日志
|
|
// 添加医生咨询日志
|
|
String content = addLogs(ct);
|
|
String content = addLogs(ct);
|
|
//推送给IM文字消息
|
|
//推送给IM文字消息
|
|
String returnJson = null;
|
|
|
|
JSONObject jo;
|
|
|
|
if(StringUtils.isNotEmpty(oldConsultCode)){
|
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
|
if(oldConsult!=null){
|
|
|
|
returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
|
|
|
|
//推送给IM图片
|
|
|
|
if (StringUtils.isNotEmpty(oldConsult.getImages())) {
|
|
|
|
String[] images = oldConsult.getImages().split(",");
|
|
|
|
for (String image : images) {
|
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StringUtils.isEmpty(returnJson))
|
|
|
|
returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
|
else
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
|
jo = new JSONObject(returnJson);
|
|
|
|
|
|
JSONObject messages = new JSONObject();
|
|
|
|
messages.put("description",content);
|
|
|
|
messages.put("title",consult.getTitle());
|
|
|
|
messages.put("img",consult.getImages());
|
|
|
|
messages.put("senderId",doctorTemp.getCode());
|
|
|
|
messages.put("senderName",doctorTemp.getName());
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put(ct.getPatient(),0);
|
|
|
|
jsonObject.put(ct.getDoctor(),0);
|
|
//设置消息ID
|
|
//设置消息ID
|
|
ct.setStartMsgId(jo.getInt("startId"));
|
|
|
|
//推送给IM图片
|
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
|
String[] images = ct.getImages().split(",");
|
|
|
|
for (String image : images) {
|
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
|
|
|
|
|
|
JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),"咨询求助:"+doctorTemp.getName(),jsonObject,messages);
|
|
|
|
if(obj==null){
|
|
|
|
throw new RuntimeException("im消息创建异常!");
|
|
|
|
}
|
|
|
|
ct.setStartMsgId(obj.get("id").toString());
|
|
|
|
//转发咨询问题
|
|
|
|
if(StringUtils.isNotBlank(oldConsultCode)){
|
|
|
|
Consult oldConsult = consultDao.findByCode(oldConsultCode);
|
|
|
|
if(oldConsult!=null){
|
|
|
|
sendIM(doctorTemp.getCode(),doctorTemp.getName(),String.valueOf(jsonObject.hashCode()),"6",content);
|
|
|
|
if(StringUtils.isNotBlank(oldConsult.getImages())){
|
|
|
|
String imgs[] = oldConsult.getImages().split(",");
|
|
|
|
for(String url :imgs)
|
|
|
|
sendIM(doctorTemp.getCode(),doctorTemp.getName(),String.valueOf(jsonObject.hashCode()),"2",url);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -1325,38 +1391,12 @@ public class ConsultTeamService extends ConsultService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param ct
|
|
|
|
* @param uid
|
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public void sendForHelpMsg(ConsultTeam ct, String uid, String oldConsultCode) throws Exception {
|
|
|
|
ct.setPatient(uid);
|
|
|
|
|
|
public void sendForHelpMsg(String oldConsultCode,String userId) throws Exception {
|
|
|
|
Consult consult = consultDao.findByCode(oldConsultCode);
|
|
//推送给IM文字消息
|
|
//推送给IM文字消息
|
|
if(StringUtils.isNotEmpty(oldConsultCode)){
|
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
|
if(oldConsult!=null){
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
|
|
|
|
//推送给IM图片
|
|
|
|
if (StringUtils.isNotEmpty(oldConsult.getImages())) {
|
|
|
|
String[] images = oldConsult.getImages().split(",");
|
|
|
|
for (String image : images) {
|
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", "咨询问题:"+ ct.getSymptoms());
|
|
|
|
//推送给IM图片
|
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
|
String[] images = ct.getImages().split(",");
|
|
|
|
for (String image : images) {
|
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
updateTopicUser(consult.getPatient(),userId);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -1393,4 +1433,6 @@ public class ConsultTeamService extends ConsultService {
|
|
public List findByTeam(String consult){
|
|
public List findByTeam(String consult){
|
|
return consultTeamDao.findByTeamAndType(consult, 10);
|
|
return consultTeamDao.findByTeamAndType(consult, 10);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|