ConsultController.java 21 KB

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