|
@@ -56,8 +56,9 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IFileRepository _fileRepository;
|
|
|
private readonly ILogger<WorkflowApplication> _logger;
|
|
|
+ private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
|
|
|
- public WorkflowApplication(
|
|
|
+ public WorkflowApplication(
|
|
|
IDefinitionDomainService definitionDomainService,
|
|
|
IWorkflowDomainService workflowDomainService,
|
|
|
IOrderDomainService orderDomainService,
|
|
@@ -435,8 +436,10 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
if (startStepDefine.InstanceMode is EInstanceMode.Dynamic &&
|
|
|
!_workflowDomainService.DynamicShouldTerminal(startStepDefine, _sessionContext.OrgLevel))
|
|
|
{
|
|
|
- var nextStepOption = await GetDynamicStepAsync(startStepDefine.InstancePolicy.Value,
|
|
|
- startStepDefine.StepType, startStepDefine.BusinessType, cancellationToken);
|
|
|
+ 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>
|
|
|
{
|
|
|
Steps = new List<NextStepOption> { nextStepOption }
|
|
@@ -500,9 +503,11 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
if (currentStep.InstanceMode is EInstanceMode.Dynamic &&
|
|
|
!_workflowDomainService.DynamicShouldTerminal(currentStepDefine, _sessionContext.OrgLevel))
|
|
|
{
|
|
|
- //动态生成下一步
|
|
|
- var nextStepOption = await GetDynamicStepAsync(currentStep.InstancePolicy.Value, currentStep.StepType,
|
|
|
- currentStep.BusinessType, cancellationToken);
|
|
|
+ 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;
|
|
|
}
|
|
@@ -1015,14 +1020,22 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
|
|
private async Task<NextStepOption> GetDynamicStepAsync(
|
|
|
EDynamicPolicy policy, EStepType stepType,
|
|
|
- EBusinessType currentBusinessType, CancellationToken cancellationToken)
|
|
|
+ EBusinessType currentBusinessType,string handleRoleCode,string leadRoleCode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
int orgLevel;
|
|
|
List<FlowStepHandler> items;
|
|
|
string upperOrgId;
|
|
|
EBusinessType businessType;
|
|
|
EFlowDirection? flowDirection = null;
|
|
|
- switch (policy)
|
|
|
+ bool isLead = false;
|
|
|
+ bool isSkip = false;
|
|
|
+ string roleId = string.Empty;
|
|
|
+ string roleName = string.Empty;
|
|
|
+ string handleRoleName = "经办人";
|
|
|
+ string leadRoleName = "领导";
|
|
|
+ EHandlerType handlerType = EHandlerType.OrgLevel;
|
|
|
+
|
|
|
+ switch (policy)
|
|
|
{
|
|
|
case EDynamicPolicy.OrgUpCenterTop:
|
|
|
orgLevel = _sessionContext.OrgLevel - 1;
|
|
@@ -1085,7 +1098,192 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
})
|
|
|
.ToListAsync(cancellationToken);
|
|
|
break;
|
|
|
- case EDynamicPolicy.OrgDownCenterTop:
|
|
|
+ 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;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ 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.OrgUpLeadCenterTop:
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
+ if (orgLevel < 0) orgLevel = 0;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(_sessionContext.OrgLevel);
|
|
|
+ isLead = _sessionContext.Roles.Any(x => x == leadRoleCode);
|
|
|
+ if (!isLead)
|
|
|
+ {
|
|
|
+ isSkip = await _userRepository.Queryable().AnyAsync(x => x.OrgId == _sessionContext.OrgId && x.Roles.Any(r => r.Name == leadRoleCode), cancellationToken);
|
|
|
+ if (isSkip)
|
|
|
+ {
|
|
|
+ roleId = leadRoleCode;
|
|
|
+ roleName = leadRoleName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isLead || !isSkip)
|
|
|
+ {
|
|
|
+ //上级部门Id
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
+ roleId = handleRoleCode;
|
|
|
+ roleName = handleRoleName;
|
|
|
+ }
|
|
|
+ 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 = roleId,
|
|
|
+ RoleName = roleName
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case EDynamicPolicy.OrgUpLead:
|
|
|
+ businessType = _sessionContext.OrgIsCenter
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : _sessionContext.RequiredOrgId.CalcOrgLevel() == 1
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : EBusinessType.Department;
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
+ if (orgLevel <= 0) orgLevel = 1;
|
|
|
+ handlerType = EHandlerType.AssignedOrgOrRole;
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(_sessionContext.OrgLevel);
|
|
|
+ isLead = _sessionContext.Roles.Any(x => x == leadRoleCode);
|
|
|
+ if (!isLead)
|
|
|
+ {
|
|
|
+ isSkip = await _userRepository.Queryable().AnyAsync(x => x.OrgId == _sessionContext.OrgId && x.Roles.Any(r => r.Name == leadRoleCode), cancellationToken);
|
|
|
+ if (isSkip)
|
|
|
+ {
|
|
|
+ roleId = leadRoleCode;
|
|
|
+ roleName = leadRoleName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isLead || !isSkip)
|
|
|
+ {
|
|
|
+ //上级部门Id
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
+ roleId = handleRoleCode;
|
|
|
+ roleName = handleRoleName;
|
|
|
+ }
|
|
|
+ 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 = roleId,
|
|
|
+ RoleName = roleName
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+ break;
|
|
|
+ case EDynamicPolicy.ArriveCenter:
|
|
|
+ businessType = _sessionContext.OrgIsCenter
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : _sessionContext.RequiredOrgId.CalcOrgLevel() == 1
|
|
|
+ ? EBusinessType.Send
|
|
|
+ : EBusinessType.Department;
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
+ if (orgLevel <= 0) orgLevel = 1;
|
|
|
+ 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);
|
|
|
+ break;
|
|
|
+ case EDynamicPolicy.OrgDownCenterTop:
|
|
|
businessType = EBusinessType.Department;
|
|
|
if (_sessionContext.OrgIsCenter)
|
|
|
{
|
|
@@ -1139,11 +1337,11 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
return new NextStepOption
|
|
|
{
|
|
|
Key = orgLevel.ToString(),
|
|
|
- Value = orgLevel == 0 ? "市民热线服务中心" : $"{orgLevel.ToChinese()}级部门",
|
|
|
+ Value = orgLevel == 0 ? "市民热线服务中心" : $"{orgLevel.ToChinese()}级部门{roleName}",
|
|
|
FlowDirection = flowDirection,
|
|
|
StepType = stepType,
|
|
|
BusinessType = businessType,
|
|
|
- HandlerType = EHandlerType.OrgLevel, //目前所有动态策略均属于部门等级
|
|
|
+ HandlerType = handlerType, //目前所有动态策略均属于部门等级
|
|
|
Items = items
|
|
|
};
|
|
|
}
|