|
@ -1,29 +1,28 @@
|
|
|
package com.yihu.wlyy.web.patient.consult;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.thoughtworks.xstream.mapper.Mapper;
|
|
|
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.discussion.WlyyTalkGroup;
|
|
|
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.logs.BusinessLogs;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
|
|
|
import com.yihu.wlyy.service.app.consult.DoctorCommentService;
|
|
|
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
|
|
|
import com.yihu.wlyy.service.app.statistics.DoctorStatisticsService;
|
|
|
import com.yihu.wlyy.service.app.talk.TalkGroupService;
|
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
|
import com.yihu.wlyy.task.DoctorStatisticsTask;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.*;
|
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.redis.listener.Topic;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@ -31,14 +30,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
|
|
|
import com.yihu.wlyy.service.app.consult.DoctorCommentService;
|
|
|
import com.yihu.wlyy.service.app.statistics.DoctorStatisticsService;
|
|
|
import com.yihu.wlyy.service.app.talk.TalkGroupService;
|
|
|
import com.yihu.wlyy.service.common.account.DoctorService;
|
|
|
import com.yihu.wlyy.task.DoctorStatisticsTask;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 患者端:三师咨询控制类
|
|
@ -81,7 +75,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
int pagesize) {
|
|
|
try {
|
|
|
JSONArray array = new JSONArray();
|
|
|
Page<Object> data = consultTeamService.findConsultRecordByPatient(getUID(), id, pagesize, title);
|
|
|
Page<Object> data = consultTeamService.findConsultRecordByPatient(getRepUID(), id, pagesize, title);
|
|
|
if (data != null) {
|
|
|
for (Object consult : data.getContent()) {
|
|
|
if (consult == null) {
|
|
@ -221,7 +215,8 @@ public class ConsultController extends WeixinBaseController {
|
|
|
@ResponseBody
|
|
|
public String getUnFinishedConsult() {
|
|
|
try {
|
|
|
List<ConsultTeam> unfinishedConsult = consultTeamService.getUnfinishedConsult(getUID());
|
|
|
// List<ConsultTeam> unfinishedConsult = consultTeamService.getUnfinishedConsult(getUID());
|
|
|
List<ConsultTeam> unfinishedConsult = consultTeamService.getUnfinishedConsult(getRepUID());
|
|
|
JSONArray result = new JSONArray(unfinishedConsult);
|
|
|
return write(200, "查询成功!", "data", result);
|
|
|
} catch (Exception e) {
|
|
@ -241,7 +236,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
public String isExistsUnfinishedConsult(@RequestParam(required = true) String doctor) {
|
|
|
try {
|
|
|
JSONObject result = new JSONObject();
|
|
|
List<ConsultTeam> consults = consultTeamService.getUnfinishedConsult(getUID(), doctor);
|
|
|
List<ConsultTeam> consults = consultTeamService.getUnfinishedConsult(getRepUID(), doctor);
|
|
|
|
|
|
if (consults != null && consults.size() > 0) {
|
|
|
return write(200, "查询成功", "data", consults.get(0).getConsult());
|
|
@ -282,7 +277,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
return error(-1, "无效请求!");
|
|
|
}
|
|
|
try {
|
|
|
if (consultTeamService.exist(getUID(), type)) {
|
|
|
if (consultTeamService.exist(getRepUID(), type)) {
|
|
|
return error(-1, "还有咨询未结束,不允许再次提交咨询!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@ -319,7 +314,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
|
|
|
System.out.println("guidance2="+guidance);
|
|
|
// 保存到数据库
|
|
|
int res = consultTeamService.addTeamConsult(consult, getUID());
|
|
|
int res = consultTeamService.addTeamConsult(consult, getRepUID(),getUID());
|
|
|
if (res == -1) {
|
|
|
return error(-1, "家庭签约信息不存在或已过期,无法进行家庭医生咨询!");
|
|
|
} else if (res == -2) {
|
|
@ -340,7 +335,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
|
|
|
// 推送消息给医生
|
|
|
PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
|
|
|
BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getUID(), new JSONObject(consult));
|
|
|
BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
|
|
|
return write(200, "提交成功", "data", consult);
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|
|
@ -348,6 +343,26 @@ public class ConsultController extends WeixinBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "intoTopic",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
@ApiOperation("进入咨询")
|
|
|
public String intoTopic(@RequestParam(required = true) String consult){
|
|
|
try{
|
|
|
int result = consultTeamService.intoTopic(consult,getRepUID(),getUID());
|
|
|
if(result==-1){
|
|
|
return error(-1,"该咨询不是进行中");
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("consult",consult);
|
|
|
json.put("content","进入咨询");
|
|
|
BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getRepUID(), json);
|
|
|
return success("进入成功");
|
|
|
}catch (Exception e){
|
|
|
error(e);
|
|
|
return error(-1,"请求失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 名医咨询添加接口
|
|
|
*
|
|
@ -391,7 +406,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
voice = CommonUtil.copyTempVoice(voice);
|
|
|
}
|
|
|
//判断是否已经存在还没有关闭的咨询
|
|
|
if (consultTeamService.isExistConsult(getUID(), doctorCode)) {
|
|
|
if (consultTeamService.isExistConsult(getRepUID(), doctorCode)) {
|
|
|
return error(-1, "还有咨询未结束,不允许再次提交咨询!");
|
|
|
}
|
|
|
ConsultTeam consult = new ConsultTeam();
|
|
@ -407,14 +422,14 @@ public class ConsultController extends WeixinBaseController {
|
|
|
consult.setVoice(voice);
|
|
|
consult.setDoctor(doctorCode);//设置专科医生
|
|
|
// 保存到数据库
|
|
|
JSONObject object = consultTeamService.famousConsult(consult, getUID(), "1");
|
|
|
JSONObject object = consultTeamService.famousConsult(consult, getRepUID(), "1",getUID());
|
|
|
JSONObject resultConsult = new JSONObject(consult);
|
|
|
resultConsult.put("session_id",object.getString("session_id"));
|
|
|
//名医咨询次数减一
|
|
|
doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
|
|
|
// 推送消息给医生
|
|
|
PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_03.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
|
|
|
BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getUID(), new JSONObject(consult));
|
|
|
BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
|
|
|
return write(200, "提交成功", "data", resultConsult);
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|
|
@ -516,7 +531,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
@ResponseBody
|
|
|
public String list(int status, long id, int pagesize) {
|
|
|
try {
|
|
|
Page<ConsultTeam> consults = consultTeamService.findByPatient(getUID(), status, id, pagesize);
|
|
|
Page<ConsultTeam> consults = consultTeamService.findByPatient(getRepUID(), status, id, pagesize);
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if (consults != null) {
|
|
|
for (ConsultTeam consult : consults) {
|
|
@ -585,7 +600,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
@ResponseBody
|
|
|
public String finish(@RequestParam(required = true) String code) {
|
|
|
try {
|
|
|
int row = consultTeamService.finishConsult(code, getUID(), 1);
|
|
|
int row = consultTeamService.finishConsult(code, getRepUID(), 1);
|
|
|
if (row > 0) {
|
|
|
return success("操作成功!");
|
|
|
} else {
|
|
@ -670,12 +685,15 @@ public class ConsultController extends WeixinBaseController {
|
|
|
|
|
|
arr = new String[]{content};
|
|
|
}
|
|
|
Patient patient = patientDao.findByCode(getUID());
|
|
|
// Patient patient = patientDao.findByCode(getUID());
|
|
|
Patient patient = patientDao.findByCode(getRepUID());
|
|
|
int i = 0;
|
|
|
List<String> failed = new ArrayList<>();
|
|
|
|
|
|
String agent = getUID()==getRepUID()?null:getUID();
|
|
|
for (ConsultTeamLog log : logs) {
|
|
|
String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
|
|
|
// String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
|
|
|
String response = ImUtill.sendTopicIM(getRepUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),agent);
|
|
|
if (StringUtils.isNotEmpty(response)) {
|
|
|
JSONObject resObj = new JSONObject(response);
|
|
|
if (resObj.getInt("status") == -1) {
|
|
@ -707,10 +725,10 @@ public class ConsultController extends WeixinBaseController {
|
|
|
if (consultModel == null) {
|
|
|
return error(-1, "咨询记录不存在!");
|
|
|
}
|
|
|
JSONObject messageObj = ImUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getUID());
|
|
|
JSONObject messageObj = ImUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
|
|
|
|
|
|
//过滤续签
|
|
|
consultTeamService.removeRenewPerson(messageObj,getUID());
|
|
|
consultTeamService.removeRenewPerson(messageObj,getRepUID());
|
|
|
|
|
|
return write(200, "查询成功", "list", messageObj);
|
|
|
} catch (Exception e) {
|
|
@ -729,7 +747,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
@ResponseBody
|
|
|
public String logs(@RequestParam String sessionId,@RequestParam(required = false) String startMsgId,@RequestParam(required = false) String endMsgId, @RequestParam int page, @RequestParam int pagesize) {
|
|
|
try {
|
|
|
JSONArray messageArray = ImUtill.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getUID());
|
|
|
JSONArray messageArray = ImUtill.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getRepUID());
|
|
|
return write(200, "查询成功", "list", messageArray);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
@ -744,7 +762,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
JSONArray participants = ImUtill.getSessions(sessionId);
|
|
|
|
|
|
//过滤续签
|
|
|
consultTeamService.removeRenewPerson(participants,getUID());
|
|
|
consultTeamService.removeRenewPerson(participants,getRepUID());
|
|
|
|
|
|
return write(200, "查询成功", "list", participants);
|
|
|
} catch (Exception e) {
|
|
@ -786,7 +804,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
json.put("id", obj.getInt("id"));
|
|
|
if (!obj.getString("from").equals(getUID())) {
|
|
|
if (!obj.getString("from").equals(getRepUID())) {
|
|
|
Doctor doc = doctorService.findDoctorByCode(obj.getString("from"));
|
|
|
// 设置回复医生姓名
|
|
|
json.put("doctorName", doc.getName());
|
|
@ -805,7 +823,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
// 设置记录类型:1文字,2图片,3语音
|
|
|
json.put("msgType", obj.getInt("contentType"));
|
|
|
// 设置类型:0患者问,1医生回复,2患者追问,3患者评价
|
|
|
if (!obj.getString("from").equals(getUID())) {
|
|
|
if (!obj.getString("from").equals(getRepUID())) {
|
|
|
json.put("type", 1);
|
|
|
} else {
|
|
|
json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
|
|
@ -832,7 +850,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
public String comment(String consult, String content, int star) {
|
|
|
try {
|
|
|
// 保存评价
|
|
|
JSONArray array = doctorCommentService.consultComment(getUID(), consult, content, star, 2);
|
|
|
JSONArray array = doctorCommentService.consultComment(getRepUID(), consult, content, star, 2);
|
|
|
// 添加到统计队列
|
|
|
if (array != null) {
|
|
|
DoctorStatisticsTask.getInstance(doctorStatisticsService).put(array);
|
|
@ -844,7 +862,7 @@ public class ConsultController extends WeixinBaseController {
|
|
|
log.setChatType(1);
|
|
|
log.setDel("1");
|
|
|
log.setType(3);
|
|
|
log = consultTeamService.reply(log, getUID(), null, log.getType());
|
|
|
log = consultTeamService.reply(log, getRepUID(), null, log.getType());
|
|
|
return success("感谢您的评价!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|