JOB:设备管理定时任务完善
master
xins 7 months ago
parent 7f566937ec
commit bf30eb5574

@ -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();
}
}

@ -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;
}
}

@ -210,6 +210,7 @@ public class SysJobServiceImpl implements ISysJobService
if (rows > 0)
{
ScheduleUtils.createScheduleJob(scheduler, job);
return job.getJobId().intValue();
}
return rows;
}

@ -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);
}

Loading…
Cancel
Save