Parcourir la source

修改报表中不关联打印配置,使用打印任务关联打印配置

zhoupeng il y a 1 an
Parent
commit
d0bb872ecb

+ 5 - 0
cqcy-ei/cqcy-ei-common/src/main/java/com/example/opc_common/entity/Print.java

@@ -22,4 +22,9 @@ public class Print extends BaseSchedule implements Serializable {
      * 报表id(这里的报表id,只能关联,手动、自动、事件驱动,相应的子报表不能关联)
      */
     private String reportTableId;
+
+    /**
+     * 打印配置id
+     */
+    private Integer printConfigId;
 }

+ 0 - 4
cqcy-ei/cqcy-ei-common/src/main/java/com/example/opc_common/entity/ReportTable.java

@@ -25,10 +25,6 @@ public class ReportTable extends BaseSchedule implements Serializable {
      */
     private Integer tableTemplateId;
     /**
-     * 打印配置id
-     */
-    private Integer printConfigId;
-    /**
      * 用户id
      */
     private String userId;

+ 0 - 14
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/controller/PrintController.java

@@ -122,20 +122,6 @@ public class PrintController {
         return printService.getPrintConfigById(id);
     }
 
-    /**
-     * 通过报表id获取打印配置
-     *
-     * @param tableId
-     * @return
-     */
-    @GetMapping("/getPrintConfigByTableId")
-    public Result getPrintConfigByTableId(String tableId) {
-        if (Blank.isEmpty(tableId)) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
-        }
-        return printService.getPrintConfigByTableId(tableId);
-    }
-
     @PostMapping("/delPrintConfigById")
     public Result delPrintConfigById(Integer id){
         if (Blank.isEmpty(id)) {

+ 2 - 0
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/dao/PrintDao.java

@@ -27,4 +27,6 @@ public interface PrintDao {
     List<PrintConfig> getAllPrintConfig(Long startNum, Long limitNum);
 
     Integer delPrintConfigById(Integer id);
+
+    int getPrintCountByPcId(Integer id);
 }

+ 0 - 4
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/dao/ReportTableDao.java

@@ -218,8 +218,4 @@ public interface ReportTableDao {
 
     Integer delTableUserGroupList(List<String> tableIdList);
 
-    int getRtCountByPcId(Integer id);
-
-    //通过子报表id查看相应的主报表
-    ReportTable getMainTableBychTableId(String chTableId);
 }

+ 0 - 2
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/service/PrintService.java

@@ -16,8 +16,6 @@ public interface PrintService {
 
     Result getPrintConfigById(Integer id);
 
-    Result getPrintConfigByTableId(String tableId);
-
     Result updatePrintConfig(PrintConfig printConfig);
 
     Result getAllPrintConfig(Integer page, Integer limit);

+ 1 - 1
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/service/impl/DataSourceServiceImpl.java

@@ -221,7 +221,7 @@ public class DataSourceServiceImpl implements DataSourceService {
         if (Blank.isNotEmpty(dataSourceList)) {
             Map<String, String> map = new HashMap<>();
             for (DataSource dataSource : dataSourceList) {
-                map.put(dataSource.getDataSourceDescribe(), dataSource.getClsId());
+                map.put(dataSource.getDriverDescribe(), dataSource.getClsId());
             }
             return Result.ok(map);
         }

+ 2 - 26
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/service/impl/PrintServiceImpl.java

@@ -3,7 +3,6 @@ package com.example.opc_da.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.example.opc_common.entity.Print;
 import com.example.opc_common.entity.PrintConfig;
-import com.example.opc_common.entity.ReportTable;
 import com.example.opc_common.enums.ResultEnum;
 import com.example.opc_common.util.Blank;
 import com.example.opc_common.util.ConstantStr;
@@ -115,9 +114,9 @@ public class PrintServiceImpl implements PrintService {
 
     @Override
     public Result delPrintConfigById(Integer id) {
-        int count = reportTableDao.getRtCountByPcId(id);
+        int count = printDao.getPrintCountByPcId(id);
         if (count > 0) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此打印配置被配置在报表中,不能删除");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此打印配置被配置在打印任务中,不能删除");
         }
         if (printDao.delPrintConfigById(id) <= 0) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "删除打印配置失败");
@@ -130,27 +129,4 @@ public class PrintServiceImpl implements PrintService {
         return Result.ok(printDao.getPrintConfigById(id));
     }
 
-    @Override
-    public Result getPrintConfigByTableId(String tableId) {
-        ReportTable reportTable = reportTableDao.getReportTableById(tableId);
-        Integer reportTableType = reportTable.getReportTableType();
-        if (reportTableType.equals(ConstantStr.MANUAL_REPORT) ||
-                reportTableType.equals(ConstantStr.AUTOMATIC_REPORT) ||
-                reportTableType.equals(ConstantStr.EVENT_DRIVEN_REPORT) ||
-                reportTableType.equals(ConstantStr.DEVICE_REPORT)) {
-            PrintConfig printConfig = printDao.getPrintConfigById(reportTable.getPrintConfigId());
-            if (Blank.isNotEmpty(printConfig)) {
-                return Result.ok(printConfig);
-            }
-            return Result.ok(printConfig);
-        } else {
-            ReportTable mianReportTable = reportTableDao.getMainTableBychTableId(reportTable.getId());
-            PrintConfig printConfig = printDao.getPrintConfigById(mianReportTable.getPrintConfigId());
-            if (Blank.isNotEmpty(printConfig)) {
-                return Result.ok(printConfig);
-            }
-        }
-        return Result.ok(new PrintConfig());
-    }
-
 }

+ 3 - 15
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/task/PrintTask.java

@@ -3,11 +3,9 @@ package com.example.opc_da.task;
 import cn.hutool.http.HttpUtil;
 import com.example.opc_common.entity.Print;
 import com.example.opc_common.entity.PrintConfig;
-import com.example.opc_common.entity.ReportTable;
 import com.example.opc_common.enums.ResultEnum;
 import com.example.opc_common.exception.CustomException;
 import com.example.opc_common.util.Blank;
-import com.example.opc_common.util.ConstantStr;
 import com.example.opc_da.dao.PrintDao;
 import com.example.opc_da.dao.ReportTableDao;
 import com.example.opc_da.service.PrintService;
@@ -43,22 +41,12 @@ public class PrintTask {
         log.info("开始执行打印任务");
         String reportTableId = print.getReportTableId();
         String printIp = print.getPrintIp();
+        Integer printConfigId = print.getPrintConfigId();
         try {
             String hostAddress = InetAddress.getLocalHost().getHostAddress();
-            ReportTable reportTable = reportTableDao.getReportTableById(reportTableId);
-            Integer reportTableType = reportTable.getReportTableType();
             PrintConfig printConfig = new PrintConfig();
-            if (reportTableType.equals(ConstantStr.MANUAL_REPORT) ||
-                    reportTableType.equals(ConstantStr.AUTOMATIC_REPORT) ||
-                    reportTableType.equals(ConstantStr.EVENT_DRIVEN_REPORT) ||
-                    reportTableType.equals(ConstantStr.DEVICE_REPORT)) {
-                PrintConfig printConfig1 = printDao.getPrintConfigById(reportTable.getPrintConfigId());
-                if (Blank.isNotEmpty(printConfig1)) {
-                    printConfig = printConfig1;
-                }
-            } else {
-                ReportTable mianReportTable = reportTableDao.getMainTableBychTableId(reportTable.getId());
-                PrintConfig printConfig1 = printDao.getPrintConfigById(mianReportTable.getPrintConfigId());
+            if (Blank.isNotEmpty(printConfigId)) {
+                PrintConfig printConfig1 = printDao.getPrintConfigById(printConfigId);
                 if (Blank.isNotEmpty(printConfig1)) {
                     printConfig = printConfig1;
                 }

+ 10 - 3
cqcy-ei/cqcy-ei-da/src/main/resources/mapper/PrintDao.xml

@@ -4,7 +4,7 @@
 
     <sql id="print">
         id
-        ,print_ip,report_table_id,cron_id,cron,run_state
+        ,print_ip,report_table_id,print_config_id,cron_id,cron,run_state
     </sql>
 
     <sql id="printConfig">
@@ -15,8 +15,8 @@
 
     <insert id="addPrint" parameterType="com.example.opc_common.entity.TableTemplate" useGeneratedKeys="true"
             keyProperty="id">
-        insert into t_print (print_ip, report_table_id, cron_id, cron)
-            value (#{printIp},#{reportTableId},#{cronId},#{cron})
+        insert into t_print (print_ip, report_table_id, print_config_id, cron_id, cron)
+            value (#{printIp},#{reportTableId},#{printConfigId},#{cronId},#{cron})
     </insert>
 
     <insert id="addPrintConfig">
@@ -33,6 +33,7 @@
         update t_print
         set print_ip=#{printIp},
             report_table_id=#{reportTableId},
+            print_config_id=#{printConfigId},
             cron=#{cron}
         where id = #{id}
     </update>
@@ -99,4 +100,10 @@
         order by create_time DESC
         limit #{startNum},#{limitNum}
     </select>
+
+    <select id="getPrintCountByPcId" resultType="java.lang.Integer">
+        select count(*)
+        from t_print
+        where pring_config_id = #{id}
+    </select>
 </mapper>

+ 8 - 25
cqcy-ei/cqcy-ei-da/src/main/resources/mapper/ReportTableDao.xml

@@ -33,7 +33,7 @@
 
     <sql id="reportTable">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, report_table_data, start_time,
+        , report_table_type, table_template_id, user_id, report_table_name, report_table_data, start_time,
             current_num, is_gen_count_time, version, create_time, is_delete
     </sql>
 
@@ -44,19 +44,19 @@
 
     <sql id="reportTableNoData">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, start_time, current_num,
+        , report_table_type, table_template_id, user_id, report_table_name, start_time, current_num,
             is_gen_count_time, version, create_time, is_delete
     </sql>
 
     <sql id="reportTableCron">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, report_table_data, start_time,
+        , report_table_type, table_template_id, user_id, report_table_name, report_table_data, start_time,
             current_num, is_gen_count_time, version, cron_id, cron , run_state, create_time, is_delete
     </sql>
 
     <sql id="reportTableCronNoData">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, start_time, current_num,
+        , report_table_type, table_template_id, user_id, report_table_name, start_time, current_num,
             is_gen_count_time, version, cron_id, cron , run_state, create_time, is_delete
     </sql>
 
@@ -102,21 +102,21 @@
 
     <insert id="addReportTable" parameterType="com.example.opc_common.entity.ReportTable" useGeneratedKeys="true"
             keyProperty="id">
-        insert into t_report_table(id, report_table_type, table_template_id, print_config_id, user_id, report_table_name,
+        insert into t_report_table(id, report_table_type, table_template_id, user_id, report_table_name,
                                    report_table_data, start_time, current_num, is_gen_count_time, version, cron_id,
                                    cron,
                                    create_time, is_delete) VALUE
-            (#{id},#{reportTableType},#{tableTemplateId}, #{printConfigId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime},
+            (#{id},#{reportTableType},#{tableTemplateId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime},
             #{currentNum}, #{isGenCountTime}, #{version},
             #{cronId}, #{cron}, #{createTime}, #{isDelete})
     </insert>
 
     <insert id="addHaveKeyReport">
-        insert into t_report_table(id, report_table_type, table_template_id, print_config_id, user_id, report_table_name,
+        insert into t_report_table(id, report_table_type, table_template_id, user_id, report_table_name,
                                    report_table_data, start_time, current_num, is_gen_count_time, version, cron_id,
                                    cron,
                                    create_time, is_delete) VALUE
-            (#{id},#{reportTableType},#{tableTemplateId}, #{printConfigId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime},
+            (#{id},#{reportTableType},#{tableTemplateId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime},
             #{currentNum}, #{isGenCountTime}, #{version},
             #{cronId}, #{cron}, #{createTime}, #{isDelete})
     </insert>
@@ -508,7 +508,6 @@
     <select id="getReportTableByUserGroupId" resultType="com.example.opc_common.entity.ReportTable">
         SELECT trt.id,
                trt.table_template_id,
-               trt.print_config_id,
                trt.user_id,
                trt.report_table_name,
                trt.start_time,
@@ -620,7 +619,6 @@
         <id property="id" column="id"/>
         <result property="reportTableType" column="report_table_type"/>
         <result property="tableTemplateId" column="table_template_id"/>
-        <result property="printConfigId" column="print_config_id"/>
         <result property="userId" column="user_id"/>
         <result property="userName" column="user_name"/>
         <result property="reportTableName" column="report_table_name"/>
@@ -650,7 +648,6 @@
         trt.id,
         trt.report_table_type,
         trt.table_template_id,
-        trt.print_config_id,
         trt.user_id,
         su.user_name,
         trt.report_table_name,
@@ -731,7 +728,6 @@
         select trt.id,
         trt.report_table_type,
         trt.table_template_id,
-        trt.print_config_id,
         trt.user_id,
         trt.report_table_name,
         trt.start_time,
@@ -1131,17 +1127,4 @@
         </foreach>
     </select>
 
-    <select id="getRtCountByPcId" resultType="java.lang.Integer">
-        select count(*)
-        from t_report_table
-        where print_config_id = #{printConfigId}
-    </select>
-
-    <select id="getMainTableBychTableId" resultType="com.example.opc_common.entity.ReportTable">
-        select
-        <include refid="reportTableCron"/>
-        from t_report_table
-        where id = (select auto_table_id from t_table_auto_log where auto_ch_table_id=#{chTableId})
-    </select>
-
 </mapper>

+ 8 - 8
cqcy-ei/cqcy-ei-ua/src/main/resources/mapper/ReportTableDao.xml

@@ -33,7 +33,7 @@
 
     <sql id="reportTable">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, report_table_data, start_time,
+        , report_table_type, table_template_id, user_id, report_table_name, report_table_data, start_time,
             current_num, is_gen_count_time, version, create_time, is_delete
     </sql>
 
@@ -44,19 +44,19 @@
 
     <sql id="reportTableNoData">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, start_time, current_num,
+        , report_table_type, table_template_id, user_id, report_table_name, start_time, current_num,
             is_gen_count_time, version, create_time, is_delete
     </sql>
 
     <sql id="reportTableCron">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, report_table_data, start_time,
+        , report_table_type, table_template_id, user_id, report_table_name, report_table_data, start_time,
             current_num, is_gen_count_time, version, cron_id, cron , run_state, create_time, is_delete
     </sql>
 
     <sql id="reportTableCronNoData">
         id
-        , report_table_type, table_template_id, print_config_id, user_id, report_table_name, start_time, current_num,
+        , report_table_type, table_template_id, user_id, report_table_name, start_time, current_num,
             is_gen_count_time, version, cron_id, cron , run_state, create_time, is_delete
     </sql>
 
@@ -87,19 +87,19 @@
 
     <insert id="addReportTable" parameterType="com.example.opc_common.entity.ReportTable" useGeneratedKeys="true"
             keyProperty="id">
-        insert into t_report_table(report_table_type, table_template_id, print_config_id, user_id, report_table_name,
+        insert into t_report_table(report_table_type, table_template_id, user_id, report_table_name,
                                    report_table_data, start_time, end_time, current_num, version, cron_id, cron,
                                    create_time) VALUE
-            (#{reportTableType},#{tableTemplateId}, #{printConfigId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime}, #{endTime}, #{currentNum}, #{version},
+            (#{reportTableType},#{tableTemplateId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime}, #{endTime}, #{currentNum}, #{version},
             #{cronId}, #{cron}, #{createTime})
     </insert>
 
     <insert id="addHaveKeyReport">
-        insert into t_report_table(id, report_table_type, table_template_id, print_config_id, user_id, report_table_name,
+        insert into t_report_table(id, report_table_type, table_template_id, user_id, report_table_name,
                                    report_table_data, start_time, current_num, is_gen_count_time, version, cron_id,
                                    cron,
                                    create_time, is_delete) VALUE
-            (#{id},#{reportTableType},#{tableTemplateId}, #{printConfigId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime},
+            (#{id},#{reportTableType},#{tableTemplateId}, #{userId}, #{reportTableName}, #{reportTableData}, #{startTime},
             #{currentNum}, #{isGenCountTime}, #{version},
             #{cronId}, #{cron}, #{createTime}, #{isDelete})
     </insert>