|
@@ -45,6 +45,7 @@ using PanGu;
|
|
|
using SqlSugar;
|
|
|
using System.Data;
|
|
|
using System.Dynamic;
|
|
|
+using ExtendedNumerics.Exceptions;
|
|
|
using FluentValidation;
|
|
|
using Hotline.FlowEngine.Definitions;
|
|
|
using Hotline.FlowEngine.Notifications;
|
|
@@ -110,6 +111,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
private readonly IRepository<OrderTsDetails> _orderTsDetailsRepository;
|
|
|
private readonly IRepository<KnowledgeQuote> _knowledgeQuoteRepository;
|
|
|
private readonly IRepository<OrderSpecial> _orderSpecialRepository;
|
|
|
+ private readonly IRepository<User> _userRepository;
|
|
|
private readonly IWorkflowApplication _workflowApplication;
|
|
|
private readonly ICircularRecordDomainService _circularRecordDomainService;
|
|
|
|
|
@@ -157,6 +159,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
IRepository<OrderTsDetails> orderTsDetailsRepository,
|
|
|
IRepository<KnowledgeQuote> knowledgeQuoteRepository,
|
|
|
IRepository<OrderSpecial> orderSpecialRepository,
|
|
|
+ IRepository<User> userRepository,
|
|
|
IWorkflowApplication workflowApplication,
|
|
|
ICircularRecordDomainService circularRecordDomainService)
|
|
|
{
|
|
@@ -203,6 +206,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
_orderTsDetailsRepository = orderTsDetailsRepository;
|
|
|
_knowledgeQuoteRepository = knowledgeQuoteRepository;
|
|
|
_orderSpecialRepository = orderSpecialRepository;
|
|
|
+ _userRepository = userRepository;
|
|
|
_workflowApplication = workflowApplication;
|
|
|
_circularRecordDomainService = circularRecordDomainService;
|
|
|
}
|
|
@@ -5232,5 +5236,96 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 依据当前待办节点获取任意一个合法办理人
|
|
|
+ /// </summary>
|
|
|
+ public async Task<ISessionContext> GetHandlerRandomAsync(WorkflowStep step, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ User user;
|
|
|
+ switch (step.BusinessType)
|
|
|
+ {
|
|
|
+ case EBusinessType.Seat:
|
|
|
+ var roleSeat = _systemSettingCacheManager.GetSetting(SettingConstants.RoleZuoXi)?.SettingValue.FirstOrDefault();
|
|
|
+ if (string.IsNullOrEmpty(roleSeat))
|
|
|
+ throw new UserFriendlyException($"未配置坐席角色, {SettingConstants.RoleZuoXi}", "未配置坐席角色");
|
|
|
+ user = await _userRepository.Queryable()
|
|
|
+ .Includes(d=>d.Organization)
|
|
|
+ .Where(d => d.Roles.Any(x => x.Name == roleSeat))
|
|
|
+ .FirstAsync(cancellationToken);
|
|
|
+ if(user is null)
|
|
|
+ throw UserFriendlyException.SameMessage("坐席角色未设置用户");
|
|
|
+ break;
|
|
|
+ case EBusinessType.Send:
|
|
|
+ var roleSend = _systemSettingCacheManager.GetSetting(SettingConstants.RolePaiDan)?.SettingValue.FirstOrDefault();
|
|
|
+ if (string.IsNullOrEmpty(roleSend))
|
|
|
+ throw new UserFriendlyException($"未配置派单角色, {SettingConstants.RolePaiDan}", "未配置派单角色");
|
|
|
+ user = await _userRepository.Queryable()
|
|
|
+ .Includes(d => d.Organization)
|
|
|
+ .Where(d => d.Roles.Any(x => x.Name == roleSend))
|
|
|
+ .FirstAsync(cancellationToken);
|
|
|
+ if (user is null)
|
|
|
+ throw UserFriendlyException.SameMessage("派单角色未设置用户");
|
|
|
+ break;
|
|
|
+ case EBusinessType.CenterMonitor:
|
|
|
+ var roleCenterMonitor = _systemSettingCacheManager.GetSetting(SettingConstants.SeatsMonitor)?.SettingValue.FirstOrDefault();
|
|
|
+ if (string.IsNullOrEmpty(roleCenterMonitor))
|
|
|
+ throw new UserFriendlyException($"未配置中心班长角色, {SettingConstants.SeatsMonitor}", "未配置中心班长角色");
|
|
|
+ user = await _userRepository.Queryable()
|
|
|
+ .Includes(d => d.Organization)
|
|
|
+ .Where(d => d.Roles.Any(x => x.Name == roleCenterMonitor))
|
|
|
+ .FirstAsync(cancellationToken);
|
|
|
+ if (user is null)
|
|
|
+ throw UserFriendlyException.SameMessage("中心班长角色未设置用户");
|
|
|
+ break;
|
|
|
+ case EBusinessType.CenterLeader:
|
|
|
+ var roleCenterLeader = _systemSettingCacheManager.GetSetting(SettingConstants.RoleCenterLeader)?.SettingValue.FirstOrDefault();
|
|
|
+ if (string.IsNullOrEmpty(roleCenterLeader))
|
|
|
+ throw new UserFriendlyException($"未配置中心领导角色, {SettingConstants.RoleCenterLeader}", "未配置中心领导角色");
|
|
|
+ user = await _userRepository.Queryable()
|
|
|
+ .Includes(d => d.Organization)
|
|
|
+ .Where(d => d.Roles.Any(x => x.Name == roleCenterLeader))
|
|
|
+ .FirstAsync(cancellationToken);
|
|
|
+ if (user is null)
|
|
|
+ throw UserFriendlyException.SameMessage("中心领导角色未设置用户");
|
|
|
+ break;
|
|
|
+ case EBusinessType.Department:
|
|
|
+ var roleJingBanRen = _systemSettingCacheManager.GetSetting(SettingConstants.RoleJingBanRen)?.SettingValue.FirstOrDefault();
|
|
|
+ if (string.IsNullOrEmpty(roleJingBanRen))
|
|
|
+ throw new UserFriendlyException($"未配置部门经办人角色, {SettingConstants.RoleJingBanRen}", "未配置部门经办人角色");
|
|
|
+ user = await _userRepository.Queryable()
|
|
|
+ .Includes(d=>d.Organization)
|
|
|
+ .Where(d => d.OrgId == step.HandlerOrgId && d.Roles.Any(x => x.Name == roleJingBanRen))
|
|
|
+ .FirstAsync(cancellationToken);
|
|
|
+ if (user is null)
|
|
|
+ throw new UserFriendlyException($"该部门经办人角色未设置用户,部门:{step.HandlerOrgId}, 角色:{SettingConstants.RoleJingBanRen}");
|
|
|
+ break;
|
|
|
+ case EBusinessType.DepartmentLeader:
|
|
|
+ var roleBuMenLingDao = _systemSettingCacheManager.GetSetting(SettingConstants.RoleLingDao)?.SettingValue.FirstOrDefault();
|
|
|
+ if (string.IsNullOrEmpty(roleBuMenLingDao))
|
|
|
+ throw new UserFriendlyException($"未配置部门领导角色, {SettingConstants.RoleJingBanRen}", "未配置部门领导角色");
|
|
|
+ user = await _userRepository.Queryable()
|
|
|
+ .Includes(d => d.Organization)
|
|
|
+ .Where(d => d.OrgId == step.HandlerOrgId && d.Roles.Any(x => x.Name == roleBuMenLingDao))
|
|
|
+ .FirstAsync(cancellationToken);
|
|
|
+ if (user is null)
|
|
|
+ throw new UserFriendlyException($"该部门领导角色未设置用户,部门:{step.HandlerOrgId}, 角色:{SettingConstants.RoleJingBanRen}");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new OutOfRangeException(nameof(GetHandlerRandomAsync));
|
|
|
+ }
|
|
|
+
|
|
|
+ return new FakeSessionContext
|
|
|
+ {
|
|
|
+ UserId = user.Id,
|
|
|
+ UserName = user.Name,
|
|
|
+ OrgId = user.OrgId,
|
|
|
+ OrgName = user.Organization.Name,
|
|
|
+ OrgAreaCode = user.Organization.AreaCode,
|
|
|
+ OrgAreaName = user.Organization.AreaName,
|
|
|
+ OrgIsCenter = user.Organization.IsCenter,
|
|
|
+ OrgLevel = user.Organization.Level,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|