|
@@ -2,6 +2,7 @@
|
|
|
using Hotline.FlowEngine.Definitions;
|
|
|
using Hotline.FlowEngine.Notifications;
|
|
|
using Hotline.FlowEngine.WorkflowModules;
|
|
|
+using Hotline.Orders;
|
|
|
using Hotline.SeedData;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Share.Dtos;
|
|
@@ -12,6 +13,7 @@ using Hotline.Users;
|
|
|
using MapsterMapper;
|
|
|
using MediatR;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
+using SqlSugar;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Dependency;
|
|
|
using XF.Domain.Entities;
|
|
@@ -614,6 +616,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
{
|
|
|
prevStep = workflow.Steps.FirstOrDefault(d => d.Id == currentStep.PrevStepId);
|
|
|
}
|
|
|
+
|
|
|
if (prevStep == null)
|
|
|
throw UserFriendlyException.SameMessage("未查询到前一节点");
|
|
|
|
|
@@ -629,19 +632,48 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 查询派单池中待办流程节点id
|
|
|
+ /// 查询派单池中流程节点id
|
|
|
/// </summary>
|
|
|
- public Task<IReadOnlyList<string>> GetUnhandleStepIdsFromSendPoolAsync(string handlerId, CancellationToken cancellationToken)
|
|
|
+ public async Task<IReadOnlyList<string>> GetUnhandleStepIdsFromSendPoolAsync(string sendPoolId, CancellationToken cancellationToken)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ return await _workflowStepRepository.Queryable()
|
|
|
+ .Where(d => d.Handlers.Any(x => x.Key == sendPoolId))
|
|
|
+ .Select(d => d.Id)
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 批量改变办理对象
|
|
|
/// </summary>
|
|
|
- public Task ChangeHandlerRangeAsync(IReadOnlyList<(string userId, IReadOnlyList<string> stepIds)> handlers)
|
|
|
+ public async Task ChangeHandlerRangeAsync(string sendPoolId,
|
|
|
+ IReadOnlyList<(string userId, string username, IReadOnlyList<string> stepIds)> handlers,
|
|
|
+ CancellationToken cancellationToken)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ var stepsIds = handlers.SelectMany(d => d.stepIds).ToList();
|
|
|
+ var steps = await _workflowStepRepository.Queryable()
|
|
|
+ .Includes(d => d.Workflow)
|
|
|
+ .Where(d => stepsIds.Contains(d.Id))
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ foreach (var handler in handlers)
|
|
|
+ {
|
|
|
+ var thisHandlers = new List<Kv> { new(handler.userId, handler.username) };
|
|
|
+ var thisSteps = steps.Where(d => handler.stepIds.Contains(d.Id)).ToList();
|
|
|
+ foreach (var thisStep in thisSteps)
|
|
|
+ {
|
|
|
+ thisStep.Handlers = thisHandlers;
|
|
|
+ // update workflow
|
|
|
+ thisStep.Workflow.FlowedUserIds.Remove(sendPoolId);
|
|
|
+ thisStep.Workflow.FlowedUserIds.Add(handler.userId);
|
|
|
+ var handlerUser = thisStep.Workflow.HandlerUsers.FirstOrDefault(d => d.Key == sendPoolId);
|
|
|
+ if (handlerUser == null) continue;
|
|
|
+ handlerUser.Key = handler.userId;
|
|
|
+ handlerUser.Value = handler.username;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ await _workflowStepRepository.UpdateNav(steps)
|
|
|
+ .Include(d => d.Workflow)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1057,8 +1089,8 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
var workflow = await GetWorkflowAsync(workflowId, cancellationToken: cancellationToken);
|
|
|
return new Kv(workflow.ActualHandleOrgCode, workflow.ActualHandleOrgName);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 流程结束
|
|
|
/// </summary>
|