|
@ -0,0 +1,238 @@
|
|
|
|
//package com.yihu.jw.door.controller.patient;
|
|
|
|
//
|
|
|
|
//import com.alibaba.fastjson.JSONObject;
|
|
|
|
//import com.yihu.jw.door.controller.BaseController;
|
|
|
|
//import com.yihu.jw.door.service.consult.ConsultTeamService;
|
|
|
|
//import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
|
|
//import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
|
|
|
|
//import com.yihu.jw.entity.patient.Patient;
|
|
|
|
//import com.yihu.jw.im.dao.ConsultTeamDao;
|
|
|
|
//import com.yihu.jw.im.util.ImUtil;
|
|
|
|
//import io.swagger.annotations.Api;
|
|
|
|
//import io.swagger.annotations.ApiOperation;
|
|
|
|
//import io.swagger.annotations.ApiParam;
|
|
|
|
//import org.apache.commons.lang3.StringUtils;
|
|
|
|
//import org.apache.http.NameValuePair;
|
|
|
|
//import org.apache.http.message.BasicNameValuePair;
|
|
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
//import org.springframework.http.MediaType;
|
|
|
|
//import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
//import org.springframework.web.bind.annotation.*;
|
|
|
|
//
|
|
|
|
//import java.util.ArrayList;
|
|
|
|
//import java.util.List;
|
|
|
|
//import java.util.Map;
|
|
|
|
//
|
|
|
|
///**
|
|
|
|
// * Created by yeshijie on 2020/12/29.
|
|
|
|
// */
|
|
|
|
//@RestController
|
|
|
|
//@RequestMapping(value = "/patient/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
|
//@Api(description = "患者端-患者咨询")
|
|
|
|
//public class ConsultController extends BaseController {
|
|
|
|
//
|
|
|
|
// @Autowired
|
|
|
|
// private ConsultTeamService consultTeamService;
|
|
|
|
// @Autowired
|
|
|
|
// private ConsultTeamDao consultTeamDao;
|
|
|
|
// @Autowired
|
|
|
|
// private ImUtil imUtil;
|
|
|
|
// @Autowired
|
|
|
|
// private JdbcTemplate jdbcTemplate;
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * 三师咨询追问接口
|
|
|
|
// *
|
|
|
|
// * @param consult 咨询标识
|
|
|
|
// * @param content 追问内容
|
|
|
|
// * @param type 追问内容类型:1文字,2图片,3语音 ... (im消息类型)
|
|
|
|
// * @return
|
|
|
|
// */
|
|
|
|
// @RequestMapping(value = "append")
|
|
|
|
// @ResponseBody
|
|
|
|
// @ApiOperation("三师咨询追问接口")
|
|
|
|
// public String append(
|
|
|
|
// @RequestParam String consult,
|
|
|
|
// @RequestParam String content,
|
|
|
|
// @RequestParam int type,
|
|
|
|
// @RequestParam(required = false, defaultValue = "0") Integer times) {
|
|
|
|
// try {
|
|
|
|
// List<ConsultTeamLogDo> logs = new ArrayList<ConsultTeamLogDo>();
|
|
|
|
// ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
|
|
|
|
//
|
|
|
|
// if (consultModel == null) {
|
|
|
|
// return error(-1, "咨询记录不存在!");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (consultModel.getEndMsgId() != null) {
|
|
|
|
// return error(-1, "咨询已结束");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// String[] arr = null;
|
|
|
|
// if (type == 3) {
|
|
|
|
// String path = fetchWxVoices();
|
|
|
|
// JSONObject obj = new JSONObject();
|
|
|
|
// // 将临时语音拷贝到正式存储路径下
|
|
|
|
// if (StringUtils.isNotEmpty(path)) {
|
|
|
|
// content = CommonUtil.copyTempVoice(path);
|
|
|
|
// obj.put("path", content);
|
|
|
|
// obj.put("times", times);
|
|
|
|
// content = obj.toString();
|
|
|
|
// }
|
|
|
|
// ConsultTeamLogDo log = new ConsultTeamLogDo();
|
|
|
|
// log.setConsult(consult);
|
|
|
|
// log.setContent(content);
|
|
|
|
// log.setDel("1");
|
|
|
|
// log.setChatType(type);
|
|
|
|
// log.setType(type);
|
|
|
|
// logs.add(log);
|
|
|
|
// } else if (type == 2) {
|
|
|
|
// // 图片消息
|
|
|
|
// 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) {
|
|
|
|
// ConsultTeamLogDo log = new ConsultTeamLogDo();
|
|
|
|
// log.setConsult(consult);
|
|
|
|
// log.setContent(image);
|
|
|
|
// log.setDel("1");
|
|
|
|
// log.setChatType(type);
|
|
|
|
// log.setType(type);
|
|
|
|
// logs.add(log);
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// ConsultTeamLogDo log = new ConsultTeamLogDo();
|
|
|
|
// log.setConsult(consult);
|
|
|
|
// log.setContent(content);
|
|
|
|
// log.setDel("1");
|
|
|
|
// log.setChatType(type);
|
|
|
|
// log.setType(type);
|
|
|
|
// logs.add(log);
|
|
|
|
//
|
|
|
|
// arr = new String[]{content};
|
|
|
|
// }
|
|
|
|
//// 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 (ConsultTeamLogDo log : logs) {
|
|
|
|
// String response = imUtil.sendTopicIM(getRepUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),agent);
|
|
|
|
//
|
|
|
|
// if (StringUtils.isNotEmpty(response)) {
|
|
|
|
// JSONObject resObj = new JSONObject(response);
|
|
|
|
// if (resObj.getInteger("status") == -1) {
|
|
|
|
// return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
|
|
|
|
// }
|
|
|
|
// failed.add(String.valueOf(resObj.get("data")));
|
|
|
|
// try {
|
|
|
|
// String sql = "";
|
|
|
|
// if (consultModel.getType() == 2){
|
|
|
|
// //家庭咨询
|
|
|
|
// sql = "SELECT t.participant_id FROM " + im +
|
|
|
|
// ".participants t where t.session_id = '" +
|
|
|
|
// patient.getCode() + "_" + consultModel.getTeam() + "_" + consultModel.getType() +
|
|
|
|
// "' and t.participant_role = 0";
|
|
|
|
// }else if (consultModel.getType() == 8 || consultModel.getType() == 9 || consultModel.getType() == 11){
|
|
|
|
// //8-续方咨询 9-在线复诊咨询 11-上门预约服务
|
|
|
|
// sql = "SELECT t.participant_id FROM " + im +
|
|
|
|
// ".participants t where t.session_id = '" +
|
|
|
|
// patient.getCode() + "_" + consultModel.getConsult() + "_" + consultModel.getType() +
|
|
|
|
// "' and t.participant_role = 0";
|
|
|
|
// }else if(consultModel.getType() == 18){
|
|
|
|
// //康复咨询
|
|
|
|
// sql = "SELECT t.participant_id FROM " + im +
|
|
|
|
// ".participants t where t.session_id = '(SELECT session_id from "+im+".topics WHERE id='"+consultModel.getConsult()+"')' and t.participant_role = 0";
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(StringUtils.isEmpty(sql)){
|
|
|
|
// return write(-1, "追问失败!", "data", "不存在该类型!【type】:" + type);
|
|
|
|
// }
|
|
|
|
// List<Map<String, Object>> participants = jdbcTemplate.queryForList(sql);
|
|
|
|
//
|
|
|
|
// for (Map<String, Object> participant : participants) {
|
|
|
|
//// //有居民、健管、全科
|
|
|
|
// String doctorCode = participant.get("participant_id").toString();
|
|
|
|
// if (doctorCode.equals(patient.getCode())) {
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return write(200, "追问成功!", "data", failed);
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// error(e);
|
|
|
|
// return invalidUserException(e, -1, "追问失败!");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * 网络咨询咨询日志查询
|
|
|
|
// *
|
|
|
|
// * @param consult 咨询标识
|
|
|
|
// * @param pagesize 每页显示数,默认为10
|
|
|
|
// * @return
|
|
|
|
// */
|
|
|
|
// @GetMapping(value = "loglist")
|
|
|
|
// @ApiOperation("网络咨询咨询日志查询")
|
|
|
|
// public String loglist(@RequestParam String consult, @RequestParam int page, @RequestParam int pagesize) {
|
|
|
|
// try {
|
|
|
|
// ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
|
|
|
|
// if (consultModel == null) {
|
|
|
|
// return error(-1, "咨询记录不存在!");
|
|
|
|
// }
|
|
|
|
// JSONObject messageObj = imUtil.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
|
|
|
|
//
|
|
|
|
// return write(200, "查询成功", "list", messageObj);
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// error(e);
|
|
|
|
// return invalidUserException(e, -1, "查询失败!");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @GetMapping(value = "getTopic")
|
|
|
|
// public String getTopic(String consult){
|
|
|
|
// try{
|
|
|
|
// return success(imUtil.getTopic(consult).get("data").toString());
|
|
|
|
// }catch (Exception e){
|
|
|
|
// error(e);
|
|
|
|
// return error(-1,e.getMessage());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @GetMapping(value = "getConsult")
|
|
|
|
// public String getConsult(String consult){
|
|
|
|
// try{
|
|
|
|
// ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
|
|
|
|
// return write(200, "查询成功", "data", consultTeam);
|
|
|
|
// }catch (Exception e){
|
|
|
|
// error(e);
|
|
|
|
// return error(-1,e.getMessage());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @GetMapping(value = "queryByRelationCode")
|
|
|
|
// @ApiOperation("根据关联业务code查询咨询记录")
|
|
|
|
// public String queryByRelationCode(@ApiParam(name = "code", value = "咨询关联业务code") @RequestParam(value = "code", required = true) String code){
|
|
|
|
// try{
|
|
|
|
// ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(code);
|
|
|
|
// return write(200, "提交成功", "data", consultTeam);
|
|
|
|
// }catch (Exception e){
|
|
|
|
// error(e);
|
|
|
|
// return error(-1,"添加失败");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|