Skip to content

Dev #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2025
Merged

Dev #118

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.4</version>
<version>3.4.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.4</version>
<version>3.4.6</version>
</parent>

<artifactId>springboot-starter-data-authorization</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-fast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.4</version>
<version>3.4.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.4</version>
<version>3.4.6</version>
</parent>

<name>springboot-starter-flow</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
@AllArgsConstructor
public class FlowRelation {

public static final int DEFAULT_ORDER = -100;

/**
* 关系id
*/
Expand All @@ -38,7 +40,7 @@ public class FlowRelation {
private FlowNode target;

/**
* 排序
* 排序 (顺序越大的排序越靠前)
*/
private int order;

Expand Down Expand Up @@ -145,12 +147,12 @@ public void verify() {
throw new RuntimeException("outTrigger is null");
}

if(source.getCode().equals(target.getCode())){
if (source.getCode().equals(target.getCode())) {
throw new RuntimeException("source node code is equals target node code");
}

if(back){
if(source.getType() != NodeType.APPROVAL){
if (back) {
if (source.getType() != NodeType.APPROVAL) {
throw new RuntimeException("source node type is not approval");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.codingapi.springboot.flow.record.FlowRecord;
import com.codingapi.springboot.flow.repository.FlowOperatorRepository;
import com.codingapi.springboot.flow.repository.FlowRecordRepository;
import com.codingapi.springboot.flow.trigger.OutTrigger;
import com.codingapi.springboot.flow.user.IFlowOperator;
import com.codingapi.springboot.framework.event.EventPusher;
import lombok.Getter;
Expand Down Expand Up @@ -113,7 +114,7 @@ public void loadDefaultBackNode(FlowRecord currentRecord) {
throw new IllegalArgumentException("back node not found");
}
FlowRecord record = historyRecords.get(index);
if (record.isDone()) {
if (record.isDone() && record.getId()== currentRecord.getPreId()) {
// 是连续的回退节点时,则根据流程记录的状态来判断
if(record.isReject()){
boolean startRemove = false;
Expand Down Expand Up @@ -172,7 +173,28 @@ public void loadCustomBackNode(FlowNode flowNode, long parentRecordId) {
* @return 下一个节点
*/
private FlowNode matcherNextNode(FlowNode flowNode, boolean back) {
List<FlowRelation> relations = flowWork.getRelations().stream()
List<FlowRelation> currentRelations = new ArrayList<>(flowWork.getRelations());
if(back){
String preCode = FlowNode.CODE_START;
if(flowRecord.getPreId()!=0){
FlowRecord preRecord = flowRecordRepository.getFlowRecordById(flowRecord.getPreId());
if(preRecord!=null){
preCode = preRecord.getNodeCode();
while (preCode.equals(flowRecord.getNodeCode())){
preRecord = flowRecordRepository.getFlowRecordById(preRecord.getPreId());
if(preRecord==null){
break;
}
preCode = preRecord.getNodeCode();
}
}
}
FlowRelation backRelation = new FlowRelation("defaultId",
"默认回退关系", flowNode, flowWork.getNodeByCode(preCode), OutTrigger.defaultOutTrigger(), FlowRelation.DEFAULT_ORDER, true);
currentRelations.add(backRelation);
}

List<FlowRelation> relations = currentRelations.stream()
.filter(relation -> relation.sourceMatcher(flowNode.getCode()))
.filter(relation -> relation.isBack() == back)
.sorted((o1, o2) -> (o2.getOrder() - o1.getOrder()))
Expand Down Expand Up @@ -313,7 +335,7 @@ private List<FlowRecord> errMatcher(FlowNode currentNode, IFlowOperator currentO
List<Long> operatorIds = ((OperatorResult) errorResult).getOperatorIds();
List<? extends IFlowOperator> operators = flowOperatorRepository.findByIds(operatorIds);
for (IFlowOperator operator : operators) {
FlowSession content = new FlowSession(flowRecord, flowWork, currentNode, createOperator, operator, snapshot.toBindData(), opinion, historyRecords);
FlowSession content = new FlowSession(flowRecord, flowWork, currentNode, createOperator, nextOperator, snapshot.toBindData(), opinion, historyRecords);
String recordTitle = currentNode.generateTitle(content);
FlowRecord record = currentNode.createRecord(flowWork.getId(), flowWork.getCode(), processId, preId, recordTitle, createOperator, operator, snapshot, opinion.isWaiting());
recordList.add(record);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private FlowResult submitCurrentFlow() {
if (flowNode.isUnSign()) {
for (FlowRecord record : historyRecords) {
if (record.isTodo() && record.getId() != flowRecord.getId()) {
record.autoPass(currentOperator, snapshot);
record.autoPass(record.getCurrentOperator(), snapshot);
FlowRecordRepository flowRecordRepository = flowServiceRepositoryHolder.getFlowRecordRepository();
flowRecordRepository.update(record);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,84 @@ void errorMatcherNodeTest(){
List<BindDataSnapshot> snapshots = flowBindDataRepository.findAll();
assertEquals(3, snapshots.size());
}


/**
* 相同人审批通过,指定人员审批时遇到异常,走异常节点配置
*/
@Test
void sameUserFlow() {
PageRequest pageRequest = PageRequest.of(0, 1000);

User user = new User("张飞");
userRepository.save(user);

User dept = new User("刘备");
userRepository.save(dept);

User boss = new User("诸葛亮");
userRepository.save(boss);

FlowWork flowWork = FlowWorkBuilder.builder(user)
.title("请假流程")
.skipIfSameApprover(true)
.nodes()
.node("开始节点", "start", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
.node("部门领导审批", "dept", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(user.getUserId()))
.node("总经理审批", "manager", "default", ApprovalType.UN_SIGN, OperatorMatcher.specifyOperatorMatcher(dept.getUserId()), new ErrTrigger("" +
"def run(content){" +
" return content.createOperatorErrTrigger(" + dept.getUserId() + ")" +
"}"+
""),true, false)
.node("结束节点", "over", "default", ApprovalType.UN_SIGN, OperatorMatcher.anyOperatorMatcher())
.relations()
.relation("部门领导审批", "start", "dept")
.relation("总经理审批", "dept", "manager")
.relation("结束节点", "manager", "over")
.build();

flowWorkRepository.save(flowWork);

String workCode = flowWork.getCode();

Leave leave = new Leave("我要出去看看");
leaveRepository.save(leave);

// 创建流程
flowService.startFlow(workCode, user, leave, "发起流程");

// 查看我的待办
List<FlowRecord> userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
assertEquals(1, userTodos.size());

// 提交流程
FlowRecord userTodo = userTodos.get(0);
assertEquals(0, userTodo.getTimeoutTime());

flowService.submitFlow(userTodo.getId(), user, leave, Opinion.pass("同意").specify(user.getUserId()));

// 查看刘备经理的待办
List<FlowRecord> deptTodos = flowRecordRepository.findTodoByOperatorId(dept.getUserId(), pageRequest).getContent();
assertEquals(1, deptTodos.size());

// 提交委托dept部门经理的审批
FlowRecord deptTodo = deptTodos.get(0);
flowService.submitFlow(deptTodo.getId(), dept, leave, Opinion.pass("同意"));

// 查看所有流程
List<FlowRecord> records = flowRecordRepository.findAll(pageRequest).getContent();
assertEquals(3, records.size());

userTodos = flowRecordRepository.findTodoByOperatorId(user.getUserId(), pageRequest).getContent();
assertEquals(0, userTodos.size());

records = flowRecordRepository.findAll(pageRequest).getContent();
assertEquals(3, records.size());
// 查看所有流程是否都已经结束
assertTrue(records.stream().allMatch(FlowRecord::isFinish));

List<BindDataSnapshot> snapshots = flowBindDataRepository.findAll();
assertEquals(4, snapshots.size());

}
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy