INSERT INTO chart_view_cache ( 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 ) 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.id = #{id} INSERT INTO chart_view_cache ( 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 ) SELECT #{newViewId} as 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_cache WHERE chart_view_cache.id = #{sourceViewId} INSERT INTO chart_view_cache ( 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 ) 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 INTO chart_view (`id`, `name`, `scene_id`, `table_id`, `type`, `title`, `x_axis`, `x_axis_ext`, `y_axis`, `custom_attr`, `custom_style`, `custom_filter`, `drill_fields`, `create_by`, `create_time`, `update_time`, `snapshot`, `style_priority`, `ext_stack`, `ext_bubble`, `y_axis_ext`, `render`, `result_count`, `result_mode`, `chart_type`, `is_plugin`, `senior`, `data_from`) SELECT #{newChartId}, GET_CHART_VIEW_COPY_NAME(#{oldChartId},#{panelId}) as `name`, #{panelId}, `table_id`, `type`, GET_CHART_VIEW_COPY_NAME(#{oldChartId},#{panelId}) as `title`, `x_axis`, `x_axis_ext`, `y_axis`, `custom_attr`, `custom_style`, `custom_filter`, `drill_fields`, `create_by`, unix_timestamp()*1000 as `create_time`, unix_timestamp()*1000 as `update_time`, `snapshot`, `style_priority`, `ext_stack`, `ext_bubble`, `y_axis_ext`, `render`, `result_count`, `result_mode`, 'private', `is_plugin`, `senior`, `data_from` FROM chart_view WHERE id = #{oldChartId} INSERT INTO chart_view (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, SNAPSHOT, data_from) SELECT pv_copy.chart_view_id AS id, `name`, title, pv_copy.panel_id AS 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, SNAPSHOT, data_from FROM ( SELECT panel_id, copy_from_view, chart_view_id FROM panel_view WHERE copy_id = #{copyId} ) pv_copy INNER JOIN chart_view ON chart_view.id = pv_copy.copy_from_view delete chart_view from (select GET_CHART_GROUP_WITH_CHILDREN( #{pid} ) cids ) t, chart_view where FIND_IN_SET ( chart_view . id, cids ) and chart_type = 'public' delete chart_group from (select GET_CHART_GROUP_WITH_CHILDREN( #{pid} ) cids ) t, chart_group where FIND_IN_SET ( chart_group . id, cids ) delete from chart_view_cache where scene_id = #{panelId} and id not in #{viewId} delete from chart_view_cache where id = #{viewId} UPDATE chart_view cv, chart_view_cache cve 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 in #{viewId} UPDATE chart_view_cache cv, chart_view cve 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 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} delete from chart_view where scene_id = #{panelId} and id not in #{viewId}