|
@@ -26,6 +26,7 @@ using Hotline.Share.Mq;
|
|
using Hotline.Users;
|
|
using Hotline.Users;
|
|
using MediatR;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
+using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Routing.Template;
|
|
using Microsoft.AspNetCore.Routing.Template;
|
|
@@ -39,6 +40,7 @@ using Tr.Sdk;
|
|
using XC.RSAUtil;
|
|
using XC.RSAUtil;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Cache;
|
|
using XF.Domain.Cache;
|
|
|
|
+using XF.Domain.Entities;
|
|
using XF.Domain.Exceptions;
|
|
using XF.Domain.Exceptions;
|
|
using XF.Domain.Filters;
|
|
using XF.Domain.Filters;
|
|
using XF.Domain.Locks;
|
|
using XF.Domain.Locks;
|
|
@@ -321,15 +323,70 @@ public class TestController : BaseController
|
|
throw new UserFriendlyException(2001, "test");
|
|
throw new UserFriendlyException(2001, "test");
|
|
}
|
|
}
|
|
|
|
|
|
- [AllowAnonymous]
|
|
|
|
[HttpGet("wfdefine")]
|
|
[HttpGet("wfdefine")]
|
|
public async Task GetWorkflowDefine([FromQuery] string id)
|
|
public async Task GetWorkflowDefine([FromQuery] string id)
|
|
{
|
|
{
|
|
- //var query = _workflowTraceRepository.Queryable()
|
|
|
|
-
|
|
|
|
- //if (!string.IsNullOrEmpty(id))
|
|
|
|
- // query = query.Where(d => d.WorkflowId == id);
|
|
|
|
- //var traces = await query.ToListAsync(HttpContext.RequestAborted);
|
|
|
|
|
|
+ var query = _workflowTraceRepository.Queryable()
|
|
|
|
+ .LeftJoin<Workflow>((t, w) => t.WorkflowId == w.Id)
|
|
|
|
+ .LeftJoin<Order>((t, w, o) => w.ExternalId == o.Id)
|
|
|
|
+ .Where((t, w, o) => o.No.Length == 14);
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(id))
|
|
|
|
+ query = query.Where(d => d.WorkflowId == id);
|
|
|
|
+ var list = await query
|
|
|
|
+ .Select((t, w, o) => new { t, w, o })
|
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ var toUsers = list.Where(d => d.t.FlowAssignType == EFlowAssignType.User).ToList();
|
|
|
|
+ var userIds = toUsers.SelectMany(d => d.t.Handlers).Select(d => d.Key).Distinct().ToList();
|
|
|
|
+ var users = await _userRepository.Queryable()
|
|
|
|
+ .Includes(d => d.Organization)
|
|
|
|
+ .Where(d => userIds.Contains(d.Id))
|
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
|
+ //var orgTraces = list.Where(d => d.FlowAssignType == EFlowAssignType.Org).ToList();
|
|
|
|
+ var stepHandlers = new List<WorkflowStepHandler>();
|
|
|
|
+ foreach (var toUser in toUsers)
|
|
|
|
+ {
|
|
|
|
+ foreach (var traceHandler in toUser.t.Handlers)
|
|
|
|
+ {
|
|
|
|
+ var user = users.FirstOrDefault(d => d.Id == traceHandler.Key);
|
|
|
|
+ if (user != null)
|
|
|
|
+ stepHandlers.Add(new WorkflowStepHandler
|
|
|
|
+ {
|
|
|
|
+ WorkflowId = toUser.w.Id,
|
|
|
|
+ ExternalId = toUser.w.ExternalId,
|
|
|
|
+ WorkflowStepId = toUser.t.StepId,
|
|
|
|
+ FlowAssignType = toUser.t.FlowAssignType.Value,
|
|
|
|
+ UserId = user.Id,
|
|
|
|
+ Username = user.Name,
|
|
|
|
+ OrgId = user.OrgId,
|
|
|
|
+ OrgName = user.Organization.Name,
|
|
|
|
+ IsActualHandler = user.Id == toUser.t.HandlerId
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var toOrgs = list.Where(d => d.t.FlowAssignType == EFlowAssignType.Org).ToList();
|
|
|
|
+ foreach (var toOrg in toOrgs)
|
|
|
|
+ {
|
|
|
|
+ foreach (var handler in toOrg.t.Handlers)
|
|
|
|
+ {
|
|
|
|
+ stepHandlers.Add(new WorkflowStepHandler
|
|
|
|
+ {
|
|
|
|
+ WorkflowId = toOrg.w.Id,
|
|
|
|
+ ExternalId = toOrg.w.ExternalId,
|
|
|
|
+ WorkflowStepId = toOrg.t.StepId,
|
|
|
|
+ FlowAssignType = toOrg.t.FlowAssignType.Value,
|
|
|
|
+ OrgId = handler.Key,
|
|
|
|
+ OrgName = handler.Value,
|
|
|
|
+ IsActualHandler = handler.Key == toOrg.t.HandlerOrgId
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _logger.LogInformation($"生成handlers: {stepHandlers.Count} 条");
|
|
|
|
+
|
|
|
|
+ await _workflowStepHandleRepository.AddRangeAsync(stepHandlers, HttpContext.RequestAborted);
|
|
}
|
|
}
|
|
|
|
|
|
[AllowAnonymous]
|
|
[AllowAnonymous]
|