JobController.java 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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 io.swagger.annotations.ApiOperation;
  6. import io.swagger.annotations.ApiParam;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.http.MediaType;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. import org.springframework.web.bind.annotation.RequestParam;
  12. import org.springframework.web.bind.annotation.RestController;
  13. /**
  14. * 任务启动
  15. *
  16. * @author chenweida
  17. */
  18. @RestController
  19. @RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  20. @Api(description = "后台-任务控制")
  21. public class JobController extends BaseController {
  22. @Autowired
  23. private JobService jobService;
  24. /**
  25. * 启动任务
  26. *
  27. * @param id id
  28. * @return
  29. */
  30. @ApiOperation(value = "根据ID立即单个任务")
  31. @RequestMapping(value = "startNowById", method = RequestMethod.GET)
  32. public String startNowById(
  33. @ApiParam(name = "id", value = "任务ID", required = true)@RequestParam(value = "id", required = true) String id) {
  34. try {
  35. jobService.startNowById(id);
  36. return success("启动成功!");
  37. } catch (Exception e) {
  38. error(e);
  39. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  40. }
  41. }
  42. /**
  43. * 生成过去几天的数据
  44. *
  45. * @param day
  46. * @return
  47. */
  48. @ApiOperation(value = "生成过去几天的数据")
  49. @RequestMapping(value = "productDataByDay", method = RequestMethod.GET)
  50. public String productDataByDay( @ApiParam(name = "day", value = "距离今天的天数(如果是要生成昨天的数据,day=1)")@RequestParam(value = "day", required = true) int day) {
  51. try {
  52. jobService.productDataByDay(day);
  53. return success("启动成功!");
  54. } catch (Exception e) {
  55. error(e);
  56. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  57. }
  58. }
  59. /**
  60. * 生成过去某一天的全部的数据
  61. *
  62. * @param day
  63. * @return
  64. */
  65. @ApiOperation(value = "生成过去某一天的全部的数据")
  66. @RequestMapping(value = "productDataByOneDay", method = RequestMethod.GET)
  67. public String productDataByOneDay( @ApiParam(name = "day", value = "yyyy-MM-dd")@RequestParam(value = "day", required = true)String day) {
  68. try {
  69. jobService.productDataByOneDay(day);
  70. return success("启动成功!");
  71. } catch (Exception e) {
  72. error(e);
  73. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  74. }
  75. }
  76. /**
  77. * 生成过去某一天到某一天的全部的数据
  78. *
  79. * @param start
  80. * @param end
  81. * @return
  82. */
  83. @ApiOperation(value = "生成过去某一天到某一天的全部的数据")
  84. @RequestMapping(value = "productDataByDayToDay", method = RequestMethod.GET)
  85. public String productDataByDayToDay( @ApiParam(name = "day", value = "yyyy-MM-dd")@RequestParam(value = "start", required = true)String start,
  86. @ApiParam(name = "day", value = "yyyy-MM-dd")@RequestParam(value = "end", required = true)String end) {
  87. try {
  88. jobService.productDataByDayToDay(start,end);
  89. return success("启动成功!");
  90. } catch (Exception e) {
  91. error(e);
  92. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  93. }
  94. }
  95. /**
  96. * 生成过去某一天的某一个指标的数据
  97. *
  98. * @param day
  99. * @return
  100. */
  101. @ApiOperation(value = "生成过去某一天的全部的数据")
  102. @RequestMapping(value = "productDataByOneDayWithId", method = RequestMethod.GET)
  103. public String productDataByOneDayWithId(
  104. @ApiParam(name = "day", value = "yyyy-MM-dd")@RequestParam(value = "day", required = true)String day,
  105. @ApiParam(name = "id", value = "任务id")@RequestParam(value = "id", required = true)String id) {
  106. try {
  107. jobService.productDataByOneDayWithId(day, id);
  108. return success("启动成功!");
  109. } catch (Exception e) {
  110. error(e);
  111. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  112. }
  113. }
  114. /**
  115. * 生成过去到现在的全部的数据
  116. *
  117. * @param day
  118. * @return
  119. */
  120. @ApiOperation(value = "生成过去到现在的全部的数据")
  121. @RequestMapping(value = "productDataByDayAndId", method = RequestMethod.GET)
  122. public String productDataByDayAndId(
  123. @ApiParam(name = "day", value = "距离今天的天数(如果是要生成昨天的数据,day=1)")@RequestParam(value = "day", required = true) int day,
  124. @ApiParam(name="id",required=true)@RequestParam(value = "id", required = true) String id) {
  125. try {
  126. jobService.productDataByDayAndId(day, id);
  127. return success("启动成功!");
  128. } catch (Exception e) {
  129. error(e);
  130. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  131. }
  132. }
  133. /**
  134. * 启动任务
  135. *
  136. * @param id id
  137. * @return
  138. */
  139. @ApiOperation(value = "启动单个任务")
  140. @RequestMapping(value = "startById", method = RequestMethod.GET)
  141. public String startById(
  142. @ApiParam(name="id",value="任务id",required=true)@RequestParam(value = "id", required = true) String id) {
  143. try {
  144. jobService.startById(id);
  145. return success("启动成功!");
  146. } catch (Exception e) {
  147. error(e);
  148. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  149. }
  150. }
  151. /**
  152. * 停止任务
  153. *
  154. * @param id id
  155. * @return
  156. */
  157. @ApiOperation(value = "停止单个任务")
  158. @RequestMapping(value = "stopById", method = RequestMethod.GET)
  159. public String stopById(@ApiParam(name="id",value="任务id",required=true)@RequestParam(value = "id", required = true)String id) {
  160. try {
  161. jobService.stopById(id);
  162. return success("停止成功!");
  163. } catch (Exception e) {
  164. error(e);
  165. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  166. }
  167. }
  168. /**
  169. * 停止所有任务
  170. *
  171. * @return
  172. */
  173. @ApiOperation(value = "停止所有任务")
  174. @RequestMapping(value = "stopAll", method = RequestMethod.GET)
  175. public String stopAll() {
  176. try {
  177. jobService.stopAll();
  178. return success("停止成功!");
  179. } catch (Exception e) {
  180. error(e);
  181. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  182. }
  183. }
  184. /**
  185. * 启动判断的任务
  186. *
  187. * @return
  188. */
  189. @ApiOperation(value = "启动檢查的任务")
  190. @RequestMapping(value = "startCheckSignJob", method = RequestMethod.GET)
  191. public String startCheckSignJob() {
  192. try {
  193. jobService.startCheckSignJob();
  194. return success("启动成功!");
  195. } catch (Exception e) {
  196. error(e);
  197. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  198. }
  199. }
  200. /**
  201. * 停止判断的任务
  202. *
  203. * @return
  204. */
  205. @ApiOperation(value = "停止檢查的任务")
  206. @RequestMapping(value = "stopCheckSignJob", method = RequestMethod.GET)
  207. public String stopCheckSignJob() {
  208. try {
  209. jobService.stopCheckSignJob();
  210. return success("停止成功!");
  211. } catch (Exception e) {
  212. error(e);
  213. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  214. }
  215. }
  216. /**
  217. * 启动所有任务
  218. *
  219. * @return
  220. */
  221. @ApiOperation(value = "启动所有任务")
  222. @RequestMapping(value = "startAll", method = RequestMethod.GET)
  223. public String startAll() {
  224. try {
  225. jobService.startAll();
  226. return success("启动成功!");
  227. } catch (Exception e) {
  228. error(e);
  229. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  230. }
  231. }
  232. //@RequestMapping(value = "startaaaa", method = RequestMethod.GET)
  233. public String startaaaa() {
  234. try {
  235. jobService.startaaaa();
  236. return success("启动成功!");
  237. } catch (Exception e) {
  238. error(e);
  239. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  240. }
  241. }
  242. }