|
@@ -78,7 +78,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <param name="dto"></param>
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task StartAsync(Workflow workflow, BasicWorkflowDto dto, StepDefine nextStepBoxDefine, CancellationToken cancellationToken)
|
|
|
+ public async Task StartAsync(Workflow workflow, BasicWorkflowDto dto, StepDefine nextStepBoxDefine, FlowAssignMode flowAssignMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//var nextStepBoxDefine = GetStepBoxDefine(workflow.Definition, dto.NextStepCode);
|
|
|
|
|
@@ -96,10 +96,14 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
//更新当前节点名称、时间、会签节点code 等字段
|
|
|
workflow.SetWorkflowCurrentStepInfo(isStartCountersign, nextStepBox);
|
|
|
+
|
|
|
+ workflow.UpdateHandlers(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgCode,
|
|
|
+ flowAssignMode.FlowAssignType, flowAssignMode.Handlers);
|
|
|
+
|
|
|
await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
|
|
|
|
//publish
|
|
|
- _mediator.Publish(new StartWorkflowNotify(workflow, nextStepBoxDefine, dto, isStartCountersign), cancellationToken);
|
|
|
+ _mediator.Publish(new StartWorkflowNotify(workflow, dto, isStartCountersign, flowAssignMode));
|
|
|
}
|
|
|
|
|
|
public async Task<Workflow> GetWorkflowAsync(string workflowId,
|
|
@@ -146,6 +150,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
public async Task AcceptAsync(Workflow workflow, string userId, string userName, string orgCode, string orgName, CancellationToken cancellationToken)
|
|
|
{
|
|
|
+ if(!workflow.CanHandle(_sessionContext.RequiredUserId,_sessionContext.RequiredOrgCode)) return;
|
|
|
//工单完成以后查看的场景
|
|
|
if (workflow.Status is not EWorkflowStatus.Runnable) return;
|
|
|
|
|
@@ -190,8 +195,10 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <summary>
|
|
|
/// 办理(流转至下一节点)
|
|
|
/// </summary>
|
|
|
- public async Task NextAsync(Workflow workflow, BasicWorkflowDto dto, StepDefine nextStepBoxDefine, bool isOutOfCallCenter, bool isStartCountersign, CancellationToken cancellationToken)
|
|
|
+ public async Task NextAsync(Workflow workflow, BasicWorkflowDto dto, StepDefine nextStepBoxDefine,
|
|
|
+ bool isOutOfCallCenter, bool isStartCountersign, FlowAssignMode flowAssignMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
+ ValidatePermission(workflow);
|
|
|
CheckWhetherRunnable(workflow.Status);
|
|
|
|
|
|
#region 办理当前节点
|
|
@@ -328,6 +335,9 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
//更新当前节点名称、时间、会签节点code 等字段
|
|
|
workflow.SetWorkflowCurrentStepInfo(isStartCountersign, nextStepBox);
|
|
|
|
|
|
+ workflow.UpdateHandlers(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgCode,
|
|
|
+ flowAssignMode.FlowAssignType, flowAssignMode.Handlers);
|
|
|
+
|
|
|
await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
|
|
|
|
#endregion
|
|
@@ -338,7 +348,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- _mediator.Publish(new NextStepNotify(workflow, nextStepBoxDefine, dto, isStartCountersign, isCountersignOver));
|
|
|
+ _mediator.Publish(new NextStepNotify(workflow, dto, isStartCountersign, isCountersignOver, flowAssignMode));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -367,6 +377,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <returns></returns>
|
|
|
public async Task PreviousAsync(Workflow workflow, PreviousWorkflowDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
+ ValidatePermission(workflow);
|
|
|
CheckWhetherRunnable(workflow.Status);
|
|
|
var (currentStepBox, currentStep) = GetUnCompleteStep(workflow.StepBoxes, _sessionContext.RequiredOrgCode, _sessionContext.RequiredUserId);
|
|
|
if (currentStepBox.StepType is EStepType.Start)
|
|
@@ -389,6 +400,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
public async Task RecallAsync(Workflow workflow, RecallDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
+ ValidatePermission(workflow);
|
|
|
CheckWhetherRunnable(workflow.Status);
|
|
|
var targetStepBox = workflow.StepBoxes.FirstOrDefault(d => d.Code == dto.TargetStepCode);
|
|
|
if (targetStepBox is null)
|
|
@@ -645,6 +657,12 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
throw new UserFriendlyException("当前流程状态不可继续流转");
|
|
|
}
|
|
|
|
|
|
+ private void ValidatePermission(Workflow workflow)
|
|
|
+ {
|
|
|
+ if (!workflow.CanHandle(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgCode))
|
|
|
+ throw new UserFriendlyException("无办理权限");
|
|
|
+ }
|
|
|
+
|
|
|
private async Task<WorkflowStep> CreateStepAsync(Workflow workflow, StepDefine stepBoxDefine, BasicWorkflowDto dto,
|
|
|
WorkflowStep? prevStepBox = null, WorkflowStep? prevStep = null, CancellationToken cancellationToken = default)
|
|
|
{
|