From 292238dcc41a98cd11b271da3b86f8e894949035 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Fri, 29 Nov 2024 10:53:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=8F=91=E5=B8=83De?= =?UTF-8?q?ployPipelineConfigManager=E9=9C=80=E6=94=AF=E6=8C=81=E6=89=B9?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1298640549675008]发布DeployPipelineConfigManager需支持批量 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1298640549675008 --- .../util/DeployPipelineConfigManager.java | 183 ++++++++++++++---- 1 file changed, 145 insertions(+), 38 deletions(-) diff --git a/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java b/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java index 139e0c98..f4535edd 100644 --- a/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java +++ b/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java @@ -212,7 +212,29 @@ public class DeployPipelineConfigManager { } } DeployPipelineConfigVo deployPipelineConfig = mergeDeployPipelineConfig(appConfig, moduleOverrideConfig, envOverrideConfig, targetLevel, isUpdateProfile, profileIdList); - specialHandling(deployPipelineConfig, isDeleteDisabledPhase, isUpdateConfig, isHasBuildOrDeployTypeTool); + if (deployPipelineConfig != null) { + if (isDeleteDisabledPhase) { + deleteDisabledPhase(deployPipelineConfig); + } + if (isUpdateConfig) { + IAutoexecServiceCrossoverService autoexecServiceCrossoverService = CrossoverServiceFactory.getApi(IAutoexecServiceCrossoverService.class); + autoexecServiceCrossoverService.updateAutoexecCombopConfig(deployPipelineConfig.getAutoexecCombopConfigVo()); + } + if (isHasBuildOrDeployTypeTool) { + Set operationIdSet = getOperationIdSet(deployPipelineConfig);List buildTypeToolIdList = new ArrayList<>(); + List deployTypeToolIdList = new ArrayList<>(); + Long buildTypeId = autoexecTypeMapper.getTypeIdByName("BUILD"); + Long deployTypeId = autoexecTypeMapper.getTypeIdByName("DEPLOY"); + List operationIdList = new ArrayList<>(operationIdSet); + if (buildTypeId != null) { + buildTypeToolIdList = autoexecToolMapper.getToolIdListByIdListAndTypeId(operationIdList, buildTypeId); + } + if (deployTypeId != null) { + deployTypeToolIdList = autoexecToolMapper.getToolIdListByIdListAndTypeId(operationIdList, deployTypeId); + } + setIsHasBuildOrDeployTypeTool(deployPipelineConfig, buildTypeToolIdList, deployTypeToolIdList); + } + } return deployPipelineConfig; } @@ -261,7 +283,6 @@ public class DeployPipelineConfigManager { envOverrideConfig = getDeployPipelineConfigVo(appSystemId, appModuleId, envId, deployAppConfigList); } DeployPipelineConfigVo deployPipelineConfigVo = mergeDeployPipelineConfig(appConfig, moduleOverrideConfig, envOverrideConfig, targetLevel, isUpdateProfile, profileIdList); - specialHandling(deployPipelineConfigVo, isDeleteDisabledPhase, isUpdateConfig, isHasBuildOrDeployTypeTool); DeployAppConfigVo deployAppConfig = new DeployAppConfigVo(); deployAppConfig.setAppSystemId(appSystemId); deployAppConfig.setAppModuleId(appModuleId); @@ -269,6 +290,43 @@ public class DeployPipelineConfigManager { deployAppConfig.setConfig(deployPipelineConfigVo); resultList.add(deployAppConfig); } + + List buildTypeToolIdList = new ArrayList<>(); + List deployTypeToolIdList = new ArrayList<>(); + if (isHasBuildOrDeployTypeTool) { + Set operationIdSet = new HashSet<>(); + for (DeployAppConfigVo deployAppConfig : resultList) { + DeployPipelineConfigVo deployPipelineConfig = deployAppConfig.getConfig(); + if (deployPipelineConfig != null) { + operationIdSet.addAll(getOperationIdSet(deployPipelineConfig)); + } + } + Long buildTypeId = autoexecTypeMapper.getTypeIdByName("BUILD"); + Long deployTypeId = autoexecTypeMapper.getTypeIdByName("DEPLOY"); + List operationIdList = new ArrayList<>(operationIdSet); + if (buildTypeId != null) { + buildTypeToolIdList = autoexecToolMapper.getToolIdListByIdListAndTypeId(operationIdList, buildTypeId); + } + if (deployTypeId != null) { + deployTypeToolIdList = autoexecToolMapper.getToolIdListByIdListAndTypeId(operationIdList, deployTypeId); + } + } + + for (DeployAppConfigVo deployAppConfig : resultList) { + DeployPipelineConfigVo deployPipelineConfig = deployAppConfig.getConfig(); + if (deployPipelineConfig != null) { + if (isDeleteDisabledPhase) { + deleteDisabledPhase(deployPipelineConfig); + } + if (isUpdateConfig) { + IAutoexecServiceCrossoverService autoexecServiceCrossoverService = CrossoverServiceFactory.getApi(IAutoexecServiceCrossoverService.class); + autoexecServiceCrossoverService.updateAutoexecCombopConfig(deployPipelineConfig.getAutoexecCombopConfigVo()); + } + if (isHasBuildOrDeployTypeTool) { + setIsHasBuildOrDeployTypeTool(deployPipelineConfig, buildTypeToolIdList, deployTypeToolIdList); + } + } + } return resultList; } } @@ -284,48 +342,41 @@ public class DeployPipelineConfigManager { return null; } - private static void specialHandling(DeployPipelineConfigVo deployPipelineConfig, boolean isDeleteDisabledPhase, boolean isUpdateConfig, boolean isHasBuildOrDeployTypeTool) { - if (deployPipelineConfig != null) { - if (isDeleteDisabledPhase) { - // 删除禁用阶段 - List deployPipelinePhaseList = deployPipelineConfig.getCombopPhaseList(); - if (CollectionUtils.isNotEmpty(deployPipelinePhaseList)) { - boolean hasRemove = false; - Iterator iterator = deployPipelinePhaseList.iterator(); - while (iterator.hasNext()) { - DeployPipelinePhaseVo deployPipelinePhaseVo = iterator.next(); - if (Objects.equals(deployPipelinePhaseVo.getIsActive(), 0)) { - iterator.remove(); - hasRemove = true; - } - } - if (hasRemove) { - Set groupIdSet = new HashSet<>(); - for (DeployPipelinePhaseVo deployPipelinePhaseVo : deployPipelinePhaseList) { - groupIdSet.add(deployPipelinePhaseVo.getGroupId()); - } - List deployPipelineGroupList = deployPipelineConfig.getCombopGroupList(); - if (CollectionUtils.isNotEmpty(deployPipelineGroupList)) { - Iterator groupIterator = deployPipelineGroupList.iterator(); - while (groupIterator.hasNext()) { - DeployPipelineGroupVo deployPipelineGroupVo = groupIterator.next(); - if (!groupIdSet.contains(deployPipelineGroupVo.getId())) { - groupIterator.remove(); - } - } + /** + * 删除禁用阶段 + */ + private static void deleteDisabledPhase(DeployPipelineConfigVo deployPipelineConfig) { + // 删除禁用阶段 + List deployPipelinePhaseList = deployPipelineConfig.getCombopPhaseList(); + if (CollectionUtils.isNotEmpty(deployPipelinePhaseList)) { + boolean hasRemove = false; + Iterator iterator = deployPipelinePhaseList.iterator(); + while (iterator.hasNext()) { + DeployPipelinePhaseVo deployPipelinePhaseVo = iterator.next(); + if (Objects.equals(deployPipelinePhaseVo.getIsActive(), 0)) { + iterator.remove(); + hasRemove = true; + } + } + if (hasRemove) { + Set groupIdSet = new HashSet<>(); + for (DeployPipelinePhaseVo deployPipelinePhaseVo : deployPipelinePhaseList) { + groupIdSet.add(deployPipelinePhaseVo.getGroupId()); + } + List deployPipelineGroupList = deployPipelineConfig.getCombopGroupList(); + if (CollectionUtils.isNotEmpty(deployPipelineGroupList)) { + Iterator groupIterator = deployPipelineGroupList.iterator(); + while (groupIterator.hasNext()) { + DeployPipelineGroupVo deployPipelineGroupVo = groupIterator.next(); + if (!groupIdSet.contains(deployPipelineGroupVo.getId())) { + groupIterator.remove(); } } } } - if (isUpdateConfig) { - IAutoexecServiceCrossoverService autoexecServiceCrossoverService = CrossoverServiceFactory.getApi(IAutoexecServiceCrossoverService.class); - autoexecServiceCrossoverService.updateAutoexecCombopConfig(deployPipelineConfig.getAutoexecCombopConfigVo()); - } - if (isHasBuildOrDeployTypeTool) { - setIsHasBuildOrDeployTypeTool(deployPipelineConfig); - } } } + /** * 获取工具库id * @@ -346,6 +397,62 @@ public class DeployPipelineConfigManager { } } + private static Set getOperationIdSet(DeployPipelineConfigVo pipelineConfigVo) { + Set operationIdSet = new HashSet<>(); + List scenarioList = pipelineConfigVo.getScenarioList(); + if (CollectionUtils.isNotEmpty(scenarioList)) { +// Map> scenarioOperationIdListMap = new HashMap<>(); + for (AutoexecCombopScenarioVo scenarioVo : scenarioList) { + Set scenarioOperationIdSet = new HashSet<>(); +// scenarioOperationIdListMap.put(scenarioVo.getScenarioId(), scenarioOperationIdSet); + List combopPhaseNameList = scenarioVo.getCombopPhaseNameList(); + for (DeployPipelinePhaseVo pipelinePhaseVo : pipelineConfigVo.getCombopPhaseList()) { + if (!combopPhaseNameList.contains(pipelinePhaseVo.getName())) { + continue; + } + if (Objects.equals(pipelinePhaseVo.getIsActive(), 0)) { + continue; + } + AutoexecCombopPhaseConfigVo combopPhaseConfigVo = pipelinePhaseVo.getConfig(); + getToolOperationId(combopPhaseConfigVo.getPhaseOperationList(), scenarioOperationIdSet); + } + operationIdSet.addAll(scenarioOperationIdSet); + } + } + return operationIdSet; + } + + /** + * 设置DeployPipelinePhaseVo中isHasBuildTypeTool和isHasDeployTypeTool字段值 + * + * @param pipelineConfigVo 配置 + */ + private static void setIsHasBuildOrDeployTypeTool(DeployPipelineConfigVo pipelineConfigVo, List buildTypeToolIdList, List deployTypeToolIdList) { + List scenarioList = pipelineConfigVo.getScenarioList(); + if (CollectionUtils.isNotEmpty(scenarioList)) { + for (AutoexecCombopScenarioVo scenarioVo : scenarioList) { + Set scenarioOperationIdSet = new HashSet<>(); + List combopPhaseNameList = scenarioVo.getCombopPhaseNameList(); + for (DeployPipelinePhaseVo pipelinePhaseVo : pipelineConfigVo.getCombopPhaseList()) { + if (!combopPhaseNameList.contains(pipelinePhaseVo.getName())) { + continue; + } + if (Objects.equals(pipelinePhaseVo.getIsActive(), 0)) { + continue; + } + AutoexecCombopPhaseConfigVo combopPhaseConfigVo = pipelinePhaseVo.getConfig(); + getToolOperationId(combopPhaseConfigVo.getPhaseOperationList(), scenarioOperationIdSet); + } + if (CollectionUtils.isNotEmpty(ListUtils.retainAll(scenarioOperationIdSet, buildTypeToolIdList))) { + scenarioVo.setIsHasBuildTypeTool(1); + } + if (CollectionUtils.isNotEmpty(ListUtils.retainAll(scenarioOperationIdSet, deployTypeToolIdList))) { + scenarioVo.setIsHasDeployTypeTool(1); + } + } + } + } + /** * 设置DeployPipelinePhaseVo中isHasBuildTypeTool和isHasDeployTypeTool字段值 * -- Gitee From 17b47ac4b171cb4d82b947a15822045d18a12041 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Fri, 29 Nov 2024 10:55:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=8F=91=E5=B8=83De?= =?UTF-8?q?ployPipelineConfigManager=E9=9C=80=E6=94=AF=E6=8C=81=E6=89=B9?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1298640549675008]发布DeployPipelineConfigManager需支持批量 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1298640549675008 --- .../module/deploy/util/DeployPipelineConfigManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java b/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java index f4535edd..6ea1b8ca 100644 --- a/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java +++ b/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java @@ -401,10 +401,8 @@ public class DeployPipelineConfigManager { Set operationIdSet = new HashSet<>(); List scenarioList = pipelineConfigVo.getScenarioList(); if (CollectionUtils.isNotEmpty(scenarioList)) { -// Map> scenarioOperationIdListMap = new HashMap<>(); for (AutoexecCombopScenarioVo scenarioVo : scenarioList) { Set scenarioOperationIdSet = new HashSet<>(); -// scenarioOperationIdListMap.put(scenarioVo.getScenarioId(), scenarioOperationIdSet); List combopPhaseNameList = scenarioVo.getCombopPhaseNameList(); for (DeployPipelinePhaseVo pipelinePhaseVo : pipelineConfigVo.getCombopPhaseList()) { if (!combopPhaseNameList.contains(pipelinePhaseVo.getName())) { -- Gitee