|
@@ -89,17 +89,17 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
{
|
|
|
//var nextStepBoxDefine = GetStepBoxDefine(workflow.Definition, dto.NextStepCode);
|
|
|
|
|
|
- var isStartCountersign = nextStepBoxDefine.IsStartCountersign(dto.NextHandlers.Count);
|
|
|
- //检查是否支持会签
|
|
|
- if (isStartCountersign && nextStepBoxDefine.CountersignMode == ECountersignMode.UnSupport)
|
|
|
- throw new UserFriendlyException($"当前节点不支持会签, defineCode: {workflow.Definition.Code}", "当前节点不支持会签");
|
|
|
-
|
|
|
//1. 如果不是按角色指派,handlers必填 2. 如果按角色指派,handlers可以不选
|
|
|
if (nextStepBoxDefine.HandlerType is not EHandlerType.Role && !dto.NextHandlers.Any())
|
|
|
throw UserFriendlyException.SameMessage("未指派办理人");
|
|
|
|
|
|
//开始节点
|
|
|
- var (startStepBox, startStep) = await CreateStartStepAsync(workflow, dto, isStartCountersign, cancellationToken);
|
|
|
+ var (startStepBox, startStep) = await CreateStartStepAsync(workflow, dto, cancellationToken);
|
|
|
+
|
|
|
+ var isStartCountersign = startStep.ShouldStartCountersign(dto.NextHandlers.Count);
|
|
|
+ //检查是否支持会签
|
|
|
+ if (isStartCountersign && startStep.CountersignMode == ECountersignMode.UnSupport)
|
|
|
+ throw new UserFriendlyException($"当前节点不支持发起会签, stepId: {startStep.Id}", "当前节点不支持发起会签");
|
|
|
|
|
|
if (isStartCountersign)
|
|
|
{
|
|
@@ -228,7 +228,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// 办理(流转至下一节点)
|
|
|
/// </summary>
|
|
|
public async Task NextAsync(Workflow workflow, BasicWorkflowDto dto, StepDefine nextStepBoxDefine,
|
|
|
- bool isOutOfCallCenter, bool isStartCountersign, FlowAssignMode flowAssignMode, CancellationToken cancellationToken)
|
|
|
+ bool isOutOfCallCenter, FlowAssignMode flowAssignMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
ValidatePermission(workflow);
|
|
|
CheckWhetherRunnable(workflow.Status);
|
|
@@ -238,6 +238,12 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
var (currentStepBox, currentStep) = GetUnCompleteStep(workflow.StepBoxes, _sessionContext.RequiredOrgCode, _sessionContext.RequiredUserId);
|
|
|
if (currentStep.Status is EWorkflowStepStatus.Completed or EWorkflowStepStatus.Created)
|
|
|
throw UserFriendlyException.SameMessage("当前节点状态无法办理");
|
|
|
+
|
|
|
+ var isStartCountersign = currentStep.ShouldStartCountersign(dto.NextHandlers.Count);
|
|
|
+ //检查是否支持会签
|
|
|
+ if (isStartCountersign && currentStep.CountersignMode == ECountersignMode.UnSupport)
|
|
|
+ throw new UserFriendlyException($"当前节点不支持发起会签, stepId: {currentStep.Id}", "当前节点不支持发起会签");
|
|
|
+
|
|
|
if (currentStep.Status is EWorkflowStepStatus.Assigned)
|
|
|
await AcceptAsync(workflow,
|
|
|
_sessionContext.RequiredUserId,
|
|
@@ -248,15 +254,15 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
if (currentStep.StepType is EStepType.End)
|
|
|
throw new UserFriendlyException("当前流程已流转到最终步骤");
|
|
|
|
|
|
- //检查是否支持会签办理
|
|
|
- if (isStartCountersign && nextStepBoxDefine.CountersignMode == ECountersignMode.UnSupport)
|
|
|
- throw UserFriendlyException.SameMessage($"下一节点不支持会签办理, code: {currentStep.Code}");
|
|
|
- WorkflowCountersign? countersign = null;
|
|
|
+ ////检查是否支持会签办理
|
|
|
+ //if (isStartCountersign && nextStepBoxDefine.CountersignMode == ECountersignMode.UnSupport)
|
|
|
+ // throw UserFriendlyException.SameMessage($"下一节点不支持会签办理, code: {currentStep.Code}");
|
|
|
+ //WorkflowCountersign? countersign = null;
|
|
|
if (isStartCountersign)
|
|
|
{
|
|
|
//创建会签数据
|
|
|
- countersign = await CreateCountersignAsync(workflow.Id, currentStep.Id, currentStep.Code,
|
|
|
- dto.NextHandlers.Count, currentStep.CountersignId, cancellationToken);
|
|
|
+ var countersign = await CreateCountersignAsync(workflow.Id, currentStep.Id, currentStep.Code,
|
|
|
+ dto.NextHandlers.Count, currentStep.CountersignId, cancellationToken);
|
|
|
currentStep.StartCountersign(countersign.Id);
|
|
|
}
|
|
|
|
|
@@ -282,7 +288,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
throw new UserFriendlyException(
|
|
|
$"未查询到会签开始stepBox, workflowId: {workflow.Id}, stepCode: {currentStep.CountersignStartCode}", "未查询到会签开始节点");
|
|
|
var countersignStartStep =
|
|
|
- countersignStartStepBox.Steps.FirstOrDefault(d => d.HasStartCountersign && d.StartCountersignId == currentStep.CountersignId);
|
|
|
+ countersignStartStepBox.Steps.FirstOrDefault(d => d.HasStartedCountersign && d.StartCountersignId == currentStep.CountersignId);
|
|
|
if (countersignStartStep != null)//如果==null,说明未发起会签是继承的外层会签
|
|
|
{
|
|
|
//结束step会签信息
|
|
@@ -364,7 +370,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
//(当前办理节点所处同一会签内的所有step全都办理完成并且如果开启了会签的step,必须会签结束)
|
|
|
var unComplete = steps.Any(d =>
|
|
|
d.Status != EWorkflowStepStatus.Completed ||
|
|
|
- (d.HasStartCountersign && !d.IsStartedCountersignComplete.Value));
|
|
|
+ (d.HasStartedCountersign && !d.IsStartedCountersignComplete.Value));
|
|
|
nextStepCanHandle = !unComplete;
|
|
|
}
|
|
|
}
|
|
@@ -426,11 +432,21 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
{
|
|
|
ValidatePermission(workflow);
|
|
|
CheckWhetherRunnable(workflow.Status);
|
|
|
+
|
|
|
+ var (currentStepBox, currentStep) = GetUnCompleteStep(workflow.StepBoxes, _sessionContext.RequiredOrgCode, _sessionContext.RequiredUserId);
|
|
|
+ if (currentStepBox.StepType is EStepType.Start)
|
|
|
+ throw UserFriendlyException.SameMessage("当前流程已退回到开始节点");
|
|
|
+
|
|
|
+ var isStartCountersign = currentStep.ShouldStartCountersign(dto.NextHandlers.Count);
|
|
|
+ //检查是否支持会签
|
|
|
+ if (isStartCountersign && currentStep.CountersignMode == ECountersignMode.UnSupport)
|
|
|
+ throw new UserFriendlyException($"当前节点不支持发起会签, stepId: {currentStep.Id}", "当前节点不支持发起会签");
|
|
|
+
|
|
|
var targetStepBox = workflow.StepBoxes.FirstOrDefault(d => d.Code == dto.TargetStepCode);
|
|
|
if (targetStepBox is null)
|
|
|
throw UserFriendlyException.SameMessage("该流程尚未流转至该节点");
|
|
|
|
|
|
- await RecallAsync(workflow, dto, targetStepBox, cancellationToken);
|
|
|
+ await RecallAsync(workflow, dto, targetStepBox, isStartCountersign, cancellationToken);
|
|
|
|
|
|
//todo publish
|
|
|
}
|
|
@@ -441,8 +457,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
public async Task JumpAsync(Workflow workflow, RecallDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
CheckWhetherRunnable(workflow.Status);
|
|
|
- //update uncompleted traces
|
|
|
- await JumpTraceAsync(workflow.Id, dto, cancellationToken);
|
|
|
|
|
|
var (currentStepBox, currentStep) = GetUnCompleteStep(workflow.StepBoxes, _sessionContext.RequiredOrgCode, _sessionContext.RequiredUserId);
|
|
|
if (currentStepBox.StepType is EStepType.Start)
|
|
@@ -450,12 +464,17 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
if (currentStepBox.StepType is EStepType.End)
|
|
|
throw UserFriendlyException.SameMessage("当前流程已流转到结束节点");
|
|
|
|
|
|
+ var isStartCountersign = currentStep.ShouldStartCountersign(dto.NextHandlers.Count);
|
|
|
+ //检查是否支持会签
|
|
|
+ if (isStartCountersign && currentStep.CountersignMode == ECountersignMode.UnSupport)
|
|
|
+ throw new UserFriendlyException($"当前节点不支持发起会签, stepId: {currentStep.Id}", "当前节点不支持发起会签");
|
|
|
+
|
|
|
var targetStepBox = workflow.StepBoxes.FirstOrDefault(d => d.Code == dto.TargetStepCode);
|
|
|
if (targetStepBox == null)
|
|
|
{
|
|
|
//向后跳转
|
|
|
var nextStepBoxDefine = GetStepBoxDefine(workflow.Definition, dto.NextStepCode);
|
|
|
- var isStartCountersign = nextStepBoxDefine.IsStartCountersign(dto.NextHandlers.Count);
|
|
|
+ //var isStartCountersign = nextStepBoxDefine.IsStartCountersign(dto.NextHandlers.Count);
|
|
|
var nextStepBox = await CreateStepAsync(isStartCountersign, workflow, nextStepBoxDefine, dto, EWorkflowStepStatus.Assigned, currentStepBox, currentStep, cancellationToken);
|
|
|
|
|
|
await ResetWorkflowCurrentStepInfo(workflow, dto, nextStepBox, cancellationToken);
|
|
@@ -488,9 +507,12 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
else
|
|
|
{
|
|
|
//返回之前节点
|
|
|
- await RecallAsync(workflow, dto, targetStepBox, cancellationToken);
|
|
|
+ await RecallAsync(workflow, dto, targetStepBox, isStartCountersign, cancellationToken);
|
|
|
}
|
|
|
|
|
|
+ //update uncompleted traces
|
|
|
+ await JumpTraceAsync(workflow.Id, dto, cancellationToken);
|
|
|
+
|
|
|
//todo publish
|
|
|
}
|
|
|
|
|
@@ -682,7 +704,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return parentTrace;
|
|
|
}
|
|
|
|
|
|
- private async Task RecallAsync(Workflow workflow, RecallDto dto, WorkflowStep targetStepBox, CancellationToken cancellationToken)
|
|
|
+ private async Task RecallAsync(Workflow workflow, RecallDto dto, WorkflowStep targetStepBox, bool isStartCountersign, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//update uncompleted traces
|
|
|
await RecallTraceAsync(workflow.Id, dto, cancellationToken);
|
|
@@ -701,7 +723,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
//recreate targetStep
|
|
|
var nextStepBoxDefine = GetStepBoxDefine(workflow.Definition, dto.NextStepCode);
|
|
|
- var isStartCountersign = nextStepBoxDefine.IsStartCountersign(dto.NextHandlers.Count);
|
|
|
+ //var isStartCountersign = nextStepBoxDefine.IsStartCountersign(dto.NextHandlers.Count);
|
|
|
await CreateStepAsync(isStartCountersign, workflow, nextStepBoxDefine, dto, EWorkflowStepStatus.Assigned, targetStepBox, targetStepBox.Steps.First(), cancellationToken);
|
|
|
|
|
|
//flow manage
|
|
@@ -743,7 +765,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <summary>
|
|
|
/// 创建开始节点(保存开始流程的办理意见,对应definition的start节点)
|
|
|
/// </summary>
|
|
|
- private async Task<(WorkflowStep stepBox, WorkflowStep step)> CreateStartStepAsync(Workflow workflow, BasicWorkflowDto dto, bool isStartCountersign, CancellationToken cancellationToken)
|
|
|
+ private async Task<(WorkflowStep stepBox, WorkflowStep step)> CreateStartStepAsync(Workflow workflow, BasicWorkflowDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (workflow.StepBoxes.Any())
|
|
|
throw UserFriendlyException.SameMessage("无法反复开始流程");
|
|
@@ -844,19 +866,19 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
await _workflowStepRepository.AddRangeAsync(subSteps, cancellationToken);
|
|
|
}
|
|
|
|
|
|
- private (WorkflowStep stepBox, WorkflowStep step) GetStep(List<WorkflowStep> stepBoxes, string stepId)
|
|
|
- {
|
|
|
- foreach (var stepBox in stepBoxes)
|
|
|
- {
|
|
|
- foreach (var step in stepBox.Steps)
|
|
|
- {
|
|
|
- if (step.Id == stepId)
|
|
|
- return (stepBox, step);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- throw new UserFriendlyException("未找到对应节点");
|
|
|
- }
|
|
|
+ //private (WorkflowStep stepBox, WorkflowStep step) GetStep(List<WorkflowStep> stepBoxes, string stepId)
|
|
|
+ //{
|
|
|
+ // foreach (var stepBox in stepBoxes)
|
|
|
+ // {
|
|
|
+ // foreach (var step in stepBox.Steps)
|
|
|
+ // {
|
|
|
+ // if (step.Id == stepId)
|
|
|
+ // return (stepBox, step);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // throw new UserFriendlyException("未找到对应节点");
|
|
|
+ //}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询未完成节点
|
|
@@ -869,7 +891,9 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
{
|
|
|
var (stepBox, step) = GetStep(stepBoxes, orgCode, userId, d => d != EWorkflowStepStatus.Completed);
|
|
|
if (step == null)
|
|
|
- throw new UserFriendlyException("未找到对应节点");
|
|
|
+ throw new UserFriendlyException(
|
|
|
+ $"未找到对应节点, workflowId: {stepBoxes.FirstOrDefault()?.WorkflowId} orgCode:{orgCode}, userId: {userId}",
|
|
|
+ "未找到对应节点");
|
|
|
return (stepBox, step);
|
|
|
}
|
|
|
|