TaskCtl.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.xt.dsp.controller;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Controller;
  4. import org.springframework.web.bind.annotation.PathVariable;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.ResponseBody;
  7. import com.xt.dsp.model.TaskBean;
  8. import com.xt.dsp.service.TaskService;
  9. import com.xt.dsp.service.TaskSqlService;
  10. import com.yuanxd.tools.io.http.JsonResult;
  11. @Controller
  12. @RequestMapping("task")
  13. public class TaskCtl {
  14. @Autowired
  15. private TaskService taskService;
  16. @Autowired
  17. private TaskSqlService taskSqlService;
  18. @RequestMapping("run/{code}")
  19. @ResponseBody
  20. public JsonResult runTask(@PathVariable String code, String condition) {
  21. TaskBean task = taskService.selectByCode(code);
  22. JsonResult result = new JsonResult();
  23. if (task == null) {
  24. result.setSuccess(false);
  25. result.setMessage("任务不存在:" + code);
  26. }
  27. if (TaskBean.TYPE_SQL.equals(task.getType())) {
  28. int res = taskSqlService.runTask(task, condition);
  29. if (res == 0) {
  30. result.setSuccess(true);
  31. return result;
  32. }
  33. }
  34. result.setSuccess(false);
  35. return result;
  36. }
  37. }