Commit bc45a923 by huangfusuper

发布工作流添加到实例表完成事件

parent 0bde4d3b
package com.byit.service.impl;
import com.byit.enums.FlowPropertyEnum;
import com.byit.event.FlowScanEndEvent;
import com.byit.job.utils.CronExpression;
import com.byit.model.Flow;
import com.byit.model.JobTask;
......@@ -12,6 +13,8 @@ import com.byit.service.RunNodeServer;
import com.byit.service.RunRecordingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -28,10 +31,11 @@ import java.util.UUID;
@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
@Slf4j
public class RunNodeServiceImpl implements RunNodeServer {
public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublisherAware {
private final RunRecordingService runRecordingService;
private final JobTaskService jobTaskService;
private final FlowService flowService;
private ApplicationEventPublisher applicationEventPublisher;
public RunNodeServiceImpl(RunRecordingService runRecordingService, JobTaskService jobTaskService,
FlowService flowService) {
......@@ -53,6 +57,7 @@ public class RunNodeServiceImpl implements RunNodeServer {
RunRecording build = new RunRecording();
BeanUtils.copyProperties(flow,build);
build.setRunId(runId);
//TODO 这个不解释 不知道干嘛的 后续需要修改
build.setDispatchIp("127.0.0.1");
build.setFlowVersionName(flow.getVersionName());
build.setTriggerTime(flow.getTriggerNextTime());
......@@ -75,7 +80,7 @@ public class RunNodeServiceImpl implements RunNodeServer {
jobTaskService.saveJobTasks(jobTasks);
log.info("-------------【开始修改工作流{}的下次运行时间,以及各种状态】---------------",flow);
updateFlow(flow);
applicationEventPublisher.publishEvent(new FlowScanEndEvent(this,flow.getFlowId()));
log.info("-------saveRunRecAndTaskAndUpdate end-----------【运行结束】-----------------");
......@@ -100,7 +105,16 @@ public class RunNodeServiceImpl implements RunNodeServer {
e.printStackTrace();
}
flow.setTriggerNextTime(nextValidTime!=null?nextValidTime.getTime():999999999999L);
flow.setScanMark(FlowPropertyEnum.NOT_SCAN.getCode());
//flow.setScanMark(FlowPropertyEnum.NOT_SCAN.getCode())
flowService.updateByIdSelective(flow);
}
/**
* 设置时间发布器
* @param applicationEventPublisher
*/
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment