瀏覽代碼

自动打印自启动

zhoupeng 1 年之前
父節點
當前提交
0e8f742206

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

@@ -29,4 +29,6 @@ public interface PrintDao {
     Integer delPrintConfigById(Integer id);
 
     int getPrintCountByPcId(Integer id);
+
+    List<Print> getAllPrint(Integer runState);
 }

+ 15 - 5
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/dynamicSchedule/DynamicScheduleConfig.java

@@ -1,17 +1,16 @@
 package com.example.opc_da.dynamicSchedule;
 
-import com.example.opc_common.entity.DataSource;
-import com.example.opc_common.entity.DataSourceType;
-import com.example.opc_common.entity.ItemGroup;
-import com.example.opc_common.entity.ReportTable;
+import com.example.opc_common.entity.*;
 import com.example.opc_common.util.Blank;
 import com.example.opc_common.util.ConstantStr;
 import com.example.opc_common.util.DateUtil;
 import com.example.opc_common.util.OpcUtil;
 import com.example.opc_da.dao.DataSourceDao;
 import com.example.opc_da.dao.ItemGroupDao;
+import com.example.opc_da.dao.PrintDao;
 import com.example.opc_da.dao.ReportTableDao;
 import com.example.opc_da.task.OpcDaTask;
+import com.example.opc_da.task.PrintTask;
 import com.example.opc_da.task.ReportTableTask;
 import com.example.opc_da.util.OpcDaUtil;
 import com.example.opc_da.util.RedisUtil;
@@ -40,6 +39,9 @@ public class DynamicScheduleConfig implements SchedulingConfigurer {
     @Resource
     private DataSourceDao dataSourceDao;
 
+    @Autowired
+    private PrintDao printDao;
+
     @Resource
     private CronTaskRegister cronTaskRegister;
 
@@ -71,7 +73,6 @@ public class DynamicScheduleConfig implements SchedulingConfigurer {
                 String readWeek = itemGroup.getReadWeek();
                 Integer id = itemGroup.getId();
                 DataSource dataSource = DataSource.convertPassword(dataSourceDao.getDataSourceById(itemGroup.getDataSourceId()));
-                String clsId = dataSource.getClsId().toUpperCase();
                 DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getTypeId());
                 if (OpcUtil.isOpcDa(dataSourceType.getDataSourceTypeKey())) {
                     if (itemGroup.getRunState() == ConstantStr.START_UP || itemGroup.getRunState() == ConstantStr.EXCEPT_STOP_UP) {
@@ -128,5 +129,14 @@ public class DynamicScheduleConfig implements SchedulingConfigurer {
                 }
             }
         }
+
+        List<Print> printList = printDao.getAllPrint(ConstantStr.START_UP);
+        if (Blank.isNotEmpty(printList)) {
+            for (Print print : printList) {
+                printDao.runAutoPrintById(print.getId(), ConstantStr.START_UP);
+                SchedulingRunnable task = new SchedulingRunnable(PrintTask.class, "autoPrint", new Object[]{print});
+                cronTaskRegister.addCronTask(task, print.getCronId(), print.getCron());
+            }
+        }
     }
 }

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

@@ -106,4 +106,11 @@
         from t_print
         where print_config_id = #{id}
     </select>
+
+    <select id="getAllPrint" resultType="com.example.opc_common.entity.Print">
+        select
+        <include refid="print"/>
+        from t_print
+        where run_state=#{runState}
+ </select>
 </mapper>