Skip to content
Merged

Dev #37

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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public boolean isFlowManager() {

@Override
public IFlowOperator forwardOperator() {
return GatewayContext.getInstance().getFlowOperator(flowOperatorId);
if(flowOperatorId!=null && flowOperatorId > 0){
return GatewayContext.getInstance().getFlowOperator(flowOperatorId);
}
return null;
}
}
1 change: 1 addition & 0 deletions flow-engine-example/src/main/resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static/
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public List<FlowRecord> generateCurrentRecords(FlowSession session) {

@Override
public void fillNewRecord(FlowSession session, FlowRecord flowRecord) {
flowRecord.setTitle("over");
flowRecord.setCurrentOperatorId(-1);

flowRecord.over();
IFlowAction currentAction = session.getCurrentAction();
// 标记当前流程结束
FlowRecord latestRecord = session.getCurrentRecord();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public class FlowActionRequest {
private FlowAdviceBody advice;


public void updateOperatorId(long operatorId) {
if (advice != null) {
advice.setOperatorId(operatorId);
}
}


public FlowAdvice toFlowAdvice(Workflow workflow, IFlowAction flowAction) {
FlowAdvice flowAdvice = new FlowAdvice();
flowAdvice.setAdvice(advice.getAdvice());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public class FlowCreateRequest {
*/
private long operatorId;

/**
* 父流程id
*/
private long parentRecordId;


public FlowActionRequest toActionRequest(long recordId) {
FlowActionRequest flowActionRequest = new FlowActionRequest();
flowActionRequest.setFormData(this.getFormData());
Expand All @@ -56,4 +62,7 @@ public void verify() {
}
}

public boolean isSubProcess() {
return this.parentRecordId!=0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.codingapi.flow.pojo.request;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 流程详情请求
*/
@Data
@NoArgsConstructor
public class FlowDetailRequest {
/**
* 详情id,可以是workId或者是recordId
*/
private String id;
/**
* 流程的操作人Id
*/
private long operatorId;

public boolean isCreateWorkflow() {
return !id.matches("^[0-9]+$");
}

public FlowDetailRequest(long id,long operatorId){
this.id = String.valueOf(id);
this.operatorId = operatorId;
}

public FlowDetailRequest(String id, long operatorId) {
this.id = id;
this.operatorId = operatorId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.codingapi.flow.pojo.request;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
* 流程节点记录请求
*/
@Data
@NoArgsConstructor
public class FlowProcessNodeRequest {
/**
* 详情id,可以是workId或者是recordId
*/
private String id;

/**
* 流程的操作人Id
*/
private long operatorId;

/**
* 表单数据
*/
private Map<String, Object> formData;

public FlowProcessNodeRequest(long id, long operatorId, Map<String, Object> formData) {
this.id = String.valueOf(id);
this.operatorId = operatorId;
this.formData = formData;
}

public FlowProcessNodeRequest(String id, long operatorId, Map<String, Object> formData) {
this.id = id;
this.operatorId = operatorId;
this.formData = formData;
}

public boolean isCreateWorkflow() {
return !id.matches("^[0-9]+$");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 流程撤回请求
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 流程催办请求
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import com.codingapi.flow.action.IFlowAction;
import com.codingapi.flow.form.FormMeta;
import com.codingapi.flow.manager.ActionManager;
import com.codingapi.flow.manager.NodeStrategyManager;
import com.codingapi.flow.manager.OperatorManager;
import com.codingapi.flow.node.IFlowNode;
import com.codingapi.flow.operator.IFlowOperator;
import com.codingapi.flow.record.FlowRecord;
import com.codingapi.flow.session.FlowSession;
import com.codingapi.flow.strategy.node.OperatorLoadStrategy;
import com.codingapi.flow.workflow.Workflow;
import lombok.Data;

Expand All @@ -26,15 +24,31 @@ public class FlowContent {
* 流程记录编号
*/
private long recordId;

/**
* 流程编号
*/
private String workflowCode;
private String workId;

/**
* 流程编码
*/
private String workCode;
/**
* 流程视图
*/
private String view;

/**
* 审批意见是否必填
*/
private boolean adviceNullable;

/**
* 签名是否必填
*/
private boolean signable;

/**
* 表单元数据
*/
Expand Down Expand Up @@ -79,37 +93,21 @@ public class FlowContent {
*/
private List<History> histories;

/**
* 下一审批
*/
private List<NextNode> nextNodes;

public void pushNextNodes(FlowSession flowSession, List<IFlowNode> nextNodes) {
List<NextNode> nextNodeList = new ArrayList<>();
for (IFlowNode node : nextNodes){
NextNode nextNode = new NextNode();
nextNode.setNodeId(node.getId());
nextNode.setNodeName(node.getName());
nextNode.setNodeType(node.getType());

NodeStrategyManager nodeStrategyManager = node.strategyManager();
OperatorManager operatorManager = nodeStrategyManager.loadOperators(flowSession);
nextNode.setOperators(operatorManager.getOperators().stream().map(FlowOperator::new).toList());

nextNodeList.add(nextNode);
}
this.nextNodes = nextNodeList;
}

public void pushCurrentNode(IFlowNode currentNode) {
this.actions = currentNode.actionManager().getActions();
ActionManager actionManager = currentNode.actionManager();
NodeStrategyManager strategyManager = currentNode.strategyManager();
this.actions = actionManager.getActions();
this.adviceNullable = strategyManager.isEnableAdvice();
this.signable = strategyManager.isEnableSignable();
Map<String,Object> nodeData = currentNode.toMap();
this.view = (String) nodeData.get("view");
}

public void pushWorkflow(Workflow workflow) {
this.form = workflow.getForm();
this.workflowCode = workflow.getCode();
this.workCode = workflow.getCode();
this.workId = workflow.getId();
}

public void pushRecords(FlowRecord record, List<FlowRecord> mergeRecords) {
Expand Down Expand Up @@ -155,30 +153,6 @@ public void pushCurrentOperator(IFlowOperator currentOperator) {
}


/**
* 流程图
*/
@Data
public static class NextNode{
/**
* 节点名称
*/
private String nodeId;
/**
* 节点名称
*/
private String nodeName;
/**
* 节点类型
*/
private String nodeType;

/**
* 节点审批人
*/
private List<FlowOperator> operators;
}

@Data
public static class History{
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.codingapi.flow.pojo.response;

import com.codingapi.flow.node.IFlowNode;
import com.codingapi.flow.operator.IFlowOperator;
import com.codingapi.flow.record.FlowRecord;
import com.codingapi.flow.workflow.Workflow;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
* 流程审批节点
*/
@Data
@NoArgsConstructor
public class ProcessNode {
/**
* 节点名称
*/
private String nodeId;
/**
* 节点名称
*/
private String nodeName;
/**
* 节点类型
*/
private String nodeType;

/**
* 是否历史记录
*/
private boolean history;

/**
* 节点审批人
*/
private List<FlowOperatorBody> operators;


public ProcessNode(FlowRecord flowRecord, Workflow workflow) {
this.nodeId = flowRecord.getNodeId();
IFlowNode flowNode = workflow.getFlowNode(this.nodeId);
this.nodeName = flowNode.getName();
this.nodeType = flowNode.getType();
this.operators = new ArrayList<>();
this.history = true;
this.operators.add(new FlowOperatorBody(flowRecord));
}


public ProcessNode(IFlowNode flowNode, List<IFlowOperator> operators) {
this.nodeId = flowNode.getId();
this.nodeName = flowNode.getName();
this.nodeType = flowNode.getType();
this.operators = operators.stream().map(FlowOperatorBody::new).toList();
this.history = false;
}


/**
* 审批意见内容,仅当历史节点存在数据
*/
@Data
@NoArgsConstructor
public static class FlowOperatorBody {

/**
* 审批意见
*/
private String advice;

/**
* 签名key
*/
private String signKey;

/**
* 审批记录
*/
private FlowOperator flowOperator;
/**
* 审批时间
*/
private long approveTime;

public FlowOperatorBody(FlowRecord flowRecord) {
this.advice = flowRecord.getAdvice();
this.signKey = flowRecord.getSignKey();
this.approveTime = flowRecord.getCreateTime();
this.flowOperator = new FlowOperator(flowRecord.getCurrentOperatorId(), flowRecord.getCurrentOperatorName());
}

public FlowOperatorBody(IFlowOperator flowOperator) {
this.flowOperator = new FlowOperator(flowOperator);
}

}

}
Loading