|
@ -13,6 +13,7 @@ import com.yihu.wlyy.entity.discussion.WlyyTalkGroup;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticle;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
|
|
@ -54,6 +55,7 @@ import java.util.*;
|
|
|
/**
|
|
|
* 網絡諮詢类.
|
|
|
* test
|
|
|
*
|
|
|
* @author George
|
|
|
*/
|
|
|
// Spring Service Bean的标识.
|
|
@ -686,7 +688,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
} else {
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
|
|
|
if (doctorTeamMember != null) {
|
|
|
if(users.isNull(doctorTeamMember.getMemberCode())){
|
|
|
if (users.isNull(doctorTeamMember.getMemberCode())) {
|
|
|
users.put(doctorTeamMember.getMemberCode(), 1);
|
|
|
}
|
|
|
}
|
|
@ -717,7 +719,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
|
|
|
if (doctorTeamMember != null) {
|
|
|
//全健同一个人导致会话成员状态问题处理
|
|
|
if(users.isNull(doctorTeamMember.getMemberCode())){
|
|
|
if (users.isNull(doctorTeamMember.getMemberCode())) {
|
|
|
users.put(doctorTeamMember.getMemberCode(), 1);
|
|
|
}
|
|
|
}
|
|
@ -755,7 +757,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
// JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), "咨询问题:"+consult.getSymptoms(), consult.getImages());
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages());
|
|
|
users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
|
|
|
JSONObject obj = ImUtill.createTopics(patient +"_"+ct.getTeam()+"_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
|
|
|
JSONObject obj = ImUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
|
|
|
if (obj == null) {
|
|
|
throw new RuntimeException("IM消息发送异常!");
|
|
|
}
|
|
@ -837,14 +839,16 @@ public class ConsultTeamService extends ConsultService {
|
|
|
//先判断从健康指导转咨询是否存在指导。
|
|
|
JSONObject json = guidanceService.findById(ct.getGuidance());
|
|
|
|
|
|
|
|
|
if (json == null) {
|
|
|
//再判断从健康教育文章转咨询是否存在文章 20170602
|
|
|
Object article = healthEduArticleService.findArticleById(ct.getGuidance());
|
|
|
if(article == null) {
|
|
|
throw new Exception("guidance not exist");
|
|
|
HealthEduArticle article = healthEduArticleService.findArticleById(ct.getGuidance());
|
|
|
if (article != null) {
|
|
|
String result = verdictAddLogs(ct);
|
|
|
return result;
|
|
|
}
|
|
|
}else{
|
|
|
throw new Exception("guidance not exist");
|
|
|
} else {
|
|
|
// 健康指导转咨询的指导内容
|
|
|
content += "医生" + (json.get("doctorName") != null ? json.get("doctorName").toString() : "")
|
|
|
+ "发出的指导:" + (json.getString("content") != null ? json.getString("content").toString() : "") + "<br/>";
|
|
|
}
|
|
@ -909,6 +913,94 @@ public class ConsultTeamService extends ConsultService {
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加三师咨询日志(增加咨询来源是否存在判断)
|
|
|
*
|
|
|
* @param ct
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private String verdictAddLogs(ConsultTeam ct) throws Exception {
|
|
|
List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
|
|
|
// 添加问题咨询日志
|
|
|
String content = "";
|
|
|
|
|
|
if (ct.getGuidance() != null && ct.getGuidance() > 0) {
|
|
|
//再判断从健康教育文章转咨询是否存在文章 20170602
|
|
|
HealthEduArticle article = healthEduArticleService.findArticleById(ct.getGuidance());
|
|
|
if (article == null) {
|
|
|
throw new Exception("guidance not exist");
|
|
|
} else {
|
|
|
// 健康指导转咨询的指导内容
|
|
|
JSONObject jsonArticle = new JSONObject();
|
|
|
|
|
|
jsonArticle.put("doctorName", ct.getDoctorName()!=null?ct.getDoctorName():"");
|
|
|
jsonArticle.put("content", article.getSummary());
|
|
|
jsonArticle.put("czrq", article.getCzrq() != null ? DateUtil.dateToStr(article.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM) : "");
|
|
|
|
|
|
content += "医生" + (jsonArticle.get("doctorName") != null ? jsonArticle.get("doctorName").toString() : "")
|
|
|
+ "发出的文章:" + (jsonArticle.getString("content") != null ? jsonArticle.getString("content").toString() : "") + "<br/>";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
content += "咨询问题:" + (StringUtils.isEmpty(ct.getSymptoms()) ? "无" : ct.getSymptoms());
|
|
|
|
|
|
// 生成提问日志,并推送相关消息
|
|
|
ConsultTeamLog infoLog = new ConsultTeamLog();
|
|
|
infoLog.setConsult(ct.getConsult());
|
|
|
infoLog.setContent(content);
|
|
|
infoLog.setDel("1");
|
|
|
infoLog.setType(0);
|
|
|
infoLog.setChatType(1);
|
|
|
infoLog.setCzrq(new Date());
|
|
|
logs.add(infoLog);
|
|
|
// 图片日志
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
String[] images = ct.getImages().split(",");
|
|
|
for (String image : images) {
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
ConsultTeamLog imgLog = new ConsultTeamLog();
|
|
|
// 设置咨询标识
|
|
|
imgLog.setConsult(ct.getConsult());
|
|
|
// 设置图片URL
|
|
|
imgLog.setContent(image);
|
|
|
imgLog.setDel("1");
|
|
|
infoLog.setType(0);
|
|
|
imgLog.setCzrq(new Date());
|
|
|
// 图片类型
|
|
|
imgLog.setChatType(2);
|
|
|
// 添加到待保存队列
|
|
|
logs.add(imgLog);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 语音日志
|
|
|
if (StringUtils.isNotEmpty(ct.getVoice())) {
|
|
|
ConsultTeamLog voiceLog = new ConsultTeamLog();
|
|
|
// 设置咨询标识
|
|
|
voiceLog.setConsult(ct.getConsult());
|
|
|
// 设置语音URL
|
|
|
voiceLog.setContent(ct.getVoice());
|
|
|
voiceLog.setDel("1");
|
|
|
infoLog.setType(0);
|
|
|
// 语音类型
|
|
|
voiceLog.setChatType(3);
|
|
|
voiceLog.setCzrq(new Date());
|
|
|
// 添加到待保存队列
|
|
|
logs.add(voiceLog);
|
|
|
}
|
|
|
if (!logs.isEmpty()) {
|
|
|
Iterable<ConsultTeamLog> iterable = consultTeamLogDao.save(logs);
|
|
|
if (iterable == null || iterable.iterator() == null || !iterable.iterator().hasNext()) {
|
|
|
// 日志保存失败
|
|
|
throw new Exception("consult team log save failed!");
|
|
|
}
|
|
|
}
|
|
|
// 患者提问或追问,给医生发消息
|
|
|
// sendMessage(ct.getDoctor(), ct.getPatient(), "三师咨询", "您有新的三师咨询消息", ct.getConsult(), 116, 1, 0, 0);
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询咨询列表
|
|
|
*
|
|
@ -1584,7 +1676,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
ConsultTeam consultTeam = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
ct.setTeam(oldConsultCode);
|
|
|
if (oldConsult != null && isSend == 1) {
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), "居民问题:"+oldConsult.getSymptoms(), oldConsult.getImages());
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), "居民问题:" + oldConsult.getSymptoms(), oldConsult.getImages());
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put(ct.getPatient(), 0);
|
|
|
jsonObject.put(ct.getDoctor(), 0);
|
|
@ -1600,7 +1692,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
for (String url : imgs)
|
|
|
ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "2", url);
|
|
|
}
|
|
|
}else if(oldConsult != null && isSend == 0){
|
|
|
} else if (oldConsult != null && isSend == 0) {
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, oldConsult.getImages());
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put(ct.getPatient(), 0);
|
|
@ -1641,12 +1733,12 @@ public class ConsultTeamService extends ConsultService {
|
|
|
String openId = p.getOpenid();
|
|
|
JSONObject json = new JSONObject();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
json.put("keyword1","满意度评价");
|
|
|
json.put("keyword2",sdf.format(new Date()));
|
|
|
json.put("keyword1", "满意度评价");
|
|
|
json.put("keyword2", sdf.format(new Date()));
|
|
|
json.put("toUser", p.getCode());
|
|
|
json.put("remark", "");
|
|
|
json.put("consult",consult);
|
|
|
json.put("first", endName +",您好!您有1条咨询已结束,请及时对咨询医生进行满意度评价。");
|
|
|
json.put("consult", consult);
|
|
|
json.put("first", endName + ",您好!您有1条咨询已结束,请及时对咨询医生进行满意度评价。");
|
|
|
PushMsgTask.getInstance().putWxMsg(accessTokenUtils.getAccessToken(), 17, openId, p.getName(), json);
|
|
|
} else {
|
|
|
if (endOperator.equals("admin")) {
|
|
@ -1657,18 +1749,18 @@ public class ConsultTeamService extends ConsultService {
|
|
|
endId = d.getCode();
|
|
|
endName = d.getName();
|
|
|
}
|
|
|
if(consultTeam.getType()==2){
|
|
|
if (consultTeam.getType() == 2) {
|
|
|
Patient p = patientDao.findByCode(consultTeam.getPatient());
|
|
|
String name = p.getName();
|
|
|
String openId = p.getOpenid();
|
|
|
JSONObject json = new JSONObject();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
json.put("keyword1","满意度评价");
|
|
|
json.put("keyword2",sdf.format(new Date()));
|
|
|
json.put("keyword1", "满意度评价");
|
|
|
json.put("keyword2", sdf.format(new Date()));
|
|
|
json.put("toUser", p.getCode());
|
|
|
json.put("remark", "");
|
|
|
json.put("consult",consult);
|
|
|
json.put("first", name +",您好!您有1条咨询已结束,请及时对咨询医生进行满意度评价。");
|
|
|
json.put("consult", consult);
|
|
|
json.put("first", name + ",您好!您有1条咨询已结束,请及时对咨询医生进行满意度评价。");
|
|
|
PushMsgTask.getInstance().putWxMsg(accessTokenUtils.getAccessToken(), 17, openId, p.getName(), json);
|
|
|
}
|
|
|
}
|
|
@ -1774,13 +1866,13 @@ public class ConsultTeamService extends ConsultService {
|
|
|
consultTeamDao.save(ct); // 保存医生咨询信息
|
|
|
consultTeamDoctorDao.save(cd);
|
|
|
consultDao.save(consult);
|
|
|
if(array==null||array.length()==0){
|
|
|
if (array == null || array.length() == 0) {
|
|
|
//由于IM是异步操作,会话生成后,可能还未生成到数据库导致无法
|
|
|
//获取会话ID。休眠1秒后继续获取相应信息
|
|
|
// PS:可以通过前端请求两次去解决,由于离职,就不挖坑了,后来者可以改善、
|
|
|
Thread.sleep(1000);
|
|
|
object = ImUtill.getTopic(ct.getConsult());
|
|
|
array = new JSONArray(object.get("data").toString());
|
|
|
Thread.sleep(1000);
|
|
|
object = ImUtill.getTopic(ct.getConsult());
|
|
|
array = new JSONArray(object.get("data").toString());
|
|
|
}
|
|
|
return array.getJSONObject(0);
|
|
|
}
|