ManagerUtilController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package com.yihu.wlyy.web.common.util;
  2. import com.yihu.wlyy.job.QuartzHelper;
  3. import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
  4. import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
  5. import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
  6. import com.yihu.wlyy.service.app.statistics.StatisticsService;
  7. import com.yihu.wlyy.service.common.util.ManageUtilService;
  8. import com.yihu.wlyy.web.BaseController;
  9. import io.swagger.annotations.Api;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.data.redis.core.StringRedisTemplate;
  12. import org.springframework.data.redis.hash.HashMapper;
  13. import org.springframework.http.MediaType;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestMethod;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import java.text.SimpleDateFormat;
  18. import java.util.Date;
  19. import java.util.HashMap;
  20. /**
  21. * Created by lyr on 2016/09/13.
  22. */
  23. @RestController
  24. @RequestMapping(value = "/manage_util", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  25. @Api(description = "管理工具及后台任务控制")
  26. public class ManagerUtilController extends BaseController {
  27. @Autowired
  28. PatientDiseaseService diseaseService;
  29. @Autowired
  30. StringRedisTemplate redisTemplate;
  31. @Autowired
  32. QuartzHelper quartzHelper;
  33. @Autowired
  34. DoctorWorkTimeService workTimeService;
  35. @Autowired
  36. StatisticsService statisticsService;
  37. @Autowired
  38. ManageUtilService manageUtilService;
  39. /*********************************************患者疾病相关******************************************/
  40. /**
  41. * 更新到redis
  42. *
  43. * @return
  44. */
  45. @RequestMapping(value = "/disease/to_redis")
  46. public String updateToRedid() {
  47. try {
  48. diseaseService.updateToRedis();
  49. return write(200, "更新成功");
  50. } catch (Exception e) {
  51. return error(-1, "更新失败");
  52. }
  53. }
  54. /**
  55. * 更新到疾病表
  56. *
  57. * @return
  58. */
  59. @RequestMapping(value = "/disease/to_disease")
  60. public String updateToDisease() {
  61. try {
  62. diseaseService.updateToDisease();
  63. return write(200, "更新成功");
  64. } catch (Exception e) {
  65. e.printStackTrace();
  66. return error(-1, "更新失败");
  67. }
  68. }
  69. /**
  70. * 查询患者redis疾病
  71. *
  72. * @param patient
  73. * @return
  74. */
  75. @RequestMapping(value = "/disease/patient")
  76. public String getDiseaseFromRedis(String patient) {
  77. try {
  78. return write(200, "查询成功", "data", redisTemplate.opsForValue().get("disease:" + patient));
  79. } catch (Exception e) {
  80. e.printStackTrace();
  81. return error(-1, "查询失败");
  82. }
  83. }
  84. /***********************************************名医咨询相关****************************************/
  85. /**
  86. * 开始名医咨询剩余次数统计任务
  87. *
  88. * @return
  89. */
  90. @RequestMapping(value = "/famous_doctor/start_job")
  91. public String startConsultTimesJob() {
  92. try {
  93. if (!quartzHelper.isExistJob("famous-doctor-times")) {
  94. quartzHelper.addJob(FamousConsultTimesJob.class, "0 0 0 * * ?", "famous-doctor-times", new HashMap<String, Object>());
  95. return write(200, "启动成功");
  96. } else {
  97. return write(200, "任务已存在");
  98. }
  99. } catch (Exception e) {
  100. e.printStackTrace();
  101. return error(-1, "启动失败");
  102. }
  103. }
  104. /**
  105. * 名医咨询剩余次数手动更新
  106. *
  107. * @return
  108. */
  109. @RequestMapping(value = "/famous_doctor/times_update")
  110. public String famousConsultTimeUpdate() {
  111. try {
  112. workTimeService.consultTimesRemain(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
  113. return write(200, "更新成功");
  114. } catch (Exception e) {
  115. e.printStackTrace();
  116. return error(-1, "更新失败");
  117. }
  118. }
  119. /*********************************************统计相关*******************************************/
  120. /**
  121. * 更新人口数据到redis
  122. *
  123. * @return
  124. */
  125. @RequestMapping(value = "/people_num_to_redis")
  126. public String peopleNumToRedis() {
  127. try {
  128. statisticsService.peopleNumToRedis();
  129. return write(200, "更新成功");
  130. } catch (Exception e) {
  131. e.printStackTrace();
  132. return error(-1, "更新失败");
  133. }
  134. }
  135. /**
  136. * 签约同步数据设置团队和分组
  137. *
  138. * @return
  139. */
  140. @RequestMapping(value = "/sign_set_group_team")
  141. public String signSetGroupAndTeam(){
  142. try {
  143. manageUtilService.signPatientSetGroup();
  144. return write(200, "更新成功");
  145. } catch (Exception e) {
  146. e.printStackTrace();
  147. return error(-1, "更新失败");
  148. }
  149. }
  150. }