【代码评审】BPM:子流程的多实例
This commit is contained in:
parent
3c0b9262d7
commit
e892dcabac
|
@ -33,4 +33,5 @@ public enum BpmChildProcessMultiInstanceSourceTypeEnum implements ArrayValuable<
|
||||||
public Integer[] array() {
|
public Integer[] array() {
|
||||||
return ARRAYS;
|
return ARRAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,7 +394,7 @@ public class BpmSimpleModelNodeVO {
|
||||||
*/
|
*/
|
||||||
@Schema(description = "回调任务 Key", example = "xxx", hidden = true)
|
@Schema(description = "回调任务 Key", example = "xxx", hidden = true)
|
||||||
private String callbackTaskDefineKey;
|
private String callbackTaskDefineKey;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schema(description = "流程表单触发器设置", example = "{}")
|
@Schema(description = "流程表单触发器设置", example = "{}")
|
||||||
|
@ -509,7 +509,7 @@ public class BpmSimpleModelNodeVO {
|
||||||
|
|
||||||
@Schema(description = "完成比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "完成比例", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
@NotNull(message = "完成比例不能为空")
|
@NotNull(message = "完成比例不能为空")
|
||||||
private Integer completeRatio;
|
private Integer completeRatio; // TODO @lesan:approveRatio 要不这个,和上面保持一致?
|
||||||
|
|
||||||
@Schema(description = "多实例来源类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "多实例来源类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "多实例来源类型不能为空")
|
@NotNull(message = "多实例来源类型不能为空")
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehav
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected int resolveNrOfInstances(DelegateExecution execution) {
|
protected int resolveNrOfInstances(DelegateExecution execution) {
|
||||||
|
// 情况一:UserTask 节点
|
||||||
if (execution.getCurrentFlowElement() instanceof UserTask) {
|
if (execution.getCurrentFlowElement() instanceof UserTask) {
|
||||||
// 第一步,设置 collectionVariable 和 CollectionVariable
|
// 第一步,设置 collectionVariable 和 CollectionVariable
|
||||||
// 从 execution.getVariable() 读取所有任务处理人的 key
|
// 从 execution.getVariable() 读取所有任务处理人的 key
|
||||||
|
@ -72,6 +73,7 @@ public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehav
|
||||||
return assigneeUserIds.size();
|
return assigneeUserIds.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 情况二:CallActivity 节点
|
||||||
if (execution.getCurrentFlowElement() instanceof CallActivity) {
|
if (execution.getCurrentFlowElement() instanceof CallActivity) {
|
||||||
FlowElement flowElement = execution.getCurrentFlowElement();
|
FlowElement flowElement = execution.getCurrentFlowElement();
|
||||||
Integer sourceType = BpmnModelUtils.parseMultiInstanceSourceType(flowElement);
|
Integer sourceType = BpmnModelUtils.parseMultiInstanceSourceType(flowElement);
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceB
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected int resolveNrOfInstances(DelegateExecution execution) {
|
protected int resolveNrOfInstances(DelegateExecution execution) {
|
||||||
|
// 情况一:UserTask 节点
|
||||||
if (execution.getCurrentFlowElement() instanceof UserTask) {
|
if (execution.getCurrentFlowElement() instanceof UserTask) {
|
||||||
// 第一步,设置 collectionVariable 和 CollectionVariable
|
// 第一步,设置 collectionVariable 和 CollectionVariable
|
||||||
// 从 execution.getVariable() 读取所有任务处理人的 key
|
// 从 execution.getVariable() 读取所有任务处理人的 key
|
||||||
|
@ -66,6 +67,7 @@ public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceB
|
||||||
return assigneeUserIds.size();
|
return assigneeUserIds.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 情况二:CallActivity 节点
|
||||||
if (execution.getCurrentFlowElement() instanceof CallActivity) {
|
if (execution.getCurrentFlowElement() instanceof CallActivity) {
|
||||||
FlowElement flowElement = execution.getCurrentFlowElement();
|
FlowElement flowElement = execution.getCurrentFlowElement();
|
||||||
Integer sourceType = BpmnModelUtils.parseMultiInstanceSourceType(flowElement);
|
Integer sourceType = BpmnModelUtils.parseMultiInstanceSourceType(flowElement);
|
||||||
|
|
|
@ -721,6 +721,8 @@ public class SimpleModelUtils {
|
||||||
} else if (node.getDelaySetting().getDelayType().equals(BpmDelayTimerTypeEnum.FIXED_TIME_DURATION.getType())) {
|
} else if (node.getDelaySetting().getDelayType().equals(BpmDelayTimerTypeEnum.FIXED_TIME_DURATION.getType())) {
|
||||||
boundaryEvent = buildTimeoutBoundaryEvent(receiveTask, BpmBoundaryEventTypeEnum.DELAY_TIMER_TIMEOUT.getType(),
|
boundaryEvent = buildTimeoutBoundaryEvent(receiveTask, BpmBoundaryEventTypeEnum.DELAY_TIMER_TIMEOUT.getType(),
|
||||||
null, null, node.getDelaySetting().getDelayTime());
|
null, null, node.getDelaySetting().getDelayTime());
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedOperationException("不支持的延迟类型:" + node.getDelaySetting());
|
||||||
}
|
}
|
||||||
flowElements.add(boundaryEvent);
|
flowElements.add(boundaryEvent);
|
||||||
}
|
}
|
||||||
|
@ -751,7 +753,7 @@ public class SimpleModelUtils {
|
||||||
// 重要:设置 callbackTaskDefineKey,用于 HTTP 回调
|
// 重要:设置 callbackTaskDefineKey,用于 HTTP 回调
|
||||||
node.getTriggerSetting().getHttpRequestSetting().setCallbackTaskDefineKey(receiveTask.getId());
|
node.getTriggerSetting().getHttpRequestSetting().setCallbackTaskDefineKey(receiveTask.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 触发器使用 ServiceTask 来实现
|
// 触发器使用 ServiceTask 来实现
|
||||||
ServiceTask serviceTask = new ServiceTask();
|
ServiceTask serviceTask = new ServiceTask();
|
||||||
serviceTask.setId(node.getId());
|
serviceTask.setId(node.getId());
|
||||||
|
@ -877,6 +879,7 @@ public class SimpleModelUtils {
|
||||||
childProcessSetting.getMultiInstanceSetting().getSourceType().equals(BpmChildProcessMultiInstanceSourceTypeEnum.MULTI_FORM.getType())) {
|
childProcessSetting.getMultiInstanceSetting().getSourceType().equals(BpmChildProcessMultiInstanceSourceTypeEnum.MULTI_FORM.getType())) {
|
||||||
multiInstanceCharacteristics.setInputDataItem(childProcessSetting.getMultiInstanceSetting().getSource());
|
multiInstanceCharacteristics.setInputDataItem(childProcessSetting.getMultiInstanceSetting().getSource());
|
||||||
}
|
}
|
||||||
|
// TODO @lesan:String.format(approveMethodEnum.getCompletionCondition(), String.format("%.2f", approveRatio / 100D)));
|
||||||
multiInstanceCharacteristics.setCompletionCondition(String.format("${ nrOfCompletedInstances/nrOfInstances >= %s}",
|
multiInstanceCharacteristics.setCompletionCondition(String.format("${ nrOfCompletedInstances/nrOfInstances >= %s}",
|
||||||
String.format("%.2f", childProcessSetting.getMultiInstanceSetting().getCompleteRatio() / 100D)));
|
String.format("%.2f", childProcessSetting.getMultiInstanceSetting().getCompleteRatio() / 100D)));
|
||||||
callActivity.setLoopCharacteristics(multiInstanceCharacteristics);
|
callActivity.setLoopCharacteristics(multiInstanceCharacteristics);
|
||||||
|
@ -901,9 +904,7 @@ public class SimpleModelUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BoundaryEvent buildTimeoutBoundaryEvent(Activity attachedToRef, Integer type,
|
private static BoundaryEvent buildTimeoutBoundaryEvent(Activity attachedToRef, Integer type,
|
||||||
String timeDuration,
|
String timeDuration, String timeCycle, String timeDate) {
|
||||||
String timeCycle,
|
|
||||||
String timeDate) {
|
|
||||||
// 1.1 定时器边界事件
|
// 1.1 定时器边界事件
|
||||||
BoundaryEvent boundaryEvent = new BoundaryEvent();
|
BoundaryEvent boundaryEvent = new BoundaryEvent();
|
||||||
boundaryEvent.setId("Event-" + IdUtil.fastUUID());
|
boundaryEvent.setId("Event-" + IdUtil.fastUUID());
|
||||||
|
@ -922,7 +923,7 @@ public class SimpleModelUtils {
|
||||||
}
|
}
|
||||||
boundaryEvent.addEventDefinition(eventDefinition);
|
boundaryEvent.addEventDefinition(eventDefinition);
|
||||||
|
|
||||||
// 2.1 添加定时器边界事件类型
|
// 2. 添加定时器边界事件类型
|
||||||
addExtensionElement(boundaryEvent, BOUNDARY_EVENT_TYPE, type);
|
addExtensionElement(boundaryEvent, BOUNDARY_EVENT_TYPE, type);
|
||||||
return boundaryEvent;
|
return boundaryEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,7 +414,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||||
// 处理每个任务的 tasks 属性
|
// 处理每个任务的 tasks 属性
|
||||||
for (HistoricActivityInstance activity : taskActivities) {
|
for (HistoricActivityInstance activity : taskActivities) {
|
||||||
HistoricTaskInstance task = taskMap.get(activity.getTaskId());
|
HistoricTaskInstance task = taskMap.get(activity.getTaskId());
|
||||||
// ChildProcess 子流程节点仅存在于 activity 中,并且没有自身的 task ,需要跳过执行
|
// 特殊情况:子流程节点 ChildProcess 仅存在于 activity 中,并且没有自身的 task,需要跳过执行
|
||||||
|
// TODO @芋艿:后续看看怎么优化!
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue