|
@@ -14,22 +14,22 @@
|
|
|
|
|
|
<sql id="reportTable">
|
|
|
id
|
|
|
- , user_id, report_table_name, report_table_data, report_value_format, is_auto_report, user_group_id, create_time
|
|
|
+ , user_id, report_table_name, report_table_data, report_value_format, is_auto_report , create_time
|
|
|
</sql>
|
|
|
|
|
|
<sql id="reportTableNoData">
|
|
|
id
|
|
|
- , user_id, report_table_name, report_value_format, is_auto_report, user_group_id, create_time
|
|
|
+ , user_id, report_table_name, report_value_format, is_auto_report , create_time
|
|
|
</sql>
|
|
|
|
|
|
<sql id="reportTableCron">
|
|
|
id
|
|
|
- , user_id, report_table_name, report_table_data, report_value_format, is_auto_report, cron_id, cron, user_group_id, create_time
|
|
|
+ , user_id, report_table_name, report_table_data, report_value_format, is_auto_report, cron_id, cron , create_time
|
|
|
</sql>
|
|
|
|
|
|
<sql id="reportTableCronNoData">
|
|
|
id
|
|
|
- , user_id, report_table_name, report_value_format, is_auto_report, cron_id, cron, user_group_id, create_time
|
|
|
+ , user_id, report_table_name, report_value_format, is_auto_report, cron_id, cron , create_time
|
|
|
</sql>
|
|
|
|
|
|
<insert id="addTableTemplate">
|
|
@@ -43,9 +43,8 @@
|
|
|
<insert id="addReportTable" parameterType="com.example.opc_common.entity.ReportTable" useGeneratedKeys="true"
|
|
|
keyProperty="id">
|
|
|
insert into t_report_table(user_id, report_table_name, report_table_data, is_auto_report, report_value_format,
|
|
|
- user_group_id,
|
|
|
create_time) VALUE
|
|
|
- (#{userId}, #{reportTableName}, #{reportTableData}, #{isAutoReport}, #{reportValueFormat}, #{userGroupId}, now())
|
|
|
+ (#{userId}, #{reportTableName}, #{reportTableData}, #{isAutoReport}, #{reportValueFormat}, now())
|
|
|
</insert>
|
|
|
|
|
|
<insert id="addTableUserGroup">
|
|
@@ -85,12 +84,6 @@
|
|
|
where id = #{id}
|
|
|
</update>
|
|
|
|
|
|
- <update id="tableAssignUserById">
|
|
|
- update t_report_table
|
|
|
- set user_group_id=#{userGroupId}
|
|
|
- where id = #{id}
|
|
|
- </update>
|
|
|
-
|
|
|
<update id="updateTableNameById">
|
|
|
update t_report_table
|
|
|
set report_table_name=#{reportTableName}
|
|
@@ -209,121 +202,11 @@
|
|
|
FROM t_report_table
|
|
|
</select>
|
|
|
|
|
|
- <select id="getAllOkReportTable1" resultType="com.example.opc_common.entity.ReportTable">
|
|
|
- select
|
|
|
- trt.id,
|
|
|
- trt.user_id,
|
|
|
- su.user_name,
|
|
|
- trt.report_table_name,
|
|
|
- trt.report_value_format,
|
|
|
- trt.is_auto_report,
|
|
|
- trt.cron_id,
|
|
|
- trt.cron,
|
|
|
- trt.create_time,
|
|
|
- trt.user_group_id
|
|
|
- from ((select
|
|
|
- <include refid="reportTableCronNoData"/>
|
|
|
- from t_report_table
|
|
|
- where
|
|
|
- 1=1
|
|
|
- <if test="reportTableName != null">
|
|
|
- AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
- </if>
|
|
|
- <if test="isAutoReport != null">
|
|
|
- AND is_auto_report = #{isAutoReport}
|
|
|
- </if>
|
|
|
- AND user_group_id in
|
|
|
- <foreach collection="userGroupUserList" item="userGroupUser" index="index" separator="," open="(" close=")">
|
|
|
- #{userGroupUser.userGroupId}
|
|
|
- </foreach>)
|
|
|
- UNION
|
|
|
- (select
|
|
|
- <include refid="reportTableCronNoData"/>
|
|
|
- from t_report_table
|
|
|
- where
|
|
|
- user_id = #{userId}
|
|
|
- <if test="reportTableName != null">
|
|
|
- AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
- </if>
|
|
|
- <if test="isAutoReport != null">
|
|
|
- AND is_auto_report = #{isAutoReport}
|
|
|
- </if>
|
|
|
- order by create_time desc)) trt LEFT JOIN sys_user su ON trt.user_id = su.user_id
|
|
|
- order by trt.create_time desc
|
|
|
- limit #{startNum},#{limitNum}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="getAllOkReportTable2" resultType="com.example.opc_common.entity.ReportTable">
|
|
|
- select
|
|
|
- trt.id,
|
|
|
- trt.user_id,
|
|
|
- su.user_name,
|
|
|
- trt.report_table_name,
|
|
|
- trt.report_value_format,
|
|
|
- trt.is_auto_report,
|
|
|
- trt.cron_id,
|
|
|
- trt.cron,
|
|
|
- trt.create_time,
|
|
|
- trt.user_group_id
|
|
|
- from t_report_table trt LEFT JOIN sys_user su ON trt.user_id = su.user_id
|
|
|
- where
|
|
|
- trt.user_id = #{userId}
|
|
|
- <if test="reportTableName != null">
|
|
|
- AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
- </if>
|
|
|
- <if test="isAutoReport != null">
|
|
|
- AND trt.is_auto_report = #{isAutoReport}
|
|
|
- </if>
|
|
|
- order by trt.create_time desc
|
|
|
- limit #{startNum},#{limitNum}
|
|
|
- </select>
|
|
|
-
|
|
|
<select id="getAllAutoReportTable" resultType="com.example.opc_common.entity.ReportTable">
|
|
|
select
|
|
|
<include refid="reportTableCronNoData"/>
|
|
|
from t_report_table
|
|
|
- where is_auto_report = #{autoReport}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="getAllOkReportTableCount1" resultType="java.lang.Integer">
|
|
|
- select count(a.id) from ((select
|
|
|
- <include refid="reportTableNoData"/>
|
|
|
- from t_report_table
|
|
|
- where 1=1
|
|
|
- <if test="reportTableName != null">
|
|
|
- AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
- </if>
|
|
|
- <if test="isAutoReport != null">
|
|
|
- AND is_auto_report = #{isAutoReport}
|
|
|
- </if>
|
|
|
- AND user_group_id in
|
|
|
- <foreach collection="userGroupUserList" item="userGroupUser" index="index" separator="," open="(" close=")">
|
|
|
- #{userGroupUser.userGroupId}
|
|
|
- </foreach>)
|
|
|
- UNION
|
|
|
- (select
|
|
|
- <include refid="reportTableNoData"/>
|
|
|
- from t_report_table
|
|
|
- where
|
|
|
- user_id = #{userId}
|
|
|
- <if test="isAutoReport != null">
|
|
|
- AND is_auto_report = #{isAutoReport}
|
|
|
- </if>
|
|
|
- order by create_time desc)) a
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="getAllOkReportTableCount2" resultType="java.lang.Integer">
|
|
|
- select count(*)
|
|
|
- from t_report_table
|
|
|
- where
|
|
|
- user_id = #{userId}
|
|
|
- <if test="reportTableName != null">
|
|
|
- AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
- </if>
|
|
|
- <if test="isAutoReport != null">
|
|
|
- AND is_auto_report = #{isAutoReport}
|
|
|
- </if>
|
|
|
- order by create_time desc
|
|
|
+ where is_auto_report = #{isAutoReport}
|
|
|
</select>
|
|
|
|
|
|
<select id="getReportTableByUserGroupId" resultType="com.example.opc_common.entity.ReportTable">
|
|
@@ -366,4 +249,89 @@
|
|
|
from t_table_user_group
|
|
|
where table_id = #{templateName}
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="getAllOkReportTableCount" resultType="java.lang.Integer">
|
|
|
+ select count(a.id) from ((select
|
|
|
+ <include refid="reportTableNoData"/>
|
|
|
+ from t_report_table
|
|
|
+ where
|
|
|
+ user_id = #{userId}
|
|
|
+ <if test="reportTableName != null">
|
|
|
+ AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="isAutoReport != null">
|
|
|
+ AND is_auto_report = #{isAutoReport}
|
|
|
+ </if>)
|
|
|
+ UNION
|
|
|
+ ( SELECT
|
|
|
+ <include refid="reportTableNoData"/>
|
|
|
+ FROM
|
|
|
+ t_report_table
|
|
|
+ WHERE
|
|
|
+ 1=1
|
|
|
+ <if test="reportTableName != null">
|
|
|
+ AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="isAutoReport != null">
|
|
|
+ AND is_auto_report = #{isAutoReport}
|
|
|
+ </if>
|
|
|
+ AND id IN (
|
|
|
+ SELECT DISTINCT
|
|
|
+ ( table_id )
|
|
|
+ FROM
|
|
|
+ t_table_user_group
|
|
|
+ WHERE
|
|
|
+ user_group_id IN
|
|
|
+ ( SELECT user_group_id FROM t_user_group_user WHERE
|
|
|
+ user_id = #{userId} )
|
|
|
+ ))) a
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getAllOkReportTable" resultType="com.example.opc_common.entity.ReportTable">
|
|
|
+ select
|
|
|
+ trt.id,
|
|
|
+ trt.user_id,
|
|
|
+ su.user_name,
|
|
|
+ trt.report_table_name,
|
|
|
+ trt.report_value_format,
|
|
|
+ trt.is_auto_report,
|
|
|
+ trt.cron_id,
|
|
|
+ trt.cron,
|
|
|
+ trt.create_time
|
|
|
+ from ((select
|
|
|
+ <include refid="reportTableCronNoData"/>
|
|
|
+ from t_report_table
|
|
|
+ where
|
|
|
+ user_id = #{userId}
|
|
|
+ <if test="reportTableName != null">
|
|
|
+ AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="isAutoReport != null">
|
|
|
+ AND is_auto_report = #{isAutoReport}
|
|
|
+ </if>)
|
|
|
+ UNION
|
|
|
+ ( SELECT
|
|
|
+ <include refid="reportTableCronNoData"/>
|
|
|
+ FROM
|
|
|
+ t_report_table
|
|
|
+ WHERE
|
|
|
+ 1=1
|
|
|
+ <if test="reportTableName != null">
|
|
|
+ AND report_table_name LIKE CONCAT('%', #{reportTableName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="isAutoReport != null">
|
|
|
+ AND is_auto_report = #{isAutoReport}
|
|
|
+ </if>
|
|
|
+ AND id IN (
|
|
|
+ SELECT DISTINCT
|
|
|
+ ( table_id )
|
|
|
+ FROM
|
|
|
+ t_table_user_group
|
|
|
+ WHERE
|
|
|
+ user_group_id IN
|
|
|
+ ( SELECT user_group_id FROM t_user_group_user WHERE
|
|
|
+ user_id = #{userId} )
|
|
|
+ ))) trt LEFT JOIN sys_user su ON trt.user_id = su.user_id
|
|
|
+ order by trt.create_time desc
|
|
|
+ </select>
|
|
|
</mapper>
|