diff --git a/hw-modules/hw-job/src/main/java/com/hw/job/controller/SysJobController.java b/hw-modules/hw-job/src/main/java/com/hw/job/controller/SysJobController.java index de422aea..fbc1a0bf 100644 --- a/hw-modules/hw-job/src/main/java/com/hw/job/controller/SysJobController.java +++ b/hw-modules/hw-job/src/main/java/com/hw/job/controller/SysJobController.java @@ -3,6 +3,8 @@ package com.hw.job.controller; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.hw.common.security.annotation.InnerAuth; import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; @@ -116,7 +118,7 @@ public class SysJobController extends BaseController return error("新增任务'" + job.getJobName() + "'失败,目标字符串不在白名单内"); } job.setCreateBy(SecurityUtils.getUsername()); - return toAjax(jobService.insertJob(job)); + return success(jobService.insertJob(job)); } /** @@ -192,4 +194,6 @@ public class SysJobController extends BaseController return success(); } + + } diff --git a/hw-modules/hw-job/src/main/java/com/hw/job/controller/SysJobInnerController.java b/hw-modules/hw-job/src/main/java/com/hw/job/controller/SysJobInnerController.java new file mode 100644 index 00000000..84773ac4 --- /dev/null +++ b/hw-modules/hw-job/src/main/java/com/hw/job/controller/SysJobInnerController.java @@ -0,0 +1,139 @@ +package com.hw.job.controller; + +import com.hw.common.core.constant.Constants; +import com.hw.common.core.exception.job.TaskException; +import com.hw.common.core.utils.StringUtils; +import com.hw.common.core.web.controller.BaseController; +import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.log.annotation.Log; +import com.hw.common.log.enums.BusinessType; +import com.hw.common.security.annotation.InnerAuth; +import com.hw.common.security.annotation.RequiresPermissions; +import com.hw.common.security.utils.SecurityUtils; +import com.hw.job.domain.SysJob; +import com.hw.job.service.ISysJobService; +import com.hw.job.util.CronUtils; +import com.hw.job.util.ScheduleUtils; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 调度任务信息内部接口 + * + * @author xins + */ +@RestController +@RequestMapping("/jobinner") +public class SysJobInnerController extends BaseController +{ + @Autowired + private ISysJobService jobService; + + //根据planrepairid查询job + @InnerAuth + @PostMapping("/jobByPlanRepairId") + public SysJob selectJobByPlanRepairId(@RequestBody Long planRepairId) + { + SysJob sysJob = jobService.selectJobByPlanRepairId(planRepairId); + return sysJob; + } + + /** + * 新增定时任务 + */ + @InnerAuth + @Log(title = "定时任务", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(job.getCronExpression())) + { + return error("新增任务'" + job.getJobName() + "'失败,Cron表达式不正确"); + } + else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS })) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap(s)'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串存在违规"); + } + else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) + { + return error("新增任务'" + job.getJobName() + "'失败,目标字符串不在白名单内"); + } + job.setCreateBy(SecurityUtils.getUsername()); + return success(jobService.insertJob(job)); + } + + + + + /** + * 修改定时任务 + */ + @InnerAuth + @Log(title = "定时任务", businessType = BusinessType.UPDATE) + @PostMapping("/update") + public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(job.getCronExpression())) + { + return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确"); + } + else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS })) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap(s)'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用"); + } + else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串存在违规"); + } + else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) + { + return error("修改任务'" + job.getJobName() + "'失败,目标字符串不在白名单内"); + } + job.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(jobService.updateJob(job)); + } + + + /** + * 删除定时任务 + */ + @InnerAuth + @Log(title = "定时任务", businessType = BusinessType.DELETE) + @PostMapping("/remove/{jobIds}") + public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException + { + jobService.deleteJobByIds(jobIds); + return success(); + } + + + @InnerAuth + @GetMapping("/info/{jobId}") + public SysJob selectJobByJobId(@PathVariable("jobId") Long jobId) + { + SysJob sysJob = jobService.selectJobById(jobId); + return sysJob; + } +} diff --git a/hw-modules/hw-job/src/main/java/com/hw/job/service/SysJobServiceImpl.java b/hw-modules/hw-job/src/main/java/com/hw/job/service/SysJobServiceImpl.java index b914c6d0..e2113b51 100644 --- a/hw-modules/hw-job/src/main/java/com/hw/job/service/SysJobServiceImpl.java +++ b/hw-modules/hw-job/src/main/java/com/hw/job/service/SysJobServiceImpl.java @@ -210,6 +210,7 @@ public class SysJobServiceImpl implements ISysJobService if (rows > 0) { ScheduleUtils.createScheduleJob(scheduler, job); + return job.getJobId().intValue(); } return rows; } diff --git a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java index 16d952ff..474b074a 100644 --- a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java +++ b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java @@ -56,13 +56,13 @@ public class RyTask System.out.println("++创建巡检工单++getDmsRepairInstance"); remoteDmsService.getDmsBillsInstance(SecurityConstants.INNER, dmsBillsInstanceId); } - public void getDmsBillsLube(String planInspectId){ - System.out.println("++创建润滑工单++getDmsRepairInstance"); - remoteDmsService.getDmsBillsLube(SecurityConstants.INNER, planInspectId); + public void getDmsBillsLube(String planLubeCode){ + System.out.println("++创建润滑工单++getDmsLubeInstance"); + remoteDmsService.getDmsBillsLube(SecurityConstants.INNER, planLubeCode); } - public void getDmsBillsMaint(String dmsBillsMaintId){ + public void getDmsBillsMaint(String planMaintCode){ System.out.println("++创建保养工单++getDmsMaintInstance"); - remoteDmsService.getDmsBillsMaintInstance(SecurityConstants.INNER,dmsBillsMaintId); + remoteDmsService.getDmsBillsMaintInstance(SecurityConstants.INNER,planMaintCode); }