!9 定时遍历task_task中间表实现定期发起满足条件的流程
Merge pull request !9 from new_new_new/feature/quartz-task-job
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
package org.jeecg.modules.quartz.job;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.extbpm.process.entity.ExtActProcessForm;
|
||||
import org.jeecg.modules.extbpm.process.service.impl.BpmBaseExtApiImpl;
|
||||
import org.jeecg.modules.extbpm.process.service.impl.ExtActProcessServiceImpl;
|
||||
import org.jeecg.modules.tasktask.constant.FlowConstants;
|
||||
import org.jeecg.modules.tasktask.entity.TaskTask;
|
||||
import org.jeecg.modules.tasktask.service.ITaskTaskService;
|
||||
import org.jeecg.modules.tasktask.service.impl.TaskTaskServiceImpl;
|
||||
import org.quartz.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Description: 同步定时任务测试
|
||||
* <p>
|
||||
* 此处的同步是指 当定时任务的执行时间大于任务的时间间隔时
|
||||
* 会等待第一个任务执行完成才会走第二个任务
|
||||
* @author: taoyan
|
||||
* @date: 2020年06月19日
|
||||
*/
|
||||
@PersistJobDataAfterExecution
|
||||
@DisallowConcurrentExecution
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TaskJob implements Job {
|
||||
@Autowired
|
||||
private TaskTaskServiceImpl taskTaskServiceImpl;
|
||||
@Autowired
|
||||
private BpmBaseExtApiImpl bpmBaseExtApiImpl;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
log.info(" --- 周期性遍历taskTask表 --- ");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<TaskTask> executeTaskTaskList = taskTaskServiceImpl.lambdaQuery().eq(TaskTask::getBpmStatus, 1).eq(TaskTask::getTriggerType, FlowConstants.Strategy.RECURRING_ONLY).lt(TaskTask::getStartTime, now).list();
|
||||
log.info(" --- 待发起流程为 --- " + executeTaskTaskList.toString());
|
||||
for (TaskTask executeTaskTask : executeTaskTaskList) {
|
||||
try {
|
||||
|
||||
bpmBaseExtApiImpl.startMutilProcess(executeTaskTask.getFlowCode(), executeTaskTask.getId(), executeTaskTask.getFormUrl(), executeTaskTask.getFormUrl(), executeTaskTask.getCreateBy(), JSON.toJSONString(executeTaskTask.getJsonData()));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
log.info(" --- 执行完毕,时间:" + LocalDateTime.now() + "---");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user