JobController.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. package com.yihu.wlyy.statistics.controller;
  2. import com.yihu.wlyy.statistics.job.business.QuartzHelper;
  3. import com.yihu.wlyy.statistics.service.JobService;
  4. import io.swagger.annotations.Api;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.http.MediaType;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RequestMethod;
  9. import org.springframework.web.bind.annotation.RestController;
  10. /**
  11. * 任务启动
  12. *
  13. * @author chenweida
  14. */
  15. @RestController
  16. @RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  17. @Api(description = "后台-任务控制")
  18. public class JobController extends BaseController {
  19. @Autowired
  20. private JobService jobService;
  21. @Autowired
  22. private QuartzHelper quartzHelper;
  23. /**
  24. * 启动任务
  25. *
  26. * @param id id
  27. * @return
  28. */
  29. @RequestMapping(value = "startNowById", method = RequestMethod.GET)
  30. public String startNowById(String id) {
  31. try {
  32. jobService.startNowById(id);
  33. return success("启动成功!");
  34. } catch (Exception e) {
  35. error(e);
  36. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  37. }
  38. }
  39. /**
  40. * 生成过去几天的数据
  41. *
  42. * @param day
  43. * @return
  44. */
  45. @RequestMapping(value = "productDataByDay", method = RequestMethod.GET)
  46. public String productDataByDay(Integer day) {
  47. try {
  48. jobService.productDataByDay(day);
  49. return success("启动成功!");
  50. } catch (Exception e) {
  51. error(e);
  52. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  53. }
  54. }
  55. /**
  56. * 生成过去某一天的全部的数据
  57. *
  58. * @param day
  59. * @return
  60. */
  61. @RequestMapping(value = "productDataByOneDay", method = RequestMethod.GET)
  62. public String productDataByOneDay(String day) {
  63. try {
  64. jobService.productDataByOneDay(day);
  65. return success("启动成功!");
  66. } catch (Exception e) {
  67. error(e);
  68. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  69. }
  70. }
  71. /**
  72. * 生成过去某一天的某一个指标的数据
  73. *
  74. * @param day
  75. * @return
  76. */
  77. @RequestMapping(value = "productDataByOneDayWithId", method = RequestMethod.GET)
  78. public String productDataByOneDayWithId(String day, String id) {
  79. try {
  80. jobService.productDataByOneDayWithId(day, id);
  81. return success("启动成功!");
  82. } catch (Exception e) {
  83. error(e);
  84. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  85. }
  86. }
  87. /**
  88. * 生成过去某几天的某一个指标的数据
  89. *
  90. * @param day
  91. * @return
  92. */
  93. @RequestMapping(value = "productDataByDayAndId", method = RequestMethod.GET)
  94. public String productDataByDayAndId(Integer day, String id) {
  95. try {
  96. jobService.productDataByDayAndId(day, id);
  97. return success("启动成功!");
  98. } catch (Exception e) {
  99. error(e);
  100. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  101. }
  102. }
  103. /**
  104. * 启动任务
  105. *
  106. * @param id id
  107. * @return
  108. */
  109. @RequestMapping(value = "startById", method = RequestMethod.GET)
  110. public String startById(String id) {
  111. try {
  112. jobService.startById(id);
  113. return success("启动成功!");
  114. } catch (Exception e) {
  115. error(e);
  116. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  117. }
  118. }
  119. /**
  120. * 停止任务
  121. *
  122. * @param id id
  123. * @return
  124. */
  125. @RequestMapping(value = "stopById", method = RequestMethod.GET)
  126. public String stopById(String id) {
  127. try {
  128. jobService.stopById(id);
  129. return success("停止成功!");
  130. } catch (Exception e) {
  131. error(e);
  132. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  133. }
  134. }
  135. /**
  136. * 停止所有任务
  137. *
  138. * @return
  139. */
  140. @RequestMapping(value = "stopAll", method = RequestMethod.GET)
  141. public String stopAll() {
  142. try {
  143. jobService.stopAll();
  144. return success("停止成功!");
  145. } catch (Exception e) {
  146. error(e);
  147. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  148. }
  149. }
  150. /**
  151. * 启动判断的任务
  152. *
  153. * @return
  154. */
  155. @RequestMapping(value = "startCheckSignJob", method = RequestMethod.GET)
  156. public String startCheckSignJob() {
  157. try {
  158. jobService.startCheckSignJob();
  159. return success("启动成功!");
  160. } catch (Exception e) {
  161. error(e);
  162. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  163. }
  164. }
  165. /**
  166. * 停止判断的任务
  167. *
  168. * @return
  169. */
  170. @RequestMapping(value = "stopCheckSignJob", method = RequestMethod.GET)
  171. public String stopCheckSignJob() {
  172. try {
  173. jobService.stopCheckSignJob();
  174. return success("停止成功!");
  175. } catch (Exception e) {
  176. error(e);
  177. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  178. }
  179. }
  180. /**
  181. * 启动所有任务
  182. *
  183. * @return
  184. */
  185. @RequestMapping(value = "startAll", method = RequestMethod.GET)
  186. public String startAll() {
  187. try {
  188. jobService.startAll();
  189. return success("启动成功!");
  190. } catch (Exception e) {
  191. error(e);
  192. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  193. }
  194. }
  195. @RequestMapping(value = "startaaaa", method = RequestMethod.GET)
  196. public String startaaaa() {
  197. try {
  198. jobService.startaaaa();
  199. return success("启动成功!");
  200. } catch (Exception e) {
  201. error(e);
  202. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  203. }
  204. }
  205. }