Quellcode durchsuchen

Merge branch 'master' of http://116.63.33.55/git/read_opc

FinalYu vor 2 Jahren
Ursprung
Commit
2e8e19466e

+ 0 - 16
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/controller/ReportTableController.java

@@ -239,22 +239,6 @@ public class ReportTableController {
     }
 
     /**
-     * 给报表分配用户组
-     *
-     * @param id
-     * @param userGroupId
-     * @return
-     */
-    @PostMapping("/tableAssignUserById")
-    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.REPORTTABLE, OperationEnum = OperationEnum.ASSIGN)
-    public Result tableAssignUserById(Integer id, Integer userGroupId) {
-        if (Blank.isEmpty(id)) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表id不能为空");
-        }
-        return reportTableService.tableAssignUserById(id, userGroupId);
-    }
-
-    /**
      * 根据id修改报表名称
      *
      * @param id

+ 5 - 11
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/dao/ReportTableDao.java

@@ -44,20 +44,10 @@ public interface ReportTableDao {
 
     Integer queryTableNum();
 
-    List<ReportTable> getAllOkReportTable1(List<UserGroupUser> userGroupUserList, Long startNum, Long limitNum, String userId, String reportTableName, Integer isAutoReport);
-
-    List<ReportTable> getAllOkReportTable2(Long startNum, Long limitNum, String userId, String reportTableName, Integer isAutoReport);
-
-    List<ReportTable> getAllAutoReportTable(Integer autoReport);
+    List<ReportTable> getAllAutoReportTable(Integer isAutoReport);
 
     Integer tableExchangeAutoById(Integer id, Integer isAutoReport, String cronId, String cron);
 
-    Integer tableAssignUserById(Integer id, Integer userGroupId);
-
-    Integer getAllOkReportTableCount1(List<UserGroupUser> userGroupUserList, String userId, String reportTableName, Integer isAutoReport);
-
-    Integer getAllOkReportTableCount2(String userId, String reportTableName, Integer isAutoReport);
-
     List<ReportTable> getReportTableByUserGroupId(Integer userGroupId);
 
     Integer updateTableNameById(Integer id, String reportTableName);
@@ -73,4 +63,8 @@ public interface ReportTableDao {
     Integer updateTableTemplateNameById(Integer id, String templateName);
 
     List<UserGroup> getTableUserGroup(Integer reportTableId);
+
+    Integer getAllOkReportTableCount(String userId, String reportTableName, Integer isAutoReport);
+
+    List<ReportTable> getAllOkReportTable(Long startNum, Long limitNum, String userId, String reportTableName, Integer isAutoReport);
 }

+ 0 - 2
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/ReportTableService.java

@@ -32,8 +32,6 @@ public interface ReportTableService {
 
     Result getAllOkReportTable(Integer page, Integer limit, String reportTableName, Integer isAutoReport);
 
-    Result tableAssignUserById(Integer id, Integer userGroupId);
-
     Result updateTableNameById(Integer id, String reportTableName);
 
     Result getSysTableTemplate(String keyType, Integer dictId, String templateName);

+ 3 - 22
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/ReportTableServiceImpl.java

@@ -35,9 +35,6 @@ public class ReportTableServiceImpl implements ReportTableService {
     @Resource
     private UserUtil userUtil;
 
-    @Resource
-    private UserGroupDao userGroupDao;
-
     //引入定时器注册类
     @Resource
     CronTaskRegister cronTaskRegister;
@@ -132,6 +129,7 @@ public class ReportTableServiceImpl implements ReportTableService {
         if (reportTableDao.delReportTableById(id) <= 0) {
             return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "删除报表失败");
         }
+        reportTableDao.delTableUserGroup(id);
         return Result.ok("删除报表成功");
     }
 
@@ -196,31 +194,14 @@ public class ReportTableServiceImpl implements ReportTableService {
     @Override
     public Result getAllOkReportTable(Integer page, Integer limit, String reportTableName, Integer isAutoReport) {
         String userId = userUtil.getCurrentUserId();
-        List<UserGroupUser> userGroupUserList = userGroupDao.getUserGroupUserList(userId);
         Long startNum = Long.valueOf((page - 1) * limit);
         JSONObject jsonObject = new JSONObject();
-        if (Blank.isNotEmpty(userGroupUserList)) {
-            jsonObject.put("count", reportTableDao.getAllOkReportTableCount1(userGroupUserList, userId, reportTableName, isAutoReport));
-            jsonObject.put("reportTableList", reportTableDao.getAllOkReportTable1(userGroupUserList, startNum, Long.valueOf(limit), userId, reportTableName, isAutoReport));
-        } else {
-            jsonObject.put("count", reportTableDao.getAllOkReportTableCount2(userId, reportTableName, isAutoReport));
-            jsonObject.put("reportTableList", reportTableDao.getAllOkReportTable2(startNum, Long.valueOf(limit), userId, reportTableName, isAutoReport));
-        }
+        jsonObject.put("count",reportTableDao.getAllOkReportTableCount(userId, reportTableName, isAutoReport));
+        jsonObject.put("reportTableList",reportTableDao.getAllOkReportTable(startNum, Long.valueOf(limit), userId, reportTableName, isAutoReport));
         return Result.ok(jsonObject);
     }
 
     @Override
-    public Result tableAssignUserById(Integer id, Integer userGroupId) {
-        if (reportTableDao.tableAssignUserById(id, userGroupId) <= 0) {
-            return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), ResultEnum.SERVER_ERROR.getRespMsg());
-        }
-        if (Blank.isEmpty(userGroupId)) {
-            return Result.ok("删除用户组成功");
-        }
-        return Result.ok("分配用户组成功");
-    }
-
-    @Override
     public synchronized Result updateTableNameById(Integer id, String reportTableName) {
         String userId = userUtil.getCurrentUserId();
         ReportTable reportTable = reportTableDao.getReportTableById(id);

+ 91 - 123
chaunyi_opc/opc_da/src/main/resources/mapper/ReportTableDao.xml

@@ -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>