|
@@ -1301,80 +1301,87 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
|
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.RequiredOrgId && x.Roles.Any(r => r.Name == leadRoleCode), cancellationToken);
|
|
|
- if (isSkip)
|
|
|
- {
|
|
|
- roleId = leadRoleCode;
|
|
|
- roleName = leadRoleName;
|
|
|
+ else {
|
|
|
+ orgLevel += 1;
|
|
|
}
|
|
|
- }
|
|
|
- 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;
|
|
|
+ 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.RequiredOrgId && 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;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ orgLevel += 1;
|
|
|
+ }
|
|
|
+ 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.ArriveOneOrg:
|
|
|
businessType = _sessionContext.OrgIsCenter ? EBusinessType.Send : EBusinessType.Department;
|
|
|
orgLevel = _sessionContext.OrgIsCenter ? 0 : 1;
|