forked from github/dataease
Merge pull request #2145 from dataease/pr@dev@refactor_panel-cache
refactor: 仪表板编辑缓存优化
This commit is contained in:
commit
162b51ee1a
@ -11,14 +11,10 @@ public class PanelConstants {
|
|||||||
|
|
||||||
public final static String COMPONENT_TYPE_PUBLIC = "public";
|
public final static String COMPONENT_TYPE_PUBLIC = "public";
|
||||||
|
|
||||||
|
|
||||||
public final static String TEMPLATE_TYPE_SYSTEM = "system";
|
public final static String TEMPLATE_TYPE_SYSTEM = "system";
|
||||||
|
|
||||||
public final static String TEMPLATE_TYPE_SELF = "self";
|
public final static String TEMPLATE_TYPE_SELF = "self";
|
||||||
|
|
||||||
public final static String PANEL_TYPE_SYSTEM = "system";
|
|
||||||
|
|
||||||
public final static String PANEL_TYPE_SELF = "self";
|
|
||||||
|
|
||||||
public final static String PANEL_NODE_TYPE_FOlDER = "folder";
|
public final static String PANEL_NODE_TYPE_FOlDER = "folder";
|
||||||
|
|
||||||
@ -47,4 +43,26 @@ public class PanelConstants {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//仪表板类型
|
||||||
|
public static final class PANEL_TYPE {
|
||||||
|
|
||||||
|
// 普通仪表板
|
||||||
|
public static final String SELF = "self";
|
||||||
|
|
||||||
|
// 默认仪表板
|
||||||
|
public static final String SYSTEM = "system";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//仪表板查询来源
|
||||||
|
public static final class QUERY_FROM {
|
||||||
|
|
||||||
|
// 普通查询
|
||||||
|
public static final String NORMAL = "normal";
|
||||||
|
|
||||||
|
// 编辑查询
|
||||||
|
public static final String EDIT = "edit";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class ChartViewController {
|
|||||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
|
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
|
||||||
@ApiOperation("保存")
|
@ApiOperation("保存")
|
||||||
@PostMapping("/save/{panelId}")
|
@PostMapping("/save/{panelId}")
|
||||||
public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewCacheRequest request) {
|
public ChartViewDTO save(@PathVariable String panelId, @RequestBody ChartViewRequest request) {
|
||||||
return chartViewService.save(request);
|
return chartViewService.save(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +54,10 @@ public class ChartViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
|
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
|
||||||
@ApiOperation("保存到缓存表")
|
@ApiOperation("保存编辑的视图信息")
|
||||||
@PostMapping("/save2Cache/{panelId}")
|
@PostMapping("/viewEditSave/{panelId}")
|
||||||
public void save2Cache(@PathVariable String panelId, @RequestBody ChartViewCacheWithBLOBs chartViewWithBLOBs) {
|
public void viewEditSave(@PathVariable String panelId, @RequestBody ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||||
chartViewService.save2Cache(chartViewWithBLOBs);
|
chartViewService.viewEditSave(chartViewWithBLOBs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@ -147,12 +147,11 @@ public class ChartViewController {
|
|||||||
chartViewService.initViewCache(panelId);
|
chartViewService.initViewCache(panelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW, paramIndex = 1)
|
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANNEL_LEVEL_VIEW, paramIndex = 1)
|
||||||
@ApiOperation("重置视图缓存")
|
@ApiOperation("重置视图")
|
||||||
@PostMapping("/resetViewCache/{id}/{panelId}")
|
@PostMapping("/resetViewCache/{id}/{panelId}")
|
||||||
public void resetViewCache(@PathVariable String id, @PathVariable String panelId) {
|
public void resetViewCache(@PathVariable String id, @PathVariable String panelId) {
|
||||||
chartViewCacheService.refreshCache(id);
|
chartViewCacheService.resetView(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("校验视图Title")
|
@ApiOperation("校验视图Title")
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package io.dataease.controller.request.panel;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author: wangjiahao
|
||||||
|
* Date: 2022/4/20
|
||||||
|
* Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PanelGroupQueryRequest {
|
||||||
|
|
||||||
|
private String panelId;
|
||||||
|
|
||||||
|
private String panelType; //仪表板类型 self 普通仪表板 or system默认仪表板
|
||||||
|
|
||||||
|
private String queryFrom; //查询来源 edit 编辑初始化查询
|
||||||
|
|
||||||
|
}
|
@ -35,7 +35,7 @@ public interface ExtChartViewMapper {
|
|||||||
|
|
||||||
List<ChartViewDTO> searchViewsWithPanelId(@Param("panelId") String panelId);
|
List<ChartViewDTO> searchViewsWithPanelId(@Param("panelId") String panelId);
|
||||||
|
|
||||||
ChartViewDTO searchOneFromCache(@Param("id") String id );
|
// ChartViewDTO searchOneFromCache(@Param("id") String id );
|
||||||
|
|
||||||
void copyToCache(@Param("id") String id );
|
void copyToCache(@Param("id") String id );
|
||||||
|
|
||||||
@ -47,7 +47,11 @@ public interface ExtChartViewMapper {
|
|||||||
|
|
||||||
int updateToCache(@Param("viewId") String viewId );
|
int updateToCache(@Param("viewId") String viewId );
|
||||||
|
|
||||||
|
int updateToViewFromCache(@Param("viewId") String viewId );
|
||||||
|
|
||||||
void copyCache(@Param("sourceViewId") String sourceViewId,@Param("newViewId") String newViewId);
|
void copyCache(@Param("sourceViewId") String sourceViewId,@Param("newViewId") String newViewId);
|
||||||
|
|
||||||
void deleteNoUseView(@Param("viewIds") List<String> viewIds,@Param("panelId") String panelId );
|
void deleteNoUseView(@Param("viewIds") List<String> viewIds,@Param("panelId") String panelId );
|
||||||
|
|
||||||
|
void initPanelChartViewCache(@Param("panelId") String panelId);
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,6 @@
|
|||||||
from chart_view where id = #{id}
|
from chart_view where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="searchOneFromCache" resultMap="BaseResultMapDTO">
|
|
||||||
select
|
|
||||||
chart_view_cache.*
|
|
||||||
from chart_view_cache where id = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="copyToCache">
|
<insert id="copyToCache">
|
||||||
INSERT INTO chart_view_cache (
|
INSERT INTO chart_view_cache (
|
||||||
id,
|
id,
|
||||||
@ -152,23 +146,68 @@
|
|||||||
chart_view_cache.id = #{sourceViewId}
|
chart_view_cache.id = #{sourceViewId}
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- <select id="searchOne" resultMap="BaseResultMapDTO">-->
|
<insert id="initPanelChartViewCache">
|
||||||
<!-- select-->
|
INSERT INTO chart_view_cache (
|
||||||
<!-- id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,-->
|
id,
|
||||||
<!-- style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot-->
|
`name`,
|
||||||
<!-- from chart_view-->
|
title,
|
||||||
<!-- <where>-->
|
scene_id,
|
||||||
<!-- <if test="sceneId != null">-->
|
table_id,
|
||||||
<!-- and scene_id = #{sceneId,jdbcType=VARCHAR}-->
|
`type`,
|
||||||
<!-- </if>-->
|
render,
|
||||||
<!-- <if test="id != null">-->
|
result_count,
|
||||||
<!-- and id = #{id,jdbcType=VARCHAR}-->
|
result_mode,
|
||||||
<!-- </if>-->
|
create_by,
|
||||||
<!-- </where>-->
|
create_time,
|
||||||
<!-- <if test="sort != null">-->
|
update_time,
|
||||||
<!-- order by ${sort}-->
|
style_priority,
|
||||||
<!-- </if>-->
|
chart_type,
|
||||||
<!-- </select>-->
|
is_plugin,
|
||||||
|
x_axis,
|
||||||
|
x_axis_ext,
|
||||||
|
y_axis,
|
||||||
|
y_axis_ext,
|
||||||
|
ext_stack,
|
||||||
|
ext_bubble,
|
||||||
|
custom_attr,
|
||||||
|
custom_style,
|
||||||
|
custom_filter,
|
||||||
|
drill_fields,
|
||||||
|
senior,
|
||||||
|
SNAPSHOT,
|
||||||
|
data_from
|
||||||
|
) SELECT
|
||||||
|
id,
|
||||||
|
`name`,
|
||||||
|
title,
|
||||||
|
scene_id,
|
||||||
|
table_id,
|
||||||
|
`type`,
|
||||||
|
render,
|
||||||
|
result_count,
|
||||||
|
result_mode,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_time,
|
||||||
|
style_priority,
|
||||||
|
chart_type,
|
||||||
|
is_plugin,
|
||||||
|
x_axis,
|
||||||
|
x_axis_ext,
|
||||||
|
y_axis,
|
||||||
|
y_axis_ext,
|
||||||
|
ext_stack,
|
||||||
|
ext_bubble,
|
||||||
|
custom_attr,
|
||||||
|
custom_style,
|
||||||
|
custom_filter,
|
||||||
|
drill_fields,
|
||||||
|
senior,
|
||||||
|
SNAPSHOT,
|
||||||
|
data_from from chart_view
|
||||||
|
WHERE
|
||||||
|
chart_view.scene_id = #{panelId}
|
||||||
|
</insert>
|
||||||
|
|
||||||
<select id="search" resultMap="BaseResultMapDTO">
|
<select id="search" resultMap="BaseResultMapDTO">
|
||||||
select
|
select
|
||||||
@ -503,6 +542,40 @@
|
|||||||
where cve.id = cv.id and cv.id =#{viewId}
|
where cve.id = cv.id and cv.id =#{viewId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
<update id="updateToViewFromCache">
|
||||||
|
UPDATE chart_view_cache cve,
|
||||||
|
chart_view cv
|
||||||
|
SET cv.`name` = cve.`name`,
|
||||||
|
cv.title = cve.title,
|
||||||
|
cv.scene_id = cve.scene_id,
|
||||||
|
cv.table_id = cve.table_id,
|
||||||
|
cv.`type` = cve.`type`,
|
||||||
|
cv.render = cve.render,
|
||||||
|
cv.result_count = cve.result_count,
|
||||||
|
cv.result_mode = cve.result_mode,
|
||||||
|
cv.create_by = cve.create_by,
|
||||||
|
cv.create_time = cve.create_time,
|
||||||
|
cv.update_time = cve.update_time,
|
||||||
|
cv.style_priority = cve.style_priority,
|
||||||
|
cv.chart_type = cve.chart_type,
|
||||||
|
cv.is_plugin = cve.is_plugin,
|
||||||
|
cv.x_axis = cve.x_axis,
|
||||||
|
cv.x_axis_ext = cve.x_axis_ext,
|
||||||
|
cv.y_axis = cve.y_axis,
|
||||||
|
cv.y_axis_ext = cve.y_axis_ext,
|
||||||
|
cv.ext_stack = cve.ext_stack,
|
||||||
|
cv.ext_bubble = cve.ext_bubble,
|
||||||
|
cv.custom_attr = cve.custom_attr,
|
||||||
|
cv.custom_style = cve.custom_style,
|
||||||
|
cv.custom_filter = cve.custom_filter,
|
||||||
|
cv.drill_fields = cve.drill_fields,
|
||||||
|
cv.senior = cve.senior,
|
||||||
|
cv.SNAPSHOT = cve.SNAPSHOT,
|
||||||
|
cv.data_from = cve.data_from
|
||||||
|
where cve.id = cv.id and cv.id =#{viewId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="deleteNoUseView">
|
<delete id="deleteNoUseView">
|
||||||
delete from chart_view
|
delete from chart_view
|
||||||
where scene_id = #{panelId}
|
where scene_id = #{panelId}
|
||||||
|
@ -34,19 +34,19 @@
|
|||||||
|
|
||||||
<select id="getViewLinkageGather" resultMap="LinkageGatherMap">
|
<select id="getViewLinkageGather" resultMap="LinkageGatherMap">
|
||||||
SELECT
|
SELECT
|
||||||
chart_view_cache.`name` as 'targetViewName',
|
chart_view.`name` as 'targetViewName',
|
||||||
chart_view_cache.id as 'target_view_id',
|
chart_view.id as 'target_view_id',
|
||||||
chart_view_cache.table_id,
|
chart_view.table_id,
|
||||||
(case when panel_view_linkage.target_view_id is null then 0 else 1 end) as 'linkageActive',
|
(case when panel_view_linkage.target_view_id is null then 0 else 1 end) as 'linkageActive',
|
||||||
panel_view_linkage_field.source_field,
|
panel_view_linkage_field.source_field,
|
||||||
panel_view_linkage_field.target_field
|
panel_view_linkage_field.target_field
|
||||||
FROM
|
FROM
|
||||||
chart_view_cache
|
chart_view
|
||||||
LEFT JOIN panel_view_linkage ON chart_view_cache.id = panel_view_linkage.target_view_id
|
LEFT JOIN panel_view_linkage ON chart_view.id = panel_view_linkage.target_view_id
|
||||||
AND panel_view_linkage.panel_id = #{panelId}
|
AND panel_view_linkage.panel_id = #{panelId}
|
||||||
AND panel_view_linkage.source_view_id = #{sourceViewId}
|
AND panel_view_linkage.source_view_id = #{sourceViewId}
|
||||||
LEFT JOIN panel_view_linkage_field ON panel_view_linkage.id = panel_view_linkage_field.linkage_id
|
LEFT JOIN panel_view_linkage_field ON panel_view_linkage.id = panel_view_linkage_field.linkage_id
|
||||||
where chart_view_cache.id in
|
where chart_view.id in
|
||||||
<foreach collection="targetViewIds" item="targetViewId" index="index" open="(" close=")" separator=",">
|
<foreach collection="targetViewIds" item="targetViewId" index="index" open="(" close=")" separator=",">
|
||||||
#{targetViewId}
|
#{targetViewId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
@ -24,4 +24,8 @@ public class ChartViewCacheService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetView(String viewId){
|
||||||
|
extChartViewMapper.updateToViewFromCache(viewId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.pentaho.di.core.util.UUIDUtil;
|
import org.pentaho.di.core.util.UUIDUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -104,23 +105,23 @@ public class ChartViewService {
|
|||||||
private ReentrantLock lock = new ReentrantLock();
|
private ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
// 直接保存统一到缓存表
|
// 直接保存统一到缓存表
|
||||||
public ChartViewDTO save(ChartViewCacheRequest chartView) {
|
public ChartViewDTO save(ChartViewRequest chartView) {
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
chartView.setUpdateTime(timestamp);
|
chartView.setUpdateTime(timestamp);
|
||||||
chartViewCacheMapper.updateByPrimaryKeySelective(chartView);
|
chartViewMapper.updateByPrimaryKeySelective(chartView);
|
||||||
Optional.ofNullable(chartView.getId()).ifPresent(id -> {
|
Optional.ofNullable(chartView.getId()).ifPresent(id -> {
|
||||||
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
|
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
|
||||||
});
|
});
|
||||||
return getOne(chartView.getId(), "panel_edit");
|
return getOne(chartView.getId(), "panel_edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkTitle(ChartViewCacheRequest chartView){
|
public String checkTitle(ChartViewCacheRequest chartView) {
|
||||||
ChartViewCacheExample example = new ChartViewCacheExample();
|
ChartViewCacheExample example = new ChartViewCacheExample();
|
||||||
example.createCriteria().andTitleEqualTo(chartView.getTitle()).andSceneIdEqualTo(chartView.getSceneId()).andIdNotEqualTo(chartView.getId());
|
example.createCriteria().andTitleEqualTo(chartView.getTitle()).andSceneIdEqualTo(chartView.getSceneId()).andIdNotEqualTo(chartView.getId());
|
||||||
List<ChartViewCache> result = chartViewCacheMapper.selectByExample(example);
|
List<ChartViewCache> result = chartViewCacheMapper.selectByExample(example);
|
||||||
if(CollectionUtils.isNotEmpty(result)){
|
if (CollectionUtils.isNotEmpty(result)) {
|
||||||
return "fail";
|
return "fail";
|
||||||
}else{
|
} else {
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,7 +132,7 @@ public class ChartViewService {
|
|||||||
ChartViewExample queryExample = new ChartViewExample();
|
ChartViewExample queryExample = new ChartViewExample();
|
||||||
queryExample.createCriteria().andSceneIdEqualTo(chartView.getSceneId()).andNameEqualTo(chartView.getName());
|
queryExample.createCriteria().andSceneIdEqualTo(chartView.getSceneId()).andNameEqualTo(chartView.getName());
|
||||||
List<ChartView> result = chartViewMapper.selectByExample(queryExample);
|
List<ChartView> result = chartViewMapper.selectByExample(queryExample);
|
||||||
if(CollectionUtils.isNotEmpty(result)){
|
if (CollectionUtils.isNotEmpty(result)) {
|
||||||
DEException.throwException(Translator.get("theme_name_repeat"));
|
DEException.throwException(Translator.get("theme_name_repeat"));
|
||||||
}
|
}
|
||||||
chartView.setUpdateTime(timestamp);
|
chartView.setUpdateTime(timestamp);
|
||||||
@ -155,11 +156,14 @@ public class ChartViewService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 直接保存统一到缓存表
|
/**
|
||||||
public void save2Cache(ChartViewCacheWithBLOBs chartView) {
|
* @Description 保存编辑的视图信息
|
||||||
|
* @param chartView
|
||||||
|
*/
|
||||||
|
public void viewEditSave(ChartViewWithBLOBs chartView) {
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
chartView.setUpdateTime(timestamp);
|
chartView.setUpdateTime(timestamp);
|
||||||
chartViewCacheMapper.updateByPrimaryKeySelective(chartView);
|
chartViewMapper.updateByPrimaryKeySelective(chartView);
|
||||||
Optional.ofNullable(chartView.getId()).ifPresent(id -> {
|
Optional.ofNullable(chartView.getId()).ifPresent(id -> {
|
||||||
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
|
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
|
||||||
});
|
});
|
||||||
@ -250,25 +254,14 @@ public class ChartViewService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public ChartViewDTO getOne(String id, String queryFrom) {
|
public ChartViewDTO getOne(String id, String queryFrom) {
|
||||||
try{
|
try {
|
||||||
ChartViewDTO result;
|
ChartViewDTO result = extChartViewMapper.searchOne(id);
|
||||||
if(CommonConstants.VIEW_QUERY_FROM.PANEL_EDIT.equals(queryFrom)) {
|
|
||||||
//仪表板编辑页面 从缓存表中取数据 缓存表中没有数据则进行插入
|
|
||||||
result = extChartViewMapper.searchOneFromCache(id);
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
chartViewCacheService.refreshCache(id);
|
|
||||||
result = extChartViewMapper.searchOneFromCache(id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = extChartViewMapper.searchOne(id);
|
|
||||||
}
|
|
||||||
if(result==null){
|
|
||||||
DataEaseException.throwException(Translator.get("i18n_chart_delete"));
|
DataEaseException.throwException(Translator.get("i18n_chart_delete"));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
DataEaseException.throwException(e);
|
DataEaseException.throwException(e);
|
||||||
}
|
}
|
||||||
@ -437,12 +430,12 @@ public class ChartViewService {
|
|||||||
|
|
||||||
List<ChartExtFilterRequest> filters = new ArrayList<>();
|
List<ChartExtFilterRequest> filters = new ArrayList<>();
|
||||||
// 联动条件
|
// 联动条件
|
||||||
if(ObjectUtils.isNotEmpty(requestList.getLinkageFilters())){
|
if (ObjectUtils.isNotEmpty(requestList.getLinkageFilters())) {
|
||||||
filters.addAll(requestList.getLinkageFilters());
|
filters.addAll(requestList.getLinkageFilters());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 外部参数条件
|
// 外部参数条件
|
||||||
if(ObjectUtils.isNotEmpty(requestList.getOuterParamsFilters())){
|
if (ObjectUtils.isNotEmpty(requestList.getOuterParamsFilters())) {
|
||||||
filters.addAll(requestList.getOuterParamsFilters());
|
filters.addAll(requestList.getOuterParamsFilters());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,10 +510,10 @@ public class ChartViewService {
|
|||||||
// 如果是插件视图 走插件内部的逻辑
|
// 如果是插件视图 走插件内部的逻辑
|
||||||
if (ObjectUtils.isNotEmpty(view.getIsPlugin()) && view.getIsPlugin()) {
|
if (ObjectUtils.isNotEmpty(view.getIsPlugin()) && view.getIsPlugin()) {
|
||||||
Map<String, List<ChartViewFieldDTO>> fieldMap = new HashMap<>();
|
Map<String, List<ChartViewFieldDTO>> fieldMap = new HashMap<>();
|
||||||
fieldMap.put("xAxis",xAxis);
|
fieldMap.put("xAxis", xAxis);
|
||||||
fieldMap.put("yAxis",yAxis);
|
fieldMap.put("yAxis", yAxis);
|
||||||
fieldMap.put("extStack",extStack);
|
fieldMap.put("extStack", extStack);
|
||||||
fieldMap.put("extBubble",extBubble);
|
fieldMap.put("extBubble", extBubble);
|
||||||
PluginViewParam pluginViewParam = buildPluginParam(fieldMap, fieldCustomFilter, extFilterList, ds, table, view);
|
PluginViewParam pluginViewParam = buildPluginParam(fieldMap, fieldCustomFilter, extFilterList, ds, table, view);
|
||||||
String sql = pluginViewSql(pluginViewParam, view);
|
String sql = pluginViewSql(pluginViewParam, view);
|
||||||
if (StringUtils.isBlank(sql)) {
|
if (StringUtils.isBlank(sql)) {
|
||||||
@ -532,7 +525,7 @@ public class ChartViewService {
|
|||||||
Map<String, Object> mapChart = pluginViewResult(pluginViewParam, view, data, isDrill);
|
Map<String, Object> mapChart = pluginViewResult(pluginViewParam, view, data, isDrill);
|
||||||
Map<String, Object> mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
|
Map<String, Object> mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
|
||||||
|
|
||||||
return uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal,view, isDrill, drillFilters);
|
return uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal, view, isDrill, drillFilters);
|
||||||
// 如果是插件到此结束
|
// 如果是插件到此结束
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,7 +764,7 @@ public class ChartViewService {
|
|||||||
}
|
}
|
||||||
// table组件,明细表,也用于导出数据
|
// table组件,明细表,也用于导出数据
|
||||||
Map<String, Object> mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
|
Map<String, Object> mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
|
||||||
return uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal,view, isDrill, drillFilters);
|
return uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal, view, isDrill, drillFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChartViewDTO uniteViewResult(String sql, Map<String, Object> chartData, Map<String, Object> tabelData, ChartViewDTO view, Boolean isDrill, List<ChartExtFilterRequest> drillFilters) {
|
public ChartViewDTO uniteViewResult(String sql, Map<String, Object> chartData, Map<String, Object> tabelData, ChartViewDTO view, Boolean isDrill, List<ChartExtFilterRequest> drillFilters) {
|
||||||
@ -800,8 +793,6 @@ public class ChartViewService {
|
|||||||
PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view);
|
PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<PluginChartFieldCustomFilter> fieldFilters = customFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartFieldCustomFilter.class)).collect(Collectors.toList());
|
List<PluginChartFieldCustomFilter> fieldFilters = customFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartFieldCustomFilter.class)).collect(Collectors.toList());
|
||||||
List<PluginChartExtFilter> panelFilters = extFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartExtFilter.class)).collect(Collectors.toList());
|
List<PluginChartExtFilter> panelFilters = extFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartExtFilter.class)).collect(Collectors.toList());
|
||||||
|
|
||||||
@ -1040,8 +1031,8 @@ public class ChartViewService {
|
|||||||
public String chartCopy(String id, String panelId) {
|
public String chartCopy(String id, String panelId) {
|
||||||
String newChartId = UUID.randomUUID().toString();
|
String newChartId = UUID.randomUUID().toString();
|
||||||
extChartViewMapper.chartCopy(newChartId, id, panelId);
|
extChartViewMapper.chartCopy(newChartId, id, panelId);
|
||||||
extChartViewMapper.copyCache(id,newChartId);
|
extChartViewMapper.copyCache(id, newChartId);
|
||||||
extPanelGroupExtendDataMapper.copyExtendData(id,newChartId,panelId);
|
extPanelGroupExtendDataMapper.copyExtendData(id, newChartId, panelId);
|
||||||
chartViewCacheService.refreshCache(newChartId);
|
chartViewCacheService.refreshCache(newChartId);
|
||||||
return newChartId;
|
return newChartId;
|
||||||
}
|
}
|
||||||
@ -1072,8 +1063,14 @@ public class ChartViewService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param panelId
|
||||||
|
* @Description 初始化仪表板内部视图的cache表
|
||||||
|
*/
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
public void initViewCache(String panelId) {
|
public void initViewCache(String panelId) {
|
||||||
extChartViewMapper.deleteCacheWithPanel(null,panelId);
|
extChartViewMapper.deleteCacheWithPanel(null, panelId);
|
||||||
|
extChartViewMapper.initPanelChartViewCache(panelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import io.dataease.commons.utils.LogUtil;
|
|||||||
import io.dataease.commons.utils.TreeUtils;
|
import io.dataease.commons.utils.TreeUtils;
|
||||||
import io.dataease.controller.request.authModel.VAuthModelRequest;
|
import io.dataease.controller.request.authModel.VAuthModelRequest;
|
||||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||||
|
import io.dataease.controller.request.panel.PanelGroupQueryRequest;
|
||||||
import io.dataease.controller.request.panel.PanelGroupRequest;
|
import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||||
import io.dataease.controller.request.panel.PanelViewDetailsRequest;
|
import io.dataease.controller.request.panel.PanelViewDetailsRequest;
|
||||||
import io.dataease.dto.PanelGroupExtendDataDTO;
|
import io.dataease.dto.PanelGroupExtendDataDTO;
|
||||||
@ -131,7 +132,7 @@ public class PanelGroupService {
|
|||||||
} else if ("toDefaultPanel".equals(request.getOptType())) { // 转存为默认仪表板
|
} else if ("toDefaultPanel".equals(request.getOptType())) { // 转存为默认仪表板
|
||||||
panelId = UUID.randomUUID().toString();
|
panelId = UUID.randomUUID().toString();
|
||||||
PanelGroupWithBLOBs newDefaultPanel = panelGroupMapper.selectByPrimaryKey(request.getId());
|
PanelGroupWithBLOBs newDefaultPanel = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||||
newDefaultPanel.setPanelType(PanelConstants.PANEL_TYPE_SYSTEM);
|
newDefaultPanel.setPanelType(PanelConstants.PANEL_TYPE.SYSTEM);
|
||||||
newDefaultPanel.setNodeType(PanelConstants.PANEL_NODE_TYPE_PANEL);
|
newDefaultPanel.setNodeType(PanelConstants.PANEL_NODE_TYPE_PANEL);
|
||||||
newDefaultPanel.setName(request.getName());
|
newDefaultPanel.setName(request.getName());
|
||||||
newDefaultPanel.setId(panelId);
|
newDefaultPanel.setId(panelId);
|
||||||
@ -221,7 +222,13 @@ public class PanelGroupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 查询仪表板信息
|
||||||
|
* @param panelId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public PanelGroupDTO findOne(String panelId) {
|
public PanelGroupDTO findOne(String panelId) {
|
||||||
|
Assert.notNull(panelId,"Method findOne panelId can not be null");
|
||||||
PanelGroupDTO panelGroup = extPanelGroupMapper.findOneWithPrivileges(panelId, String.valueOf(AuthUtils.getUser().getUserId()));
|
PanelGroupDTO panelGroup = extPanelGroupMapper.findOneWithPrivileges(panelId, String.valueOf(AuthUtils.getUser().getUserId()));
|
||||||
// 默认仪表板取源仪表板样式
|
// 默认仪表板取源仪表板样式
|
||||||
if (panelGroup != null && StringUtils.isNotEmpty(panelGroup.getSource())) {
|
if (panelGroup != null && StringUtils.isNotEmpty(panelGroup.getSource())) {
|
||||||
|
@ -125,7 +125,7 @@ public class PanelViewService {
|
|||||||
extPanelViewMapper.savePanelView(panelViewInsertDTOList);
|
extPanelViewMapper.savePanelView(panelViewInsertDTOList);
|
||||||
//将视图从cache表中更新到正式表中
|
//将视图从cache表中更新到正式表中
|
||||||
viewIds = panelViewInsertDTOList.stream().map(panelView ->panelView.getChartViewId()).collect(Collectors.toList());
|
viewIds = panelViewInsertDTOList.stream().map(panelView ->panelView.getChartViewId()).collect(Collectors.toList());
|
||||||
extChartViewMapper.copyCacheToView(viewIds);
|
// extChartViewMapper.copyCacheToView(viewIds);
|
||||||
}
|
}
|
||||||
extChartViewMapper.deleteCacheWithPanel(viewIds,panelId);
|
extChartViewMapper.deleteCacheWithPanel(viewIds,panelId);
|
||||||
extChartViewMapper.deleteNoUseView(viewIds,panelId);
|
extChartViewMapper.deleteNoUseView(viewIds,panelId);
|
||||||
|
@ -86,9 +86,9 @@ export function getChartDetails(id, panelId, data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function save2Cache(panelId, data) {
|
export function viewEditSave(panelId, data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/chart/view/save2Cache/' + panelId,
|
url: '/chart/view/viewEditSave/' + panelId,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
loading: false,
|
loading: false,
|
||||||
data
|
data
|
||||||
|
@ -1160,7 +1160,7 @@ import {
|
|||||||
ajaxGetDataOnly,
|
ajaxGetDataOnly,
|
||||||
post,
|
post,
|
||||||
getChartDetails,
|
getChartDetails,
|
||||||
save2Cache,
|
viewEditSave,
|
||||||
resetViewCacheCallBack
|
resetViewCacheCallBack
|
||||||
} from '@/api/chart/chart'
|
} from '@/api/chart/chart'
|
||||||
import DimensionItem from '../components/drag-item/DimensionItem'
|
import DimensionItem from '../components/drag-item/DimensionItem'
|
||||||
@ -1792,7 +1792,7 @@ export default {
|
|||||||
this.changeEditStatus(true)
|
this.changeEditStatus(true)
|
||||||
const view = this.buildParam(true, 'chart', false, switchType)
|
const view = this.buildParam(true, 'chart', false, switchType)
|
||||||
if (!view) return
|
if (!view) return
|
||||||
save2Cache(this.panelInfo.id, view).then(() => {
|
viewEditSave(this.panelInfo.id, view).then(() => {
|
||||||
bus.$emit('view-in-cache', { type: 'propChange', viewId: this.param.id })
|
bus.$emit('view-in-cache', { type: 'propChange', viewId: this.param.id })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -1819,7 +1819,7 @@ export default {
|
|||||||
// 保存到缓存表
|
// 保存到缓存表
|
||||||
const viewSave = this.buildParam(true, 'chart', false, false)
|
const viewSave = this.buildParam(true, 'chart', false, false)
|
||||||
if (!viewSave) return
|
if (!viewSave) return
|
||||||
save2Cache(this.panelInfo.id, viewSave)
|
viewEditSave(this.panelInfo.id, viewSave)
|
||||||
|
|
||||||
bus.$emit('view-in-cache', { type: 'styleChange', viewId: this.param.id, viewInfo: view })
|
bus.$emit('view-in-cache', { type: 'styleChange', viewId: this.param.id, viewInfo: view })
|
||||||
},
|
},
|
||||||
@ -2565,10 +2565,10 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.changeEditStatus(false)
|
|
||||||
this.getChart(this.param.id, 'panel')
|
|
||||||
const _this = this
|
const _this = this
|
||||||
resetViewCacheCallBack(this.param.id, this.panelInfo.id, function(rsp) {
|
resetViewCacheCallBack(_this.param.id, _this.panelInfo.id, function(rsp) {
|
||||||
|
_this.changeEditStatus(false)
|
||||||
|
_this.getChart(_this.param.id, 'panel')
|
||||||
bus.$emit('view-in-cache', { type: 'propChange', viewId: _this.param.id })
|
bus.$emit('view-in-cache', { type: 'propChange', viewId: _this.param.id })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user