diff --git a/cf-gateway/src/main/resources/application.yaml b/cf-gateway/src/main/resources/application.yaml index 97e9eab42..3b1c0aae3 100644 --- a/cf-gateway/src/main/resources/application.yaml +++ b/cf-gateway/src/main/resources/application.yaml @@ -106,5 +106,5 @@ knife4j: chenfeng: gateway: access-log-ignore-urls: - - /report/template/ + - /report/template - /system/captcha/get \ No newline at end of file diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/config/CfReportProperties.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/config/CfReportProperties.java index da9ab15b8..15b6a5b06 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/config/CfReportProperties.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/config/CfReportProperties.java @@ -13,7 +13,7 @@ import java.util.Set; * @since 2024/9/26 16:41 */ @Configuration -@ConfigurationProperties("chenfeng.report") +@ConfigurationProperties(prefix = "chenfeng.report") @Data public class CfReportProperties { /** diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java index bf065e7d7..fabd876f3 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java @@ -13,6 +13,7 @@ import com.bstek.datasource.bean.PreviewParams; import com.bstek.ureport.definition.dataset.Field; import com.bstek.ureport.definition.dataset.Parameter; import com.bstek.ureport.definition.dataset.SqlDatasetDefinition; +import com.bstek.ureport.definition.dataset.TenantParams; import com.bstek.ureport.utils.ProcedureUtils; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil; @@ -230,9 +231,9 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService { sqlDatasetDefinition.setSql(sql); sqlDatasetDefinition.setParameters(BeanUtils.toBean(parameters, Parameter.class)); - Map params = new HashMap(); + Map params = new HashMap<>(); Map pmap = sqlDatasetDefinition.buildParameters(params); - String sqlForUse = sqlDatasetDefinition.parseSql(pmap); + String sqlForUse = sqlDatasetDefinition.parseSql(pmap, new TenantParams()); if (ProcedureUtils.isProcedure(sqlForUse)) { return ProcedureUtils.procedureColumnsQuery(sqlForUse, pmap, conn); } diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/template/ReportTemplateServiceImpl.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/template/ReportTemplateServiceImpl.java index c754bd873..d9fc5ccf9 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/template/ReportTemplateServiceImpl.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/template/ReportTemplateServiceImpl.java @@ -64,6 +64,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR; @@ -353,15 +354,37 @@ public class ReportTemplateServiceImpl implements ReportTemplateService { @Override public HtmlReport preview(PreviewParameters params) { + Long userOrganId = SecurityFrameworkUtils.getUserOrganId(); + HtmlProducer htmlProducer = new HtmlProducer(); ReportRender reportRender = new ReportRender(); ReportDefinition reportDefinition = getReportDefinition(reportRender, params); Map parameters = params.getQuery(); - // imes多租户业务表表名列表 - Set tenantTableNames = cfReportProperties.getTenantTableNames(); - if (CollUtil.isNotEmpty(tenantTableNames)) { + if (Boolean.FALSE.equals(SecurityFrameworkUtils.isSuperAdmin())) { + // 根据前端传递的数据集id,判断是不是内置数据源下的,是就把name传给ureport + List datasetIds = (List) parameters.get("datasetIds"); + if (CollUtil.isNotEmpty(datasetIds)) { + // 内置数据集名称列表 + List buildinDsNames = new ArrayList<>(); + // 遍历获取所有上级数据源 + List reportDatasetDOS = datasetMapper.selectNormalDatasetList(datasetIds.stream().collect(Collectors.toSet())); + for (ReportDatasetDO datasetDO : reportDatasetDOS) { + Long datasourceId = datasetDO.getDatasourceId(); + // 查询数据源,如果是内置数据源则把数据集的name传给ureport + // 机构下 + 内置数据源查询 + ReportDatasourceDO datasourceDO = datasourceMapper.selectNormalDatasourceById(datasourceId, userOrganId); + if (ObjectUtil.equal(datasourceDO.getBuildinType(), ReportTemplateTypeEnum.SYSTEM)) { + buildinDsNames.add(datasetDO.getName()); + } + } + if (CollUtil.isNotEmpty(buildinDsNames)) { + parameters.put("buildinDsNames", buildinDsNames); + } + } + // imes多租户业务表表名列表 parameters.put("tenantTableNames", cfReportProperties.getTenantTableNames()); - parameters.put("organId", SecurityFrameworkUtils.getUserOrganId()); + // 用户组织id + parameters.put("organId", userOrganId); } Report report = reportRender.render(reportDefinition, parameters); return htmlProducer.produce(reportDefinition, report); diff --git a/cf-module-report/cf-module-report-biz/src/main/resources/application.yaml b/cf-module-report/cf-module-report-biz/src/main/resources/application.yaml index 14843fb48..25bdc81f9 100644 --- a/cf-module-report/cf-module-report-biz/src/main/resources/application.yaml +++ b/cf-module-report/cf-module-report-biz/src/main/resources/application.yaml @@ -106,7 +106,8 @@ chenfeng: encrypt: enable: false publicKey: cfimes - tenant-table-names: + report: + tenant-table-names: - system_dept - system_user - system_organization diff --git a/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar b/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar index a6900ecfd..ba225c0e2 100644 Binary files a/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar and b/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar differ