Commit 4b320574 by huangfusuper

添加完结工作流的时间信息和事件监听

parent 231461e7
package com.byit.event;
import org.springframework.context.ApplicationEvent;
/**
* 完结工作流的事件
* @author huangfu
*/
public class EndFlowEvent extends ApplicationEvent {
private Integer flowId;
/**
* 创建工作流完结的事件
*
* @param source the object on which the event initially occurred (never {@code null})
* @param flowId 工作流id
*/
public EndFlowEvent(Object source,Integer flowId) {
super(source);
this.flowId = flowId;
}
public Integer getFlowId() {
return flowId;
}
}
package com.byit.listener;
import com.byit.enums.FlowPropertyEnum;
import com.byit.event.EndFlowEvent;
import com.byit.model.Flow;
import com.byit.service.FlowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
/**
* 工作流的事件监听操作
* @author huangfu
*/
@Component
@Slf4j
public class FlowEventListener {
private final FlowService flowService;
public FlowEventListener(FlowService flowService) {
this.flowService = flowService;
}
/**
* 工作流完成事件监听
* @param endFlowEvent 事件信息
*/
@EventListener
public void flowEndEvent(EndFlowEvent endFlowEvent){
log.info("-----------监听到事件{},工作流实例完成事件-------",endFlowEvent);
Flow flow = Flow.builder()
.flowId(endFlowEvent.getFlowId())
.scanMark(FlowPropertyEnum.SCAN.getCode())
.build();
flowService.updateByIdSelective(flow);
}
}
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