瀏覽代碼

手动打印报表时,如果打印子报表,则获取主报表的配置进行打印

zhoupeng 1 年之前
父節點
當前提交
947f26c5bf

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

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

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

@@ -3,6 +3,7 @@ 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;
@@ -126,6 +127,17 @@ public class PrintServiceImpl implements PrintService {
 
     @Override
     public Result getPrintConfigByTableId(String reportTableId) {
+        ReportTable reportTable = reportTableDao.getReportTableById(reportTableId);
+        if (Blank.isEmpty(reportTable)) {
+            return Result.ok(new PrintConfig());
+        }
+        Integer reportTableType = reportTable.getReportTableType();
+        if (reportTableType.equals(ConstantStr.AUTOMATIC_GENERATE_REPORT) ||
+                reportTableType.equals(ConstantStr.EVENT_GENERATE_REPORT) ||
+                reportTableType.equals(ConstantStr.DEVICE_GENERATE_REPORT)) {
+            ReportTable mainReportTable = reportTableDao.getMainTableBychTableId(reportTableId);
+            reportTableId = mainReportTable.getId();
+        }
         Print print = printDao.getPrintByReportId(reportTableId);
         if (Blank.isEmpty(print)) {
             return Result.ok(new PrintConfig());

+ 7 - 0
cqcy-ei/cqcy-ei-da/src/main/resources/mapper/ReportTableDao.xml

@@ -1127,4 +1127,11 @@
         </foreach>
     </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>