xfe 1 год назад
Родитель
Сommit
4e52c61417

+ 1 - 1
src/Hotline/FlowEngine/Workflows/IWorkflowDomainService.cs

@@ -217,7 +217,7 @@ namespace Hotline.FlowEngine.Workflows
         /// 批量改派工单至指定用户
         /// </summary>
         Task<ICollection<string>> ChangeHandlerRangeAsync(string sendPoolId,
-            IReadOnlyList<(string userId, string username, IReadOnlyList<string> stepIds)> handlers,
+            IReadOnlyList<(string userId, string username, string orgId, string orgName, IReadOnlyList<string> stepIds)> handlers,
             CancellationToken cancellationToken);
 
         /// <summary>

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

@@ -556,7 +556,10 @@ namespace Hotline.FlowEngine.Workflows
                 await DuplicateStepWithTraceAsync(workflow, prevStep, EWorkflowTraceStatus.Previous, cancellationToken);
 
             //remove workflow.steps
-            await _workflowStepRepository.RemoveRangeAsync(removeSteps, cancellationToken);
+            //await _workflowStepRepository.RemoveRangeAsync(removeSteps, cancellationToken);
+            await _workflowStepRepository.RemoveNav(removeSteps)
+                .Include(d => d.StepHandlers)
+                .ExecuteCommandAsync();
 
             if (workflow.Status is EWorkflowStatus.Completed)
                 workflow.SetStatusRunnable();
@@ -635,13 +638,14 @@ namespace Hotline.FlowEngine.Workflows
         /// 批量改变办理对象
         /// </summary>
         public async Task<ICollection<string>> ChangeHandlerRangeAsync(string sendPoolId,
-            IReadOnlyList<(string userId, string username, IReadOnlyList<string> stepIds)> handlers,
+            IReadOnlyList<(string userId, string username, string orgId, string orgName, IReadOnlyList<string> stepIds)> handlers,
             CancellationToken cancellationToken)
         {
             var stepsIds = handlers.SelectMany(d => d.stepIds).ToList();
             var steps = await _workflowStepRepository.Queryable()
                 .Includes(d => d.Workflow)
                 .Includes(d => d.WorkflowTrace)
+                .Includes(d => d.StepHandlers)
                 .Where(d => stepsIds.Contains(d.Id))
                 .ToListAsync(cancellationToken);
             foreach (var handler in handlers)
@@ -656,6 +660,11 @@ namespace Hotline.FlowEngine.Workflows
                 var thisSteps = steps.Where(d => handler.stepIds.Contains(d.Id)).ToList();
                 foreach (var thisStep in thisSteps)
                 {
+                    var stepHandler = WorkflowStepHandler.Create(thisStep.Workflow.Id, thisStep.Workflow.ExternalId,
+                        thisStep.FlowAssignType ?? EFlowAssignType.User, handler.userId, handler.username, handler.orgId, handler.orgName);
+                    thisStep.StepHandlers.Clear();
+                    thisStep.StepHandlers.Add(stepHandler);
+
                     thisStep.Handlers = thisHandlers;
 
                     //update trace
@@ -677,6 +686,7 @@ namespace Hotline.FlowEngine.Workflows
             await _workflowStepRepository.UpdateNav(steps)
                 .Include(d => d.WorkflowTrace)
                 .Include(d => d.Workflow)
+                .Include(d=>d.StepHandlers)
                 .ExecuteCommandAsync();
 
             return steps.Select(d => d.WorkflowId).ToList();
@@ -1770,7 +1780,10 @@ namespace Hotline.FlowEngine.Workflows
             var removeSteps = GetStepsBehindTargetStep(workflow.Steps, targetStep);
             if (removeSteps.Any())
             {
-                await _workflowStepRepository.RemoveRangeAsync(removeSteps, cancellationToken);
+                //await _workflowStepRepository.RemoveRangeAsync(removeSteps, cancellationToken);
+                await _workflowStepRepository.RemoveNav(removeSteps)
+                    .Include(d => d.StepHandlers)
+                    .ExecuteCommandAsync();
                 workflow.Steps.RemoveAll(d => removeSteps.Contains(d));
             }
 
@@ -1804,7 +1817,7 @@ namespace Hotline.FlowEngine.Workflows
             return isOrgToCenter;
         }
 
-        private ICollection<WorkflowStep> GetStepsBehindTargetStep(List<WorkflowStep> steps, WorkflowStep targetStep)
+        private List<WorkflowStep> GetStepsBehindTargetStep(List<WorkflowStep> steps, WorkflowStep targetStep)
         {
             var behindSteps = new List<WorkflowStep> { targetStep };
             if (!steps.Any()) return behindSteps;
@@ -2054,7 +2067,10 @@ namespace Hotline.FlowEngine.Workflows
 
                 HandleStepsByTerminalCs(startCountersignStep, workflow.Steps, workflow.Traces, ref updateSteps, ref updateTraces);
                 if (updateSteps.Any())
-                    await _workflowStepRepository.RemoveRangeAsync(updateSteps, cancellationToken);
+                    //await _workflowStepRepository.RemoveRangeAsync(updateSteps, cancellationToken);
+                    await _workflowStepRepository.RemoveNav(updateSteps)
+                        .Include(d => d.StepHandlers)
+                        .ExecuteCommandAsync();
                 if (updateTraces.Any())
                     await _workflowTraceRepository.UpdateRangeAsync(updateTraces, cancellationToken);
 

+ 8 - 6
src/Hotline/Orders/OrderDomainService.cs

@@ -229,7 +229,9 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
         var steps = await _workflowDomainService.GetUnhandleStepIdsFromSendPoolAsync(OrderDefaults.SourceChannel.SendPoolId, cancellationToken);
         var stepsList = steps.ToList();
 
-        var user = await _userRepository.GetAsync(userId, cancellationToken);
+        var user = await _userRepository.Queryable()
+            .Includes(d => d.Organization)
+            .FirstAsync(d => d.Id == userId, cancellationToken);
         DateTime time = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
         var schedulings = await _schedulingRepository.Queryable().Includes(x => x.SchedulingUser)
             .Where(x => x.SchedulingTime == time && x.WorkingTime <= DateTime.Now.TimeOfDay && x.OffDutyTime >= DateTime.Now.TimeOfDay).CountAsync(cancellationToken);
@@ -243,8 +245,8 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
                 stepIds.Add(stepsList[i]);
                 stepsList.Remove(stepsList[i]);
             }
-            List<(string userId, string username, IReadOnlyList<string> stepIds)> handlers = new();
-            ; handlers.Add(new ValueTuple<string, string, IReadOnlyList<string>>(user.Id, user.Name, stepIds));
+            List<(string, string, string, string, IReadOnlyList<string> stepIds)> handlers = new();
+            ; handlers.Add(new ValueTuple<string, string, string, string, IReadOnlyList<string>>(user.Id, user.Name, user.OrgId, user.Organization.Name, stepIds));
             var workflowIds = await _workflowDomainService.ChangeHandlerRangeAsync(OrderDefaults.SourceChannel.SendPoolId, handlers, cancellationToken);
             var orders = await _orderRepository.Queryable().Includes(d => d.Workflow).Where(d => workflowIds.Contains(d.WorkflowId))
                 .ToListAsync(cancellationToken);
@@ -277,7 +279,7 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
             var stepsList = steps.ToList();
 
             var sendNum = steps.Count() / schedulings.Count();
-            List<(string userId, string username, IReadOnlyList<string> stepIds)> handlers = new();
+            List<(string userId, string username, string orgId, string orgName, IReadOnlyList<string> stepIds)> handlers = new();
             if (sendNum > 0)
             {
 
@@ -289,7 +291,7 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
                         stepIds.Add(stepsList[0]);
                         stepsList.Remove(stepsList[0]);
                     }
-                    handlers.Add(new ValueTuple<string, string, IReadOnlyList<string>>(scheduling.SchedulingUser.UserId, scheduling.SchedulingUser.UserName, stepIds));
+                    handlers.Add(new ValueTuple<string, string, string, string, IReadOnlyList<string>>(scheduling.SchedulingUser.UserId, scheduling.SchedulingUser.UserName, "", "", stepIds));//todo
 
                 }
             }
@@ -302,7 +304,7 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
                     stepIds.Add(stepsList[0]);
                     stepsList.Remove(stepsList[0]);
                 }
-                handlers.Add(new ValueTuple<string, string, IReadOnlyList<string>>(schedulings[0].SchedulingUser.UserId, schedulings[0].SchedulingUser.UserName, stepIds));
+                handlers.Add(new ValueTuple<string, string, string, string, IReadOnlyList<string>>(schedulings[0].SchedulingUser.UserId, schedulings[0].SchedulingUser.UserName, "", "", stepIds));//todo
 
             }
             if (handlers.Any())