JobController.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.yihu.figure.controller.job;
  2. import com.yihu.figure.controller.BaseController;
  3. import com.yihu.figure.service.JobService;
  4. import io.swagger.annotations.Api;
  5. import io.swagger.annotations.ApiOperation;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.http.MediaType;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import org.springframework.web.bind.annotation.RestController;
  11. /**
  12. * 任务启动
  13. *
  14. * @author chenweida
  15. */
  16. @RestController
  17. @RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  18. @Api(description = "后台-任务控制")
  19. public class JobController extends BaseController {
  20. @Autowired
  21. private JobService jobService;
  22. @ApiOperation(value = "启动自动生成体征数据任务")
  23. @RequestMapping(value = "startHealthJob", method = RequestMethod.GET)
  24. public String startHealthJob() {
  25. try {
  26. jobService.startHealthJob();
  27. return success("启动成功!");
  28. } catch (Exception e) {
  29. error(e);
  30. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  31. }
  32. }
  33. @ApiOperation(value = "停止自动生成体征数据任务")
  34. @RequestMapping(value = "stopHealthJob", method = RequestMethod.GET)
  35. public String stopHealthJob() {
  36. try {
  37. jobService.stopHealthJob();
  38. return success("停止成功!");
  39. } catch (Exception e) {
  40. error(e);
  41. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  42. }
  43. }
  44. }