增加 BpmProcessInstanceResultEvent 实现,实现自定义的流程实例的状态的监听
parent
7c62b1a211
commit
5437775172
@ -1,18 +1,21 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||||
|
|
||||||
import lombok.*;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.*;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.AssertTrue;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
@ApiModel("请假申请创建 Request VO")
|
@ApiModel("请假申请创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class BpmOALeaveCreateReqVO extends BpmOALeaveBaseVO {
|
public class BpmOALeaveCreateReqVO extends BpmOALeaveBaseVO {
|
||||||
|
|
||||||
|
@AssertTrue(message = "结束时间,需要在开始时间之后")
|
||||||
|
public boolean isEndTimeValid() {
|
||||||
|
return !getEndTime().before(getStartTime());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BpmProcessInstanceResultEvent} 的监听器
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public abstract class BpmProcessInstanceResultEventListener
|
||||||
|
implements ApplicationListener<BpmProcessInstanceResultEvent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void onApplicationEvent(BpmProcessInstanceResultEvent event) {
|
||||||
|
if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 返回监听的流程定义 Key
|
||||||
|
*/
|
||||||
|
protected abstract String getProcessDefinitionKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理事件
|
||||||
|
*
|
||||||
|
* @param event 事件
|
||||||
|
*/
|
||||||
|
protected abstract void onEvent(BpmProcessInstanceResultEvent event);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BpmProcessInstanceResultEvent} 的生产者
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Validated
|
||||||
|
public class BpmProcessInstanceResultEventPublisher {
|
||||||
|
|
||||||
|
private final ApplicationEventPublisher publisher;
|
||||||
|
|
||||||
|
public void sendProcessInstanceResultEvent(@Valid BpmProcessInstanceResultEvent event) {
|
||||||
|
publisher.publishEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.listener;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventListener;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.OALeaveServiceImpl;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OA 请假单的结果的监听器实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class BpmOALeaveResultListener extends BpmProcessInstanceResultEventListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmOALeaveService leaveService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getProcessDefinitionKey() {
|
||||||
|
return OALeaveServiceImpl.PROCESS_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEvent(BpmProcessInstanceResultEvent event) {
|
||||||
|
leaveService.updateLeaveResult(Long.parseLong(event.getBusinessKey()), event.getResult());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue