Merge pull request #2003 from dataease/pr@dev@fix_panel-view-copy
fix: 模板视图复制出错问题
This commit is contained in:
commit
5fdc028602
@ -214,7 +214,7 @@
|
|||||||
`is_plugin`,
|
`is_plugin`,
|
||||||
`senior`,
|
`senior`,
|
||||||
`data_from`
|
`data_from`
|
||||||
FROM chart_view_cache
|
FROM chart_view
|
||||||
WHERE id = #{oldChartId}
|
WHERE id = #{oldChartId}
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@ -298,7 +298,7 @@
|
|||||||
FROM panel_view
|
FROM panel_view
|
||||||
WHERE copy_id = #{copyId}
|
WHERE copy_id = #{copyId}
|
||||||
) pv_copy
|
) pv_copy
|
||||||
LEFT JOIN chart_view ON chart_view.id = pv_copy.copy_from_view
|
INNER JOIN chart_view ON chart_view.id = pv_copy.copy_from_view
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<delete id="deleteCircleView">
|
<delete id="deleteCircleView">
|
||||||
|
|||||||
@ -7,4 +7,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface ExtPanelGroupExtendDataMapper {
|
public interface ExtPanelGroupExtendDataMapper {
|
||||||
void savePanelExtendData(@Param("records") List<PanelGroupExtendDataDTO> records);
|
void savePanelExtendData(@Param("records") List<PanelGroupExtendDataDTO> records);
|
||||||
|
|
||||||
|
void copyExtendData(@Param("sourceViewId")String sourceViewId,@Param("newViewId")String newViewId,@Param("newPanelId")String newPanelId);
|
||||||
|
|
||||||
|
void copyWithCopyId(@Param("copyId")String copyId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,53 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="io.dataease.base.mapper.ext.ExtPanelGroupExtendDataMapper">
|
<mapper namespace="io.dataease.base.mapper.ext.ExtPanelGroupExtendDataMapper">
|
||||||
|
|
||||||
<insert id ="savePanelExtendData">
|
<insert id="savePanelExtendData">
|
||||||
INSERT INTO `panel_group_extend_data` (id, panel_id,view_id,view_details) VALUES
|
INSERT INTO `panel_group_extend_data` (id, panel_id,view_id,view_details) VALUES
|
||||||
<foreach collection="records" item="item" index="index" separator=",">
|
<foreach collection="records" item="item" index="index" separator=",">
|
||||||
(uuid(),#{item.panelId},#{item.viewId},#{item.viewDetails})
|
(uuid(),#{item.panelId},#{item.viewId},#{item.viewDetails})
|
||||||
</foreach>
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="copyExtendData">
|
||||||
|
INSERT INTO `panel_group_extend_data` ( id, panel_id, view_id, view_details ) SELECT
|
||||||
|
uuid() as id,
|
||||||
|
#{newPanelId},
|
||||||
|
#{newViewId},
|
||||||
|
view_details
|
||||||
|
FROM
|
||||||
|
panel_group_extend_data
|
||||||
|
WHERE
|
||||||
|
view_id =#{sourceViewId}
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<insert id="copyWithCopyId">
|
||||||
|
INSERT INTO `panel_group_extend_data` (
|
||||||
|
id,
|
||||||
|
panel_id,
|
||||||
|
view_id,
|
||||||
|
view_details,
|
||||||
|
copy_from,
|
||||||
|
copy_id
|
||||||
|
) SELECT
|
||||||
|
uuid() AS id,
|
||||||
|
pv_copy.panel_id AS panel_id,
|
||||||
|
pv_copy.chart_view_id AS view_id,
|
||||||
|
view_details,
|
||||||
|
id AS copy_from,
|
||||||
|
#{copyId} AS copy_id
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
panel_id,
|
||||||
|
copy_from_view,
|
||||||
|
chart_view_id
|
||||||
|
FROM
|
||||||
|
panel_view
|
||||||
|
WHERE
|
||||||
|
copy_id = #{copyId}
|
||||||
|
) pv_copy
|
||||||
|
INNER JOIN panel_group_extend_data ON panel_group_extend_data.view_id = pv_copy.copy_from_view
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import io.dataease.base.mapper.ChartViewMapper;
|
|||||||
import io.dataease.base.mapper.PanelViewMapper;
|
import io.dataease.base.mapper.PanelViewMapper;
|
||||||
import io.dataease.base.mapper.ext.ExtChartGroupMapper;
|
import io.dataease.base.mapper.ext.ExtChartGroupMapper;
|
||||||
import io.dataease.base.mapper.ext.ExtChartViewMapper;
|
import io.dataease.base.mapper.ext.ExtChartViewMapper;
|
||||||
|
import io.dataease.base.mapper.ext.ExtPanelGroupExtendDataMapper;
|
||||||
import io.dataease.commons.constants.ColumnPermissionConstants;
|
import io.dataease.commons.constants.ColumnPermissionConstants;
|
||||||
import io.dataease.commons.constants.CommonConstants;
|
import io.dataease.commons.constants.CommonConstants;
|
||||||
import io.dataease.commons.constants.JdbcConstants;
|
import io.dataease.commons.constants.JdbcConstants;
|
||||||
@ -47,6 +48,7 @@ import io.dataease.service.panel.PanelViewService;
|
|||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -90,9 +92,11 @@ public class ChartViewService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ChartViewCacheMapper chartViewCacheMapper;
|
private ChartViewCacheMapper chartViewCacheMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PanelViewService panelViewService;
|
private PanelViewMapper panelViewMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PanelGroupExtendDataService extendDataService;
|
private PanelGroupExtendDataService extendDataService;
|
||||||
|
@Resource
|
||||||
|
private ExtPanelGroupExtendDataMapper extPanelGroupExtendDataMapper;
|
||||||
|
|
||||||
|
|
||||||
//默认使用非公平
|
//默认使用非公平
|
||||||
@ -121,6 +125,14 @@ public class ChartViewService {
|
|||||||
// 新建的视图也存入缓存表中
|
// 新建的视图也存入缓存表中
|
||||||
extChartViewMapper.copyToCache(chartView.getId());
|
extChartViewMapper.copyToCache(chartView.getId());
|
||||||
|
|
||||||
|
PanelView newPanelView = new PanelView();
|
||||||
|
newPanelView.setId(UUIDUtil.getUUIDAsString());
|
||||||
|
newPanelView.setChartViewId(chartView.getId());
|
||||||
|
newPanelView.setCreateBy(chartView.getCreateBy());
|
||||||
|
newPanelView.setPanelId(chartView.getSceneId());
|
||||||
|
newPanelView.setCreateTime(timestamp);
|
||||||
|
newPanelView.setPosition("panel");
|
||||||
|
panelViewMapper.insertSelective(newPanelView);
|
||||||
return chartView;
|
return chartView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1028,6 +1040,7 @@ 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);
|
||||||
|
extPanelGroupExtendDataMapper.copyExtendData(id,newChartId,panelId);
|
||||||
extChartViewMapper.copyToCache(newChartId);
|
extChartViewMapper.copyToCache(newChartId);
|
||||||
return newChartId;
|
return newChartId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -291,6 +291,8 @@ public class PanelGroupService {
|
|||||||
extChartViewMapper.chartCopyWithPanel(copyId);
|
extChartViewMapper.chartCopyWithPanel(copyId);
|
||||||
//TODO 替换panel_data viewId 数据
|
//TODO 替换panel_data viewId 数据
|
||||||
List<PanelView> panelViewList = panelViewService.findPanelViews(copyId);
|
List<PanelView> panelViewList = panelViewService.findPanelViews(copyId);
|
||||||
|
//TODO 复制模板缓存数据
|
||||||
|
extPanelGroupExtendDataMapper.copyWithCopyId(copyId);
|
||||||
if (CollectionUtils.isNotEmpty(panelViewList)) {
|
if (CollectionUtils.isNotEmpty(panelViewList)) {
|
||||||
String panelData = newPanel.getPanelData();
|
String panelData = newPanel.getPanelData();
|
||||||
//TODO 替换panel_data viewId 数据 并保存
|
//TODO 替换panel_data viewId 数据 并保存
|
||||||
|
|||||||
@ -66,9 +66,12 @@ CREATE TABLE `panel_group_extend_data` (
|
|||||||
`panel_id` varchar(50) DEFAULT NULL,
|
`panel_id` varchar(50) DEFAULT NULL,
|
||||||
`view_id` varchar(50) DEFAULT NULL,
|
`view_id` varchar(50) DEFAULT NULL,
|
||||||
`view_details` longtext,
|
`view_details` longtext,
|
||||||
|
`copy_from` varchar(255) DEFAULT NULL,
|
||||||
|
`copy_id` varchar(255) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user