Переглянути джерело

Merge branch 'ytservice-187' of hanzhengyi/ytService into master

James 1 рік тому
батько
коміт
9babbe0bb3

+ 64 - 103
ytServiceCore/core.cpp

@@ -72,7 +72,7 @@ Core::Core(QObject *parent) :
     ytShm->updatetime[CORE_MAIN] = time(static_cast<time_t *>(nullptr));
     ytShm->updatetime[CORE_MAIN] = time(static_cast<time_t *>(nullptr));
     ytShm->updatetime[DB_THREAD] = ytShm->updatetime[CORE_MAIN] ;
     ytShm->updatetime[DB_THREAD] = ytShm->updatetime[CORE_MAIN] ;
     db = QSqlDatabase::addDatabase("QSQLITE","dog_conf");
     db = QSqlDatabase::addDatabase("QSQLITE","dog_conf");
-    db.setDatabaseName("db/watchdog2.db");
+    db.setDatabaseName("/root/db/watchdog2.db");
     mdb = QSqlDatabase::addDatabase("QMYSQL","jdxf2_db");
     mdb = QSqlDatabase::addDatabase("QMYSQL","jdxf2_db");
     mdb.setDatabaseName("jdxf");
     mdb.setDatabaseName("jdxf");
     mdb.setHostName("47.98.201.187");
     mdb.setHostName("47.98.201.187");
@@ -85,6 +85,7 @@ Core::Core(QObject *parent) :
     }
     }
     thread = new DB_SyncThread(this);
     thread = new DB_SyncThread(this);
     timer = new QTimer(this);
     timer = new QTimer(this);
+    repThread = new Rep_DBThread(this);
     netAccessManager = new QNetworkAccessManager(this);
     netAccessManager = new QNetworkAccessManager(this);
     connect(timer,SIGNAL(timeout()),this,SLOT(time_out()));
     connect(timer,SIGNAL(timeout()),this,SLOT(time_out()));
     connect(thread,SIGNAL(SyncData(QString,QString)),this,SLOT(SyncData(QString,QString)));
     connect(thread,SIGNAL(SyncData(QString,QString)),this,SLOT(SyncData(QString,QString)));
@@ -137,6 +138,7 @@ void Core::start()
     printf("core start\n");
     printf("core start\n");
         timer->start(1000);
         timer->start(1000);
         thread->start();
         thread->start();
+        repThread->start();
         dc->start();
         dc->start();
         subReportServer->start();
         subReportServer->start();
 //    }
 //    }
@@ -419,7 +421,12 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                             jdata.append(QString(",\"state\":\"%1\"").arg(2));
                             jdata.append(QString(",\"state\":\"%1\"").arg(2));
                         }
                         }
 
 
-                        XfzdSyncData(6,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                        if(qry8.value(4).toString().compare("23")==0){
+                            XfzdSyncData(9,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry8.value(6).toString());
+                        }else{
+                            XfzdSyncData(6,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry8.value(6).toString());
+                        }
+
                     }else if(xfzdQry1.value(7).toString().compare("故障")==0){
                     }else if(xfzdQry1.value(7).toString().compare("故障")==0){
                         logThread->appendData(QString("xfzdceshi4[%1, %2, %3, %4]").arg(subType).arg(DeviceID).arg(insertId).arg(flag));
                         logThread->appendData(QString("xfzdceshi4[%1, %2, %3, %4]").arg(subType).arg(DeviceID).arg(insertId).arg(flag));
                         jdata.append(QString("\"descript\":\"%1\"").arg(qry8.value(0).toString()));
                         jdata.append(QString("\"descript\":\"%1\"").arg(qry8.value(0).toString()));
@@ -447,7 +454,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                         jdata.append(QString(",\"handleAlarmTime\":\"%1\"").arg(xfzdQry1.value(6).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                         jdata.append(QString(",\"handleAlarmTime\":\"%1\"").arg(xfzdQry1.value(6).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                         jdata.append(QString(",\"alarmTime\":\"%1\"").arg(xfzdQry1.value(5).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                         jdata.append(QString(",\"alarmTime\":\"%1\"").arg(xfzdQry1.value(5).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                         jdata.append(QString(",\"state\":\"%1\"").arg(1));
                         jdata.append(QString(",\"state\":\"%1\"").arg(1));
-                        XfzdSyncData(7,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                        XfzdSyncData(7,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry8.value(6).toString());
                     }else if(xfzdQry1.value(7).toString().compare("手报")==0){
                     }else if(xfzdQry1.value(7).toString().compare("手报")==0){
                         jdata.append(QString("\"descript\":\"%1\"").arg(qry8.value(0).toString()));
                         jdata.append(QString("\"descript\":\"%1\"").arg(qry8.value(0).toString()));
                         jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry8.value(1).toString()));
                         jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry8.value(1).toString()));
@@ -478,7 +485,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                         }else{
                         }else{
                             jdata.append(QString(",\"state\":\"%1\"").arg(2));
                             jdata.append(QString(",\"state\":\"%1\"").arg(2));
                         }
                         }
-                        XfzdSyncData(9,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                        XfzdSyncData(9,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry8.value(6).toString());
                     }
                     }
                     break;
                     break;
                     }
                     }
@@ -806,7 +813,11 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"alarmTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"alarmTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"state\":\"%1\"").arg(0));
                           jdata.append(QString(",\"state\":\"%1\"").arg(0));
-                          XfzdSyncData(6,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                          if(qry1.value(4).toString().compare("23")==0){
+                              XfzdSyncData(9,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry1.value(6).toString());
+                          }else{
+                              XfzdSyncData(6,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry1.value(6).toString());
+                          }
                       }else if(qry.value(1).toString().compare("故障")==0){
                       }else if(qry.value(1).toString().compare("故障")==0){
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
@@ -827,7 +838,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"alarmTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"alarmTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"state\":\"%1\"").arg(0));
                           jdata.append(QString(",\"state\":\"%1\"").arg(0));
-                          XfzdSyncData(7,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                          XfzdSyncData(7,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry1.value(6).toString());
                       }else if(qry.value(1).toString().compare("监管")==0){
                       }else if(qry.value(1).toString().compare("监管")==0){
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
@@ -848,7 +859,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"reportTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"reportTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"devStatus\":\"%1\"").arg("正常"));
                           jdata.append(QString(",\"devStatus\":\"%1\"").arg("正常"));
-                          XfzdSyncData(8,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                          XfzdSyncData(8,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry1.value(6).toString());
                       }else if(qry.value(1).toString().compare("手报")==0){
                       }else if(qry.value(1).toString().compare("手报")==0){
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
@@ -869,7 +880,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"alarmTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"alarmTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"state\":\"%1\"").arg(0));
                           jdata.append(QString(",\"state\":\"%1\"").arg(0));
-                          XfzdSyncData(9,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                          XfzdSyncData(9,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry1.value(6).toString());
                       }else if(qry.value(1).toString().compare("复位")==0){
                       }else if(qry.value(1).toString().compare("复位")==0){
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
@@ -889,7 +900,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                           md5str[32]='\0';
                           md5str[32]='\0';
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"logTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"logTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
-                          XfzdSyncData(10,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                          XfzdSyncData(10,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry1.value(6).toString());
                       }else if(qry.value(1).toString().compare("反馈")==0){
                       }else if(qry.value(1).toString().compare("反馈")==0){
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString("\"descript\":\"%1\"").arg(qry1.value(0).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
                           jdata.append(QString(",\"deviceName\":\"%1\"").arg(qry1.value(1).toString()));
@@ -910,7 +921,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"openEventId\":\"%1\"").arg(md5str));
                           jdata.append(QString(",\"reportTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"reportTime\":\"%1\"").arg(qry.value(4).toDateTime().toString("yyyy-MM-dd hh:mm:ss")));
                           jdata.append(QString(",\"devStatus\":\"%1\"").arg("正常"));
                           jdata.append(QString(",\"devStatus\":\"%1\"").arg("正常"));
-                          XfzdSyncData(11,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                          XfzdSyncData(11,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory,DeviceID,qry1.value(6).toString());
                       }
                       }
                       break;
                       break;
                   }
                   }
@@ -1253,11 +1264,11 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                             }
                             }
                         }
                         }
                         if(xfzddev.DeviceType==258){
                         if(xfzddev.DeviceType==258){
-                            XfzdSyncData(4,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory);
+                            XfzdSyncData(4,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory,DeviceID,xfzddev.OpenProjectId);
                         }else if(xfzddev.DeviceType==256){
                         }else if(xfzddev.DeviceType==256){
-                            XfzdSyncData(5,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory);
+                            XfzdSyncData(5,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory,DeviceID,xfzddev.OpenProjectId);
                         }else if(xfzddev.DeviceType==452){
                         }else if(xfzddev.DeviceType==452){
-                            XfzdSyncData(12,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory);
+                            XfzdSyncData(12,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory,DeviceID,xfzddev.OpenProjectId);
                         }
                         }
                     }
                     }
                 }
                 }
@@ -2208,9 +2219,9 @@ void Core::NewcnSyncData(int xh,QString uuid, QString jsonstr, int devCategory)
     NewcnSyncdataLiet.append(NewCnSyncRep(xh,uuid,jsonstr,devCategory));
     NewcnSyncdataLiet.append(NewCnSyncRep(xh,uuid,jsonstr,devCategory));
 }
 }
 
 
-void Core::XfzdSyncData(int xh,QString uuid, QString jsonstr, int devCategory)
+void Core::XfzdSyncData(int xh,QString uuid, QString jsonstr, int devCategory, QString deviceCode, QString openProjectId)
 {
 {
-    XfzdSyncdataLiet.append(XfzdSyncRep(xh,uuid,jsonstr,devCategory));
+    XfzdSyncdataLiet.append(XfzdSyncRep(xh,uuid,jsonstr,devCategory,deviceCode,openProjectId));
 }
 }
 
 
 void Core::jaSyncData(int xh,QString uuid,QString jsonstr)
 void Core::jaSyncData(int xh,QString uuid,QString jsonstr)
@@ -2248,10 +2259,10 @@ void Core::finishedSlot(QNetworkReply *reply)
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             ypCount=0;
             ypCount=0;
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `ypsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `ypsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypSyncdataList.removeFirst();
         ypSyncdataList.removeFirst();
     }
     }
@@ -2266,10 +2277,10 @@ void Core::finishedSlot2(QNetworkReply *reply)
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             cnCount=0;
             cnCount=0;
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `cnsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `cnsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `cnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `cnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         cnSyncdataLiet.removeFirst();
         cnSyncdataLiet.removeFirst();
     }
     }
@@ -2284,11 +2295,11 @@ void Core::finishedSlot3(QNetworkReply *reply)
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             jaCount=0;
             jaCount=0;
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `jasync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `jasync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
 //            printf("%s\n",bak_info.toUtf8().data());
 //            printf("%s\n",bak_info.toUtf8().data());
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `jasync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `jasync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         jaSyncdataLiet.removeFirst();
         jaSyncdataLiet.removeFirst();
     }
     }
@@ -2304,10 +2315,10 @@ void Core::finishedSlot4(QNetworkReply *reply)
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             ypdisCount=0;
             ypdisCount=0;
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `ypsync_t_rec_dis` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec_dis` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `ypsync_t_rec_dis` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec_dis` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypSyncDisdataList.removeFirst();
         ypSyncDisdataList.removeFirst();
     }
     }
@@ -2322,10 +2333,10 @@ void Core::finishedSlot5(QNetworkReply *reply)
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             ypxyCount=0;
             ypxyCount=0;
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `ypsync_t_rec_xy` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec_xy` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `ypsync_t_rec_xy` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec_xy` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypSyncXydataList.removeFirst();
         ypSyncXydataList.removeFirst();
     }
     }
@@ -2340,11 +2351,11 @@ void Core::finishedSlot6(QNetworkReply *reply)
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             hpCount=0;
             hpCount=0;
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `hpsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `hpsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
 //            printf("%s\n",bak_info.toUtf8().data());
 //            printf("%s\n",bak_info.toUtf8().data());
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `hpsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `hpsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         hpSyncdataLiet.removeFirst();
         hpSyncdataLiet.removeFirst();
     }
     }
@@ -2358,11 +2369,11 @@ void Core::finishedSlot7(QNetworkReply *reply)
         NewCnSyncRep rep = NewcnSyncdataLiet.first();
         NewCnSyncRep rep = NewcnSyncdataLiet.first();
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `newcnsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `newcnsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
 //            printf("%s\n",bak_info.toUtf8().data());
 //            printf("%s\n",bak_info.toUtf8().data());
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `newcnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `newcnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         NewcnSyncdataLiet.removeFirst();
         NewcnSyncdataLiet.removeFirst();
     }
     }
@@ -2376,11 +2387,11 @@ void Core::finishedSlot8(QNetworkReply *reply)
         YpYwSyncRep rep = ypYwSyncDataList.first();
         YpYwSyncRep rep = ypYwSyncDataList.first();
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `ypywsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `ypywsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
 //            printf("%s\n",bak_info.toUtf8().data());
 //            printf("%s\n",bak_info.toUtf8().data());
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `ypywsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `ypywsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypYwSyncDataList.removeFirst();
         ypYwSyncDataList.removeFirst();
     }
     }
@@ -2394,11 +2405,11 @@ void Core::finishedSlot9(QNetworkReply *reply)
         XfzdSyncRep rep = XfzdSyncdataLiet.first();
         XfzdSyncRep rep = XfzdSyncdataLiet.first();
         if(reply->error()==QNetworkReply::NoError){
         if(reply->error()==QNetworkReply::NoError){
             QString bak_info = QString::fromUtf8(reply->readAll());
             QString bak_info = QString::fromUtf8(reply->readAll());
-            sqlList2.append(QString::fromUtf8("update `xfzdsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
+            repThread->appendSql(QString::fromUtf8("update `xfzdsync_t_rec` set `send`=1, `reply_str`='%1', `reply_time`='%2' where `uuid`='%3'")
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(bak_info).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
 //            printf("%s\n",bak_info.toUtf8().data());
 //            printf("%s\n",bak_info.toUtf8().data());
         }else
         }else
-            sqlList2.append(QString::fromUtf8("update `xfzdsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+            repThread->appendSql(QString::fromUtf8("update `xfzdsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                            .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         XfzdSyncdataLiet.removeFirst();
         XfzdSyncdataLiet.removeFirst();
     }
     }
@@ -2410,7 +2421,7 @@ void Core::reply_timeout()
 {
 {
     if(ypSyncdataList.length()>0){
     if(ypSyncdataList.length()>0){
         SyncRep rep = ypSyncdataList.first();
         SyncRep rep = ypSyncdataList.first();
-        sqlList2.append(QString::fromUtf8("update `ypsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypSyncdataList.removeFirst();
         ypSyncdataList.removeFirst();
     }
     }
@@ -2421,7 +2432,7 @@ void Core::reply_timeout2()
 {
 {
     if(cnSyncdataLiet.length()>0){
     if(cnSyncdataLiet.length()>0){
         CnSyncRep rep = cnSyncdataLiet.first();
         CnSyncRep rep = cnSyncdataLiet.first();
-        sqlList2.append(QString::fromUtf8("update `cnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `cnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         cnSyncdataLiet.removeFirst();
         cnSyncdataLiet.removeFirst();
     }
     }
@@ -2432,7 +2443,7 @@ void Core::reply_timeout3()
 {
 {
     if(jaSyncdataLiet.length()>0){
     if(jaSyncdataLiet.length()>0){
         JaSyncRep rep = jaSyncdataLiet.first();
         JaSyncRep rep = jaSyncdataLiet.first();
-        sqlList2.append(QString::fromUtf8("update `jasync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `jasync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         jaSyncdataLiet.removeFirst();
         jaSyncdataLiet.removeFirst();
 //       printf("replytimeout jawater start\n");
 //       printf("replytimeout jawater start\n");
@@ -2445,7 +2456,7 @@ void Core::reply_timeout4()
 {
 {
     if(ypSyncDisdataList.length()>0){
     if(ypSyncDisdataList.length()>0){
         SyncRep rep = ypSyncDisdataList.first();
         SyncRep rep = ypSyncDisdataList.first();
-        sqlList2.append(QString::fromUtf8("update `ypsync_t_rec_dis` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec_dis` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypSyncDisdataList.removeFirst();
         ypSyncDisdataList.removeFirst();
     }
     }
@@ -2456,7 +2467,7 @@ void Core::reply_timeout5()
 {
 {
     if(ypSyncXydataList.length()>0){
     if(ypSyncXydataList.length()>0){
         YpXySyncRep rep = ypSyncXydataList.first();
         YpXySyncRep rep = ypSyncXydataList.first();
-        sqlList2.append(QString::fromUtf8("update `ypsync_t_rec_xy` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `ypsync_t_rec_xy` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypSyncXydataList.removeFirst();
         ypSyncXydataList.removeFirst();
     }
     }
@@ -2467,7 +2478,7 @@ void Core::reply_timeout6()
 {
 {
     if(hpSyncdataLiet.length()>0){
     if(hpSyncdataLiet.length()>0){
         HpSyncRep rep = hpSyncdataLiet.first();
         HpSyncRep rep = hpSyncdataLiet.first();
-        sqlList2.append(QString::fromUtf8("update `hpsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `hpsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         hpSyncdataLiet.removeFirst();
         hpSyncdataLiet.removeFirst();
     }
     }
@@ -2478,7 +2489,7 @@ void Core::reply_timeout7()
 {
 {
     if(NewcnSyncdataLiet.length()>0){
     if(NewcnSyncdataLiet.length()>0){
         NewCnSyncRep rep = NewcnSyncdataLiet.first();
         NewCnSyncRep rep = NewcnSyncdataLiet.first();
-        sqlList2.append(QString::fromUtf8("update `newcnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `newcnsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         NewcnSyncdataLiet.removeFirst();
         NewcnSyncdataLiet.removeFirst();
     }
     }
@@ -2489,7 +2500,7 @@ void Core::reply_timeout8()
 {
 {
     if(ypYwSyncDataList.length()>0){
     if(ypYwSyncDataList.length()>0){
         YpYwSyncRep rep = ypYwSyncDataList.first();
         YpYwSyncRep rep = ypYwSyncDataList.first();
-        sqlList2.append(QString::fromUtf8("update `ypywsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `ypywsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         ypYwSyncDataList.removeFirst();
         ypYwSyncDataList.removeFirst();
     }
     }
@@ -2500,7 +2511,7 @@ void Core::reply_timeout9()
 {
 {
     if(XfzdSyncdataLiet.length()>0){
     if(XfzdSyncdataLiet.length()>0){
         XfzdSyncRep rep = XfzdSyncdataLiet.first();
         XfzdSyncRep rep = XfzdSyncdataLiet.first();
-        sqlList2.append(QString::fromUtf8("update `xfzdsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
+        repThread->appendSql(QString::fromUtf8("update `xfzdsync_t_rec` set `reply_time`='%1' where `uuid`='%2'")
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
                        .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.Id));
         XfzdSyncdataLiet.removeFirst();
         XfzdSyncdataLiet.removeFirst();
     }
     }
@@ -4128,7 +4139,7 @@ void Core::time_out()
 //        }
 //        }
 //        req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
 //        req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
 //        req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
 //        req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
-//        sqlList2.append(QString("insert into `cnsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+//        repThread->appendSql(QString("insert into `cnsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
 //                        .arg(rep.Id).arg(
 //                        .arg(rep.Id).arg(
 //                            req->url().toString()+"\r\n"+
 //                            req->url().toString()+"\r\n"+
 //                            rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
 //                            rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
@@ -4166,7 +4177,7 @@ void Core::time_out()
 //        req->setUrl(QUrl("http://www.jd-ioe.com:80/ytapi/admin/order/jingan"));
 //        req->setUrl(QUrl("http://www.jd-ioe.com:80/ytapi/admin/order/jingan"));
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
-        sqlList2.append(QString("insert into `jasync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `jasync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
                         .arg(rep.Id).arg(
                         .arg(rep.Id).arg(
                             req->url().toString()+"\r\n"+
                             req->url().toString()+"\r\n"+
 //                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
 //                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
@@ -4181,7 +4192,7 @@ void Core::time_out()
         isSending = true;
         isSending = true;
         ypCount=ypCount+1;
         ypCount=ypCount+1;
         SyncRep rep = ypSyncdataList.first();
         SyncRep rep = ypSyncdataList.first();
-        sqlList2.append(QString("insert into `ypsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `ypsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
                 .arg(rep.Id).arg(rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
                 .arg(rep.Id).arg(rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
         QByteArray Report = rep.JsonStr.toUtf8();
         QByteArray Report = rep.JsonStr.toUtf8();
         QNetworkRequest *req = new QNetworkRequest();
         QNetworkRequest *req = new QNetworkRequest();
@@ -4198,7 +4209,7 @@ void Core::time_out()
         isSending4 = true;
         isSending4 = true;
         ypdisCount=ypdisCount+1;
         ypdisCount=ypdisCount+1;
         SyncRep rep = ypSyncDisdataList.first();
         SyncRep rep = ypSyncDisdataList.first();
-        sqlList2.append(QString("insert into `ypsync_t_rec_dis` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `ypsync_t_rec_dis` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
                 .arg(rep.Id).arg(rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
                 .arg(rep.Id).arg(rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
         QByteArray Report = rep.JsonStr.toUtf8();
         QByteArray Report = rep.JsonStr.toUtf8();
         QNetworkRequest *req = new QNetworkRequest();
         QNetworkRequest *req = new QNetworkRequest();
@@ -4229,7 +4240,7 @@ void Core::time_out()
 //        }
 //        }
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
-        sqlList2.append(QString("insert into `ypsync_t_rec_xy` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `ypsync_t_rec_xy` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
                         .arg(rep.Id).arg(
                         .arg(rep.Id).arg(
                             req->url().toString()+"\r\n"+
                             req->url().toString()+"\r\n"+
 //                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
 //                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
@@ -4267,7 +4278,7 @@ void Core::time_out()
 //        req->setUrl(QUrl("http://www.jd-ioe.com:80/ytapi/admin/order/jingan"));
 //        req->setUrl(QUrl("http://www.jd-ioe.com:80/ytapi/admin/order/jingan"));
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
-        sqlList2.append(QString("insert into `hpsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `hpsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
                         .arg(rep.Id).arg(
                         .arg(rep.Id).arg(
                             req->url().toString()+"\r\n"+
                             req->url().toString()+"\r\n"+
 //                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
 //                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
@@ -4312,7 +4323,7 @@ void Core::time_out()
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setRawHeader("appKey","748935525548687361");
         req->setRawHeader("appKey","748935525548687361");
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
-        sqlList2.append(QString("insert into `newcnsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `newcnsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
                         .arg(rep.Id).arg(
                         .arg(rep.Id).arg(
                             req->url().toString()+"\r\n"+
                             req->url().toString()+"\r\n"+
                             rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
                             rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
@@ -4335,7 +4346,7 @@ void Core::time_out()
         }
         }
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
-        sqlList2.append(QString("insert into `ypywsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `ypywsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
                         .arg(rep.Id).arg(
                         .arg(rep.Id).arg(
                             req->url().toString()+"\r\n"+
                             req->url().toString()+"\r\n"+
                             rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
                             rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
@@ -4386,10 +4397,10 @@ void Core::time_out()
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setRawHeader("appKey","850404889644236801");
         req->setRawHeader("appKey","850404889644236801");
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
         req->setHeader(QNetworkRequest::ContentLengthHeader,QString("%1").arg(Report.length()).toUtf8());
-        sqlList2.append(QString("insert into `xfzdsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`) values (NULL,'%1','%2',0,'%3')")
+        repThread->appendSql(QString("insert into `xfzdsync_t_rec` (`id`,`uuid`,`data_str`, `send`, `store_time`, `device_code`, `open_project_id`) values (NULL,'%1','%2',0,'%3','%4','%5')")
                         .arg(rep.Id).arg(
                         .arg(rep.Id).arg(
                             req->url().toString()+"\r\n"+
                             req->url().toString()+"\r\n"+
-                            rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
+                            rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")).arg(rep.deviceCode).arg(rep.openProjectId));
         QNetworkReply *reply = XfzdnetAccessManager->post(*req,Report);
         QNetworkReply *reply = XfzdnetAccessManager->post(*req,Report);
         QReplayTimeout *pTimeout = new QReplayTimeout(reply,10000);
         QReplayTimeout *pTimeout = new QReplayTimeout(reply,10000);
         connect(pTimeout, SIGNAL(net_timeout()),this,SLOT(reply_timeout9()));
         connect(pTimeout, SIGNAL(net_timeout()),this,SLOT(reply_timeout9()));
@@ -4404,57 +4415,7 @@ void Core::time_out()
             db.commit();
             db.commit();
         }
         }
     }
     }
-    if(sqlList2.length()>0){
-        QSqlDatabase recdb;
-        if(QSqlDatabase::contains("rec_db")){
-            recdb = QSqlDatabase::database("rec_db");
-        }else{
-            recdb = QSqlDatabase::addDatabase("QSQLITE","rec_db");
-        }
-        QString name = QString("db/watchdoglog%1.db").arg(QDate::currentDate().toString("yyyyMMdd"));
-        recdb.setDatabaseName(name);
-        if(recdb.open()){
-            if(!chk_table("ypsync_t_rec",recdb.tables()))
-            {
-                recdb.exec("create table `ypsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("ypsync_t_rec_dis",recdb.tables()))
-            {
-                recdb.exec("create table `ypsync_t_rec_dis` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("ypsync_t_rec_xy",recdb.tables()))
-            {
-                recdb.exec("create table `ypsync_t_rec_xy` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("cnsync_t_rec",recdb.tables())){
-                recdb.exec("create table `cnsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("jasync_t_rec",recdb.tables())){
-                recdb.exec("create table `jasync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("hpsync_t_rec",recdb.tables())){
-                recdb.exec("create table `hpsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("newcnsync_t_rec",recdb.tables())){
-                recdb.exec("create table `newcnsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("ypywsync_t_rec",recdb.tables())){
-                recdb.exec("create table `ypywsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(!chk_table("xfzdsync_t_rec",recdb.tables())){
-                recdb.exec("create table `xfzdsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
-            }
-            if(recdb.transaction()){
-                while(sqlList2.length()>0){
-                    recdb.exec(sqlList2.first());
-                    sqlList2.removeFirst();
-                }
-                recdb.commit();
-            }
-            recdb.close();
-        }
-//        QSqlDatabase::removeDatabase("rec_db");
-    }
+
     if((tmp_time-work_time)>59){
     if((tmp_time-work_time)>59){
         work_time = tmp_time;
         work_time = tmp_time;
         qry = db.exec("select `app_name`, `app_path`, `keep_working`, `wait_time` , `log_limit`, `keep_size` from `app_t_conf`");
         qry = db.exec("select `app_name`, `app_path`, `keep_working`, `wait_time` , `log_limit`, `keep_size` from `app_t_conf`");

+ 8 - 2
ytServiceCore/core.h

@@ -17,6 +17,7 @@
 #include <QNetworkReply>
 #include <QNetworkReply>
 #include "ytServiceShm.h"
 #include "ytServiceShm.h"
 #include "db_syncthread.h"
 #include "db_syncthread.h"
+#include "rep_dbthread.h"
 #include "QReplyTimeout.h"
 #include "QReplyTimeout.h"
 #include "datacenter.h"
 #include "datacenter.h"
 #include "wscenter.h"
 #include "wscenter.h"
@@ -90,17 +91,21 @@ public:
 
 
 class XfzdSyncRep {
 class XfzdSyncRep {
 public:
 public:
-    explicit XfzdSyncRep(int xh=0,QString id="", QString str="", int devcategory=0){
+    explicit XfzdSyncRep(int xh=0,QString id="", QString str="", int devcategory=0, QString devCode="", QString openPId=""){
         Xh = xh;
         Xh = xh;
         Id = id;
         Id = id;
         JsonStr = str;
         JsonStr = str;
         devCategory =devcategory;
         devCategory =devcategory;
+        deviceCode = devCode;
+        openProjectId = openPId;
     }
     }
 
 
     int Xh;
     int Xh;
     int devCategory;
     int devCategory;
     QString Id;
     QString Id;
     QString JsonStr;
     QString JsonStr;
+    QString deviceCode;
+    QString openProjectId;
 };
 };
 
 
 class JaSyncRep {
 class JaSyncRep {
@@ -148,7 +153,7 @@ public slots:
     void SyncXyData(int xh,QString uuid, QString jsonstr);
     void SyncXyData(int xh,QString uuid, QString jsonstr);
     void cnSyncData(int xh,QString uuid, QString jsonstr, int devCategory);
     void cnSyncData(int xh,QString uuid, QString jsonstr, int devCategory);
     void NewcnSyncData(int xh,QString uuid, QString jsonstr, int devCategory);
     void NewcnSyncData(int xh,QString uuid, QString jsonstr, int devCategory);
-    void XfzdSyncData(int xh,QString uuid, QString jsonstr, int devCategory);
+    void XfzdSyncData(int xh,QString uuid, QString jsonstr, int devCategory, QString deviceCode, QString openProjectId);
     void jaSyncData(int xh,QString uuid,QString jsonstr);
     void jaSyncData(int xh,QString uuid,QString jsonstr);
     void hpSyncData(int xh,QString uuid,QString jsonstr);
     void hpSyncData(int xh,QString uuid,QString jsonstr);
     void ypYwSyncData(int xh,QString uuid,QString jsonstr);
     void ypYwSyncData(int xh,QString uuid,QString jsonstr);
@@ -183,6 +188,7 @@ private:
     int ypCount,ypdisCount,ypxyCount,cnCount,jaCount,hpCount;
     int ypCount,ypdisCount,ypxyCount,cnCount,jaCount,hpCount;
     QTimer *timer;
     QTimer *timer;
     DB_SyncThread *thread;
     DB_SyncThread *thread;
+    Rep_DBThread *repThread;
     QList<JASyncDev> jaDevList;
     QList<JASyncDev> jaDevList;
     QList<YPYWSyncDev> ypYwDevList;
     QList<YPYWSyncDev> ypYwDevList;
     QList<HPSyncDev> hpDevList;
     QList<HPSyncDev> hpDevList;

+ 90 - 0
ytServiceCore/rep_dbthread.cpp

@@ -0,0 +1,90 @@
+#include "rep_dbthread.h"
+
+Rep_DBThread::Rep_DBThread(QObject *parent) : QThread(parent)
+{
+    keep = false;
+    sqlList2.clear();
+
+
+}
+
+void Rep_DBThread::stop()
+{
+    keep = false;
+}
+
+void Rep_DBThread::appendSql(QString sql)
+{
+    sqlList2.append(sql);
+}
+
+bool Rep_DBThread::chk_table(QString tablename, QStringList tables)
+{
+    for(int i=0;i<tables.length();i++)
+    {
+        if(tables.at(i).compare(tablename)==0)
+            return true;
+    }
+    return false;
+}
+
+void Rep_DBThread::run()
+{
+    keep = true;
+    while (keep) {
+        if(sqlList2.length()>0){
+
+            if(QSqlDatabase::contains("rec_db")){
+                recdb = QSqlDatabase::database("rec_db");
+            }else{
+                recdb = QSqlDatabase::addDatabase("QSQLITE","rec_db");
+            }
+            QString name = QString("/root/db/watchdoglog%1.db").arg(QDate::currentDate().toString("yyyyMMdd"));
+            recdb.setDatabaseName(name);
+            if(recdb.open()){
+                if(!chk_table("ypsync_t_rec",recdb.tables()))
+                {
+                    recdb.exec("create table `ypsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("ypsync_t_rec_dis",recdb.tables()))
+                {
+                    recdb.exec("create table `ypsync_t_rec_dis` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("ypsync_t_rec_xy",recdb.tables()))
+                {
+                    recdb.exec("create table `ypsync_t_rec_xy` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("cnsync_t_rec",recdb.tables())){
+                    recdb.exec("create table `cnsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("jasync_t_rec",recdb.tables())){
+                    recdb.exec("create table `jasync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("hpsync_t_rec",recdb.tables())){
+                    recdb.exec("create table `hpsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("newcnsync_t_rec",recdb.tables())){
+                    recdb.exec("create table `newcnsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("ypywsync_t_rec",recdb.tables())){
+                    recdb.exec("create table `ypywsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20))");
+                }
+                if(!chk_table("xfzdsync_t_rec",recdb.tables())){
+                    recdb.exec("create table `xfzdsync_t_rec` (`id` integer primary key autoincrement, `uuid` text(40), `data_str` text(1024), `send` integer , `store_time` text(20), `reply_str` text(1024), `reply_time` text(20), `device_code` text(40), `open_project_id` text(30))");
+                }
+                if(recdb.transaction()){
+                    while(sqlList2.length()>0){
+                        recdb.exec(sqlList2.first());
+                        sqlList2.removeFirst();
+                        usleep(1000);
+                    }
+                    recdb.commit();
+                }
+                recdb.close();
+            }
+        }
+
+        usleep(10000);
+    }
+
+}

+ 36 - 0
ytServiceCore/rep_dbthread.h

@@ -0,0 +1,36 @@
+#ifndef REP_DBTHREAD_H
+#define REP_DBTHREAD_H
+
+#include <QThread>
+#include <QSqlDatabase>
+#include <QDateTime>
+#include <QSqlQuery>
+#include <QSqlError>
+#include <QVariant>
+#include <QStringList>
+
+class Rep_DBThread : public QThread
+{
+    Q_OBJECT
+public:
+    explicit Rep_DBThread(QObject *parent = nullptr);
+    void run();
+    void stop();
+    void init_db();
+    void appendSql(QString sql);
+    bool chk_table(QString tablename, QStringList tables);
+
+
+signals:
+
+public slots:
+
+private:
+    QStringList sqlList2;
+    bool keep;
+    QSqlDatabase recdb;
+
+
+};
+
+#endif // REP_DBTHREAD_H

+ 4 - 2
ytServiceCore/ytServiceCore.pro

@@ -19,7 +19,8 @@ SOURCES += main.cpp \
     wsclient.cpp \
     wsclient.cpp \
     logthread.cpp \
     logthread.cpp \
     subsysreport.cpp \
     subsysreport.cpp \
-    subreportthread.cpp
+    subreportthread.cpp \
+    rep_dbthread.cpp
 
 
 HEADERS += \
 HEADERS += \
     ytServiceShm.h \
     ytServiceShm.h \
@@ -37,7 +38,8 @@ HEADERS += \
     logthread.h \
     logthread.h \
     subreportthread.h \
     subreportthread.h \
     subsysreport.h \
     subsysreport.h \
-    redis.h
+    redis.h \
+    rep_dbthread.h
 
 
 LIBS += -ljson-c -lssl -lcrypto
 LIBS += -ljson-c -lssl -lcrypto
 LIBS += "/usr/local/lib/libhiredis.a"
 LIBS += "/usr/local/lib/libhiredis.a"

+ 4 - 2
ytServiceDog/main.cpp

@@ -24,12 +24,14 @@ void chk_program(){
     isRuning = true;
     isRuning = true;
     if((uptime-ytShm->updatetime[CORE_MAIN])>300)
     if((uptime-ytShm->updatetime[CORE_MAIN])>300)
         need_start = true;
         need_start = true;
-    if((uptime-ytShm->updatetime[DB_THREAD])>300)
-        need_start = true;
+//    if((uptime-ytShm->updatetime[DB_THREAD])>300)
+//        need_start = true;
     if(need_start){
     if(need_start){
         ytShm->updatetime[CORE_MAIN] = uptime+30;
         ytShm->updatetime[CORE_MAIN] = uptime+30;
         ytShm->updatetime[DB_THREAD] = uptime+30;
         ytShm->updatetime[DB_THREAD] = uptime+30;
         ret = system("killall ytServiceCore");
         ret = system("killall ytServiceCore");
+        system("killall ytDP0006");
+        system("killall ytDP0007");
         ret = system("ytServiceCore &");
         ret = system("ytServiceCore &");
     }
     }
     isRuning = false;
     isRuning = false;