|
@@ -61,7 +61,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
private readonly IOptions<CityBaseConfiguration> _cityBaseConfiguration;
|
|
|
|
|
|
- public WorkflowApplication(
|
|
|
+ public WorkflowApplication(
|
|
|
IDefinitionDomainService definitionDomainService,
|
|
|
IWorkflowDomainService workflowDomainService,
|
|
|
IOrderDomainService orderDomainService,
|
|
@@ -80,7 +80,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
IMapper mapper,
|
|
|
IFileRepository fileRepository,
|
|
|
ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
- ILogger<WorkflowApplication> logger,
|
|
|
+ ILogger<WorkflowApplication> logger,
|
|
|
IOptions<CityBaseConfiguration> cityBaseConfiguration)
|
|
|
{
|
|
|
_definitionDomainService = definitionDomainService;
|
|
@@ -103,7 +103,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
_logger = logger;
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
_cityBaseConfiguration = cityBaseConfiguration;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
public async Task<string> StartWorkflowAsync(StartWorkflowDto dto, ISessionContext current, string externalId,
|
|
|
DateTime? expiredTime, CancellationToken cancellationToken = default)
|
|
@@ -237,9 +237,9 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
var workflow = await _workflowDomainService.CreateWorkflowAsync(wfModule, dto.Title,
|
|
|
current.RequiredUserId, current.RequiredOrgId,
|
|
|
externalId, cancellationToken);
|
|
|
-
|
|
|
+
|
|
|
var defineHandler = startStepDefine.HandlerTypeItems.First();
|
|
|
-
|
|
|
+
|
|
|
//todo 需求:所有坐席都可以办,临时方案,后期重构:依据策略决定指派对象
|
|
|
var startStep = _workflowDomainService.CreateStartStep(workflow, startStepDefine, dto,
|
|
|
new FlowStepHandler
|
|
@@ -254,7 +254,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
RoleName = defineHandler.Value,
|
|
|
}, expiredTime,
|
|
|
EFlowAssignType.Role);
|
|
|
-
|
|
|
+
|
|
|
if (dto.Files.Any())
|
|
|
startStep.FileJson = await _fileRepository.AddFileAsync(dto.Files, workflow.ExternalId, startStep.Id, cancellationToken);
|
|
|
|
|
@@ -277,7 +277,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
current.StaffNo,
|
|
|
current.RequiredOrgId,
|
|
|
current.OrgName);
|
|
|
-
|
|
|
+
|
|
|
return workflow.Id;
|
|
|
}
|
|
|
|
|
@@ -398,27 +398,27 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
var targetStepDefine = _workflowDomainService.GetStepDefine(workflow.WorkflowDefinition, dto.NextStepCode);
|
|
|
if (targetStepDefine.StepType is EStepType.End)
|
|
|
throw UserFriendlyException.SameMessage("结束节点不支持撤回");
|
|
|
- //var isStartCountersign = targetStepDefine.CouldPrevStartCountersign(dto.NextHandlers.Count);
|
|
|
- var targetStep = workflow.Steps.FirstOrDefault(d => d.Code == dto.NextStepCode && d.IsOrigin);
|
|
|
- if (targetStep is null)
|
|
|
- throw UserFriendlyException.SameMessage("该流程尚未流转至该节点");
|
|
|
-
|
|
|
- ///退回到派单组 没有下一步办理人 获取之前节点办理人
|
|
|
- if (!dto.NextHandlers.Any())
|
|
|
- {
|
|
|
- dto.NextHandlers.Add(new FlowStepHandler()
|
|
|
- {
|
|
|
- UserId = targetStep.HandlerId,
|
|
|
- Username = targetStep.HandlerName,
|
|
|
- OrgId = targetStep.HandlerOrgId,
|
|
|
- OrgName = targetStep.HandlerOrgName,
|
|
|
- Key = targetStep.HandlerId,
|
|
|
- Value = targetStep.HandlerName,
|
|
|
- RoleId = targetStep.RoleId,
|
|
|
- RoleName = targetStep.RoleName
|
|
|
- });
|
|
|
- }
|
|
|
- var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, dto.HandlerType, dto.IsStartCountersign,
|
|
|
+ //var isStartCountersign = targetStepDefine.CouldPrevStartCountersign(dto.NextHandlers.Count);
|
|
|
+ var targetStep = workflow.Steps.FirstOrDefault(d => d.Code == dto.NextStepCode && d.IsOrigin);
|
|
|
+ if (targetStep is null)
|
|
|
+ throw UserFriendlyException.SameMessage("该流程尚未流转至该节点");
|
|
|
+
|
|
|
+ ///退回到派单组 没有下一步办理人 获取之前节点办理人
|
|
|
+ if (!dto.NextHandlers.Any())
|
|
|
+ {
|
|
|
+ dto.NextHandlers.Add(new FlowStepHandler()
|
|
|
+ {
|
|
|
+ UserId = targetStep.HandlerId,
|
|
|
+ Username = targetStep.HandlerName,
|
|
|
+ OrgId = targetStep.HandlerOrgId,
|
|
|
+ OrgName = targetStep.HandlerOrgName,
|
|
|
+ Key = targetStep.HandlerId,
|
|
|
+ Value = targetStep.HandlerName,
|
|
|
+ RoleId = targetStep.RoleId,
|
|
|
+ RoleName = targetStep.RoleName
|
|
|
+ });
|
|
|
+ }
|
|
|
+ var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, dto.HandlerType, dto.IsStartCountersign,
|
|
|
dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
|
|
|
|
|
|
//var stepHandlers = await GetNextStepHandlersAsync(workflow, targetStepDefine, dto, cancellationToken);
|
|
@@ -528,9 +528,9 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
if (startStepDefine.InstanceMode is EInstanceMode.Dynamic &&
|
|
|
!_workflowDomainService.DynamicShouldTerminal(startStepDefine, _sessionContext.OrgLevel))
|
|
|
{
|
|
|
- var settingHandle = _systemSettingCacheManager.GetSetting(SettingConstants.RoleJingBanRen);
|
|
|
- var settingLead = _systemSettingCacheManager.GetSetting(SettingConstants.RoleLingDao);
|
|
|
- var nextStepOption = await GetDynamicStepAsync(startStepDefine.InstancePolicy.Value,
|
|
|
+ var settingHandle = _systemSettingCacheManager.GetSetting(SettingConstants.RoleJingBanRen);
|
|
|
+ var settingLead = _systemSettingCacheManager.GetSetting(SettingConstants.RoleLingDao);
|
|
|
+ var nextStepOption = await GetDynamicStepAsync(startStepDefine.InstancePolicy.Value,
|
|
|
startStepDefine.StepType, startStepDefine.BusinessType, settingHandle?.SettingValue[0], settingLead?.SettingValue[0], cancellationToken);
|
|
|
return new NextStepsDto<NextStepOption>
|
|
|
{
|
|
@@ -595,10 +595,10 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
if (currentStep.InstanceMode is EInstanceMode.Dynamic &&
|
|
|
!_workflowDomainService.DynamicShouldTerminal(currentStepDefine, _sessionContext.OrgLevel))
|
|
|
{
|
|
|
- var settingHandle = _systemSettingCacheManager.GetSetting(SettingConstants.RoleJingBanRen);
|
|
|
- var settingLead = _systemSettingCacheManager.GetSetting(SettingConstants.RoleLingDao);
|
|
|
- //动态生成下一步
|
|
|
- var nextStepOption = await GetDynamicStepAsync(currentStep.InstancePolicy.Value, currentStep.StepType,
|
|
|
+ var settingHandle = _systemSettingCacheManager.GetSetting(SettingConstants.RoleJingBanRen);
|
|
|
+ var settingLead = _systemSettingCacheManager.GetSetting(SettingConstants.RoleLingDao);
|
|
|
+ //动态生成下一步
|
|
|
+ var nextStepOption = await GetDynamicStepAsync(currentStep.InstancePolicy.Value, currentStep.StepType,
|
|
|
currentStep.BusinessType, settingHandle?.SettingValue[0], settingLead?.SettingValue[0], cancellationToken);
|
|
|
dto.Steps = new List<NextStepOption> { nextStepOption };
|
|
|
return dto;
|
|
@@ -1112,7 +1112,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
|
|
private async Task<NextStepOption> GetDynamicStepAsync(
|
|
|
EDynamicPolicy policy, EStepType stepType,
|
|
|
- EBusinessType currentBusinessType,string handleRoleCode,string leadRoleCode, CancellationToken cancellationToken)
|
|
|
+ EBusinessType currentBusinessType, string handleRoleCode, string leadRoleCode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
int orgLevel;
|
|
|
List<FlowStepHandler> items;
|
|
@@ -1121,13 +1121,13 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
EFlowDirection? flowDirection = null;
|
|
|
bool isLead = false;
|
|
|
bool isSkip = false;
|
|
|
- string roleId = string.Empty;
|
|
|
+ string roleId = string.Empty;
|
|
|
string roleName = string.Empty;
|
|
|
string handleRoleName = "经办人";
|
|
|
string leadRoleName = "领导";
|
|
|
EHandlerType handlerType = EHandlerType.OrgLevel;
|
|
|
|
|
|
- switch (policy)
|
|
|
+ switch (policy)
|
|
|
{
|
|
|
case EDynamicPolicy.OrgUpCenterTop:
|
|
|
orgLevel = _sessionContext.OrgLevel - 1;
|
|
@@ -1190,58 +1190,58 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
})
|
|
|
.ToListAsync(cancellationToken);
|
|
|
break;
|
|
|
- case EDynamicPolicy.OrgUpHandleCenterTop:
|
|
|
- orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
- if (orgLevel < 0) orgLevel = 0;
|
|
|
+ case EDynamicPolicy.OrgUpHandleCenterTop:
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
+ if (orgLevel < 0) orgLevel = 0;
|
|
|
|
|
|
- if (orgLevel == 0)
|
|
|
- {
|
|
|
- businessType = EBusinessType.Send;
|
|
|
- if (currentBusinessType == EBusinessType.Department)
|
|
|
- flowDirection = EFlowDirection.OrgToCenter;
|
|
|
+ if (orgLevel == 0)
|
|
|
+ {
|
|
|
+ businessType = EBusinessType.Send;
|
|
|
+ if (currentBusinessType == EBusinessType.Department)
|
|
|
+ flowDirection = EFlowDirection.OrgToCenter;
|
|
|
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => d.IsCenter)
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- businessType = EBusinessType.Department;
|
|
|
- handlerType = EHandlerType.AssignedOrgOrRole;
|
|
|
- roleName = handleRoleName;
|
|
|
- //上级部门Id
|
|
|
- upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => d.Id == upperOrgId)
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name,
|
|
|
- RoleId = handleRoleCode,
|
|
|
- RoleName = handleRoleName,
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- }
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => d.IsCenter)
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ businessType = EBusinessType.Department;
|
|
|
+ handlerType = EHandlerType.AssignedOrgOrRole;
|
|
|
+ roleName = handleRoleName;
|
|
|
+ //上级部门Id
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => d.Id == upperOrgId)
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name,
|
|
|
+ RoleId = handleRoleCode,
|
|
|
+ RoleName = handleRoleName,
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ }
|
|
|
|
|
|
- break;
|
|
|
- case EDynamicPolicy.OrgUpHandle:
|
|
|
- businessType = _sessionContext.OrgIsCenter
|
|
|
- ? EBusinessType.Send
|
|
|
- : _sessionContext.RequiredOrgId.CalcOrgLevel() == 1
|
|
|
- ? EBusinessType.Send
|
|
|
- : EBusinessType.Department;
|
|
|
- orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
- handlerType = EHandlerType.AssignedOrgOrRole;
|
|
|
- if (orgLevel <= 0) orgLevel = 1;
|
|
|
+ break;
|
|
|
+ case EDynamicPolicy.OrgUpHandle:
|
|
|
+ businessType = _sessionContext.OrgIsCenter
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : _sessionContext.RequiredOrgId.CalcOrgLevel() == 1
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : EBusinessType.Department;
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
+ handlerType = EHandlerType.AssignedOrgOrRole;
|
|
|
+ if (orgLevel <= 0) orgLevel = 1;
|
|
|
roleName = handleRoleName;
|
|
|
//上级部门Id
|
|
|
upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
@@ -1382,22 +1382,22 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
.ToListAsync(cancellationToken);
|
|
|
break;
|
|
|
case EDynamicPolicy.ArriveOneOrg:
|
|
|
- businessType = _sessionContext.OrgIsCenter? EBusinessType.Send: EBusinessType.Department;
|
|
|
+ businessType = _sessionContext.OrgIsCenter ? EBusinessType.Send : EBusinessType.Department;
|
|
|
orgLevel = _sessionContext.OrgIsCenter ? 0 : 1;
|
|
|
- //上级部门Id
|
|
|
- upperOrgId = _sessionContext.OrgIsCenter ? _sessionContext.RequiredOrgId.Substring(0,3) : _sessionContext.RequiredOrgId.Substring(0, 6);
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => d.Id == upperOrgId)
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- break;
|
|
|
- case EDynamicPolicy.OrgDownCenterTop:
|
|
|
+ //上级部门Id
|
|
|
+ upperOrgId = _sessionContext.OrgIsCenter ? _sessionContext.RequiredOrgId.Substring(0, 3) : _sessionContext.RequiredOrgId.Substring(0, 6);
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => d.Id == upperOrgId)
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ break;
|
|
|
+ case EDynamicPolicy.OrgDownCenterTop:
|
|
|
businessType = EBusinessType.Department;
|
|
|
if (_sessionContext.OrgIsCenter)
|
|
|
{
|
|
@@ -1465,144 +1465,144 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
|
|
|
- private async Task<NextStepOption> GetDynamicStepAsync(
|
|
|
- EDynamicPolicyCountersign policy, EStepType stepType,
|
|
|
- EBusinessType currentBusinessType, CancellationToken cancellationToken)
|
|
|
- {
|
|
|
- int orgLevel;
|
|
|
- List<FlowStepHandler> items;
|
|
|
- string upperOrgId;
|
|
|
- EBusinessType businessType;
|
|
|
- EFlowDirection? flowDirection = null;
|
|
|
- switch (policy)
|
|
|
- {
|
|
|
- case EDynamicPolicyCountersign.OrgUpCenterTop:
|
|
|
- orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
- if (orgLevel < 0) orgLevel = 0;
|
|
|
+ private async Task<NextStepOption> GetDynamicStepAsync(
|
|
|
+ EDynamicPolicyCountersign policy, EStepType stepType,
|
|
|
+ EBusinessType currentBusinessType, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ int orgLevel;
|
|
|
+ List<FlowStepHandler> items;
|
|
|
+ string upperOrgId;
|
|
|
+ EBusinessType businessType;
|
|
|
+ EFlowDirection? flowDirection = null;
|
|
|
+ switch (policy)
|
|
|
+ {
|
|
|
+ case EDynamicPolicyCountersign.OrgUpCenterTop:
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
+ if (orgLevel < 0) orgLevel = 0;
|
|
|
|
|
|
- if (orgLevel == 0)
|
|
|
- {
|
|
|
- businessType = EBusinessType.Send;
|
|
|
- if (currentBusinessType == EBusinessType.Department)
|
|
|
- flowDirection = EFlowDirection.OrgToCenter;
|
|
|
+ if (orgLevel == 0)
|
|
|
+ {
|
|
|
+ businessType = EBusinessType.Send;
|
|
|
+ if (currentBusinessType == EBusinessType.Department)
|
|
|
+ flowDirection = EFlowDirection.OrgToCenter;
|
|
|
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => d.IsCenter)
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- businessType = EBusinessType.Department;
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => d.IsCenter)
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ businessType = EBusinessType.Department;
|
|
|
|
|
|
- //上级部门Id
|
|
|
- upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => d.Id == upperOrgId)
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- }
|
|
|
+ //上级部门Id
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => d.Id == upperOrgId)
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ }
|
|
|
|
|
|
- break;
|
|
|
- case EDynamicPolicyCountersign.OrgUp:
|
|
|
- businessType = _sessionContext.OrgIsCenter
|
|
|
- ? EBusinessType.Send
|
|
|
- : _sessionContext.RequiredOrgId.CalcOrgLevel() == 1
|
|
|
- ? EBusinessType.Send
|
|
|
- : EBusinessType.Department;
|
|
|
- orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
- if (orgLevel <= 0) orgLevel = 1;
|
|
|
- //上级部门Id
|
|
|
- upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => d.Id == upperOrgId)
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- break;
|
|
|
- case EDynamicPolicyCountersign.OrgDownCenterTop:
|
|
|
- businessType = EBusinessType.Department;
|
|
|
- if (_sessionContext.OrgIsCenter)
|
|
|
- {
|
|
|
- orgLevel = 1;
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => !d.IsCenter && d.Level == orgLevel)
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- orgLevel = _sessionContext.OrgLevel + 1;
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => !d.IsCenter && d.Level == orgLevel &&
|
|
|
- d.Id.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- }
|
|
|
+ break;
|
|
|
+ case EDynamicPolicyCountersign.OrgUp:
|
|
|
+ businessType = _sessionContext.OrgIsCenter
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : _sessionContext.RequiredOrgId.CalcOrgLevel() == 1
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : EBusinessType.Department;
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
+ if (orgLevel <= 0) orgLevel = 1;
|
|
|
+ //上级部门Id
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => d.Id == upperOrgId)
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ break;
|
|
|
+ case EDynamicPolicyCountersign.OrgDownCenterTop:
|
|
|
+ businessType = EBusinessType.Department;
|
|
|
+ if (_sessionContext.OrgIsCenter)
|
|
|
+ {
|
|
|
+ orgLevel = 1;
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => !d.IsCenter && d.Level == orgLevel)
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ orgLevel = _sessionContext.OrgLevel + 1;
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => !d.IsCenter && d.Level == orgLevel &&
|
|
|
+ d.Id.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ }
|
|
|
|
|
|
- break;
|
|
|
- case EDynamicPolicyCountersign.OrgDown:
|
|
|
- businessType = EBusinessType.Department;
|
|
|
- orgLevel = _sessionContext.OrgLevel + 1;
|
|
|
- items = await _organizeRepository.Queryable()
|
|
|
- .Where(d => d.Level == orgLevel && d.Id.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
- .Select(d => new FlowStepHandler
|
|
|
- {
|
|
|
- Key = d.Id,
|
|
|
- Value = d.Name,
|
|
|
- OrgId = d.Id,
|
|
|
- OrgName = d.Name
|
|
|
- })
|
|
|
- .ToListAsync(cancellationToken);
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new ArgumentOutOfRangeException(nameof(policy), policy, null);
|
|
|
- }
|
|
|
-
|
|
|
- return new NextStepOption
|
|
|
- {
|
|
|
- Key = orgLevel.ToString(),
|
|
|
- Value = orgLevel == 0 ? "市民热线服务中心" : $"{orgLevel.ToChinese()}级部门",
|
|
|
- FlowDirection = flowDirection,
|
|
|
- StepType = stepType,
|
|
|
- BusinessType = businessType,
|
|
|
- HandlerType = EHandlerType.OrgLevel, //目前所有动态策略均属于部门等级
|
|
|
- Items = items
|
|
|
- };
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 查询下一节点办理对象类型(user or org)及实际办理对象
|
|
|
- /// </summary>
|
|
|
- public async Task<FlowAssignInfo> GetNextStepFlowAssignInfoAsync(Workflow workflow, WorkflowStep currentStep,
|
|
|
+ break;
|
|
|
+ case EDynamicPolicyCountersign.OrgDown:
|
|
|
+ businessType = EBusinessType.Department;
|
|
|
+ orgLevel = _sessionContext.OrgLevel + 1;
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
+ .Where(d => d.Level == orgLevel && d.Id.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
+ {
|
|
|
+ Key = d.Id,
|
|
|
+ Value = d.Name,
|
|
|
+ OrgId = d.Id,
|
|
|
+ OrgName = d.Name
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new ArgumentOutOfRangeException(nameof(policy), policy, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new NextStepOption
|
|
|
+ {
|
|
|
+ Key = orgLevel.ToString(),
|
|
|
+ Value = orgLevel == 0 ? "市民热线服务中心" : $"{orgLevel.ToChinese()}级部门",
|
|
|
+ FlowDirection = flowDirection,
|
|
|
+ StepType = stepType,
|
|
|
+ BusinessType = businessType,
|
|
|
+ HandlerType = EHandlerType.OrgLevel, //目前所有动态策略均属于部门等级
|
|
|
+ Items = items
|
|
|
+ };
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 查询下一节点办理对象类型(user or org)及实际办理对象
|
|
|
+ /// </summary>
|
|
|
+ public async Task<FlowAssignInfo> GetNextStepFlowAssignInfoAsync(Workflow workflow, WorkflowStep currentStep,
|
|
|
BasicWorkflowDto dto, StepDefine nextStepDefine, bool isNextDynamic, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (nextStepDefine.StepType is EStepType.End) return new();
|
|
@@ -1656,8 +1656,27 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
}
|
|
|
|
|
|
if (isNextDynamic)
|
|
|
- return dto.HandlerType == EHandlerType.AssignedOrgOrRole? FlowAssignInfo.Create(EFlowAssignType.OrgAndRole, handlers, isStartCountersign)
|
|
|
- : FlowAssignInfo.Create(EFlowAssignType.Org, handlers, isStartCountersign);
|
|
|
+ {
|
|
|
+ switch (currentStep.InstancePolicy)
|
|
|
+ {
|
|
|
+ case EDynamicPolicy.OrgUpCenterTop:
|
|
|
+ case EDynamicPolicy.OrgUp:
|
|
|
+ case EDynamicPolicy.OrgDownCenterTop:
|
|
|
+ case EDynamicPolicy.OrgDown:
|
|
|
+ case EDynamicPolicy.ArriveCenter:
|
|
|
+ case EDynamicPolicy.ArriveOneOrg:
|
|
|
+ return FlowAssignInfo.Create(EFlowAssignType.Org, handlers, isStartCountersign);
|
|
|
+ case EDynamicPolicy.OrgUpHandleCenterTop:
|
|
|
+ case EDynamicPolicy.OrgUpHandle:
|
|
|
+ case EDynamicPolicy.OrgUpLeadCenterTop:
|
|
|
+ case EDynamicPolicy.OrgUpLead:
|
|
|
+ return FlowAssignInfo.Create(EFlowAssignType.OrgAndRole, handlers, isStartCountersign);
|
|
|
+ default:
|
|
|
+ throw new ArgumentOutOfRangeException();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return await GetNextStepFlowAssignInfoByDefineAsync(nextStepDefine, dto.HandlerType, isStartCountersign, handlers,
|
|
|
cancellationToken);
|
|
@@ -1695,7 +1714,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
case EHandlerType.AssignedUser:
|
|
|
return FlowAssignInfo.Create(EFlowAssignType.User, handlers, isStartCountersign);
|
|
|
case EHandlerType.AssignedOrgOrRole:
|
|
|
- return FlowAssignInfo.Create(EFlowAssignType.OrgAndRole, handlers, isStartCountersign);
|
|
|
+ return FlowAssignInfo.Create(EFlowAssignType.OrgAndRole, handlers, isStartCountersign);
|
|
|
|
|
|
default:
|
|
|
throw new ArgumentOutOfRangeException();
|
|
@@ -1771,8 +1790,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
var workflow = await _workflowDomainService.GetWorkflowAsync(workflowId, withSteps: true, withTraces: true,
|
|
|
cancellationToken: cancellationToken);
|
|
|
var step = workflow.Steps.FirstOrDefault(d =>
|
|
|
- //d.StepHandlers.Any(d => d.OrgId == _cityBaseConfiguration.Value.CityProvince.OrgId || d.OrgId == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId));
|
|
|
- d.HandlerOrgId == _cityBaseConfiguration.Value.CityProvince.OrgId || d.HandlerOrgId == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId);
|
|
|
+ //d.StepHandlers.Any(d => d.OrgId == _cityBaseConfiguration.Value.CityProvince.OrgId || d.OrgId == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId));
|
|
|
+ d.HandlerOrgId == _cityBaseConfiguration.Value.CityProvince.OrgId || d.HandlerOrgId == _cityBaseConfiguration.Value.CityProvinceAssign.OrgId);
|
|
|
if (step is not null)
|
|
|
{
|
|
|
step.FileJson = await _fileRepository.AddFileAsync(files, workflow.ExternalId, step.Id, cancellationToken);
|