ConsultController.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. package com.yihu.wlyy.web.patient.consult;
  2. import java.util.*;
  3. import com.yihu.wlyy.entity.consult.ConsultTeam;
  4. import com.yihu.wlyy.entity.consult.ConsultTeamLog;
  5. import com.yihu.wlyy.entity.doctor.profile.Doctor;
  6. import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
  7. import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
  8. import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
  9. import io.swagger.annotations.Api;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.json.JSONArray;
  12. import org.json.JSONObject;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.data.domain.Page;
  15. import org.springframework.stereotype.Controller;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestParam;
  18. import org.springframework.web.bind.annotation.ResponseBody;
  19. import com.yihu.wlyy.service.app.consult.ConsultTeamService;
  20. import com.yihu.wlyy.service.app.consult.DoctorCommentService;
  21. import com.yihu.wlyy.service.app.statistics.DoctorStatisticsService;
  22. import com.yihu.wlyy.service.app.talk.TalkGroupService;
  23. import com.yihu.wlyy.service.common.account.DoctorService;
  24. import com.yihu.wlyy.task.DoctorStatisticsTask;
  25. import com.yihu.wlyy.task.PushMsgTask;
  26. import com.yihu.wlyy.util.CommonUtil;
  27. import com.yihu.wlyy.util.DateUtil;
  28. import com.yihu.wlyy.util.MessageType;
  29. import com.yihu.wlyy.web.WeixinBaseController;
  30. /**
  31. * 患者端:三师咨询控制类
  32. * @author George
  33. *
  34. */
  35. @Controller
  36. @RequestMapping(value = "/patient/consult")
  37. @Api(description = "患者端-患者咨询")
  38. public class ConsultController extends WeixinBaseController {
  39. @Autowired
  40. private ConsultTeamService consultTeamService;
  41. @Autowired
  42. private DoctorCommentService doctorCommentService;
  43. @Autowired
  44. private DoctorStatisticsService doctorStatisticsService;
  45. @Autowired
  46. private DoctorService doctorService;
  47. @Autowired
  48. private TalkGroupService talkGroupService;
  49. @Autowired
  50. private DoctorWorkTimeService doctorWorkTimeService;
  51. /**
  52. * 患者咨询记录查询
  53. * @param title 咨询标题
  54. * @param id
  55. * @param pagesize 分页大小
  56. * @return
  57. */
  58. @RequestMapping(value = "records")
  59. @ResponseBody
  60. public String consultRecords(
  61. @RequestParam(required = false) String title,
  62. long id,
  63. int pagesize) {
  64. try {
  65. JSONArray array = new JSONArray();
  66. Page<Object> data = consultTeamService.findConsultRecordByPatient(getUID(), id, pagesize,title);
  67. if (data != null) {
  68. for (Object consult : data.getContent()) {
  69. if (consult == null) {
  70. continue;
  71. }
  72. Object[] result = (Object[])consult;
  73. JSONObject json = new JSONObject();
  74. json.put("id", result[0]);
  75. // 设置咨询类型:1三师咨询,2视频咨询,3图文咨询,4公共咨询,5病友圈
  76. json.put("type", result[1]);
  77. // 设置咨询标识
  78. json.put("code", result[2]);
  79. // 设置显示标题
  80. json.put("title", result[3]);
  81. // 设置主诉
  82. json.put("symptoms", result[4]);
  83. // 咨询状态
  84. json.put("status", result[6]);
  85. // 设置咨询日期
  86. json.put("czrq", DateUtil.dateToStrLong((Date)result[5]));
  87. array.put(json);
  88. }
  89. }
  90. return write(200, "查询成功!", "list", array);
  91. } catch (Exception e) {
  92. error(e);
  93. return error(-1, "查询失败!");
  94. }
  95. }
  96. /**
  97. * 获取医生的排班时间
  98. *
  99. * @param doctor
  100. * @param week
  101. * @return
  102. */
  103. @RequestMapping(value = "/doctor_worktime/week")
  104. @ResponseBody
  105. public String getDoctorWeekWorkTime(String doctor,String week){
  106. try{
  107. JSONObject result = doctorWorkTimeService.findDoctorWeekWorkTime(doctor,week);
  108. return write(200,"查询成功!","data",result);
  109. }catch (Exception e){
  110. e.printStackTrace();
  111. return error(-1,"查询失败!");
  112. }
  113. }
  114. /**
  115. * 获取医生某天的排班时间
  116. *
  117. * @param doctor
  118. * @return
  119. */
  120. @RequestMapping(value = "/doctor_worktime")
  121. @ResponseBody
  122. public String getDoctorWorkTime(String doctor){
  123. try{
  124. JSONObject result = doctorWorkTimeService.findDoctorWorkTime(doctor);
  125. return write(200,"查询成功!","data",result);
  126. }catch (Exception e){
  127. e.printStackTrace();
  128. return error(-1,"查询失败!");
  129. }
  130. }
  131. /**
  132. * 医生是否在工作
  133. *
  134. * @param doctor
  135. * @return
  136. */
  137. @RequestMapping(value = "is_doctor_working")
  138. @ResponseBody
  139. public String isDoctorAtWorking(String doctor){
  140. try{
  141. JSONObject result = doctorWorkTimeService.isDoctorWorking(doctor);
  142. return write(200,result.getString("msg"),"data",result.getString("status"));
  143. }catch (Exception e){
  144. e.printStackTrace();
  145. return error(-1,"查询失败");
  146. }
  147. }
  148. /**
  149. * 名医咨询剩余次数查询
  150. *
  151. * @param doctor
  152. * @return
  153. */
  154. @RequestMapping(value = "/consult_times_remain")
  155. @ResponseBody
  156. public String famousDoctorTimesRemain(String doctor){
  157. try{
  158. int result = doctorWorkTimeService.getDoctorConsultTimesRemain(doctor);
  159. return write(200,"查询成功","data",result);
  160. }catch (Exception e){
  161. e.printStackTrace();
  162. return error(-1,"查询失败");
  163. }
  164. }
  165. /**
  166. * 获取未完成咨询
  167. *
  168. * @return
  169. */
  170. @RequestMapping(value = "/unfinished")
  171. @ResponseBody
  172. public String getUnFinishedConsult(){
  173. try{
  174. List<ConsultTeam> unfinishedConsult = consultTeamService.getUnfinishedConsult(getUID());
  175. JSONArray result = new JSONArray(unfinishedConsult);
  176. return write(200,"查询成功!","data",result);
  177. }catch (Exception e){
  178. e.printStackTrace();
  179. return error(-1,"查询失败!");
  180. }
  181. }
  182. /**
  183. * 三师咨询添加接口
  184. * @param type 咨询类型:1三师咨询,2家庭医生咨询
  185. * @param when 发病时间
  186. * @param symptoms 主要症状
  187. * @param images 图片URL地址,多图以逗号分隔
  188. * @param voice 语音URL地址
  189. * @return
  190. */
  191. @RequestMapping(value = "add")
  192. @ResponseBody
  193. public String add(@RequestParam(required = false) Integer type,
  194. String when,
  195. String symptoms,
  196. @RequestParam(required = false) String images,
  197. @RequestParam(required = false) String voice) {
  198. try {
  199. if (type == null) {
  200. type = 1;
  201. }
  202. if (type != 1 && type != 2) {
  203. return error(-1, "无效请求!");
  204. }
  205. if (consultTeamService.exist(getUID(),type)) {
  206. return error(-1, "还有咨询未结束,不允许再次提交咨询!");
  207. }
  208. if (StringUtils.isEmpty(images)) {
  209. images = fetchWxImages();
  210. }
  211. // 将临时图片拷贝到正式存储路径下
  212. if (StringUtils.isNotEmpty(images)) {
  213. images = CommonUtil.copyTempImage(images);
  214. }
  215. if (StringUtils.isEmpty(voice)) {
  216. voice = fetchWxVoices();
  217. }
  218. if (StringUtils.isNotEmpty(voice)) {
  219. voice = CommonUtil.copyTempVoice(voice);
  220. }
  221. ConsultTeam consult = new ConsultTeam();
  222. // 设置咨询类型:1三师咨询,2家庭医生咨询 6.名医咨询
  223. consult.setType(type);
  224. // 设置发病时间
  225. consult.setWhen(when);
  226. // 设置主要症状
  227. consult.setSymptoms(symptoms);
  228. // 设置咨询图片URL
  229. consult.setImages(images);
  230. // 设置咨询语音URL
  231. consult.setVoice(voice);
  232. // 保存到数据库
  233. int res = consultTeamService.addTeamConsult(consult, getUID());
  234. if (res == -1) {
  235. return error(-1, "家庭签约信息不存在或已过期,无法进行家庭医生咨询!");
  236. } else if (res == -2) {
  237. return error(-1, "家庭签约信息不存在或已过期,无法进行三师医生咨询!");
  238. }
  239. Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());
  240. //创建咨询讨论组
  241. talkGroupService.createConsultTalkGroup(consult.getDoctor(), doctor.getName(), doctor.getHospital(), doctor.getHosptialName(),
  242. consult.getPatient(), consult.getName(),consult.getConsult());
  243. // 添加到统计队列
  244. if (consult.getType() == 2) {
  245. DoctorStatisticsTask.getInstance(doctorStatisticsService).put(consult.getDoctor(), 1, 1, 0);
  246. }
  247. // 推送消息给医生
  248. 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());
  249. return success("提交成功");
  250. } catch (Exception ex) {
  251. error(ex);
  252. return invalidUserException(ex, -1, "提交失败!");
  253. }
  254. }
  255. /**
  256. * 名医咨询添加接口
  257. * @param when 发病时间
  258. * @param symptoms 主要症状
  259. * @param images 图片URL地址,多图以逗号分隔
  260. * @param voice 语音URL地址
  261. * @param doctorCode 名医的code
  262. * @return
  263. */
  264. @RequestMapping(value = "famousAdd")
  265. @ResponseBody
  266. public String famousAdd(
  267. @RequestParam(required = false)String when,
  268. String symptoms,
  269. @RequestParam(required = false) String doctorCode,
  270. @RequestParam(required = false) String images,
  271. @RequestParam(required = false) String voice) {
  272. try {
  273. //判断医生是否是在工作时间
  274. JSONObject jo=doctorWorkTimeService.isDoctorWorking(doctorCode);
  275. if(!jo.get("status").equals("1")){
  276. return error(-1, jo.get("msg").toString());
  277. }
  278. //判断医生是否剩下咨询次数
  279. int result = doctorWorkTimeService.getDoctorConsultTimesRemain(doctorCode);
  280. if(result==0){
  281. return error(-1, "没有次数");
  282. }
  283. if (StringUtils.isEmpty(images)) {
  284. images = fetchWxImages();
  285. }
  286. // 将临时图片拷贝到正式存储路径下
  287. if (StringUtils.isNotEmpty(images)) {
  288. images = CommonUtil.copyTempImage(images);
  289. }
  290. if (StringUtils.isEmpty(voice)) {
  291. voice = fetchWxVoices();
  292. }
  293. if (StringUtils.isNotEmpty(voice)) {
  294. voice = CommonUtil.copyTempVoice(voice);
  295. }
  296. //判断是否已经存在还没有关闭的名医咨询
  297. if(consultTeamService.isExistFamousConsult(getUID())){
  298. return error(-1, "已经存在名医咨询!");
  299. }
  300. ConsultTeam consult = new ConsultTeam();
  301. // 设置咨询类型:1三师咨询,2家庭医生咨询 6.名医咨询
  302. consult.setType(6);
  303. // 设置发病时间
  304. consult.setWhen(when);
  305. // 设置主要症状
  306. consult.setSymptoms(symptoms);
  307. // 设置咨询图片URL
  308. consult.setImages(images);
  309. // 设置咨询语音URL
  310. consult.setVoice(voice);
  311. consult.setDoctor(doctorCode);//设置专科医生
  312. // 保存到数据库
  313. consultTeamService.addFamousTeamConsult(consult, getUID());
  314. //名医咨询次数减一
  315. doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
  316. // 推送消息给医生
  317. PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
  318. return success("提交成功");
  319. } catch (Exception ex) {
  320. error(ex);
  321. return invalidUserException(ex, -1, "提交失败!");
  322. }
  323. }
  324. /**
  325. * 名医列表
  326. * @return
  327. */
  328. @RequestMapping(value = "famousDoctorList")
  329. @ResponseBody
  330. public String famousDoctorList(
  331. @RequestParam(required = false) String name,
  332. int page,
  333. int pagesize) {
  334. try {
  335. JSONArray array = new JSONArray();
  336. Page<Doctor>list = doctorService.famousDoctorList(name, page, pagesize);
  337. if (list != null) {
  338. for (Doctor doctor : list) {
  339. if (doctor == null) {
  340. continue;
  341. }
  342. JSONObject json = new JSONObject();
  343. json.put("id", doctor.getId());
  344. // 医生标识
  345. json.put("code", doctor.getCode());
  346. // 医生性别
  347. json.put("sex", doctor.getSex());
  348. // 医生姓名
  349. json.put("name", doctor.getName());
  350. // 所在医院名称
  351. json.put("hospital", doctor.getHospital());
  352. // 所在医院名称
  353. json.put("hospital_name", doctor.getHosptialName());
  354. // 科室名称
  355. json.put("dept_name", (doctor.getDeptName() == null ||
  356. StringUtils.isEmpty(doctor.getDeptName().toString())) ? " " : doctor.getDeptName());
  357. // 职称名称
  358. json.put("job_name", (doctor.getJobName() == null ||
  359. StringUtils.isEmpty(doctor.getJobName().toString())) ? " " : doctor.getJobName());
  360. // 头像
  361. json.put("photo", doctor.getPhoto());
  362. // 简介
  363. json.put("introduce", doctor.getIntroduce());
  364. // 专长
  365. json.put("expertise", doctor.getExpertise());
  366. // 剩余咨询次数
  367. json.put("num", doctorWorkTimeService.getDoctorConsultTimesRemain(doctor.getCode()));
  368. array.put(json);
  369. }
  370. }
  371. return write(200, "获取医院医生列表成功!", "list", array);
  372. } catch (Exception e) {
  373. error(e);
  374. return error(-1, "获取医院医生列表失败!");
  375. }
  376. }
  377. @RequestMapping(value = "status")
  378. @ResponseBody
  379. public String status(String consult) {
  380. try {
  381. ConsultTeam ct = consultTeamService.findByCode(consult);
  382. if (ct == null) {
  383. return error(-1, "获取状态失败!");
  384. } else {
  385. return write(200, "获取状态成功!", "data", ct.getStatus());
  386. }
  387. } catch (Exception e) {
  388. error(e);
  389. return invalidUserException(e, -1, "获取状态失败!");
  390. }
  391. }
  392. /**
  393. * 查询患者三师咨询咨询列表
  394. * @param status 咨询状态(0未结束,1已结束,-1 已取消)
  395. * @param pagesize 页数
  396. * @return 查询结果
  397. */
  398. @RequestMapping(value = "list")
  399. @ResponseBody
  400. public String list(int status, long id, int pagesize) {
  401. try {
  402. Page<ConsultTeam> consults = consultTeamService.findByPatient(getUID(), status, id, pagesize);
  403. JSONArray jsonArray = new JSONArray();
  404. if (consults != null) {
  405. for (ConsultTeam consult : consults) {
  406. if (consult == null) {
  407. continue;
  408. }
  409. JSONObject json = new JSONObject();
  410. json.put("id", consult.getId());
  411. // 设置咨询标志
  412. json.put("code", consult.getConsult());
  413. // 设置咨询类型:0公共咨询,1指定医生,2三师咨询
  414. json.put("type", consult.getType());
  415. // 设置标题
  416. json.put("title", consult.getSymptoms());
  417. // 设置发病时间
  418. json.put("when", consult.getWhen());
  419. // 设置患者未读数量
  420. json.put("patientRead", consult.getPatientRead());
  421. // 设置状态
  422. json.put("status", consult.getStatus());
  423. // 设置患者评价标识
  424. json.put("comment", consult.getComment());
  425. // 设置咨询或回复时间
  426. json.put("time", DateUtil.dateToStr(consult.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
  427. jsonArray.put(json);
  428. }
  429. }
  430. return write(200, "查询成功", "list", jsonArray);
  431. } catch (Exception ex) {
  432. error(ex);
  433. return invalidUserException(ex, -1, "查询失败!");
  434. }
  435. }
  436. /**
  437. * 患者取消三师咨询
  438. * @param consult
  439. * @return
  440. */
  441. @RequestMapping(value = "cancel")
  442. @ResponseBody
  443. public String cancel(String consult) {
  444. try {
  445. int row = consultTeamService.cancel(consult);
  446. if (row > 0) {
  447. return success("咨询已取消!");
  448. } else {
  449. return error(-1, "咨询不能取消!");
  450. }
  451. } catch (Exception e) {
  452. error(e);
  453. return invalidUserException(e, -1, "操作失败!");
  454. }
  455. }
  456. /**
  457. * 修改状态为1的咨询记录为结束
  458. * @param code 咨询标识
  459. * @return
  460. */
  461. @RequestMapping(value = "finish")
  462. @ResponseBody
  463. public String finish(String code) {
  464. try {
  465. int row = consultTeamService.finish(code);
  466. if (row > 0) {
  467. return success("操作成功!");
  468. } else {
  469. return error(-1, "操作失败!");
  470. }
  471. } catch (Exception e) {
  472. error(e);
  473. return invalidUserException(e, -1, "操作失败!");
  474. }
  475. }
  476. /**
  477. * 三师咨询追问接口
  478. * @param consult 咨询标识
  479. * @param content 追问内容
  480. * @param type 追问内容类型:1文字,2图片,3语音
  481. * @return
  482. */
  483. @RequestMapping(value = "append")
  484. @ResponseBody
  485. public String append(String consult, String content, int type) {
  486. try {
  487. List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
  488. if (type == 2) {
  489. // 图片消息
  490. if (StringUtils.isEmpty(content)) {
  491. content = fetchWxImages();
  492. }
  493. // 将临时图片拷贝到正式存储路径下
  494. if (StringUtils.isNotEmpty(content)) {
  495. content = CommonUtil.copyTempImage(content);
  496. }
  497. if (StringUtils.isEmpty(content)) {
  498. return error(-1, "图片上传失败!");
  499. }
  500. String[] images = content.split(",");
  501. for (String image : images) {
  502. ConsultTeamLog log = new ConsultTeamLog();
  503. log.setConsult(consult);
  504. log.setContent(image);
  505. log.setDel("1");
  506. log.setChatType(type);
  507. log.setType(2);
  508. logs.add(log);
  509. }
  510. } else {
  511. ConsultTeamLog log = new ConsultTeamLog();
  512. log.setConsult(consult);
  513. log.setContent(content);
  514. log.setDel("1");
  515. log.setChatType(type);
  516. log.setType(2);
  517. logs.add(log);
  518. }
  519. consultTeamService.reply(logs, getUID());
  520. return write(200, "追问成功!", "data", content);
  521. } catch (Exception e) {
  522. error(e);
  523. return invalidUserException(e, -1, "追问失败!");
  524. }
  525. }
  526. /**
  527. * 网络咨询咨询日志查询
  528. * @param consult 咨询标识
  529. * @param pagesize 每页显示数,默认为10
  530. * @return
  531. */
  532. @RequestMapping(value = "loglist")
  533. @ResponseBody
  534. public String loglist(String consult, long id, int pagesize) {
  535. try {
  536. ConsultTeam consultModel = consultTeamService.findByCode(consult);
  537. if (consultModel == null) {
  538. return error(-1, "咨询记录不存在!");
  539. }
  540. if (id <= 0) {
  541. // 更新患者未读数量为0
  542. consultTeamService.clearPatientRead(consult);
  543. }
  544. // 查询日志列表
  545. JSONArray jsonArray = new JSONArray();
  546. Page<ConsultTeamLog> list = consultTeamService.findLogByConsult(consult, id, pagesize);
  547. if (list != null) {
  548. for (ConsultTeamLog log : list) {
  549. if (consult == null) {
  550. continue;
  551. }
  552. JSONObject json = new JSONObject();
  553. json.put("id", log.getId());
  554. // 设置回复医生姓名
  555. json.put("doctorName", log.getDoctorName());
  556. // 设置回复内容
  557. json.put("content", log.getContent());
  558. // 设置咨询或回复时间
  559. json.put("time", DateUtil.dateToStr(log.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
  560. // 设置记录类型:1文字,2图片,3语音
  561. json.put("msgType", log.getChatType());
  562. // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
  563. json.put("type", log.getType());
  564. jsonArray.put(json);
  565. }
  566. }
  567. // 返回结果
  568. return write(200, "查询成功", "list", jsonArray);
  569. } catch (Exception e) {
  570. error(e);
  571. return invalidUserException(e, -1, "查询失败!");
  572. }
  573. }
  574. /**
  575. * 查找单个咨询记录
  576. * @param consult 咨询标识
  577. * @param logId 记录标识
  578. *
  579. * @return
  580. */
  581. @RequestMapping(value = "oneLog")
  582. @ResponseBody
  583. public String oneLog(String consult,Long logId) {
  584. try {
  585. ConsultTeam consultModel = consultTeamService.findByCode(consult);
  586. if (consultModel == null) {
  587. return error(-1, "咨询记录不存在!");
  588. }
  589. // 查询日志列表
  590. JSONObject json = new JSONObject();
  591. ConsultTeamLog log = consultTeamService.oneLog(logId);
  592. if (log != null) {
  593. json.put("id", log.getId());
  594. // 设置回复医生姓名
  595. json.put("doctorName", log.getDoctorName());
  596. // 设置回复内容
  597. json.put("content", log.getContent());
  598. // 设置咨询或回复时间
  599. json.put("time", DateUtil.dateToStr(log.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
  600. // 设置记录类型:1文字,2图片,3语音
  601. json.put("msgType", log.getChatType());
  602. // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
  603. json.put("type", log.getType());
  604. }
  605. // 返回结果
  606. return write(200, "查询成功", "consult", json);
  607. } catch (Exception e) {
  608. error(e);
  609. return invalidUserException(e, -1, "查询失败!");
  610. }
  611. }
  612. /**
  613. * 三师咨询评论
  614. * @param consult 咨询标识
  615. * @param content 评价内容
  616. * @param star 星级
  617. * @return 操作结果
  618. */
  619. @RequestMapping(value = "comment")
  620. @ResponseBody
  621. public String comment(String consult, String content, int star) {
  622. try {
  623. // 保存评价
  624. JSONArray array = doctorCommentService.consultComment(getUID(), consult, content, star, 2);
  625. // 添加到统计队列
  626. if (array != null) {
  627. DoctorStatisticsTask.getInstance(doctorStatisticsService).put(array);
  628. }
  629. // 添加评价记录
  630. ConsultTeamLog log = new ConsultTeamLog();
  631. log.setConsult(consult);
  632. log.setContent(content);
  633. log.setChatType(1);
  634. log.setDel("1");
  635. log.setType(3);
  636. log = consultTeamService.reply(log, getUID(), null, log.getType());
  637. return success("感谢您的评价!");
  638. } catch (Exception e) {
  639. error(e);
  640. return invalidUserException(e, -1, "评价失败!");
  641. }
  642. }
  643. }