From 0929b9d81b12b93129a96a49e22e078f2c9caa8b Mon Sep 17 00:00:00 2001 From: zixi0825 Date: Mon, 16 Sep 2024 10:14:51 +0800 Subject: [PATCH] [Fix][Engine] Fix data quality report pie error --- .../impl/JobQualityReportServiceImpl.java | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/JobQualityReportServiceImpl.java b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/JobQualityReportServiceImpl.java index 1ea898eb..cd88e30b 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/JobQualityReportServiceImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/JobQualityReportServiceImpl.java @@ -230,13 +230,32 @@ public JobQualityReportScore getScoreByCondition(JobQualityReportDashboardParam throw new DataVinesException("param can not be null"); } - queryWrapper.eq(dashboardParam.getDatasourceId()!= null, JobQualityReport::getDatasourceId, dashboardParam.getDatasourceId()); + queryWrapper.eq(JobQualityReport::getDatasourceId, dashboardParam.getDatasourceId()); + String entityLevel = DATASOURCE; - queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getSchemaName()), JobQualityReport::getDatabaseName, dashboardParam.getSchemaName()); - if (StringUtils.isEmpty(dashboardParam.getTableName())) { - queryWrapper.eq(JobQualityReport::getTableName, "--"); - } else { - queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getTableName()), JobQualityReport::getTableName, dashboardParam.getTableName()); + if (StringUtils.isNotEmpty(dashboardParam.getSchemaName())) { + entityLevel = DATABASE; + } + + if (StringUtils.isNotEmpty(dashboardParam.getTableName())) { + entityLevel = TABLE; + } + + switch (entityLevel) { + case DATASOURCE: + queryWrapper.eq(JobQualityReport::getEntityLevel, DATASOURCE); + break; + case DATABASE: + queryWrapper.eq(JobQualityReport::getEntityLevel, DATABASE); + queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getSchemaName()), JobQualityReport::getDatabaseName, dashboardParam.getSchemaName()); + break; + case TABLE: + queryWrapper.eq(JobQualityReport::getEntityLevel, TABLE); + queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getSchemaName()), JobQualityReport::getDatabaseName, dashboardParam.getSchemaName()); + queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getTableName()), JobQualityReport::getTableName, dashboardParam.getTableName()); + break; + default: + break; } if (StringUtils.isEmpty(dashboardParam.getReportDate())) { @@ -250,6 +269,7 @@ public JobQualityReportScore getScoreByCondition(JobQualityReportDashboardParam if (CollectionUtils.isEmpty(jobQualityReports)) { return null; } + JobQualityReportScore reportScore = new JobQualityReportScore(); reportScore.setScore(new BigDecimal(0)); reportScore.setQualityLevel(DataQualityLevel.UNQUALIFIED.getZhDescription()); @@ -293,18 +313,33 @@ public JobQualityReportScoreTrend getScoreTrendByCondition(JobQualityReportDashb } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(dashboardParam.getDatasourceId()!= null, JobQualityReport::getDatasourceId, dashboardParam.getDatasourceId()); + queryWrapper.eq(JobQualityReport::getDatasourceId, dashboardParam.getDatasourceId()); - if (StringUtils.isEmpty(dashboardParam.getTableName())) { - queryWrapper.eq(JobQualityReport::getDatabaseName, "--"); - } else { - queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getSchemaName()), JobQualityReport::getDatabaseName, dashboardParam.getSchemaName()); + String entityLevel = DATASOURCE; + + if (StringUtils.isNotEmpty(dashboardParam.getSchemaName())) { + entityLevel = DATABASE; } - if (StringUtils.isEmpty(dashboardParam.getTableName())) { - queryWrapper.eq(JobQualityReport::getTableName, "--"); - } else { - queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getTableName()), JobQualityReport::getTableName, dashboardParam.getTableName()); + if (StringUtils.isNotEmpty(dashboardParam.getTableName())) { + entityLevel = TABLE; + } + + switch (entityLevel) { + case DATASOURCE: + queryWrapper.eq(JobQualityReport::getEntityLevel, DATASOURCE); + break; + case DATABASE: + queryWrapper.eq(JobQualityReport::getEntityLevel, DATABASE); + queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getSchemaName()), JobQualityReport::getDatabaseName, dashboardParam.getSchemaName()); + break; + case TABLE: + queryWrapper.eq(JobQualityReport::getEntityLevel, TABLE); + queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getSchemaName()), JobQualityReport::getDatabaseName, dashboardParam.getSchemaName()); + queryWrapper.eq(StringUtils.isNotEmpty(dashboardParam.getTableName()), JobQualityReport::getTableName, dashboardParam.getTableName()); + break; + default: + break; } queryWrapper.between(JobQualityReport::getReportDate, startDateStr, endDateStr);