feat(XPack): 定时报告支持自定义过滤组件值

This commit is contained in:
wangjiahao 2024-06-25 18:25:08 +08:00
parent e75850e169
commit 1ab3d261a3
7 changed files with 66 additions and 9 deletions

View File

@ -117,6 +117,16 @@
</properties>
<dependencies>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-permissions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>

View File

@ -14,18 +14,18 @@ public class MybatisPlusGenerator {
* 第一 我嫌麻烦
* 第二 后面配置会放到nacos读起来更麻烦了
*/
private static final String url = "jdbc:mysql://localhost:3306/de_standalone?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false";
private static final String url = "jdbc:mysql://localhost:3306/dataease?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false";
private static final String username = "root";
private static final String password = "Password123@mysql";
private static final String password = "123456";
/**
* 业务模块例如datasource,dataset,panel等
*/
private static final String busi = "share";
private static final String busi = "visualization";
/**
* 这是要生成代码的表名称
*/
private static final String TABLE_NAME = "xpack_share";
private static final String TABLE_NAME = "visualization_report_filter";
/**
* 下面两个配置基本上不用动

View File

@ -2,6 +2,16 @@ package io.dataease.commons.constants;
public class DataVisualizationConstants {
//新建仪表板来源
public static final class QUERY_SOURCE {
// 定时报告
public static final String REPORT = "report";
// 主工程
public static final String MAIN = "main";
}
//新建仪表板来源
public static final class NEW_PANEL_FROM {

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import io.dataease.api.visualization.dto.VisualizationViewTableDTO;
import io.dataease.api.visualization.vo.DataVisualizationBaseVO;
import io.dataease.api.visualization.vo.DataVisualizationVO;
import io.dataease.api.visualization.vo.VisualizationReportFilterVO;
import io.dataease.api.visualization.vo.VisualizationResourceVO;
import io.dataease.chart.dao.auto.entity.CoreChartView;
import io.dataease.visualization.dao.ext.po.StorePO;
@ -48,5 +49,7 @@ public interface ExtDataVisualizationMapper {
List<VisualizationViewTableDTO> getVisualizationViewDetails(@Param("dvId") Long dvId);
List<VisualizationReportFilterVO> queryReportFilter(@Param("dvId") Long dvId,@Param("reportId") Long reportId);
}

View File

@ -2,6 +2,7 @@ package io.dataease.visualization.server;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.dataease.api.visualization.vo.VisualizationReportFilterVO;
import io.dataease.extensions.view.dto.ChartViewDTO;
import io.dataease.api.template.dto.TemplateManageFileDTO;
import io.dataease.api.template.dto.VisualizationTemplateExtendDataDTO;
@ -35,6 +36,7 @@ import io.dataease.utils.*;
import io.dataease.visualization.dao.auto.entity.DataVisualizationInfo;
import io.dataease.visualization.dao.auto.entity.VisualizationWatermark;
import io.dataease.visualization.dao.auto.mapper.DataVisualizationInfoMapper;
import io.dataease.visualization.dao.auto.mapper.VisualizationReportFilterMapper;
import io.dataease.visualization.dao.auto.mapper.VisualizationWatermarkMapper;
import io.dataease.visualization.dao.ext.mapper.ExtDataVisualizationMapper;
import io.dataease.visualization.manage.CoreVisualizationManage;
@ -90,9 +92,12 @@ public class DataVisualizationServer implements DataVisualizationApi {
@Resource
private VisualizationWatermarkMapper watermarkMapper;
@Resource
private VisualizationReportFilterMapper reportFilterMapper;
@Override
public DataVisualizationVO findCopyResource(Long dvId, String busiFlag) {
DataVisualizationVO result = findById(dvId, busiFlag);
DataVisualizationVO result = findById(new DataVisualizationBaseRequest(dvId, busiFlag));
if (result != null && result.getPid() == -1) {
return result;
} else {
@ -100,10 +105,12 @@ public class DataVisualizationServer implements DataVisualizationApi {
}
}
@DeLog(id = "#p0", ot = LogOT.READ, stExp = "#p1")
@DeLog(id = "#p0.id", ot = LogOT.READ, stExp = "#p0.busiFlag")
@Override
@XpackInteract(value = "dataVisualizationServer", original = true)
public DataVisualizationVO findById(Long dvId, String busiFlag) {
public DataVisualizationVO findById(DataVisualizationBaseRequest request) {
Long dvId = request.getId();
String busiFlag = request.getBusiFlag();
DataVisualizationVO result = extDataVisualizationMapper.findDvInfo(dvId, busiFlag);
if (result != null) {
//获取图表信息
@ -116,6 +123,16 @@ public class DataVisualizationServer implements DataVisualizationApi {
VisualizationWatermarkVO watermarkVO = new VisualizationWatermarkVO();
BeanUtils.copyBean(watermarkVO, watermark);
result.setWatermarkInfo(watermarkVO);
if(DataVisualizationConstants.QUERY_SOURCE.REPORT.equals(request.getSource()) && request.getReportId() != null){
//获取定时报告过自定义过滤组件信息
List<VisualizationReportFilterVO> filterVOS = extDataVisualizationMapper.queryReportFilter(dvId,request.getReportId());
if (!CollectionUtils.isEmpty(filterVOS)) {
Map<Long, VisualizationReportFilterVO> reportFilterInfo = filterVOS.stream().collect(Collectors.toMap(VisualizationReportFilterVO::getFilterId, filterVo ->filterVo));
result.setReportFilterInfo(reportFilterInfo);
}
}
return result;
} else {
DEException.throwException("资源不存在或已经被删除...");

View File

@ -403,4 +403,20 @@
WHERE core_chart_view.scene_id = #{dvId}
AND core_chart_view.id IS NOT NULL and core_chart_view.`type` != 'VQuery'
</select>
<select id="queryReportFilter" resultType="io.dataease.api.visualization.vo.VisualizationReportFilterVO">
SELECT
`id`,
`resource_id`,
`dv_type`,
`component_id`,
`filter_id`,
`filter_info`,
`filter_version`,
`create_time`,
`create_user`
FROM
visualization_report_filter
where visualization_report_filter.resource_id = #{dvId} and visualization_report_filter.id = #{reportId}
</select>
</mapper>

View File

@ -20,14 +20,15 @@ export const findCopyResource = async (dvId, busiFlag): Promise<IResponse> => {
return request.get({ url: '/dataVisualization/findCopyResource/' + dvId + '/' + busiFlag })
}
export const findById = async (dvId, busiFlag): Promise<IResponse> => {
export const findById = async (dvId, busiFlag, source = 'main'): Promise<IResponse> => {
let busiFlagResult = busiFlag
if (!busiFlagResult) {
await findDvType(dvId).then(res => {
busiFlagResult = res.data
})
}
return request.get({ url: '/dataVisualization/findById/' + dvId + '/' + busiFlagResult })
const data = { id: dvId, busiFlag: busiFlagResult, source }
return request.post({ url: '/dataVisualization/findById', data })
}
export const queryTreeApi = async (data: BusiTreeRequest): Promise<IResponse> => {