update - 添加任务扩展记录表,记录每个节点审批通过的人
This commit is contained in:
parent
954f36d982
commit
1418b3ef68
@ -1,28 +0,0 @@
|
||||
package cn.axzo.workflow.core.common.enums;
|
||||
|
||||
public enum BpmnProcessInstanceStatusEnum {
|
||||
RUNNING(1, "进行中"),
|
||||
FINISH(2, "已完成");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String desc;
|
||||
|
||||
BpmnProcessInstanceStatusEnum(Integer status, String desc) {
|
||||
this.status = status;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package cn.axzo.workflow.core.common.enums;
|
||||
|
||||
import cn.axzo.framework.rocketmq.Event;
|
||||
|
||||
/**
|
||||
* Flowable Event Enum For RocketMQ
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/9/4 10:38
|
||||
*/
|
||||
public enum FlowableEventModuleEnum {
|
||||
PROCESS_CREATED("process", "process-created", "流程创建"),
|
||||
;
|
||||
|
||||
private final String module;
|
||||
|
||||
private final String tag;
|
||||
|
||||
private final String desc;
|
||||
|
||||
private final Event.EventCode eventCode;
|
||||
|
||||
FlowableEventModuleEnum(String module, String tag, String desc) {
|
||||
this.module = module;
|
||||
this.tag = tag;
|
||||
this.desc = desc;
|
||||
this.eventCode = Event.EventCode.builder()
|
||||
.module(module)
|
||||
.name(tag)
|
||||
.build();
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public Event.EventCode getEventCode() {
|
||||
return eventCode;
|
||||
}
|
||||
}
|
||||
@ -43,11 +43,11 @@ public class EngineTaskEventListener implements TaskListener {
|
||||
i.onAssigned(delegateTask);
|
||||
break;
|
||||
case EVENTNAME_COMPLETE:
|
||||
//审批完成
|
||||
// 审批通过
|
||||
i.onCompleted(delegateTask);
|
||||
break;
|
||||
case EVENTNAME_DELETE:
|
||||
// 审批删除
|
||||
// 审批
|
||||
i.onDeleted(delegateTask);
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -31,6 +31,8 @@ public interface BpmnTaskEventListener extends Ordered {
|
||||
|
||||
/**
|
||||
* 用户任务已删除
|
||||
*
|
||||
* 删除不代表驳回或拒绝,因为通过也会走该事件
|
||||
*/
|
||||
default void onDeleted(DelegateTask delegateTask) {}
|
||||
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package cn.axzo.workflow.core.listener.impl;
|
||||
|
||||
import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
|
||||
import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaksInst;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Core 包内置的,可共用与 Jar 包集成和微服务集成
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/12/9 22:56
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class InternalTaskEventListener implements BpmnTaskEventListener {
|
||||
private final ExtAxHiTaskInstService hiTaskInstService;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(DelegateTask delegateTask) {
|
||||
ExtAxHiTaksInst entity = new ExtAxHiTaksInst();
|
||||
entity.setProcInstId(delegateTask.getProcessInstanceId());
|
||||
entity.setTaskDefinitionKey(delegateTask.getTaskDefinitionKey());
|
||||
entity.setTaskId(delegateTask.getId());
|
||||
entity.setStatus(BpmnProcessInstanceResultEnum.APPROVED.getStatus());
|
||||
hiTaskInstService.save(entity);
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
package cn.axzo.workflow.core.repository.entity;
|
||||
|
||||
import cn.axzo.framework.data.mybatisplus.model.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* rocket mq log
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/12/8 22:23
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "ext_ax_rocket_log", autoResultMap = true)
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class ExtAxRocketLog extends BaseEntity<ExtAxRocketLog> {
|
||||
|
||||
/**
|
||||
* shardKey
|
||||
*/
|
||||
@TableField("shard_key")
|
||||
private String shardKey;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@TableField("event")
|
||||
private String event;
|
||||
|
||||
/**
|
||||
* 事件源数据
|
||||
*/
|
||||
@TableField("event_source")
|
||||
private String eventSource;
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package cn.axzo.workflow.core.repository.mapper;
|
||||
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxRocketLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ExtAxReProcDefMapper
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/11/18 22:16
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExtAxRocketLogMapper extends BaseMapper<ExtAxRocketLog> {
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package cn.axzo.workflow.core.service;
|
||||
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaksInst;
|
||||
|
||||
/**
|
||||
* 流程定义扩展表操作 Service
|
||||
*
|
||||
@ -8,4 +10,5 @@ package cn.axzo.workflow.core.service;
|
||||
*/
|
||||
public interface ExtAxHiTaskInstService {
|
||||
|
||||
void save(ExtAxHiTaksInst entity);
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
package cn.axzo.workflow.core.service;
|
||||
|
||||
/**
|
||||
* 流程定义扩展表操作 Service
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/11/18 22:25
|
||||
*/
|
||||
public interface ExtAxRocketLogService {
|
||||
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package cn.axzo.workflow.core.service.impl;
|
||||
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxHiTaksInst;
|
||||
import cn.axzo.workflow.core.repository.mapper.ExtAxHiTaskInstMapper;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -15,11 +15,13 @@ import javax.annotation.Resource;
|
||||
* @since 2023/11/18 22:27
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ExtAxHiTaskInstServiceImpl implements ExtAxHiTaskInstService {
|
||||
|
||||
@Resource
|
||||
private ExtAxHiTaskInstMapper extAxHiTaskInstMapper;
|
||||
|
||||
@Override
|
||||
public void save(ExtAxHiTaksInst entity) {
|
||||
extAxHiTaskInstMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
package cn.axzo.workflow.core.service.impl;
|
||||
|
||||
import cn.axzo.workflow.core.repository.mapper.ExtAxReProcDefMapper;
|
||||
import cn.axzo.workflow.core.service.ExtAxRocketLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 流程定义扩展表操作服务实现
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/11/18 22:27
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ExtAxRocketLogServiceImpl implements ExtAxRocketLogService {
|
||||
|
||||
@Resource
|
||||
private ExtAxReProcDefMapper extAxReProcDefMapper;
|
||||
|
||||
}
|
||||
@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS EXT_AX_HI_TASKINST
|
||||
`task_id` varchar(100) NOT NULL DEFAULT '' COMMENT '流程任务ID',
|
||||
`task_definition_key` varchar(100) NOT NULL DEFAULT '' COMMENT '流程节点定义ID',
|
||||
`status` varchar(100) NOT NULL DEFAULT '' COMMENT '状态 通过/拒绝等',
|
||||
`assignee` varchar(100) NOT NULL DEFAULT '' COMMENT '操作人',
|
||||
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_delete` bigint NOT NULL DEFAULT '0' COMMENT '是否删除',
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
DROP TABLE IF EXISTS `EXT_AX_ROCKET_LOG`;
|
||||
CREATE TABLE IF NOT EXISTS EXT_AX_ROCKET_LOG
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`event` varchar(100) NOT NULL DEFAULT '' COMMENT '事件类型',
|
||||
`shard_key` varchar(100) NOT NULL DEFAULT '' COMMENT 'shardKey',
|
||||
`event_source` varchar(4000) NOT NULL DEFAULT '' COMMENT '事件源数据',
|
||||
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_delete` bigint NOT NULL DEFAULT '0' COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB COMMENT '流程模型信息扩展表';
|
||||
create index idx_proc_def_id on EXT_AX_ROCKET_LOG (event, shard_key);
|
||||
@ -37,16 +37,16 @@ import static cn.axzo.workflow.core.common.enums.BpmnProcessTaskResultEnum.REJEC
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class AutoOperatorEventListener implements BpmnTaskEventListener, Ordered {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 103;
|
||||
}
|
||||
|
||||
private final TaskService taskService;
|
||||
private final RuntimeService runtimeService;
|
||||
private final RepositoryService repositoryService;
|
||||
private final BpmnProcessInstanceService processInstanceService;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 3;
|
||||
}
|
||||
private final BpmnProcessInstanceService processInstanceService;
|
||||
|
||||
@Override
|
||||
public void onCreated(DelegateTask delegateTask) {
|
||||
|
||||
@ -41,14 +41,13 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ASSIGNEE_SKIP_
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class MessagePushTaskEventListener implements BpmnTaskEventListener, Ordered {
|
||||
|
||||
private final RuntimeService runtimeService;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 4;
|
||||
return Integer.MIN_VALUE + 104;
|
||||
}
|
||||
|
||||
private final RuntimeService runtimeService;
|
||||
|
||||
@Override
|
||||
public void onAssigned(DelegateTask delegateTask) {
|
||||
if (log.isDebugEnabled()) {
|
||||
|
||||
@ -41,7 +41,10 @@ import static cn.axzo.workflow.common.enums.ProcessTaskEventEnum.PROCESS_TASK_DE
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RocketMqBpmnTaskEventListener implements BpmnTaskEventListener, Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 101;
|
||||
}
|
||||
@Resource
|
||||
private EventProducer<?> eventProducer;
|
||||
@Resource
|
||||
@ -143,8 +146,5 @@ public class RocketMqBpmnTaskEventListener implements BpmnTaskEventListener, Ord
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,13 +2,13 @@ package cn.axzo.workflow.server.controller.listener.task;
|
||||
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.core.listener.BpmnTaskEventListener;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -25,10 +25,15 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELAT
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class SnapshotBpmnTaskTaskEventListener implements BpmnTaskEventListener, Ordered {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 100;
|
||||
}
|
||||
|
||||
private final RuntimeService runtimeService;
|
||||
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
@Override
|
||||
public void onAssigned(DelegateTask delegateTask) {
|
||||
if (log.isDebugEnabled()) {
|
||||
@ -46,9 +51,4 @@ public class SnapshotBpmnTaskTaskEventListener implements BpmnTaskEventListener,
|
||||
log.debug("SnapshotBpmnTaskTaskEventListener#onAssigned...end");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,16 +30,14 @@ import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_STARTER;
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class StartNodeAutoCompleteEventListener implements BpmnTaskEventListener, Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 1022;
|
||||
}
|
||||
private final TaskService taskService;
|
||||
private final RuntimeService runtimeService;
|
||||
private final RepositoryService repositoryService;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Integer.MIN_VALUE + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(DelegateTask delegateTask) {
|
||||
if (log.isDebugEnabled()) {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
### 本包下的监听器执行顺序
|
||||
|
||||
1. SnapshotBpmTaskTaskEventListener `(Integer.MIN_VALUE)`
|
||||
2. RocketMqBpmTaskEventListener `(Integer.MIN_VALUE+1)`
|
||||
3. StartNodeAutoCompleteEventListener `(Integer.MIN_VALUE+2)`
|
||||
4. AutoOperatorEventListener `(Integer.MIN_VALUE+3)`
|
||||
5. PushPendingTaskEventListener `(Integer.MIN_VALUE+4)`
|
||||
> 排序不允许再低于这里的最小值, 因为还有系统内置的一些事件会占用优先级
|
||||
|
||||
1. SnapshotBpmTaskTaskEventListener `(Integer.MIN_VALUE + 100)`
|
||||
2. RocketMqBpmTaskEventListener `(Integer.MIN_VALUE+101)`
|
||||
3. StartNodeAutoCompleteEventListener `(Integer.MIN_VALUE+102)`
|
||||
4. AutoOperatorEventListener `(Integer.MIN_VALUE+103)`
|
||||
5. PushPendingTaskEventListener `(Integer.MIN_VALUE+104)`
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
package cn.axzo.workflow.server.mq;
|
||||
|
||||
import cn.axzo.framework.rocketmq.Event;
|
||||
import cn.axzo.framework.rocketmq.EventConsumer;
|
||||
import cn.axzo.framework.rocketmq.EventHandler;
|
||||
import cn.axzo.workflow.core.common.enums.FlowableEventModuleEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/9/4 10:51
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ProcessCreateListener implements EventHandler, InitializingBean {
|
||||
|
||||
@Autowired
|
||||
private EventConsumer eventConsumer;
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event, EventConsumer.Context context) {
|
||||
log.info("rocketmq event: {}", event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
eventConsumer.registerHandler(FlowableEventModuleEnum.PROCESS_CREATED.getEventCode(), this);
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package cn.axzo.workflow.server.mq;
|
||||
|
||||
import cn.axzo.framework.rocketmq.Event;
|
||||
import cn.axzo.framework.rocketmq.EventProducer;
|
||||
import cn.axzo.workflow.core.common.enums.FlowableEventModuleEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wangli
|
||||
* @since 2023/9/4 10:31
|
||||
*/
|
||||
@RequestMapping("/web/v1/test")
|
||||
@RestController
|
||||
public class TestController {
|
||||
|
||||
@Autowired
|
||||
private EventProducer eventProducer;
|
||||
|
||||
@GetMapping("/producer")
|
||||
public void producer() {
|
||||
eventProducer.send(Event.builder()
|
||||
.shardingKey(FlowableEventModuleEnum.PROCESS_CREATED.getModule())
|
||||
.targetId("1")
|
||||
.targetType(FlowableEventModuleEnum.PROCESS_CREATED.getModule())
|
||||
.eventCode(FlowableEventModuleEnum.PROCESS_CREATED.getEventCode())
|
||||
.eventModule(FlowableEventModuleEnum.PROCESS_CREATED.getModule())
|
||||
.eventName(FlowableEventModuleEnum.PROCESS_CREATED.getTag())
|
||||
.data("自定义数据")
|
||||
.build());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user