|
|
|
@ -2,11 +2,12 @@ package cn.estsh.i3plus.core.apiservice.controller;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.icloud.wms.sdk.IWmsScheduleJobCloud;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseResultBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.quartz.IQuartzJobService;
|
|
|
|
|
import cn.estsh.impp.framework.boot.quartz.ScheduleTool;
|
|
|
|
|
import cn.estsh.impp.framework.boot.quartz.TaskInfo;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
@ -19,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :
|
|
|
|
|
* @Description : 定时任务调用demo
|
|
|
|
|
* @Reference :
|
|
|
|
|
* @Author : alwaysfrin
|
|
|
|
|
* @CreateDate : 2018-09-26 10:34
|
|
|
|
@ -38,13 +39,27 @@ public class DemoScheduleController extends CoreBaseController{
|
|
|
|
|
@Autowired
|
|
|
|
|
private IWmsScheduleJobCloud wmsScheduleJobCloud;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据来源切换定时任务服务
|
|
|
|
|
* @param source CommonEnumUtil.SOFT_TYPE
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private IQuartzJobService getJobService(int source){
|
|
|
|
|
IQuartzJobService quartzJobService = scheduleTool;
|
|
|
|
|
|
|
|
|
|
if(source == CommonEnumUtil.SOFT_TYPE.CORE.getValue()){
|
|
|
|
|
//平台定时任务
|
|
|
|
|
quartzJobService = scheduleTool;
|
|
|
|
|
}else if(source == CommonEnumUtil.SOFT_TYPE.WMS.getValue()){
|
|
|
|
|
quartzJobService = wmsScheduleJobCloud;
|
|
|
|
|
}
|
|
|
|
|
return quartzJobService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value="/list-task")
|
|
|
|
|
@ApiOperation(value="查询定时任务",notes="查询所有定时任务")
|
|
|
|
|
public ResultBean listTask(int sourceType){
|
|
|
|
|
List<TaskInfo> taskList = null;
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
//本地任务
|
|
|
|
|
taskList = ScheduleTool.queryJobList(scheduleTool.getScheduler());
|
|
|
|
|
List<TaskInfo> taskList = getJobService(sourceType).listTask().getResultList();
|
|
|
|
|
if(taskList != null) {
|
|
|
|
|
for (TaskInfo ti : taskList) {
|
|
|
|
|
LOGGER.info("任务:{}",ti);
|
|
|
|
@ -52,19 +67,6 @@ public class DemoScheduleController extends CoreBaseController{
|
|
|
|
|
}else{
|
|
|
|
|
LOGGER.info("任务列表为空");
|
|
|
|
|
}
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
//wms任务
|
|
|
|
|
BaseResultBean<TaskInfo> baseResult = wmsScheduleJobCloud.listTask();
|
|
|
|
|
LOGGER.info("任务数量:{}",baseResult.getResultList().size());
|
|
|
|
|
taskList = baseResult.getResultList();
|
|
|
|
|
if (taskList != null) {
|
|
|
|
|
for (TaskInfo ti : taskList) {
|
|
|
|
|
LOGGER.info("任务:{}",ti);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
LOGGER.info("任务列表为空");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true,taskList);
|
|
|
|
|
}
|
|
|
|
@ -73,23 +75,14 @@ public class DemoScheduleController extends CoreBaseController{
|
|
|
|
|
@ApiOperation(value="添加定时任务",notes="添加定时任务")
|
|
|
|
|
public ResultBean addTask(int sourceType,
|
|
|
|
|
String packageName,String className,String jobName,String jobGroup,String cronExpression){
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
scheduleTool.addJob(new TaskInfo(packageName,className,jobName,jobGroup,cronExpression,"测试任务"));
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
wmsScheduleJobCloud.addTask(packageName,className,jobName,jobGroup,cronExpression,"wms新任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.getJobService(sourceType).addTask(packageName,className,jobName,jobGroup,cronExpression,"wms新任务");
|
|
|
|
|
return new ResultBean(true,"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value="/delete-task")
|
|
|
|
|
@ApiOperation(value="删除定时任务",notes="删除定时任务")
|
|
|
|
|
public ResultBean deleteTask(int sourceType,String jobName,String jobGroup){
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
scheduleTool.deleteJob(jobName,jobGroup);
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
wmsScheduleJobCloud.deleteTask(jobName,jobGroup);
|
|
|
|
|
}
|
|
|
|
|
this.getJobService(sourceType).deleteTask(jobName,jobGroup);
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true);
|
|
|
|
|
}
|
|
|
|
@ -97,11 +90,7 @@ public class DemoScheduleController extends CoreBaseController{
|
|
|
|
|
@GetMapping(value="/pause-task")
|
|
|
|
|
@ApiOperation(value="暂停定时任务",notes="暂停定时任务")
|
|
|
|
|
public ResultBean pauseJob(int sourceType,String jobName,String jobGroup){
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
scheduleTool.pauseJob(jobName,jobGroup);
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
wmsScheduleJobCloud.pauseJob(jobName,jobGroup);
|
|
|
|
|
}
|
|
|
|
|
this.getJobService(sourceType).pauseJob(jobName,jobGroup);
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true);
|
|
|
|
|
}
|
|
|
|
@ -109,23 +98,15 @@ public class DemoScheduleController extends CoreBaseController{
|
|
|
|
|
@GetMapping(value="/resume-task")
|
|
|
|
|
@ApiOperation(value="继续定时任务",notes="继续定时任务")
|
|
|
|
|
public ResultBean resumeJob(int sourceType,String jobName,String jobGroup){
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
scheduleTool.resumeJob(jobName,jobGroup);
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
wmsScheduleJobCloud.resumeJob(jobName,jobGroup);
|
|
|
|
|
}
|
|
|
|
|
this.getJobService(sourceType).resumeJob(jobName,jobGroup);
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value="/exceute-task")
|
|
|
|
|
@GetMapping(value="/execeute-task")
|
|
|
|
|
@ApiOperation(value="立即执行定时任务",notes="立即执行定时任务")
|
|
|
|
|
public ResultBean excuteJob(int sourceType,String jobName,String jobGroup){
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
scheduleTool.executeJob(jobName,jobGroup);
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
wmsScheduleJobCloud.excuteJob(jobName,jobGroup);
|
|
|
|
|
}
|
|
|
|
|
public ResultBean executeJob(int sourceType,String jobName,String jobGroup){
|
|
|
|
|
this.getJobService(sourceType).executeJob(jobName,jobGroup);
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true);
|
|
|
|
|
}
|
|
|
|
@ -133,11 +114,7 @@ public class DemoScheduleController extends CoreBaseController{
|
|
|
|
|
@GetMapping(value="/stand-by-schedule")
|
|
|
|
|
@ApiOperation(value="定时器待机",notes="定时器待机")
|
|
|
|
|
public ResultBean restartJob(int sourceType,String jobName,String jobGroup){
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
scheduleTool.standBySchedule();
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
wmsScheduleJobCloud.standBySchedule();
|
|
|
|
|
}
|
|
|
|
|
this.getJobService(sourceType).standBySchedule();
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true);
|
|
|
|
|
}
|
|
|
|
@ -146,11 +123,7 @@ public class DemoScheduleController extends CoreBaseController{
|
|
|
|
|
@GetMapping(value="/start-schedule")
|
|
|
|
|
@ApiOperation(value="启动定时器",notes="启动定时器")
|
|
|
|
|
public ResultBean startSchedule(int sourceType,String jobName,String jobGroup){
|
|
|
|
|
if(sourceType == 1) {
|
|
|
|
|
scheduleTool.startSchedule();
|
|
|
|
|
}else if(sourceType == 2){
|
|
|
|
|
wmsScheduleJobCloud.startSchedule();
|
|
|
|
|
}
|
|
|
|
|
this.getJobService(sourceType).startSchedule();
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true);
|
|
|
|
|
}
|
|
|
|
|