Selaa lähdekoodia

除工单流程外,开启流程改为开启流程并办理至下一节点

xf 2 kuukautta sitten
vanhempi
commit
6066375c71

+ 3 - 2
src/Hotline.Api/Controllers/KnowledgeController.cs

@@ -1290,8 +1290,9 @@ namespace Hotline.Api.Controllers
             dto.DefinitionModuleCode = moduleCode;
             //dto.Title = knowledge.Title;
             //return await _workflowApplication.StartWorkflowAsync(dto, id, cancellationToken: HttpContext.RequestAborted);
-            var result = await _workflowDomainService.StartAsync(dto, id, cancellationToken: HttpContext.RequestAborted);
-            return result.Item1.Id;
+            // var result = await _workflowDomainService.StartAsync(dto, id, cancellationToken: HttpContext.RequestAborted);
+            var result = await _workflowDomainService.StartToFirstStepAsync(dto, id, cancellationToken: HttpContext.RequestAborted);
+            return result.First().WorkflowId;
         }
         #endregion
 

+ 4 - 2
src/Hotline.Api/Controllers/OrderController.cs

@@ -2047,7 +2047,8 @@ public class OrderController : BaseController
             //     cancellationToken: HttpContext.RequestAborted);
             //model.WorkflowId = workFlowId;
             //await _orderDelayRepository.UpdateAsync(model, HttpContext.RequestAborted);
-            await _workflowDomainService.StartAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
+            // await _workflowDomainService.StartAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
+            await _workflowDomainService.StartToFirstStepAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
         }
         catch (Exception ex)
         {
@@ -2636,7 +2637,8 @@ public class OrderController : BaseController
             startDto.Opinion = dto.Data.Content;
             startDto.Title = "申请甄别流程";
             //workflowId = await _workflowApplication.StartWorkflowAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
-            await _workflowDomainService.StartAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
+            //await _workflowDomainService.StartAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
+            await _workflowDomainService.StartToFirstStepAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
         }
         catch (Exception e)
         {

+ 2 - 1
src/Hotline.Api/Controllers/OrderTerminateController.cs

@@ -176,7 +176,8 @@ namespace Hotline.Api.Controllers
 				startDto.Opinion = dto.Data.Content;
 				startDto.Title = "申请终止流程";
 				// await _workflowApplication.StartWorkflowAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
-				await _workflowDomainService.StartAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
+				// await _workflowDomainService.StartAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
+				await _workflowDomainService.StartToFirstStepAsync(startDto, model.Id, cancellationToken: HttpContext.RequestAborted);
 			}
 			catch (Exception e)
 			{

+ 4 - 2
src/Hotline.Api/Controllers/PbxController.cs

@@ -306,7 +306,8 @@ namespace Hotline.Api.Controllers
                 startWorkflowDto.Opinion = dto.Reason;
                 startWorkflowDto.Title = "分机休息申请流程";
 				// await _workflowApplication.StartWorkflowAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
-				await _workflowDomainService.StartAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
+				//await _workflowDomainService.StartAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
+                await _workflowDomainService.StartToFirstStepAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
             }
         }
 
@@ -343,7 +344,8 @@ namespace Hotline.Api.Controllers
             startWorkflowDto.Opinion = dto.Reason;
             startWorkflowDto.Title = "分机休息申请流程";
 			// await _workflowApplication.StartWorkflowAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
-			await _workflowDomainService.StartAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
+			//await _workflowDomainService.StartAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
+            await _workflowDomainService.StartToFirstStepAsync(startWorkflowDto, telRest.Id, cancellationToken: HttpContext.RequestAborted);
         }
 
 

+ 1 - 1
src/Hotline.Application/Handlers/FlowEngine/WorkflowStartHandler.cs

@@ -152,7 +152,7 @@ namespace Hotline.Application.Handlers.FlowEngine
                         {
                             if (notification.Dto.IsSms)
                             {
-                                switch (notification.FlowAssignType)
+                                switch (notification.Trace.FlowAssignType)
                                 {
                                     case EFlowAssignType.Org:
                                         var orgCodes = notification.Trace.NextHandlers.Select(x => x.OrgId); //notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);

+ 1 - 1
src/Hotline/FlowEngine/Notifications/WorkflowNotify.cs

@@ -10,7 +10,7 @@ namespace Hotline.FlowEngine.Notifications;
 
 public record WorkflowNotify(Workflow Workflow, BasicWorkflowDto Dto) : INotification;
 
-public record StartWorkflowNotify(Workflow Workflow, BasicWorkflowDto Dto, EFlowAssignType FlowAssignType, WorkflowTrace Trace) : WorkflowNotify(Workflow, Dto);
+public record StartWorkflowNotify(Workflow Workflow, BasicWorkflowDto Dto, WorkflowTrace Trace) : WorkflowNotify(Workflow, Dto);
 
 public record NextStepNotify(Workflow Workflow, BasicWorkflowDto Dto, WorkflowTrace Trace,
     StepDefine NextStepDefine, string HandlerOrgId, bool ExpiredTimeChanged) : WorkflowNotify(Workflow, Dto);

+ 7 - 0
src/Hotline/FlowEngine/Workflows/IWorkflowDomainService.cs

@@ -43,6 +43,13 @@ namespace Hotline.FlowEngine.Workflows
             Action<Workflow, StepDefine, WorkflowStep, WorkflowStep>? stepConfig = null,
             CancellationToken cancellationToken = default);
 
+        /// <summary>
+        /// 开启流程并办理至第一个节点
+        /// </summary>
+        Task<List<WorkflowStep>> StartToFirstStepAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null,
+            Action<Workflow, StepDefine, WorkflowStep, WorkflowStep>? stepConfig = null,
+            CancellationToken cancellationToken = default);
+
         /// <summary>
         /// 查询工作流
         /// </summary>

+ 3 - 3
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -268,11 +268,11 @@ namespace Hotline.FlowEngine.Workflows
 
             await _workflowRepository.AddAsync(workflow, cancellationToken);
 
-            var flowAssignInfo =
-                await GetNextStepFlowAssignInfoAsync(workflow, startStep, dto, firstStepDefine, isNextDynamic, cancellationToken);
+            // var flowAssignInfo =
+            //     await GetNextStepFlowAssignInfoAsync(workflow, startStep, dto, firstStepDefine, isNextDynamic, cancellationToken);
 
             //publish
-            await _publisher.PublishAsync(new StartWorkflowNotify(workflow, dto, flowAssignInfo.FlowAssignType, startTrace),
+            await _publisher.PublishAsync(new StartWorkflowNotify(workflow, dto, startTrace),
                 PublishStrategy.ParallelWhenAll, cancellationToken);
 
             return (workflow, startStep);