• 大小: 43.54MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-10
  • 语言: Java
  • 标签: java  scheduler  

资源简介

可以通过少量修改直接融入到已有的java项目,有维护定时器的界面,包括新增修改删除,立即执行,暂停,恢复等功能,省去了项目中大量配置定时器的繁琐,而且便于维护

资源截图

代码片段和文件信息

package com.trustfar.collector.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trustfar.collector.domain.ScheduleJobEntity;
import com.trustfar.collector.service.ScheduleJobService;
import com.trustfar.collector.utils.MyException;
import com.trustfar.collector.utils.PageUtils;
import com.trustfar.collector.utils.R;

/**
 * 定时任务
 * @author 李文军
 *
 */
@Controller
@RequestMapping(“/sys/schedule“)
public class ScheduleJobAction {
@Autowired
private ScheduleJobService scheduleJobService;

/**
 * 定时任务列表
 */
@RequestMapping(“/list.do“)
@ResponseBody
public R list(Integer page Integer limit){
Mapject> map = new HashMapject>();
map.put(“offset“ (page - 1) * limit);
map.put(“limit“ limit*page);

//查询列表数据
List jobList = scheduleJobService.queryList(map);
int total = scheduleJobService.queryTotal(map);

PageUtils pageUtil = new PageUtils(jobList total limit page);

return R.ok().put(“page“ pageUtil);
}

/**
 * 定时任务信息
 */
@RequestMapping(“/info/{jobId}.do“)
@ResponseBody
public R info(@PathVariable(“jobId“) Long jobId){
ScheduleJobEntity schedule = scheduleJobService.queryobject(jobId);

return R.ok().put(“schedule“ schedule);
}

/**
 * 保存定时任务
 */
@RequestMapping(“/save.do“)
@ResponseBody
public R save(@RequestBody ScheduleJobEntity scheduleJob){
//数据校验
verifyForm(scheduleJob);

scheduleJobService.save(scheduleJob);

return R.ok();
}

/**
 * 修改定时任务
 */
@RequestMapping(“/update.do“)
@ResponseBody
public R update(@RequestBody ScheduleJobEntity scheduleJob){
//数据校验
verifyForm(scheduleJob);

scheduleJobService.update(scheduleJob);

return R.ok();
}

/**
 * 删除定时任务
 */
@RequestMapping(“/delete.do“)
@ResponseBody
public R delete(@RequestBody Long[] jobIds){
scheduleJobService.deleteBatch(jobIds);

return R.ok();
}

/**
 * 立即执行任务
 */
@RequestMapping(“/run.do“)
@ResponseBody
public R run(@RequestBody Long[] jobIds){
scheduleJobService.run(jobIds);

return R.ok();
}

/**
 * 暂停定时任务
 */
@RequestMapping(“/pause.do“)
@ResponseBody
public R pause(@RequestBody Long[] jobIds){
scheduleJobService.pause(jobIds);

return R.ok();
}

/**
 * 恢复定时任务
 */
@RequestMapping(“/resume.do“)
@ResponseBody
public R resume(@RequestBody Long[] jobIds){
scheduleJobService.resume(jobIds);

return R.ok();
}

/**
 * 验证参数是否正确
 */
pri

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-08-28 16:38  citic_scheduler\
     文件        5435  2018-08-28 16:39  citic_scheduler\.classpath
     文件         313  2017-04-11 08:47  citic_scheduler\.mymetadata
     文件        1625  2018-08-28 16:39  citic_scheduler\.project
     目录           0  2018-08-28 16:39  citic_scheduler\.settings\
     文件         522  2018-08-28 16:39  citic_scheduler\.settings\.jsdtscope
     文件        1040  2017-04-11 08:47  citic_scheduler\.settings\com.genuitec.eclipse.j2eedt.core.prefs
     文件         423  2018-08-28 16:39  citic_scheduler\.settings\com.genuitec.eclipse.migration.prefs
     文件         285  2017-04-07 18:21  citic_scheduler\.settings\org.eclipse.core.resources.prefs
     文件         629  2017-04-06 11:21  citic_scheduler\.settings\org.eclipse.jdt.core.prefs
     文件         644  2018-08-28 16:39  citic_scheduler\.settings\org.eclipse.wst.common.component
     文件         412  2018-08-28 16:39  citic_scheduler\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-08-28 16:39  citic_scheduler\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-08-28 16:39  citic_scheduler\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\
     文件           3  2017-04-11 08:53  citic_scheduler\.svn\entries
     文件           3  2017-04-11 08:53  citic_scheduler\.svn\format
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\pristine\
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\pristine\00\
     文件        3798  2017-04-11 08:53  citic_scheduler\.svn\pristine\00\00783069ce1edf9f02b3361499bc85e832154269.svn-base
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\pristine\01\
     文件      863065  2017-04-11 08:53  citic_scheduler\.svn\pristine\01\01a80f0e1405219a19cf3e1b30812f73de8e117d.svn-base
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\pristine\02\
     文件        4467  2017-04-11 08:53  citic_scheduler\.svn\pristine\02\0235ba8b489512805ac13a8f9ea77a1ca5ebe3e8.svn-base
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\pristine\03\
     文件         248  2017-04-11 08:53  citic_scheduler\.svn\pristine\03\0345dbda6bc8f37b05a5e0249d618571b6a90e9b.svn-base
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\pristine\04\
     文件      134808  2017-04-11 08:53  citic_scheduler\.svn\pristine\04\048707bc52ac4b6563aaa383bfe8660a0ddc908c.svn-base
     文件        1991  2017-04-11 08:53  citic_scheduler\.svn\pristine\04\04b358f5fc6fd5ed93037057defd44fc55d65f1d.svn-base
     目录           0  2018-08-28 16:38  citic_scheduler\.svn\pristine\06\
     文件        1754  2017-04-11 08:53  citic_scheduler\.svn\pristine\06\0668777d54ac00ba73197955fbbf9439a2b01f19.svn-base
............此处省略599个文件信息

评论

共有 条评论