|
@ -1,6 +1,6 @@
|
|
/*******************************************************************************
|
|
/*******************************************************************************
|
|
* Copyright (c) 2005, 2014 springside.github.io
|
|
* Copyright (c) 2005, 2014 springside.github.io
|
|
*
|
|
|
|
|
|
* <p>
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
*******************************************************************************/
|
|
*******************************************************************************/
|
|
package com.yihu.wlyy.service.app.consult;
|
|
package com.yihu.wlyy.service.app.consult;
|
|
@ -24,8 +24,12 @@ import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
|
|
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
|
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.http.NameValuePair;
|
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
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.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
@ -89,7 +93,7 @@ public class ConsultTeamService extends ConsultService {
|
|
if (type == 1) {
|
|
if (type == 1) {
|
|
// 查询三师签约信息
|
|
// 查询三师签约信息
|
|
SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
|
|
SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
|
|
if(sc == null){
|
|
|
|
|
|
if (sc == null) {
|
|
throw new Exception("不存在三师签约");
|
|
throw new Exception("不存在三师签约");
|
|
}
|
|
}
|
|
// 设置健康管理师,三师咨询默认给健康管理师处理
|
|
// 设置健康管理师,三师咨询默认给健康管理师处理
|
|
@ -104,7 +108,7 @@ public class ConsultTeamService extends ConsultService {
|
|
} else if (type == 2) {
|
|
} else if (type == 2) {
|
|
// 咨询家庭医生
|
|
// 咨询家庭医生
|
|
SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
|
|
SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
|
|
if(sf == null){
|
|
|
|
|
|
if (sf == null) {
|
|
throw new Exception("不存在家庭签约");
|
|
throw new Exception("不存在家庭签约");
|
|
}
|
|
}
|
|
// 设置健康管理师,家庭医生咨询默认给健康管理师处理
|
|
// 设置健康管理师,家庭医生咨询默认给健康管理师处理
|
|
@ -117,7 +121,7 @@ public class ConsultTeamService extends ConsultService {
|
|
member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
|
|
member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(member == null){
|
|
|
|
|
|
if (member == null) {
|
|
throw new Exception("找不到签约服务团队医生");
|
|
throw new Exception("找不到签约服务团队医生");
|
|
}
|
|
}
|
|
int count = consultTeamDao.countByPatient(patient, member.getMemberCode());
|
|
int count = consultTeamDao.countByPatient(patient, member.getMemberCode());
|
|
@ -536,6 +540,8 @@ public class ConsultTeamService extends ConsultService {
|
|
public void reply(List<ConsultTeamLog> logs, String patient) {
|
|
public void reply(List<ConsultTeamLog> logs, String patient) {
|
|
for (ConsultTeamLog log : logs) {
|
|
for (ConsultTeamLog log : logs) {
|
|
reply(log, patient, null, log.getType());
|
|
reply(log, patient, null, log.getType());
|
|
|
|
//推送给IM
|
|
|
|
sendIM(patient, log.getDoctor(), log.getChatType()+"", log.getContent());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@ -585,6 +591,7 @@ public class ConsultTeamService extends ConsultService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
* 患者端
|
|
* 添加三师咨询
|
|
* 添加三师咨询
|
|
*
|
|
*
|
|
* @param ct 三师咨询对象
|
|
* @param ct 三师咨询对象
|
|
@ -672,17 +679,46 @@ public class ConsultTeamService extends ConsultService {
|
|
consultDao.save(consult);
|
|
consultDao.save(consult);
|
|
consultTeamDoctorDao.save(cd);
|
|
consultTeamDoctorDao.save(cd);
|
|
// 添加医生咨询日志
|
|
// 添加医生咨询日志
|
|
addLogs(ct);
|
|
|
|
|
|
String content = addLogs(ct);
|
|
|
|
|
|
|
|
//推送给IM文字消息
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "1", content);
|
|
|
|
//推送给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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 发送消息给IM
|
|
|
|
* @param from 来自
|
|
|
|
* @param to
|
|
|
|
* @param contentType 1文字 2图片消息
|
|
|
|
* @param content 内容
|
|
|
|
*/
|
|
|
|
private void 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");
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 添加三师咨询日志
|
|
* 添加三师咨询日志
|
|
*
|
|
*
|
|
* @param ct
|
|
* @param ct
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
private void addLogs(ConsultTeam ct) throws Exception {
|
|
|
|
|
|
private String addLogs(ConsultTeam ct) throws Exception {
|
|
List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
|
|
List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
|
|
// 添加问题咨询日志
|
|
// 添加问题咨询日志
|
|
String content = "";
|
|
String content = "";
|
|
@ -751,6 +787,7 @@ public class ConsultTeamService extends ConsultService {
|
|
}
|
|
}
|
|
// 患者提问或追问,给医生发消息
|
|
// 患者提问或追问,给医生发消息
|
|
// sendMessage(ct.getDoctor(), ct.getPatient(), "三师咨询", "您有新的三师咨询消息", ct.getConsult(), 116, 1, 0, 0);
|
|
// sendMessage(ct.getDoctor(), ct.getPatient(), "三师咨询", "您有新的三师咨询消息", ct.getConsult(), 116, 1, 0, 0);
|
|
|
|
return content;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -1054,7 +1091,18 @@ public class ConsultTeamService extends ConsultService {
|
|
cd.setTo(ct.getDoctor());
|
|
cd.setTo(ct.getDoctor());
|
|
consultTeamDoctorDao.save(cd);
|
|
consultTeamDoctorDao.save(cd);
|
|
// 添加医生咨询日志
|
|
// 添加医生咨询日志
|
|
addLogs(ct);
|
|
|
|
|
|
String content=addLogs(ct);
|
|
|
|
//推送给IM文字消息
|
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "1", content);
|
|
|
|
//推送给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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|