|
@@ -1,46 +1,59 @@
|
|
package com.xt.dsp.controller;
|
|
package com.xt.dsp.controller;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import org.h2.util.StringUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
+import com.xt.dsp.common.util.CommonUtil;
|
|
|
|
+import com.xt.dsp.model.TaskBean;
|
|
|
|
+import com.xt.dsp.service.TaskService;
|
|
|
|
+import com.xt.dsp.service.TaskSqlService;
|
|
|
|
+import com.xt.dsp.vo.TaskVo;
|
|
import com.yuanxd.tools.io.http.JsonResult;
|
|
import com.yuanxd.tools.io.http.JsonResult;
|
|
|
|
+import com.yuanxd.tools.pagehelper.PageHelper;
|
|
|
|
+import com.yuanxd.tools.pagehelper.PageInfo;
|
|
|
|
|
|
@Controller
|
|
@Controller
|
|
@RequestMapping("task")
|
|
@RequestMapping("task")
|
|
public class TaskCtl {
|
|
public class TaskCtl {
|
|
-// @Autowired
|
|
|
|
-// private TaskService taskService;
|
|
|
|
-// @Autowired
|
|
|
|
-// private TaskSqlService taskSqlService;
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private TaskService taskService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TaskSqlService taskSqlService;
|
|
|
|
|
|
@RequestMapping("run/{code}")
|
|
@RequestMapping("run/{code}")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public JsonResult runTask(@PathVariable String code, String condition) {
|
|
public JsonResult runTask(@PathVariable String code, String condition) {
|
|
-// TaskBean task = taskService.selectByCode(code);
|
|
|
|
|
|
+ TaskBean task = taskService.selectByCode(code);
|
|
JsonResult result = new JsonResult();
|
|
JsonResult result = new JsonResult();
|
|
-// if (task == null) {
|
|
|
|
-// result.setSuccess(false);
|
|
|
|
-// result.setMessage("任务不存在:" + code);
|
|
|
|
-// return result;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if (TaskBean.TYPE_SQL.equals(task.getType())) {
|
|
|
|
-// int res = -1;
|
|
|
|
-// try {
|
|
|
|
-// res = taskSqlService.runTask(task, condition);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// e.printStackTrace();
|
|
|
|
-// result.setSuccess(false);
|
|
|
|
-// result.setMessage(e.getMessage());
|
|
|
|
-// return result;
|
|
|
|
-// }
|
|
|
|
-// if (res == 0) {
|
|
|
|
-// result.setSuccess(true);
|
|
|
|
-// return result;
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
|
|
+ if (task == null) {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("任务不存在:" + code);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (TaskBean.TYPE_SQL.equals(task.getType())) {
|
|
|
|
+ int res = -1;
|
|
|
|
+ try {
|
|
|
|
+ res = taskSqlService.runTask(task, condition);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ if (res == 0) {
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
result.setSuccess(false);
|
|
result.setSuccess(false);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -54,31 +67,67 @@ public class TaskCtl {
|
|
return "rwgl/task/task";
|
|
return "rwgl/task/task";
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
|
|
+ /**
|
|
* 初始化页面加载数据
|
|
* 初始化页面加载数据
|
|
*/
|
|
*/
|
|
- public String initTask() {
|
|
|
|
- /*String wldwCode = getReqStr("wldwCode");
|
|
|
|
- String wldwName = getReqStr("wldwName");
|
|
|
|
- String dataFlg = getReqStr("dataFlg");
|
|
|
|
- if (wldwdyForm == null) {
|
|
|
|
- wldwdyForm = new WldwdyForm();
|
|
|
|
- }
|
|
|
|
- Map<String, String> mapParam = new HashMap<String, String>();
|
|
|
|
- mapParam.put("wldwCode", wldwCode.trim());
|
|
|
|
- mapParam.put("wldwName", wldwName.trim());
|
|
|
|
- if (!StringUtil.isBlank(dataFlg)) {
|
|
|
|
- mapParam.put("dataFlg", "Y");
|
|
|
|
- mapParam.put("statusFlg", DictionaryConst.Status.ADD);
|
|
|
|
- mapParam.put("cFlg", DictionaryConst.CancelFlag.NO);
|
|
|
|
- }
|
|
|
|
- // 获取带分页信息的数据
|
|
|
|
- PageList<WldwdyBean> dataList = wldwdyService.queryByConditions(wldwdyForm, mapParam);
|
|
|
|
- // 生成分页数据
|
|
|
|
- createPagingJsonResult(dataList);
|
|
|
|
-
|
|
|
|
- return PAGING;*/
|
|
|
|
- return "";
|
|
|
|
|
|
+ @RequestMapping("initTask")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public PageInfo<TaskBean> initTask(Model model,TaskVo vo) {
|
|
|
|
+ // 初始化参数
|
|
|
|
+ if (vo.getPage() < 1) {
|
|
|
|
+ vo.setPage(1);
|
|
|
|
+ }
|
|
|
|
+ if (vo.getRows() < 1) {
|
|
|
|
+ vo.setRows(1);
|
|
|
|
+ }
|
|
|
|
+ PageHelper.startPage(vo.getPage(), vo.getRows());
|
|
|
|
+ List<TaskBean> list = taskService.selectByJobCode(vo.getCode());
|
|
|
|
+ PageInfo<TaskBean> pageResult = new PageInfo<>(list);
|
|
|
|
+ return pageResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存实体
|
|
|
|
+ * @param vo
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("save")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public TaskBean saveTask(Model model,TaskVo vo) {
|
|
|
|
+ TaskBean saveBean = new TaskBean();
|
|
|
|
+ // 新增
|
|
|
|
+ if(StringUtils.isNullOrEmpty(vo.getId())) {
|
|
|
|
+ BeanUtils.copyProperties(vo, saveBean);
|
|
|
|
+ saveBean.setId(CommonUtil.getUUID());
|
|
|
|
+ //saveBean.setStatus("0");
|
|
|
|
+ } else {
|
|
|
|
+ // 修改
|
|
|
|
+ saveBean = taskService.selectByCode(vo.getId());
|
|
|
|
+ saveBean.setName(vo.getName());
|
|
|
|
+ saveBean.setCode(vo.getCode());
|
|
|
|
+ }
|
|
|
|
+ //taskService.save(saveBean);
|
|
|
|
+ return saveBean;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 初始化页面加载数据
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("initEditTask")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public TaskBean initEditTask(Model model, String id) {
|
|
|
|
+ TaskBean bean = null;//taskService.(arg0).selectByCode(arg0);
|
|
|
|
+ return bean;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除数据
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("delTask")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public TaskBean delTask(Model model, String ids) {
|
|
|
|
+ TaskBean bean = null;//taskService.findOne(ids);
|
|
|
|
+ return bean;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|