|
@ -34,6 +34,7 @@ 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.NameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
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;
|
|
@ -142,7 +143,7 @@ public class ConsultTeamService extends ConsultService {
|
|
* @param pagesize 每页显示数,默认为10
|
|
* @param pagesize 每页显示数,默认为10
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Page<ConsultTeam> findByDoctor(String uid, int type, long id, int pagesize, String title) {
|
|
|
|
|
|
public Page<ConsultTeam> findByDoctor(String uid, int type, long id, int pagesize, String patient, String title) {
|
|
if (id < 0) {
|
|
if (id < 0) {
|
|
id = 0;
|
|
id = 0;
|
|
}
|
|
}
|
|
@ -152,7 +153,7 @@ public class ConsultTeamService extends ConsultService {
|
|
switch (type) {
|
|
switch (type) {
|
|
case 0:
|
|
case 0:
|
|
// 全部
|
|
// 全部
|
|
return findByDoctorType0(uid, id, pagesize);
|
|
|
|
|
|
return findByDoctorType0(uid, id, patient, pagesize);
|
|
case 1:
|
|
case 1:
|
|
// 咨询我的
|
|
// 咨询我的
|
|
return findByDoctorType1(uid, type, id, pagesize);
|
|
return findByDoctorType1(uid, type, id, pagesize);
|
|
@ -390,15 +391,23 @@ public class ConsultTeamService extends ConsultService {
|
|
* @param pagesize
|
|
* @param pagesize
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Page<ConsultTeam> findByDoctorType0(String uid, long id, int pagesize) {
|
|
|
|
|
|
public Page<ConsultTeam> findByDoctorType0(String uid, long id, String patient, int pagesize) {
|
|
// 排序
|
|
// 排序
|
|
Sort sort = new Sort(Direction.DESC, "id");
|
|
Sort sort = new Sort(Direction.DESC, "id");
|
|
// 分页信息
|
|
// 分页信息
|
|
PageRequest pageRequest = new PageRequest(0, pagesize, sort);
|
|
PageRequest pageRequest = new PageRequest(0, pagesize, sort);
|
|
if (id > 0) {
|
|
|
|
return consultTeamDao.findDoctorList(uid, id, pageRequest);
|
|
|
|
|
|
if (StringUtils.isEmpty(patient)) {
|
|
|
|
if (id > 0) {
|
|
|
|
return consultTeamDao.findDoctorList(uid, id, pageRequest);
|
|
|
|
} else {
|
|
|
|
return consultTeamDao.findDoctorList(uid, pageRequest);
|
|
|
|
}
|
|
} else {
|
|
} else {
|
|
return consultTeamDao.findDoctorList(uid, pageRequest);
|
|
|
|
|
|
if (id > 0) {
|
|
|
|
return consultTeamDao.findDoctorPatientList(uid, patient, id, pageRequest);
|
|
|
|
} else {
|
|
|
|
return consultTeamDao.findDoctorPatientList(uid, patient, pageRequest);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@ -543,17 +552,17 @@ public class ConsultTeamService extends ConsultService {
|
|
* @param logs
|
|
* @param logs
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
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);
|
|
|
|
|
|
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) {
|
|
for (ConsultTeamLog log : logs) {
|
|
reply(log, patient, null, log.getType());
|
|
reply(log, patient, null, log.getType());
|
|
//判断当前咨询是否创建讨论租
|
|
//判断当前咨询是否创建讨论租
|
|
if(wlyyTalkGroup!=null){
|
|
|
|
sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType()+"", log.getContent());
|
|
|
|
}else{
|
|
|
|
|
|
if (wlyyTalkGroup != null) {
|
|
|
|
sendGroupIM(patient, wlyyTalkGroup.getCode(), log.getChatType() + "", log.getContent());
|
|
|
|
} else {
|
|
//推送给IM
|
|
//推送给IM
|
|
sendIM(patient, consultTeam.getDoctor(), log.getChatType()+"", log.getContent());
|
|
|
|
|
|
sendIM(patient, consultTeam.getDoctor(), log.getChatType() + "", log.getContent());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -689,9 +698,9 @@ 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);
|
|
|
|
if(jo.has("startId")){
|
|
|
|
|
|
String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
|
JSONObject jo = new JSONObject(returnJson);
|
|
|
|
if (jo.has("startId")) {
|
|
//设置消息ID
|
|
//设置消息ID
|
|
ct.setStartMsgId(jo.getInt("startId"));
|
|
ct.setStartMsgId(jo.getInt("startId"));
|
|
//推送给IM图片
|
|
//推送给IM图片
|
|
@ -713,10 +722,11 @@ public class ConsultTeamService extends ConsultService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送消息给IM
|
|
* 发送消息给IM
|
|
* @param from 来自
|
|
|
|
|
|
*
|
|
|
|
* @param from 来自
|
|
* @param to
|
|
* @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) {
|
|
private String sendIM(String from, String to, String contentType, String content) {
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/pm";
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/pm";
|
|
@ -728,24 +738,27 @@ public class ConsultTeamService extends ConsultService {
|
|
String response = HttpClientUtil.post(imAddr, params, "UTF-8");
|
|
String response = HttpClientUtil.post(imAddr, params, "UTF-8");
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送消息给IM
|
|
* 发送消息给IM
|
|
* @param from 来自
|
|
|
|
|
|
*
|
|
|
|
* @param from 来自
|
|
* @param groupCode
|
|
* @param groupCode
|
|
* @param contentType 1文字 2图片消息
|
|
* @param contentType 1文字 2图片消息
|
|
* @param content 内容
|
|
|
|
|
|
* @param content 内容
|
|
*/
|
|
*/
|
|
private String sendGroupIM(String from, String groupCode, String contentType, String content) {
|
|
private String sendGroupIM(String from, String groupCode, String contentType, String content) {
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/gm";
|
|
String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/gm";
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
params.add(new BasicNameValuePair("from", from));
|
|
params.add(new BasicNameValuePair("from", from));
|
|
params.add(new BasicNameValuePair("group", groupCode));
|
|
params.add(new BasicNameValuePair("group", groupCode));
|
|
params.add(new BasicNameValuePair("groupType","1"));
|
|
|
|
|
|
params.add(new BasicNameValuePair("groupType", "1"));
|
|
params.add(new BasicNameValuePair("contentType", contentType));
|
|
params.add(new BasicNameValuePair("contentType", contentType));
|
|
params.add(new BasicNameValuePair("content", content));
|
|
params.add(new BasicNameValuePair("content", content));
|
|
String response = HttpClientUtil.post(imAddr, params, "UTF-8");
|
|
String response = HttpClientUtil.post(imAddr, params, "UTF-8");
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 添加三师咨询日志
|
|
* 添加三师咨询日志
|
|
*
|
|
*
|
|
@ -882,10 +895,11 @@ public class ConsultTeamService extends ConsultService {
|
|
*/
|
|
*/
|
|
public int finish(String consult) {
|
|
public int finish(String consult) {
|
|
|
|
|
|
ConsultTeam consultTeam=consultTeamDao.findByConsult(consult);
|
|
|
|
|
|
ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
|
|
//推送给IM文字消息
|
|
//推送给IM文字消息
|
|
String returnJson= sendIM(consultTeam.getPatient(), consultTeam.getDoctor(), "7", "本次咨询结束");;
|
|
|
|
JSONObject jo=new JSONObject(returnJson);
|
|
|
|
|
|
String returnJson = sendIM(consultTeam.getPatient(), consultTeam.getDoctor(), "7", "本次咨询结束");
|
|
|
|
;
|
|
|
|
JSONObject jo = new JSONObject(returnJson);
|
|
//设置消息ID
|
|
//设置消息ID
|
|
consultTeam.setEndMsgId(jo.getInt("startId"));
|
|
consultTeam.setEndMsgId(jo.getInt("startId"));
|
|
return consultTeamDao.updateStatusByConsult(consult);
|
|
return consultTeamDao.updateStatusByConsult(consult);
|
|
@ -899,7 +913,7 @@ public class ConsultTeamService extends ConsultService {
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
public int readMessage(String consult) {
|
|
public int readMessage(String consult) {
|
|
ConsultTeam consultTeam=consultTeamDao.findByConsult(consult);
|
|
|
|
|
|
ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
|
|
consultTeam.setDoctorRead(0);
|
|
consultTeam.setDoctorRead(0);
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
@ -1130,10 +1144,11 @@ public class ConsultTeamService extends ConsultService {
|
|
cd.setCzrq(new Date());
|
|
cd.setCzrq(new Date());
|
|
cd.setTo(ct.getDoctor());
|
|
cd.setTo(ct.getDoctor());
|
|
// 添加医生咨询日志
|
|
// 添加医生咨询日志
|
|
String content=addLogs(ct);
|
|
|
|
|
|
String content = addLogs(ct);
|
|
//推送给IM文字消息
|
|
//推送给IM文字消息
|
|
String returnJson= sendIM(ct.getPatient(), ct.getDoctor(), "6", content);;
|
|
|
|
JSONObject jo=new JSONObject(returnJson);
|
|
|
|
|
|
String returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
|
;
|
|
|
|
JSONObject jo = new JSONObject(returnJson);
|
|
//设置消息ID
|
|
//设置消息ID
|
|
ct.setStartMsgId(jo.getInt("startId"));
|
|
ct.setStartMsgId(jo.getInt("startId"));
|
|
//推送给IM图片
|
|
//推送给IM图片
|