BPM:增加任务监听器、执行监听器的管理
This commit is contained in:
parent
528a321f0a
commit
889b9406b8
@ -66,4 +66,10 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CATEGORY_NAME_DUPLICATE = new ErrorCode(1_009_012_001, "流程分类名字【{}】重复");
|
||||
ErrorCode CATEGORY_CODE_DUPLICATE = new ErrorCode(1_009_012_002, "流程分类编码【{}】重复");
|
||||
|
||||
// ========== BPM 流程监听器 1-009-013-000 ==========
|
||||
ErrorCode PROCESS_LISTENER_NOT_EXISTS = new ErrorCode(1_009_013_000, "流程监听器不存在");
|
||||
ErrorCode PROCESS_LISTENER_CLASS_NOT_FOUND = new ErrorCode(1_009_013_001, "流程监听器类({})不存在");
|
||||
ErrorCode PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR = new ErrorCode(1_009_013_002, "流程监听器类({})没有实现接口({})");
|
||||
ErrorCode PROCESS_LISTENER_EXPRESSION_INVALID = new ErrorCode(1_009_013_003, "流程监听器表达式({})不合法");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.bpm.enums.definition;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* BPM 流程监听器的类型
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum BpmProcessListenerType {
|
||||
|
||||
EXECUTION("execution", "执行监听器"),
|
||||
TASK("task", "任务执行器");
|
||||
|
||||
private final String type;
|
||||
private final String name;
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.bpm.enums.definition;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* BPM 流程监听器的值类型
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum BpmProcessListenerValueType {
|
||||
|
||||
CLASS("class", "Java 类"),
|
||||
DELEGATE_EXPRESSION("delegateExpression", "代理表达式"),
|
||||
EXPRESSION("expression", "表达式");
|
||||
|
||||
private final String type;
|
||||
private final String name;
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessListenerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - BPM 流程监听器")
|
||||
@RestController
|
||||
@RequestMapping("/bpm/process-listener")
|
||||
@Validated
|
||||
public class BpmProcessListenerController {
|
||||
|
||||
@Resource
|
||||
private BpmProcessListenerService processListenerService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建流程监听器")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-listener:create')")
|
||||
public CommonResult<Long> createProcessListener(@Valid @RequestBody BpmProcessListenerSaveReqVO createReqVO) {
|
||||
return success(processListenerService.createProcessListener(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新流程监听器")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-listener:update')")
|
||||
public CommonResult<Boolean> updateProcessListener(@Valid @RequestBody BpmProcessListenerSaveReqVO updateReqVO) {
|
||||
processListenerService.updateProcessListener(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除流程监听器")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-listener:delete')")
|
||||
public CommonResult<Boolean> deleteProcessListener(@RequestParam("id") Long id) {
|
||||
processListenerService.deleteProcessListener(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得流程监听器")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-listener:query')")
|
||||
public CommonResult<BpmProcessListenerRespVO> getProcessListener(@RequestParam("id") Long id) {
|
||||
BpmProcessListenerDO processListener = processListenerService.getProcessListener(id);
|
||||
return success(BeanUtils.toBean(processListener, BpmProcessListenerRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得流程监听器分页")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-listener:query')")
|
||||
public CommonResult<PageResult<BpmProcessListenerRespVO>> getProcessListenerPage(
|
||||
@Valid BpmProcessListenerPageReqVO pageReqVO) {
|
||||
PageResult<BpmProcessListenerDO> pageResult = processListenerService.getProcessListenerPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, BpmProcessListenerRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -15,8 +15,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - BPM 流程分类分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmCategoryPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "分类名", example = "王五")
|
||||
|
@ -8,8 +8,6 @@ import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 动态表单分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmFormPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "表单名称", example = "芋道")
|
||||
|
@ -12,8 +12,6 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 用户组分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmUserGroupPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "编号", example = "1024")
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - BPM 流程监听器分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmProcessListenerPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "监听器名字", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "监听器类型", example = "execution")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "监听事件", example = "start")
|
||||
private String event;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - BPM 流程监听器 Response VO")
|
||||
@Data
|
||||
public class BpmProcessListenerRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13089")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "监听器名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "监听器类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "execution")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "监听器状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "监听事件", requiredMode = Schema.RequiredMode.REQUIRED, example = "start")
|
||||
private String event;
|
||||
|
||||
@Schema(description = "监听器值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "class")
|
||||
private String valueType;
|
||||
|
||||
@Schema(description = "监听器值", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String value;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - BPM 流程监听器新增/修改 Request VO")
|
||||
@Data
|
||||
public class BpmProcessListenerSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13089")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "监听器名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "监听器名字不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "监听器类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "execution")
|
||||
@NotEmpty(message = "监听器类型不能为空")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "监听器状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "监听器状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "监听事件", requiredMode = Schema.RequiredMode.REQUIRED, example = "start")
|
||||
@NotEmpty(message = "监听事件不能为空")
|
||||
private String event;
|
||||
|
||||
@Schema(description = "监听器值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "class")
|
||||
@NotEmpty(message = "监听器值类型不能为空")
|
||||
private String valueType;
|
||||
|
||||
@Schema(description = "监听器值", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "监听器值不能为空")
|
||||
private String value;
|
||||
|
||||
}
|
@ -10,8 +10,6 @@ import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 流程模型的导入 Request VO 相比流程模型的新建来说,只是多了一个 bpmnFile 文件")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmModeImportReqVO extends BpmModelCreateReqVO {
|
||||
|
||||
@Schema(description = "BPMN 文件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
@ -9,8 +9,6 @@ import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 流程模型分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmModelPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标识,精准匹配", example = "process1641042089407")
|
||||
|
@ -8,8 +8,6 @@ import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 流程定义分页 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BpmProcessDefinitionPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标识-精准匹配", example = "process1641042089407")
|
||||
|
@ -13,8 +13,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - 请假申请分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmOALeavePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - 流程实例抄送的分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmProcessInstanceCopyPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "流程名称", example = "芋道")
|
||||
|
@ -12,8 +12,6 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 流程任务的的分页 Request VO") // 待办、已办,都使用该分页
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmTaskPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "流程任务名", example = "芋道")
|
||||
|
@ -14,8 +14,6 @@ import lombok.*;
|
||||
@TableName("bpm_category")
|
||||
@KeySequence("bpm_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
@ -10,15 +10,13 @@ import lombok.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工作流的表单定义
|
||||
* BPM 工作流的表单定义
|
||||
* 用于工作流的申请表单,需要动态配置的场景
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "bpm_form", autoResultMap = true)
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
@ -11,15 +11,13 @@ import lombok.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bpm 流程定义的拓信息
|
||||
* BPM 流程定义的拓信息
|
||||
* 主要解决 Flowable {@link org.flowable.engine.repository.ProcessDefinition} 不支持拓展字段,所以新建该表
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "bpm_process_definition_info", autoResultMap = true)
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* BPM 流程监听器 DO
|
||||
*
|
||||
* 目的:本质上它是流程监听器的模版,用于 BPMN 在设计时,直接选择这些模版
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "bpm_process_listener")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BpmProcessListenerDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键 ID,自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 监听器名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 监听类型
|
||||
*
|
||||
* 枚举 {@link cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerType}
|
||||
*
|
||||
* 1. execution:ExecutionListener <a href="https://tkjohn.github.io/flowable-userguide/#executionListeners">执行监听器</a>
|
||||
* 2. task:TaskListener <a href="https://tkjohn.github.io/flowable-userguide/#taskListeners">任务监听器</a>
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 监听事件
|
||||
*
|
||||
* execution 时:start、end
|
||||
* task 时:create 创建、assignment 指派、complete 完成、delete 删除、update 更新、timeout 超时
|
||||
*/
|
||||
private String event;
|
||||
|
||||
/**
|
||||
* 值类型
|
||||
*
|
||||
* 1. class:Java 类,ExecutionListener 需要 {@link org.flowable.engine.delegate.JavaDelegate},TaskListener 需要 {@link org.flowable.engine.delegate.TaskListener}
|
||||
* 2. delegateExpression:委托表达式,在 class 的基础上,需要注册到 Spring 容器里,后续表达式通过 Spring Bean 名称即可
|
||||
* 3. expression:表达式,一个普通类的普通方法,将这个普通类注册到 Spring 容器中,然后表达式中还可以执行这个类中的方法
|
||||
*/
|
||||
private String valueType;
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
|
||||
|
||||
// TODO 芋艿:先埋个坑。任务消息的配置规则。说白了,就是不同的
|
||||
public class BpmTaskMessageRuleDO {
|
||||
}
|
@ -11,14 +11,12 @@ import lombok.*;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Bpm 用户组
|
||||
* BPM 用户组
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "bpm_user_group", autoResultMap = true)
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
@ -18,8 +18,6 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@TableName("bpm_oa_leave")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
@ -13,8 +13,6 @@ import lombok.*;
|
||||
*/
|
||||
@TableName(value = "bpm_process_instance_copy", autoResultMap = true)
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* BPM 流程监听器 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmProcessListenerMapper extends BaseMapperX<BpmProcessListenerDO> {
|
||||
|
||||
default PageResult<BpmProcessListenerDO> selectPage(BpmProcessListenerPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BpmProcessListenerDO>()
|
||||
.likeIfPresent(BpmProcessListenerDO::getName, reqVO.getName())
|
||||
.eqIfPresent(BpmProcessListenerDO::getType, reqVO.getType())
|
||||
.eqIfPresent(BpmProcessListenerDO::getEvent, reqVO.getEvent())
|
||||
.orderByDesc(BpmProcessListenerDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.delegate.JavaDelegate;
|
||||
|
||||
/**
|
||||
* 类型为 class 的 ExecutionListener 监听器示例
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Slf4j
|
||||
public class DemoDelegateClassExecutionListener implements JavaDelegate {
|
||||
|
||||
@Override
|
||||
public void execute(DelegateExecution execution) {
|
||||
log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(),
|
||||
execution.getCurrentFlowableListener().getFieldExtensions());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.delegate.JavaDelegate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类型为 delegateExpression 的 ExecutionListener 监听器示例
|
||||
*
|
||||
* 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DemoDelegateExpressionExecutionListener implements JavaDelegate {
|
||||
|
||||
@Override
|
||||
public void execute(DelegateExecution execution) {
|
||||
log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(),
|
||||
execution.getCurrentFlowableListener().getFieldExtensions());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.exection;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类型为 expression 的 ExecutionListener 监听器示例
|
||||
*
|
||||
* 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中,但不用实现 {@link org.flowable.engine.delegate.JavaDelegate} 接口
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DemoSpringExpressionExecutionListener {
|
||||
|
||||
public void execute(DelegateExecution execution) {
|
||||
log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(),
|
||||
execution.getCurrentFlowableListener().getFieldExtensions());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.delegate.TaskListener;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类型为 class 的 TaskListener 监听器示例
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DemoDelegateClassExecutionListener implements TaskListener {
|
||||
|
||||
@Override
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
log.info("[execute][task({}) 被调用]", delegateTask.getId());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.delegate.TaskListener;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
|
||||
/**
|
||||
* 类型为 delegateExpression 的 TaskListener 监听器示例
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Slf4j
|
||||
public class DemoDelegateExpressionExecutionListener implements TaskListener {
|
||||
|
||||
@Override
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
log.info("[execute][task({}) 被调用]", delegateTask.getId());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.delegate.TaskListener;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
|
||||
/**
|
||||
* 类型为 expression 的 TaskListener 监听器示例
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Slf4j
|
||||
public class DemoSpringExpressionExecutionListener {
|
||||
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
log.info("[execute][task({}) 被调用]", delegateTask.getId());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* BPM 流程监听器 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface BpmProcessListenerService {
|
||||
|
||||
/**
|
||||
* 创建流程监听器
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createProcessListener(@Valid BpmProcessListenerSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新流程监听器
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateProcessListener(@Valid BpmProcessListenerSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除流程监听器
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteProcessListener(Long id);
|
||||
|
||||
/**
|
||||
* 获得流程监听器
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 流程监听器
|
||||
*/
|
||||
BpmProcessListenerDO getProcessListener(Long id);
|
||||
|
||||
/**
|
||||
* 获得流程监听器分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 流程监听器分页
|
||||
*/
|
||||
PageResult<BpmProcessListenerDO> getProcessListenerPage(BpmProcessListenerPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.definition;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.listener.BpmProcessListenerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessListenerDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessListenerMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerType;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmProcessListenerValueType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.engine.delegate.JavaDelegate;
|
||||
import org.flowable.engine.delegate.TaskListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* BPM 流程监听器 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class BpmProcessListenerServiceImpl implements BpmProcessListenerService {
|
||||
|
||||
@Resource
|
||||
private BpmProcessListenerMapper processListenerMapper;
|
||||
|
||||
@Override
|
||||
public Long createProcessListener(BpmProcessListenerSaveReqVO createReqVO) {
|
||||
// 校验
|
||||
validateCreateProcessListenerValue(createReqVO);
|
||||
// 插入
|
||||
BpmProcessListenerDO processListener = BeanUtils.toBean(createReqVO, BpmProcessListenerDO.class);
|
||||
processListenerMapper.insert(processListener);
|
||||
return processListener.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProcessListener(BpmProcessListenerSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateProcessListenerExists(updateReqVO.getId());
|
||||
validateCreateProcessListenerValue(updateReqVO);
|
||||
// 更新
|
||||
BpmProcessListenerDO updateObj = BeanUtils.toBean(updateReqVO, BpmProcessListenerDO.class);
|
||||
processListenerMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private void validateCreateProcessListenerValue(BpmProcessListenerSaveReqVO createReqVO) {
|
||||
// class 类型
|
||||
if (createReqVO.getValueType().equals(BpmProcessListenerValueType.CLASS.getType())) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(createReqVO.getValue());
|
||||
if (createReqVO.getType().equals(BpmProcessListenerType.EXECUTION.getType())
|
||||
&& !JavaDelegate.class.isAssignableFrom(clazz)) {
|
||||
throw exception(PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR, createReqVO.getValue(),
|
||||
JavaDelegate.class.getName());
|
||||
} else if (createReqVO.getType().equals(BpmProcessListenerType.TASK.getType())
|
||||
&& !TaskListener.class.isAssignableFrom(clazz)) {
|
||||
throw exception(PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR, createReqVO.getValue(),
|
||||
TaskListener.class.getName());
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw exception(PROCESS_LISTENER_CLASS_NOT_FOUND, createReqVO.getValue());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 表达式
|
||||
if (!StrUtil.startWith(createReqVO.getValue(), "${") || !StrUtil.endWith(createReqVO.getValue(), "}")) {
|
||||
throw exception(PROCESS_LISTENER_EXPRESSION_INVALID, createReqVO.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProcessListener(Long id) {
|
||||
// 校验存在
|
||||
validateProcessListenerExists(id);
|
||||
// 删除
|
||||
processListenerMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateProcessListenerExists(Long id) {
|
||||
if (processListenerMapper.selectById(id) == null) {
|
||||
throw exception(PROCESS_LISTENER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmProcessListenerDO getProcessListener(Long id) {
|
||||
return processListenerMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BpmProcessListenerDO> getProcessListenerPage(BpmProcessListenerPageReqVO pageReqVO) {
|
||||
return processListenerMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user