This commit is contained in:
kk
2026-07-07 18:05:54 +08:00
commit d4ef46bf97
743 changed files with 159169 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>blade-ops-api</artifactId>
<groupId>org.springblade</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-flow-api</artifactId>
<name>${project.artifactId}</name>
<packaging>jar</packaging>
</project>

View File

@@ -0,0 +1,70 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.constant;
/**
* 流程常量.
*
* @author Chill
*/
public interface ProcessConstant {
/**
* 请假流程标识
*/
String LEAVE_KEY = "Leave";
/**
* 报销流程标识
*/
String EXPENSE_KEY = "Expense";
/**
* 同意标识
*/
String PASS_KEY = "pass";
/**
* 同意代号
*/
String PASS_ALIAS = "ok";
/**
* 同意默认批复
*/
String PASS_COMMENT = "同意";
/**
* 驳回默认批复
*/
String NOT_PASS_COMMENT = "驳回";
/**
* 创建人变量名
*/
String TASK_VARIABLE_CREATE_USER = "createUser";
}

View File

@@ -0,0 +1,109 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.feign;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.tool.api.R;
import org.springblade.flow.core.pojo.entity.BladeFlow;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
/**
* 工作流远程调用接口.
*
* @author Chill
*/
@FeignClient(
value = AppConstant.APPLICATION_FLOW_NAME,
fallback = IFlowClientFallback.class
)
public interface IFlowClient {
String API_PREFIX = "/feign/client/flow";
String START_PROCESS_INSTANCE_BY_ID = API_PREFIX + "/start-process-instance-by-id";
String START_PROCESS_INSTANCE_BY_KEY = API_PREFIX + "/start-process-instance-by-key";
String COMPLETE_TASK = API_PREFIX + "/complete-task";
String TASK_VARIABLE = API_PREFIX + "/task-variable";
String TASK_VARIABLES = API_PREFIX + "/task-variables";
/**
* 开启流程
*
* @param processDefinitionId 流程id
* @param businessKey 业务key
* @param variables 参数
* @return BladeFlow
*/
@PostMapping(START_PROCESS_INSTANCE_BY_ID)
R<BladeFlow> startProcessInstanceById(@RequestParam("processDefinitionId") String processDefinitionId, @RequestParam("businessKey") String businessKey, @RequestBody Map<String, Object> variables);
/**
* 开启流程
*
* @param processDefinitionKey 流程标识
* @param businessKey 业务key
* @param variables 参数
* @return BladeFlow
*/
@PostMapping(START_PROCESS_INSTANCE_BY_KEY)
R<BladeFlow> startProcessInstanceByKey(@RequestParam("processDefinitionKey") String processDefinitionKey, @RequestParam("businessKey") String businessKey, @RequestBody Map<String, Object> variables);
/**
* 完成任务
*
* @param taskId 任务id
* @param processInstanceId 流程实例id
* @param comment 评论
* @param variables 参数
* @return R
*/
@PostMapping(COMPLETE_TASK)
R completeTask(@RequestParam("taskId") String taskId, @RequestParam("processInstanceId") String processInstanceId, @RequestParam("comment") String comment, @RequestBody Map<String, Object> variables);
/**
* 获取流程变量
*
* @param taskId 任务id
* @param variableName 变量名
* @return R
*/
@GetMapping(TASK_VARIABLE)
R<Object> taskVariable(@RequestParam("taskId") String taskId, @RequestParam("variableName") String variableName);
/**
* 获取流程变量集合
*
* @param taskId 任务id
* @return R
*/
@GetMapping(TASK_VARIABLES)
R<Map<String, Object>> taskVariables(@RequestParam("taskId") String taskId);
}

View File

@@ -0,0 +1,67 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.feign;
import org.springblade.core.tool.api.R;
import org.springblade.flow.core.pojo.entity.BladeFlow;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* 流程远程调用失败处理类
*
* @author Chill
*/
@Component
public class IFlowClientFallback implements IFlowClient {
@Override
public R<BladeFlow> startProcessInstanceById(String processDefinitionId, String businessKey, Map<String, Object> variables) {
return R.fail("远程调用失败");
}
@Override
public R<BladeFlow> startProcessInstanceByKey(String processDefinitionKey, String businessKey, Map<String, Object> variables) {
return R.fail("远程调用失败");
}
@Override
public R completeTask(String taskId, String processInstanceId, String comment, Map<String, Object> variables) {
return R.fail("远程调用失败");
}
@Override
public R<Object> taskVariable(String taskId, String variableName) {
return R.fail("远程调用失败");
}
@Override
public R<Map<String, Object>> taskVariables(String taskId) {
return R.fail("远程调用失败");
}
}

View File

@@ -0,0 +1,190 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.pojo.entity;
import lombok.Data;
import org.springblade.flow.core.constant.ProcessConstant;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
* 工作流通用实体类
*
* @author Chill
*/
@Data
public class BladeFlow implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 任务编号
*/
private String taskId;
/**
* 任务名称
*/
private String taskName;
/**
* 任务定义Key
*/
private String taskDefinitionKey;
/**
* 任务执行人编号
*/
private String assignee;
/**
* 任务执行人名称
*/
private String assigneeName;
/**
* 流程分类
*/
private String category;
/**
* 流程分类名
*/
private String categoryName;
/**
* 创建时间
*/
private Date createTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 签收时间
*/
private Date claimTime;
/**
* 历史任务结束时间
*/
private Date historyTaskEndTime;
/**
* 执行ID
*/
private String executionId;
/**
* 流程实例ID
*/
private String processInstanceId;
/**
* 流程ID
*/
private String processDefinitionId;
/**
* 流程标识
*/
private String processDefinitionKey;
/**
* 流程名
*/
private String processDefinitionName;
/**
* 流程版本
*/
private int processDefinitionVersion;
/**
* 流程说明
*/
private String processDefinitionDesc;
/**
* 流程简图名
*/
private String processDefinitionDiagramResName;
/**
* 流程重命名
*/
private String processDefinitionResName;
/**
* 历史任务流程实例ID 查看流程图会用到
*/
private String historyProcessInstanceId;
/**
* 流程实例是否结束
*/
private String processIsFinished;
/**
* 历史活动ID
*/
private String historyActivityId;
/**
* 历史活动流程
*/
private String historyActivityName;
/**
* 历史活动耗时
*/
private String historyActivityDurationTime;
/**
* 业务绑定Table
*/
private String businessTable;
/**
* 业务绑定ID
*/
private String businessId;
/**
* 任务状态
*/
private String status;
/**
* 任务意见
*/
private String comment;
/**
* 是否通过
*/
private boolean isPass;
/**
* 是否通过代号
*/
private String flag;
/**
* 开始查询日期
*/
private Date beginDate;
/**
* 结束查询日期
*/
private Date endDate;
/**
* 流程参数
*/
private Map<String, Object> variables;
/**
* 获取是否通过
*/
public boolean isPass() {
return ProcessConstant.PASS_ALIAS.equals(flag) || ProcessConstant.PASS_COMMENT.equals(comment);
}
}

View File

@@ -0,0 +1,52 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* FlowEntity
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class FlowEntity extends BaseEntity {
@TableField(exist = false)
private BladeFlow flow;
public BladeFlow getFlow() {
if (flow == null) {
flow = new BladeFlow();
}
return flow;
}
}

View File

@@ -0,0 +1,54 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.pojo.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 流程类型枚举
*
* @author Chill
*/
@Getter
@AllArgsConstructor
public enum FlowModeEnum {
/**
* 通用流程
*/
COMMON("common", 1),
/**
* 定制流程
*/
CUSTOM("custom", 2),
;
final String name;
final int mode;
}

View File

@@ -0,0 +1,76 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.utils;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.flow.core.constant.ProcessConstant;
import java.util.HashMap;
import java.util.Map;
/**
* 工作流工具类
*
* @author Chill
*/
public class FlowUtil {
/**
* 定义流程key对应的表名
*/
private final static Map<String, String> BUSINESS_TABLE = new HashMap<>();
static {
BUSINESS_TABLE.put(ProcessConstant.LEAVE_KEY, "blade_process_leave");
}
/**
* 通过流程key获取业务表名
*
* @param key 流程key
*/
public static String getBusinessTable(String key) {
String businessTable = BUSINESS_TABLE.get(key);
if (Func.isEmpty(businessTable)) {
return StringPool.EMPTY;
}
return businessTable;
}
/**
* 获取业务标识
*
* @param businessTable 业务表
* @param businessId 业务表主键
* @return businessKey
*/
public static String getBusinessKey(String businessTable, String businessId) {
return StringUtil.format("{}:{}", businessTable, businessId);
}
}

View File

@@ -0,0 +1,80 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.flow.core.utils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import static org.springblade.core.launch.constant.FlowConstant.TASK_USR_PREFIX;
/**
* 工作流任务工具类
*
* @author Chill
*/
public class TaskUtil {
/**
* 获取任务用户格式
*
* @return taskUser
*/
public static String getTaskUser() {
return StringUtil.format("{}{}", TASK_USR_PREFIX, AuthUtil.getUserId());
}
/**
* 获取任务用户格式
*
* @param userId 用户id
* @return taskUser
*/
public static String getTaskUser(String userId) {
return StringUtil.format("{}{}", TASK_USR_PREFIX, userId);
}
/**
* 获取用户主键
*
* @param taskUser 任务用户
* @return userId
*/
public static Long getUserId(String taskUser) {
return Func.toLong(StringUtil.removePrefix(taskUser, TASK_USR_PREFIX));
}
/**
* 获取用户组格式
*
* @return candidateGroup
*/
public static String getCandidateGroup() {
return AuthUtil.getUserRole();
}
}