670 lines
24 KiB
XML
670 lines
24 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="io.dataease.ext.ExtChartViewMapper">
|
|
|
|
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.chart.ChartViewDTO"
|
|
extends="io.dataease.plugins.common.base.mapper.ChartViewMapper.ResultMapWithBLOBs">
|
|
<result column="label" property="label"/>
|
|
<result column="privileges" property="privileges"/>
|
|
</resultMap>
|
|
|
|
<select id="findByPanelId" resultMap="BaseResultMapDTO">
|
|
SELECT chart_view.*
|
|
FROM chart_view
|
|
LEFT JOIN panel_view ON chart_view.id = panel_view.chart_view_id
|
|
WHERE panel_view.panel_id = #{panelId}
|
|
</select>
|
|
|
|
<select id="searchOneWithPrivileges" resultMap="BaseResultMapDTO">
|
|
select chart_view.*
|
|
from chart_view
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<select id="searchOne" resultMap="BaseResultMapDTO">
|
|
select chart_view.*
|
|
from chart_view
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="copyToCache">
|
|
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,
|
|
refresh_view_enable,
|
|
refresh_unit,
|
|
refresh_time,
|
|
view_fields)
|
|
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,
|
|
refresh_view_enable,
|
|
refresh_unit,
|
|
refresh_time,
|
|
view_fields
|
|
from chart_view
|
|
WHERE chart_view.id = #{id}
|
|
</insert>
|
|
|
|
<insert id="copyCache">
|
|
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,
|
|
refresh_view_enable,
|
|
refresh_unit,
|
|
refresh_time)
|
|
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,
|
|
refresh_view_enable,
|
|
refresh_unit,
|
|
refresh_time
|
|
from chart_view_cache
|
|
WHERE chart_view_cache.id = #{sourceViewId}
|
|
</insert>
|
|
|
|
<insert id="initPanelChartViewCache">
|
|
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,
|
|
refresh_view_enable,
|
|
refresh_unit,
|
|
refresh_time)
|
|
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,
|
|
refresh_view_enable,
|
|
refresh_unit,
|
|
refresh_time
|
|
from chart_view
|
|
WHERE chart_view.scene_id = #{panelId}
|
|
</insert>
|
|
|
|
<select id="search" resultMap="BaseResultMapDTO">
|
|
select
|
|
id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,
|
|
style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot,
|
|
authInfo.privileges as `privileges`
|
|
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'chart') cids) t,chart_view
|
|
left join (
|
|
SELECT
|
|
auth_source,
|
|
group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges`
|
|
FROM
|
|
(
|
|
`sys_auth`
|
|
LEFT JOIN `sys_auth_detail` ON ((
|
|
`sys_auth`.`id` = `sys_auth_detail`.`auth_id`
|
|
)))
|
|
WHERE
|
|
sys_auth_detail.privilege_value = 1
|
|
AND sys_auth.auth_source_type = 'chart'
|
|
AND (
|
|
(
|
|
sys_auth.auth_target_type = 'dept'
|
|
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} )
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'user'
|
|
AND sys_auth.auth_target = #{userId}
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'role'
|
|
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
|
|
)
|
|
)
|
|
GROUP BY
|
|
`sys_auth`.`auth_source`
|
|
) authInfo
|
|
on chart_view.id = authInfo.auth_source
|
|
<where>
|
|
FIND_IN_SET(chart_view.id,cids)
|
|
<if test="sceneId != null">
|
|
and scene_id = #{sceneId,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="name != null">
|
|
and name like CONCAT('%', #{name},'%')
|
|
</if>
|
|
</where>
|
|
ORDER BY CONVERT(`name` using gbk)
|
|
|
|
</select>
|
|
|
|
<insert id="chartCopy">
|
|
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`,
|
|
`view_fields`)
|
|
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`,
|
|
`view_fields`
|
|
FROM chart_view
|
|
WHERE id = #{oldChartId}
|
|
</insert>
|
|
|
|
<select id="searchAdviceSceneId" resultType="String">
|
|
SELECT DISTINCT (scene_id)
|
|
FROM (SELECT GET_V_AUTH_MODEL_ID_P_USE(#{userId}, 'chart') cids) t,
|
|
panel_view
|
|
LEFT JOIN chart_view ON panel_view.chart_view_id = chart_view.id
|
|
LEFT JOIN chart_group ON chart_view.scene_id = chart_group.id
|
|
WHERE FIND_IN_SET(chart_view.scene_id, cids)
|
|
and panel_view.panel_id = #{panelId}
|
|
ORDER BY chart_group.create_time DESC LIMIT 1
|
|
</select>
|
|
|
|
<select id="checkSameDataSet" resultType="int">
|
|
select count(DISTINCT table_id)
|
|
from chart_view
|
|
where id = #{viewIdSource}
|
|
or id = #{viewIdTarget}
|
|
</select>
|
|
|
|
<insert id='chartCopyWithPanel'>
|
|
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,
|
|
senior,
|
|
data_from,
|
|
view_fields)
|
|
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,
|
|
senior,
|
|
data_from,
|
|
view_fields
|
|
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
|
|
</insert>
|
|
|
|
<delete id="deleteCircleView">
|
|
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>
|
|
|
|
<delete id="deleteCircleGroup">
|
|
delete
|
|
chart_group from (select GET_CHART_GROUP_WITH_CHILDREN(
|
|
#{pid}
|
|
)
|
|
cids
|
|
)
|
|
t,
|
|
chart_group
|
|
where
|
|
FIND_IN_SET
|
|
(
|
|
chart_group
|
|
.
|
|
id,
|
|
cids
|
|
)
|
|
</delete>
|
|
|
|
|
|
<select id="searchViewsWithPanelId" resultMap="BaseResultMapDTO">
|
|
SELECT *
|
|
FROM chart_view
|
|
WHERE id IN (SELECT chart_view_id
|
|
FROM panel_view
|
|
WHERE panel_id = #{panelId})
|
|
</select>
|
|
|
|
<delete id="deleteCacheWithPanel">
|
|
delete from chart_view_cache
|
|
where scene_id = #{panelId}
|
|
<if test="viewIds != null and viewIds.size() > 0">
|
|
and id not in
|
|
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
|
|
#{viewId}
|
|
</foreach>
|
|
</if>
|
|
</delete>
|
|
<delete id="deleteViewCache">
|
|
delete
|
|
from chart_view_cache
|
|
where id = #{viewId}
|
|
</delete>
|
|
|
|
<update id="copyCacheToView">
|
|
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,
|
|
cv.refresh_view_enable = cve.refresh_view_enable,
|
|
cv.refresh_unit = cve.refresh_unit,
|
|
cv.refresh_time = cve.refresh_time,
|
|
cv.view_fields = cve.view_fields
|
|
where cve.id = cv.id and cv.id in
|
|
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
|
|
#{viewId}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="updateToCache">
|
|
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,
|
|
cv.refresh_view_enable = cve.refresh_view_enable,
|
|
cv.refresh_unit = cve.refresh_unit,
|
|
cv.refresh_time = cve.refresh_time,
|
|
cv.view_fields = cve.view_fields
|
|
where cve.id = cv.id and cv.id =#{viewId}
|
|
</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,
|
|
cv.refresh_view_enable = cve.refresh_view_enable,
|
|
cv.refresh_unit = cve.refresh_unit,
|
|
cv.refresh_time = cve.refresh_time
|
|
where cve.id = cv.id and cv.id =#{viewId}
|
|
</update>
|
|
|
|
<delete id="deleteNoUseView">
|
|
delete from chart_view
|
|
where scene_id = #{panelId}
|
|
<if test="viewIds != null and viewIds.size() > 0">
|
|
and id not in
|
|
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
|
|
#{viewId}
|
|
</foreach>
|
|
</if>
|
|
</delete>
|
|
|
|
<select id="chartOptions" resultType="io.dataease.dto.chart.ViewOption">
|
|
select id, title as name
|
|
from chart_view
|
|
where scene_id = #{panelId}
|
|
</select>
|
|
|
|
<insert id='chartFiledCopyWithPanel'>
|
|
INSERT INTO chart_view_field (id,
|
|
table_id,
|
|
chart_id,
|
|
origin_name,
|
|
`name`,
|
|
dataease_name,
|
|
group_type,
|
|
`type`,
|
|
`size`,
|
|
de_type,
|
|
de_type_format,
|
|
de_extract_type,
|
|
ext_field,
|
|
`checked`,
|
|
column_index,
|
|
last_sync_time)
|
|
SELECT uuid() AS id,
|
|
chart_view_field.table_id,
|
|
chart_view_field.pv_copy.chart_view_id AS chart_id,
|
|
chart_view_field.origin_name,
|
|
chart_view_field.`name`,
|
|
chart_view_field.dataease_name,
|
|
chart_view_field.group_type,
|
|
chart_view_field.`type`,
|
|
chart_view_field.`size`,
|
|
chart_view_field.de_type,
|
|
chart_view_field.de_type_format,
|
|
chart_view_field.de_extract_type,
|
|
chart_view_field.ext_field,
|
|
chart_view_field.`checked`,
|
|
chart_view_field.column_index,
|
|
chart_view_field.last_sync_time
|
|
FROM (SELECT panel_id,
|
|
copy_from_view,
|
|
chart_view_id
|
|
FROM panel_view
|
|
WHERE copy_id = #{copyId}) pv_copy
|
|
INNER JOIN chart_view_field ON chart_view_field.chart_id = pv_copy.copy_from_view
|
|
</insert>
|
|
</mapper>
|