浏览代码

将每个小时同步一次共享内存程序换个位置,不要放在数据和告警List条件里

James 3 年之前
父节点
当前提交
7b4a1e8c3c
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      ytWG/ytWGElectric/databasethread.cpp

+ 11 - 5
ytWG/ytWGElectric/databasethread.cpp

@@ -492,6 +492,17 @@ void DatabaseThread::run()
            db.close();
        }
 
+       if(QDateTime::currentDateTime().time().hour() != hour){
+           printf("enter initDb\n");
+           hour = QDateTime::currentDateTime().time().hour();
+           if(!db.open())
+           {
+               db.open();
+           }
+           initDb();
+           db.close();
+       }
+
        int devcount = 0;
        QString St,Et;
        if(devAlarmList.length()>0){
@@ -535,11 +546,6 @@ void DatabaseThread::run()
                count++;
                db.open();
            }else{
-               if(QDateTime::currentDateTime().time().hour() != hour){
-                   printf("enter initDb\n");
-                   hour = QDateTime::currentDateTime().time().hour();
-                   initDb();
-               }
 
                count=0;
                while(sqlList.length()>0){