打印了JENKINS节点日志
This commit is contained in:
parent
8b940229fc
commit
dc01b87943
@ -70,14 +70,18 @@ public class DeployApiController {
|
|||||||
/**
|
/**
|
||||||
* 获取当前用户的部署审批任务列表
|
* 获取当前用户的部署审批任务列表
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "获取我的部署审批任务", description = "查询当前登录用户待审批的部署任务,包含完整的部署业务上下文信息")
|
@Operation(summary = "获取我的部署审批任务", description = "查询当前登录用户待审批的部署任务,支持按团队和环境筛选")
|
||||||
@GetMapping("/my-approval-tasks")
|
@GetMapping("/my-approval-tasks")
|
||||||
@PreAuthorize("isAuthenticated()")
|
@PreAuthorize("isAuthenticated()")
|
||||||
public Response<List<DeployApprovalTaskDTO>> getMyApprovalTasks(
|
public Response<List<DeployApprovalTaskDTO>> getMyApprovalTasks(
|
||||||
|
@Parameter(description = "团队ID(可选,用于筛选指定团队的审批任务)")
|
||||||
|
@RequestParam(required = false) Long teamId,
|
||||||
|
@Parameter(description = "环境ID(可选,用于筛选指定环境的审批任务)")
|
||||||
|
@RequestParam(required = false) Long environmentId,
|
||||||
@Parameter(description = "工作流定义Key列表(可选,支持查询多个工作流的待审批任务)")
|
@Parameter(description = "工作流定义Key列表(可选,支持查询多个工作流的待审批任务)")
|
||||||
@RequestParam(required = false) List<String> workflowDefinitionKeys
|
@RequestParam(required = false) List<String> workflowDefinitionKeys
|
||||||
) {
|
) {
|
||||||
return Response.success(deployService.getMyApprovalTasks(workflowDefinitionKeys));
|
return Response.success(deployService.getMyApprovalTasks(teamId, environmentId, workflowDefinitionKeys));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -31,10 +31,12 @@ public interface IDeployService {
|
|||||||
* 获取当前用户的部署审批任务列表
|
* 获取当前用户的部署审批任务列表
|
||||||
* <p>查询当前登录用户待审批的部署任务,包含完整的部署业务上下文信息
|
* <p>查询当前登录用户待审批的部署任务,包含完整的部署业务上下文信息
|
||||||
*
|
*
|
||||||
|
* @param teamId 团队ID(可选,用于筛选指定团队的审批任务)
|
||||||
|
* @param environmentId 环境ID(可选,用于筛选指定环境的审批任务)
|
||||||
* @param workflowDefinitionKeys 工作流定义Key列表(可选,支持查询多个工作流的待审批任务)
|
* @param workflowDefinitionKeys 工作流定义Key列表(可选,支持查询多个工作流的待审批任务)
|
||||||
* @return 部署审批任务列表
|
* @return 部署审批任务列表
|
||||||
*/
|
*/
|
||||||
List<DeployApprovalTaskDTO> getMyApprovalTasks(List<String> workflowDefinitionKeys);
|
List<DeployApprovalTaskDTO> getMyApprovalTasks(Long teamId, Long environmentId, List<String> workflowDefinitionKeys);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 完成部署审批
|
* 完成部署审批
|
||||||
|
|||||||
@ -329,39 +329,24 @@ public class DeployServiceImpl implements IDeployService {
|
|||||||
List<TeamApplication> teamApps = teamAppsMap.get(teamId);
|
List<TeamApplication> teamApps = teamAppsMap.get(teamId);
|
||||||
List<UserDeployableTeamEnvironmentDTO> environments = new ArrayList<>();
|
List<UserDeployableTeamEnvironmentDTO> environments = new ArrayList<>();
|
||||||
|
|
||||||
if (teamApps != null && !teamApps.isEmpty()) {
|
// 按环境分组应用(如果有应用的话)
|
||||||
// 有应用配置:按环境分组
|
Map<Long, List<TeamApplication>> appsByEnv = (teamApps != null && !teamApps.isEmpty())
|
||||||
Map<Long, List<TeamApplication>> appsByEnv = teamApps.stream()
|
? teamApps.stream().collect(groupingBy(TeamApplication::getEnvironmentId))
|
||||||
.collect(groupingBy(TeamApplication::getEnvironmentId));
|
: Collections.emptyMap();
|
||||||
|
|
||||||
for (Map.Entry<Long, List<TeamApplication>> entry : appsByEnv.entrySet()) {
|
// 遍历所有团队配置的环境,有应用就显示应用,没应用就显示空列表
|
||||||
Long envId = entry.getKey();
|
for (Environment env : envMap.values()) {
|
||||||
Environment env = envMap.get(envId);
|
// 获取该环境的应用列表(没有则为空列表)
|
||||||
if (env == null) {
|
List<TeamApplication> envApps = appsByEnv.getOrDefault(env.getId(), Collections.emptyList());
|
||||||
continue;
|
|
||||||
}
|
UserDeployableTeamEnvironmentDTO envDTO = buildUserDeployableTeamEnvironmentDTO(
|
||||||
|
currentUserId, team.getOwnerId(),
|
||||||
UserDeployableTeamEnvironmentDTO envDTO = buildUserDeployableTeamEnvironmentDTO(
|
teamId, env, envApps,
|
||||||
currentUserId, team.getOwnerId(),
|
appMap, systemMap, workflowMap,
|
||||||
teamId, env, entry.getValue(),
|
teamEnvConfigMap, approverMap,
|
||||||
appMap, systemMap, workflowMap,
|
statisticsMap, latestRecordMap, recentRecordsMap
|
||||||
teamEnvConfigMap, approverMap,
|
);
|
||||||
statisticsMap, latestRecordMap, recentRecordsMap
|
environments.add(envDTO);
|
||||||
);
|
|
||||||
environments.add(envDTO);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 没有应用配置:显示所有可用环境,但应用列表为空
|
|
||||||
for (Environment env : envMap.values()) {
|
|
||||||
UserDeployableTeamEnvironmentDTO envDTO = buildUserDeployableTeamEnvironmentDTO(
|
|
||||||
currentUserId, team.getOwnerId(),
|
|
||||||
teamId, env, Collections.emptyList(), // 空的应用列表
|
|
||||||
appMap, systemMap, workflowMap,
|
|
||||||
teamEnvConfigMap, approverMap,
|
|
||||||
statisticsMap, latestRecordMap, recentRecordsMap
|
|
||||||
);
|
|
||||||
environments.add(envDTO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按sort排序
|
// 按sort排序
|
||||||
@ -725,10 +710,11 @@ public class DeployServiceImpl implements IDeployService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeployApprovalTaskDTO> getMyApprovalTasks(List<String> workflowDefinitionKeys) {
|
public List<DeployApprovalTaskDTO> getMyApprovalTasks(Long teamId, Long environmentId, List<String> workflowDefinitionKeys) {
|
||||||
// 1. 获取当前登录用户
|
// 1. 获取当前登录用户
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
log.info("查询用户 {} 的部署审批任务, workflowDefinitionKeys={}", currentUsername, workflowDefinitionKeys);
|
log.info("查询用户 {} 的部署审批任务, teamId={}, environmentId={}, workflowDefinitionKeys={}",
|
||||||
|
currentUsername, teamId, environmentId, workflowDefinitionKeys);
|
||||||
|
|
||||||
// 2. 查询用户的部署工作流待办任务(支持多个工作流)
|
// 2. 查询用户的部署工作流待办任务(支持多个工作流)
|
||||||
TaskQuery taskQuery = taskService.createTaskQuery()
|
TaskQuery taskQuery = taskService.createTaskQuery()
|
||||||
@ -772,7 +758,22 @@ public class DeployServiceImpl implements IDeployService {
|
|||||||
// 4. 批量查询团队信息(解决 N+1 查询问题)
|
// 4. 批量查询团队信息(解决 N+1 查询问题)
|
||||||
enrichTeamInfo(result);
|
enrichTeamInfo(result);
|
||||||
|
|
||||||
log.info("用户 {} 共有 {} 个部署审批任务", currentUsername, result.size());
|
// 5. 后置筛选:按团队和环境过滤
|
||||||
|
if (teamId != null) {
|
||||||
|
result = result.stream()
|
||||||
|
.filter(task -> teamId.equals(task.getTeamId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
log.debug("按团队ID筛选后剩余 {} 个任务", result.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (environmentId != null) {
|
||||||
|
result = result.stream()
|
||||||
|
.filter(task -> environmentId.equals(task.getEnvironmentId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
log.debug("按环境ID筛选后剩余 {} 个任务", result.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("用户 {} 共有 {} 个部署审批任务(筛选后)", currentUsername, result.size());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user