Quellcode durchsuchen

重构 StartToEndAsync 方法并添加命名空间导入

在 IWorkflowDomainService.cs 文件中,添加了新的 StartToEndAsync 方法声明,并移除了原有声明。
在 WorkflowDomainService.cs 文件中,添加了新的 StartToEndAsync 方法实现,并移除了原有实现。
在 WorkflowDomainService.cs 文件中,添加了 using Hotline.Share.Dtos.Users; 语句。
xf vor 2 Wochen
Ursprung
Commit
0eb1daabdc

+ 8 - 6
src/Hotline/FlowEngine/Workflows/IWorkflowDomainService.cs

@@ -62,6 +62,14 @@ namespace Hotline.FlowEngine.Workflows
             Action<Workflow, WorkflowStep, StepDefine, WorkflowStep>? newStepConfig = null,
             CancellationToken cancellationToken = default);
 
+
+        /// <summary>
+        /// 开启流程直接归档
+        /// </summary>
+        Task StartToEndAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null,
+            CancellationToken cancellationToken = default);
+
+
         /// <summary>
         /// 查询工作流
         /// </summary>
@@ -290,12 +298,6 @@ namespace Hotline.FlowEngine.Workflows
         /// </summary>
         Task<List<WorkflowStep>> GetStepsBelongsToAsync(string userId, CancellationToken cancellationToken);
 
-        /// <summary>
-        /// 开启流程直接归档
-        /// </summary>
-        Task StartToEndAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null,
-            CancellationToken cancellationToken = default);
-
         /// <summary>
         /// 批量修改工单办理对象
         /// </summary>

+ 38 - 21
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -23,6 +23,7 @@ using Hotline.Configurations;
 using Hotline.Share.Dtos.File;
 using Hotline.Share.Dtos.FlowEngine.Workflow;
 using Microsoft.Extensions.Options;
+using Hotline.Share.Dtos.Users;
 
 namespace Hotline.FlowEngine.Workflows
 {
@@ -640,6 +641,43 @@ namespace Hotline.FlowEngine.Workflows
             return nextSteps;
         }
 
+
+        /// <summary>
+        /// 开启流程直接归档
+        /// </summary>
+        public async Task StartToEndAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null,
+            CancellationToken cancellationToken = default)
+        {
+            //var wfModule = await GetWorkflowModuleAsync(dto.DefinitionModuleCode, cancellationToken);
+            //var definition = wfModule.Definition;
+            //if (definition == null)
+            //    throw new UserFriendlyException("无效模板编码");
+            //if (definition.Status is not EDefinitionStatus.Enable)
+            //    throw new UserFriendlyException("该模板不可用");
+
+            //var endStepDefine = definition.FindEndStepDefine();
+            //dto.NextStepCode = endStepDefine.Code;
+            //dto.NextStepName = endStepDefine.Name;
+            //dto.FlowDirection = EFlowDirection.CenterToFile;
+
+            //await StartAsync(dto, externalId, expiredTime, cancellationToken: cancellationToken);
+
+            var (workflow, startStep) = await StartAsync(dto, externalId, expiredTime, cancellationToken: cancellationToken);
+            var nextDto = _mapper.Map<NextWorkflowDto>(dto);
+            nextDto.WorkflowId = workflow.Id;
+            nextDto.StepId = startStep.Id;
+
+            var endStepDefine = workflow.WorkflowDefinition.FindEndStepDefine();
+            nextDto.NextStepCode = endStepDefine.Code;
+            nextDto.NextStepName = endStepDefine.Name;
+
+            await NextAsync(workflow, nextDto,
+                expiredTime: expiredTime,
+                isAutoFillSummaryOpinion: true,
+                cancellationToken: cancellationToken);
+        }
+
+
         public async Task<Workflow> GetWorkflowAsync(string workflowId,
             bool withDefine = false, bool withSteps = false,
             bool withTraces = false, bool withTracesTree = false,
@@ -1136,27 +1174,6 @@ namespace Hotline.FlowEngine.Workflows
             return (currentStep, prevStep, countersignStartStep);
         }
 
-        /// <summary>
-        /// 开启流程直接归档
-        /// </summary>
-        public async Task StartToEndAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null,
-            CancellationToken cancellationToken = default)
-        {
-            var wfModule = await GetWorkflowModuleAsync(dto.DefinitionModuleCode, cancellationToken);
-            var definition = wfModule.Definition;
-            if (definition == null)
-                throw new UserFriendlyException("无效模板编码");
-            if (definition.Status is not EDefinitionStatus.Enable)
-                throw new UserFriendlyException("该模板不可用");
-
-            var endStepDefine = definition.FindEndStepDefine();
-            dto.NextStepCode = endStepDefine.Code;
-            dto.NextStepName = endStepDefine.Name;
-            dto.FlowDirection = EFlowDirection.CenterToFile;
-
-            await StartAsync(dto, externalId, expiredTime, cancellationToken: cancellationToken);
-        }
-
         /// <summary>
         /// 查询派单池中流程节点id
         /// </summary>