|
@ -2,11 +2,14 @@ package com.yihu.wlyy.web.patient.consult;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.yihu.wlyy.entity.consult.Consult;
|
|
|
import com.yihu.wlyy.entity.consult.ConsultTeam;
|
|
|
import com.yihu.wlyy.entity.consult.ConsultTeamLog;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
|
|
|
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
|
|
|
import com.yihu.wlyy.util.*;
|
|
|
import io.swagger.annotations.Api;
|
|
@ -55,6 +58,8 @@ public class ConsultController extends WeixinBaseController {
|
|
|
private TalkGroupService talkGroupService;
|
|
|
@Autowired
|
|
|
private DoctorWorkTimeService doctorWorkTimeService;
|
|
|
@Autowired
|
|
|
PatientDao patientDao;
|
|
|
|
|
|
/**
|
|
|
* 患者咨询记录查询
|
|
@ -570,6 +575,58 @@ public class ConsultController extends WeixinBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// /**
|
|
|
// * 三师咨询追问接口
|
|
|
// *
|
|
|
// * @param consult 咨询标识
|
|
|
// * @param content 追问内容
|
|
|
// * @param type 追问内容类型:1文字,2图片,3语音
|
|
|
// * @return
|
|
|
// */
|
|
|
// @RequestMapping(value = "append")
|
|
|
// @ResponseBody
|
|
|
// public String append(String consult, String content, int type) {
|
|
|
// try {
|
|
|
// List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
|
|
|
// if (type == 2) {
|
|
|
// // 图片消息
|
|
|
// if (StringUtils.isEmpty(content)) {
|
|
|
// content = fetchWxImages();
|
|
|
// }
|
|
|
// // 将临时图片拷贝到正式存储路径下
|
|
|
// if (StringUtils.isNotEmpty(content)) {
|
|
|
// content = CommonUtil.copyTempImage(content);
|
|
|
// }
|
|
|
// if (StringUtils.isEmpty(content)) {
|
|
|
// return error(-1, "图片上传失败!");
|
|
|
// }
|
|
|
// String[] images = content.split(",");
|
|
|
// for (String image : images) {
|
|
|
// ConsultTeamLog log = new ConsultTeamLog();
|
|
|
// log.setConsult(consult);
|
|
|
// log.setContent(image);
|
|
|
// log.setDel("1");
|
|
|
// log.setChatType(type);
|
|
|
// log.setType(2);
|
|
|
// logs.add(log);
|
|
|
// }
|
|
|
// } else {
|
|
|
// ConsultTeamLog log = new ConsultTeamLog();
|
|
|
// log.setConsult(consult);
|
|
|
// log.setContent(content);
|
|
|
// log.setDel("1");
|
|
|
// log.setChatType(type);
|
|
|
// log.setType(1);
|
|
|
// logs.add(log);
|
|
|
// }
|
|
|
// consultTeamService.reply(logs, getUID());
|
|
|
// return write(200, "追问成功!", "data", content);
|
|
|
// } catch (Exception e) {
|
|
|
// error(e);
|
|
|
// return invalidUserException(e, -1, "追问失败!");
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 三师咨询追问接口
|
|
|
*
|
|
@ -580,14 +637,35 @@ public class ConsultController extends WeixinBaseController {
|
|
|
*/
|
|
|
@RequestMapping(value = "append")
|
|
|
@ResponseBody
|
|
|
public String append(String consult, String content, int type) {
|
|
|
public String append(@RequestParam String consult, @RequestParam String content, @RequestParam int type) {
|
|
|
try {
|
|
|
List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
|
|
|
ConsultTeam consultModel = consultTeamService.findByCode(consult);
|
|
|
|
|
|
if (consultModel == null) {
|
|
|
return error(-1, "咨询记录不存在!");
|
|
|
}
|
|
|
|
|
|
if(consultModel.getEndMsgId() != null){
|
|
|
return error(-1,"咨询已结束");
|
|
|
}
|
|
|
|
|
|
String[] arr = null;
|
|
|
|
|
|
if (type == 2) {
|
|
|
// 图片消息
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
String images = request.getParameter("mediaIds");
|
|
|
|
|
|
if (!StringUtils.isEmpty(images)) {
|
|
|
arr = images.split(",");
|
|
|
}
|
|
|
|
|
|
content = fetchWxImages();
|
|
|
} else {
|
|
|
arr = content.split(",");
|
|
|
}
|
|
|
|
|
|
// 将临时图片拷贝到正式存储路径下
|
|
|
if (StringUtils.isNotEmpty(content)) {
|
|
|
content = CommonUtil.copyTempImage(content);
|
|
@ -613,15 +691,87 @@ public class ConsultController extends WeixinBaseController {
|
|
|
log.setChatType(type);
|
|
|
log.setType(1);
|
|
|
logs.add(log);
|
|
|
|
|
|
arr = new String[]{content};
|
|
|
}
|
|
|
|
|
|
int i = 0;
|
|
|
List<String> failed = new ArrayList<>();
|
|
|
|
|
|
for (ConsultTeamLog log : logs) {
|
|
|
String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
|
|
|
+ "api/v1/chats/pm";
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("from", getUID()));
|
|
|
params.add(new BasicNameValuePair("to", consultModel.getDoctor()));
|
|
|
params.add(new BasicNameValuePair("content", log.getContent()));
|
|
|
params.add(new BasicNameValuePair("contentType", String.valueOf(log.getType())));
|
|
|
|
|
|
String response = HttpClientUtil.post(url, params, "UTF-8");
|
|
|
|
|
|
if (StringUtils.isEmpty(response)) {
|
|
|
failed.add(arr[i]);
|
|
|
}
|
|
|
}
|
|
|
consultTeamService.reply(logs, getUID());
|
|
|
return write(200, "追问成功!", "data", content);
|
|
|
|
|
|
return write(200, "追问成功!", "data", failed);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return invalidUserException(e, -1, "追问失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// /**
|
|
|
// * 网络咨询咨询日志查询
|
|
|
// *
|
|
|
// * @param consult 咨询标识
|
|
|
// * @param pagesize 每页显示数,默认为10
|
|
|
// * @return
|
|
|
// */
|
|
|
// @RequestMapping(value = "loglist")
|
|
|
// @ResponseBody
|
|
|
// public String loglist(String consult, long id, int pagesize) {
|
|
|
// try {
|
|
|
// ConsultTeam consultModel = consultTeamService.findByCode(consult);
|
|
|
// Consult cons =consultTeamService.findConsultByCode(consult);
|
|
|
// if (consultModel == null) {
|
|
|
// return error(-1, "咨询记录不存在!");
|
|
|
// }
|
|
|
// if (id <= 0) {
|
|
|
// // 更新患者未读数量为0
|
|
|
// consultTeamService.clearPatientRead(consult);
|
|
|
// }
|
|
|
// // 查询日志列表
|
|
|
// JSONArray jsonArray = new JSONArray();
|
|
|
// Page<ConsultTeamLog> list = consultTeamService.findLogByConsult(consult, id, pagesize);
|
|
|
// if (list != null) {
|
|
|
// for (ConsultTeamLog log : list) {
|
|
|
// if (consult == null) {
|
|
|
// continue;
|
|
|
// }
|
|
|
// JSONObject json = new JSONObject();
|
|
|
// json.put("id", log.getId());
|
|
|
// // 设置回复医生姓名
|
|
|
// json.put("doctorName", log.getDoctorName());
|
|
|
// // 设置回复内容
|
|
|
// json.put("content", log.getContent());
|
|
|
// // 设置咨询或回复时间
|
|
|
// json.put("time", DateUtil.dateToStr(log.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
// // 设置记录类型:1文字,2图片,3语音
|
|
|
// json.put("msgType", log.getChatType());
|
|
|
// // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
|
|
|
// json.put("type", log.getType());
|
|
|
// jsonArray.put(json);
|
|
|
// }
|
|
|
// }
|
|
|
// // 返回结果
|
|
|
// return write(200, "查询成功", "list", jsonArray);
|
|
|
// } catch (Exception e) {
|
|
|
// error(e);
|
|
|
// return invalidUserException(e, -1, "查询失败!");
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 网络咨询咨询日志查询
|
|
|
*
|
|
@ -631,39 +781,63 @@ public class ConsultController extends WeixinBaseController {
|
|
|
*/
|
|
|
@RequestMapping(value = "loglist")
|
|
|
@ResponseBody
|
|
|
public String loglist(String consult, long id, int pagesize) {
|
|
|
public String loglist(@RequestParam String consult, @RequestParam long id, @RequestParam int pagesize) {
|
|
|
try {
|
|
|
ConsultTeam consultModel = consultTeamService.findByCode(consult);
|
|
|
|
|
|
if (consultModel == null) {
|
|
|
return error(-1, "咨询记录不存在!");
|
|
|
}
|
|
|
if (id <= 0) {
|
|
|
// 更新患者未读数量为0
|
|
|
consultTeamService.clearPatientRead(consult);
|
|
|
}
|
|
|
// 查询日志列表
|
|
|
|
|
|
JSONObject result = null;
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
Page<ConsultTeamLog> list = consultTeamService.findLogByConsult(consult, id, pagesize);
|
|
|
if (list != null) {
|
|
|
for (ConsultTeamLog log : list) {
|
|
|
if (consult == null) {
|
|
|
String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
|
|
|
+ "api/v1/chats/pm";
|
|
|
String re = HttpUtil.sendGet(url, "closed_interval=true&user_id=" + getUID() + "&peer_id=" + consultModel.getDoctor()
|
|
|
+ "&message_end_id=" + consultModel.getStartMsgId() + (consultModel.getEndMsgId() != null ? ("&message_start_id=" + consultModel.getEndMsgId()) : ""));
|
|
|
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(re)) {
|
|
|
result = new JSONObject(re);
|
|
|
}
|
|
|
|
|
|
if (result != null && result.getInt("count") > 0) {
|
|
|
JSONArray list = result.getJSONArray("records");
|
|
|
|
|
|
for (int i = list.length() - 1; i >= 0; i--) {
|
|
|
JSONObject obj = list.getJSONObject(i);
|
|
|
|
|
|
if (obj.getInt("contentType") == 5) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", log.getId());
|
|
|
// 设置回复医生姓名
|
|
|
json.put("doctorName", log.getDoctorName());
|
|
|
json.put("id", obj.getInt("id"));
|
|
|
if (!obj.getString("from").equals(getUID())) {
|
|
|
Doctor doc = doctorService.findDoctorByCode(obj.getString("from"));
|
|
|
// 设置回复医生姓名
|
|
|
json.put("doctorName", doc.getName());
|
|
|
} else {
|
|
|
Patient p = patientDao.findByCode(obj.getString("from"));
|
|
|
// 设置回复医生姓名
|
|
|
json.put("doctorName", p.getName());
|
|
|
}
|
|
|
|
|
|
// 设置回复内容
|
|
|
json.put("content", log.getContent());
|
|
|
json.put("content", obj.getString("content"));
|
|
|
// 设置咨询或回复时间
|
|
|
json.put("time", DateUtil.dateToStr(log.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
json.put("time", DateUtil.dateToStr(new Date(obj.getLong("timestamp")), DateUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
// 设置记录类型:1文字,2图片,3语音
|
|
|
json.put("msgType", log.getChatType());
|
|
|
json.put("msgType", obj.getInt("contentType") == 2 ? 2 : 1);
|
|
|
// 设置类型:0患者问,1医生回复,2患者追问,3患者评价
|
|
|
json.put("type", log.getType());
|
|
|
if (!obj.getString("from").equals(getUID())) {
|
|
|
json.put("type", 1);
|
|
|
} else {
|
|
|
json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
|
|
|
}
|
|
|
jsonArray.put(json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回结果
|
|
|
return write(200, "查询成功", "list", jsonArray);
|
|
|
} catch (Exception e) {
|