Przeglądaj źródła

消防总队配置变更,优化程序

James 2 lat temu
rodzic
commit
53399b5dd1

+ 238 - 133
ytServiceCore/core.cpp

@@ -7,6 +7,7 @@
 
 //extern YT_SERVICE_SHM *ytShm;
 
+
 void chkmd5(const char *data, char *md5){
     MD5_CTX ctx;
     unsigned char tmp,md[16];
@@ -51,6 +52,7 @@ Core::Core(QObject *parent) :
     times = 0;
     jaworktime = 0;
     ypdisworktime = 0;
+    xfzdworktime = 0;
     ypxyworktime = 0;
     ypSyncdataList.clear();
     ypSyncDisdataList.clear();
@@ -88,14 +90,14 @@ Core::Core(QObject *parent) :
     connect(thread,SIGNAL(SyncData(QString,QString)),this,SLOT(SyncData(QString,QString)));
 //    connect(thread,SIGNAL(SyncDisData(QString,QString)),this,SLOT(SyncDisData(QString,QString)));
 //    connect(thread,SIGNAL(SyncXyData(int,QString,QString)),this,SLOT(SyncXyData(int,QString,QString)));
-    connect(thread,SIGNAL(cnSyncData(int,QString,QString,int)),this,SLOT(cnSyncData(int,QString,QString,int)));
+    connect(thread,SIGNAL(cnSyncData(int,QString,QString,int)),this,SLOT(cnSyncData(int,QString,QString,int)));   //unused
     connect(thread,SIGNAL(NewcnSyncData(int,QString,QString,int)),this,SLOT(NewcnSyncData(int,QString,QString,int)));
     connect(thread,SIGNAL(jaSyncData(int,QString,QString)),this,SLOT(jaSyncData(int,QString,QString)));
     connect(thread,SIGNAL(hpSyncData(int,QString,QString)),this,SLOT(hpSyncData(int,QString,QString)));
     connect(netAccessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(finishedSlot(QNetworkReply*)));
     connect(thread,SIGNAL(companyAlarmChanged(QString)),this,SLOT(companyAlarmChanged(QString)));
     connect(thread,SIGNAL(appendLog(QString)),this,SLOT(appendLog(QString)));
-    cnnetAccessManager = new QNetworkAccessManager(this);
+    cnnetAccessManager = new QNetworkAccessManager(this);   //unused
     NewcnnetAccessManager = new QNetworkAccessManager(this);
     janetAccessManager = new QNetworkAccessManager(this);
     hpnetAccessManager = new QNetworkAccessManager(this);
@@ -120,6 +122,7 @@ Core::Core(QObject *parent) :
     connect(subReportServer,&SubSysReport::subReport2,this,&Core::subReport2);
     connect(subReportServer,&SubSysReport::appendLog,this,&Core::appendLog);
     time_out();
+
 }
 
 void Core::appendLog(QString log){
@@ -668,6 +671,19 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
                }
               }
           }
+          if(!found2){
+                for(int i=0;i<syncXyDevList.length();i++){
+                    QString jdata1 = "";
+                    YPSyncXyDev ypxydev1 = syncXyDevList.at(i);
+                    if(ypxydev1.OwnerCode==DeviceID){
+                        found2 = true;
+                        jdata1.append(QString("\"status\":\"%1\"").arg("1"));
+                        jdata1.append(QString(",\"deviceId\":\"%1\"").arg(ypxydev1.ObjCode));
+                        jdata1.append(QString(",\"companyCode\":\"%1\"").arg(ypxydev1.CompanyCode));
+                        SyncXyData(3,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata1+"}");
+                    }
+                }
+         }
 
         }else{
 //       QString sql = QString("select company from sp_owner where owner_code=%1").arg(DeviceID);
@@ -1016,6 +1032,7 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
        for(int i=0;i<hpDevList.length();i++){
            HPSyncDev hpdev = hpDevList.at(i);
            if(hpdev.Detection_id==DeviceID){
+               found=true;
                QString sql1 = QString("select port,data3,data4 from sp_hj2017 where id=%1").arg(insertId);
                qry1 = mdb.exec(sql1);
                QString jdata = "";
@@ -1074,6 +1091,50 @@ void Core::subReport(quint16 subType, QString DeviceID, quint64 insertId, bool f
            }
          }
         }
+       if(!found){
+                  for(int i=0;i<syncXyDevList.length();i++){
+                      QString jdata1 = "";
+                      QSqlQuery qry7;
+                      QSqlQuery qry8;
+                      uint MaxT = 0;
+                      YPSyncXyDev ypxydev1 = syncXyDevList.at(i);
+                      if(ypxydev1.OwnerCode==DeviceID){
+                          QString sql5 = QString("select data1, time from sp_hj2017 where id=%1").arg(insertId);
+                          qry7 = mdb.exec(sql5);
+                          while(qry7.next()){
+                              uint cTime = qry7.value(1).toDateTime().toTime_t();
+                              if(cTime>MaxT)
+                                  MaxT = cTime;
+                              jdata1.append(QString("\"companyCode\":\"%1\"").arg(ypxydev1.CompanyCode));
+                              jdata1.append(QString(",\"companyName\":\"%1\"").arg(ypxydev1.CompanyName));
+                              jdata1.append(QString(",\"deviceId\":\"%1\"").arg(ypxydev1.ObjCode));
+                              jdata1.append(QString(",\"deviceName\":\"%1\"").arg(ypxydev1.OwnerName+ypxydev1.DeviceName));
+                              jdata1.append(QString(",\"wirelessSignal\":%1").arg(5));
+                              jdata1.append(QString(",\"time\":\"%1\"").arg(QDateTime::fromTime_t(cTime).toString("yyyy-MM-dd HH:mm:ss")));
+                              if(qry7.value(0).toString().compare("02")==0){
+                                  jdata1.append(QString(",\"alarmName\":\"%1\"").arg("火灾报警"));
+                                  jdata1.append(QString(",\"alarmCode\":\"%1\"").arg("Y07"));
+                              }else if(qry7.value(0).toString().compare("04")==0){
+                                  jdata1.append(QString(",\"alarmName\":\"%1\"").arg("故障"));
+                                  jdata1.append(QString(",\"alarmCode\":\"%1\"").arg("Y11"));
+                              }else if(qry7.value(0).toString().compare("10")==0){
+                                  jdata1.append(QString(",\"alarmName\":\"%1\"").arg("监管"));
+                                  jdata1.append(QString(",\"alarmCode\":\"%1\"").arg("Y13"));
+                              }else if(qry7.value(0).toString().compare("40")==0){
+                                  jdata1.append(QString(",\"alarmName\":\"%1\"").arg("反馈"));
+                                  jdata1.append(QString(",\"alarmCode\":\"%1\"").arg("Y14"));
+                              }else if(qry7.value(0).toString().compare("20")==0){
+                                  jdata1.append(QString(",\"alarmName\":\"%1\"").arg("启动"));
+                                  jdata1.append(QString(",\"alarmCode\":\"%1\"").arg("Y15"));
+                              }else if(qry7.value(0).toString().compare("08")==0){
+                                  jdata1.append(QString(",\"alarmName\":\"%1\"").arg("屏蔽"));
+                                  jdata1.append(QString(",\"alarmCode\":\"%1\"").arg("Y16"));
+                              }
+                              SyncXyData(1,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata1+"}");
+                          }
+                      }
+                  }
+              }
     }
     }else if(subType==6){
         if(flag){
@@ -2352,6 +2413,7 @@ void Core::time_out()
 {
     QSqlQuery qry;
     QSqlQuery qry1;
+
     int ret = 0;
 //    printf("core time_out start\n");
     time_t tmp_time = time(static_cast<time_t *>(nullptr));
@@ -2406,6 +2468,7 @@ void Core::time_out()
 //                                       qry.value(8).toInt()));
 //        }
 //        qry.clear();
+
         syncXyDevList.clear();
         qry = mdb.exec("select owner_code,owner_dwtype,object_code,start_port,rec_cur,object_name,device_name,company_code,company_name from sp_yangpuxy_share");
         while(qry.next()){
@@ -2418,7 +2481,11 @@ void Core::time_out()
                                          qry.value(6).toString(),
                                          qry.value(7).toString(),
                                          qry.value(8).toString()));
+
         }
+
+
+
 //        printf("core ypxyworktime start\n");
         qry.clear();
         hpDevList.clear();
@@ -3670,7 +3737,98 @@ void Core::time_out()
                         }
                     }
         }
+    }
 
+    if((tmp_time-ypdisworktime)>=21600){
+        QSqlQuery qry12;
+        ypdisworktime=tmp_time;
+        qry.clear();
+        syncDevList.clear();
+        qry = mdb.exec("select owner_code,dwtype,object_code,start_port,rec_cur from sp_yangpu_share");
+        while(qry.next()){
+            syncDevList.append(YPSyncDev(qry.value(0).toString(),
+                                         qry.value(1).toString(),
+                                         qry.value(2).toString(),
+                                         qry.value(3).toInt(),
+                                         qry.value(4).toUInt()));
+        }
+        qry.clear();
+        ypYwDevList.clear();
+        qry = mdb.exec("select device_code,device_name,device_address,longitude,latitude,device_type,company_code from sp_ypywtg_share");
+        while(qry.next()){
+            ypYwDevList.append(YPYWSyncDev(qry.value(0).toString(),
+                                         qry.value(1).toString(),
+                                         qry.value(2).toString(),
+                                         qry.value(3).toString(),
+                                         qry.value(4).toString(),
+                                         qry.value(5).toInt(),
+                                         qry.value(6).toString()));
+        }
+        qry.clear();
+        XfzdDevList.clear();
+        qry = mdb.exec("select device_code,device_name,descript,device_type,device_type_name,open_project_id, dwtype, data, port,device_floor from sp_corps_share");
+        while(qry.next()){
+            XfzdDevList.append(XfzdSyncDev(qry.value(0).toString(),
+                                       qry.value(1).toString(),
+                                       qry.value(2).toString(),
+                                       qry.value(3).toInt(),
+                                       qry.value(4).toString(),
+                                       qry.value(5).toString(),
+                                       qry.value(6).toInt(),
+                                       qry.value(7).toString().trimmed(),
+                                       qry.value(8).toString(),
+                                       qry.value(9).toString()));
+        }
+        qry.clear();
+        for(int i=0;i<syncDevList.length();i++){
+            time_t tmp_time = time(static_cast<time_t *>(nullptr));
+            ytShm->updatetime[CORE_MAIN] = tmp_time;
+                    YPSyncDev syncdev = syncDevList.at(i);
+                    time_t myt=time(NULL);
+                    QString jdata = "";
+                  if(syncdev.ObjType.compare("YTWP")==0){
+                      QString sql = QString("select dwtype,point_code,point_data,data_time from sp_owner_status where device_id='%1' and point_code>%2 order by point_code limit 0,1").arg(syncdev.OwnerCode).arg((syncdev.StartPort>0)?(syncdev.StartPort+63):3);
+                      QString sql12 = QString("select insert_id from aypdis_time where id=%1").arg(205);
+                      qry = mdb.exec(sql);
+                      qry12 = mdb.exec(sql12);
+                      while(qry.next()){
+                       while(qry12.next()){
+                          uint cTime = qry.value(3).toDateTime().toTime_t();
+                          QString WaterPressure = "0.0";
+                          if((myt-cTime)>=qry12.value(0).toInt()){
+                                      WaterPressure = qry.value(2).toString();
+                                      mdb.exec(QString("update sp_yangpu_share set rec_cur=%1 where object_code='%2'").arg(myt).arg(syncdev.ObjCode));
+                                      QString jsonstr = QString("{\"dataCode\":\"DATA_WATERPRE\",\"deviceId\":\"%1\",\"postTime\":\"%2\",\"data\":{\"WaterPressure\":%3}}")
+                                              .arg(syncdev.ObjCode).arg(QDateTime::fromTime_t(myt).toString("yyyy-MM-dd HH:mm:ss")).arg(WaterPressure);
+                                      SyncDisData(QUuid::createUuid().toString().replace("{","").replace("}",""), jsonstr);
+                          }
+                        }
+                      }
+                  }else if(syncdev.ObjType.compare("YTLL")==0){
+                      QString LiquidLevel = "0.0";
+                      QDateTime dataTime = QDateTime::fromTime_t(0);
+                      QString sql = QString("select dwtype,point_code,point_data,data_time from sp_owner_status where device_id='%1' and point_code>%2 order by point_code limit 0,1").arg(syncdev.OwnerCode).arg((syncdev.StartPort>0)?(syncdev.StartPort+63):3);
+                      QString sql12 = QString("select insert_id from aypdis_time where id=%1").arg(205);
+                      qry = mdb.exec(sql);
+                      qry12 = mdb.exec(sql12);
+                      if(qry.next()){
+                          while(qry12.next()){
+                             uint cTime = qry.value(3).toDateTime().toTime_t();
+                             if((myt-cTime)>=qry12.value(0).toInt()){
+                                 LiquidLevel = qry.value(2).toString();
+                                 mdb.exec(QString("update sp_yangpu_share set rec_cur=%1 where object_code='%2'").arg(myt).arg(syncdev.ObjCode));
+                                 QString jsonstr = QString("{\"dataCode\":\"DATA_LIQUIDLE\",\"deviceId\":\"%1\",\"postTime\":\"%2\",\"data\":{\"LiquidLevel\":%3}}")
+                                         .arg(syncdev.ObjCode).arg(QDateTime::fromTime_t(myt).toString("yyyy-MM-dd HH:mm:ss")).arg(LiquidLevel);
+                                 SyncDisData(QUuid::createUuid().toString().replace("{","").replace("}",""), jsonstr);
+                             }
+                          }
+                      }
+                  }
+        }
+    }
+
+    if((tmp_time-xfzdworktime)>=86400){
+        xfzdworktime=tmp_time;
         for(int i=0;i<XfzdDevList.length();i++){
             time_t tmp_time = time(static_cast<time_t *>(nullptr));
             ytShm->updatetime[CORE_MAIN] = tmp_time;
@@ -3689,6 +3847,7 @@ void Core::time_out()
                     jdata.append(QString(",\"deviceType\":\"%1\"").arg(xfzddev.DeviceType));
                     jdata.append(QString(",\"deviceTypeName\":\"%1\"").arg(xfzddev.DeviceTypeName));
                     jdata.append(QString(",\"openProjectId\":\"%1\"").arg(xfzddev.OpenProjectId));
+                    jdata.append(QString(",\"floor\":\"%1\"").arg(xfzddev.DeviceFloor));
                     qry = mdb.exec(sql);
 
                     if(xfzddev.devCategory==2){
@@ -3708,10 +3867,13 @@ void Core::time_out()
                         }
                         if(xfzddev.DeviceType==302){
                             XfzdSyncData(0,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
-                        }else{
+                        }else if(xfzddev.DeviceType==301){
                             XfzdSyncData(1,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                        }else if(xfzddev.DeviceType==305){
+                            XfzdSyncData(13,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                        }else if(xfzddev.DeviceType==304){
+                            XfzdSyncData(14,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
                         }
-
                     }else if(xfzddev.devCategory==5){
                         while(qry.next()){
                             if(qry.value(0).toInt()==4){
@@ -3733,7 +3895,7 @@ void Core::time_out()
                             XfzdSyncData(3,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
                         }
                     }else if(xfzddev.devCategory==6){
-                        if(xfzddev.DeviceType==258||xfzddev.DeviceType==256){
+                        if(xfzddev.DeviceType==258||xfzddev.DeviceType==256||xfzddev.DeviceType==452){
                             QList<CnPno> pnoList = getPnoValue(xfzddev.Data);
                             QJsonArray jajsonArray;
                             for(int i=0;i<pnoList.length();i++){
@@ -3791,8 +3953,10 @@ void Core::time_out()
                             }
                             if(xfzddev.DeviceType==258){
                                 XfzdSyncData(4,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory);
-                            }else{
+                            }else if(xfzddev.DeviceType==256){
                                 XfzdSyncData(5,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory);
+                            }else if(xfzddev.DeviceType==452){
+                                XfzdSyncData(12,QUuid::createUuid().toString().replace("{","").replace("}",""),"{"+jdata+"}",xfzddev.devCategory);
                             }
                         }else{
                             QList<CnPno> pnoList = getPnoValue(xfzddev.Data);
@@ -3816,102 +3980,31 @@ void Core::time_out()
                             }
                             if(xfzddev.DeviceType==302){
                                 XfzdSyncData(0,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
-                            }else{
+                            }else if(xfzddev.DeviceType==301){
                                 XfzdSyncData(1,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                            }else if(xfzddev.DeviceType==305){
+                                XfzdSyncData(13,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                            }else if(xfzddev.DeviceType==304){
+                                XfzdSyncData(14,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
                             }
                         }
-                    }
-        }
-
-    }
-
-    if((tmp_time-ypdisworktime)>=21600){
-        QSqlQuery qry12;
-        ypdisworktime=tmp_time;
-        qry.clear();
-        syncDevList.clear();
-        qry = mdb.exec("select owner_code,dwtype,object_code,start_port,rec_cur from sp_yangpu_share");
-        while(qry.next()){
-            syncDevList.append(YPSyncDev(qry.value(0).toString(),
-                                         qry.value(1).toString(),
-                                         qry.value(2).toString(),
-                                         qry.value(3).toInt(),
-                                         qry.value(4).toUInt()));
-        }
-        qry.clear();
-        ypYwDevList.clear();
-        qry = mdb.exec("select device_code,device_name,device_address,longitude,latitude,device_type,company_code from sp_ypywtg_share");
-        while(qry.next()){
-            ypYwDevList.append(YPYWSyncDev(qry.value(0).toString(),
-                                         qry.value(1).toString(),
-                                         qry.value(2).toString(),
-                                         qry.value(3).toString(),
-                                         qry.value(4).toString(),
-                                         qry.value(5).toInt(),
-                                         qry.value(6).toString()));
-        }
-        qry.clear();
-        XfzdDevList.clear();
-        qry = mdb.exec("select device_code,device_name,descript,device_type,device_type_name,open_project_id, dwtype, data, port from sp_corps_share");
-        while(qry.next()){
-            XfzdDevList.append(XfzdSyncDev(qry.value(0).toString(),
-                                       qry.value(1).toString(),
-                                       qry.value(2).toString(),
-                                       qry.value(3).toInt(),
-                                       qry.value(4).toString(),
-                                       qry.value(5).toString(),
-                                       qry.value(6).toInt(),
-                                       qry.value(7).toString().trimmed(),
-                                       qry.value(8).toString()));
-        }
-        qry.clear();
-        for(int i=0;i<syncDevList.length();i++){
-            time_t tmp_time = time(static_cast<time_t *>(nullptr));
-            ytShm->updatetime[CORE_MAIN] = tmp_time;
-                    YPSyncDev syncdev = syncDevList.at(i);
-                    time_t myt=time(NULL);
-                    QString jdata = "";
-                  if(syncdev.ObjType.compare("YTWP")==0){
-                      QString sql = QString("select dwtype,point_code,point_data,data_time from sp_owner_status where device_id='%1' and point_code>%2 order by point_code limit 0,1").arg(syncdev.OwnerCode).arg((syncdev.StartPort>0)?(syncdev.StartPort+63):3);
-                      QString sql12 = QString("select insert_id from aypdis_time where id=%1").arg(205);
-                      qry = mdb.exec(sql);
-                      qry12 = mdb.exec(sql12);
-                      while(qry.next()){
-                       while(qry12.next()){
-                          uint cTime = qry.value(3).toDateTime().toTime_t();
-                          QString WaterPressure = "0.0";
-                          if((myt-cTime)>=qry12.value(0).toInt()){
-                                      WaterPressure = qry.value(2).toString();
-                                      mdb.exec(QString("update sp_yangpu_share set rec_cur=%1 where object_code='%2'").arg(myt).arg(syncdev.ObjCode));
-                                      QString jsonstr = QString("{\"dataCode\":\"DATA_WATERPRE\",\"deviceId\":\"%1\",\"postTime\":\"%2\",\"data\":{\"WaterPressure\":%3}}")
-                                              .arg(syncdev.ObjCode).arg(QDateTime::fromTime_t(myt).toString("yyyy-MM-dd HH:mm:ss")).arg(WaterPressure);
-                                      SyncDisData(QUuid::createUuid().toString().replace("{","").replace("}",""), jsonstr);
-                          }
+                    }else if(xfzddev.devCategory==1){
+                        while(qry.next()){
+                            if(qry.value(0).toInt()==1){
+                                if(qry.value(2).toString().indexOf(QString::fromUtf8("监测连线故障"))==0){
+                                    jdata.append(QString(",\"connectStatus\":\"%1\"").arg(1));
+                                }else{
+                                    jdata.append(QString(",\"connectStatus\":\"%1\"").arg(0));
+                                }
+                                jdata.append(QString(",\"workStatus\":\"%1\"").arg(0));
+                                jdata.append(QString(",\"mainPower\":\"%1\"").arg(0));
+                                jdata.append(QString(",\"logTime\":\"%1\"").arg(QDateTime::fromTime_t(myt).toString("yyyy-MM-dd HH:mm:ss")));
+                                XfzdSyncData(15,QUuid::createUuid().toString().replace("{","").replace("}",""), "{"+jdata+"}",xfzddev.devCategory);
+                            }
                         }
-                      }
-                  }else if(syncdev.ObjType.compare("YTLL")==0){
-                      QString LiquidLevel = "0.0";
-                      QDateTime dataTime = QDateTime::fromTime_t(0);
-                      QString sql = QString("select dwtype,point_code,point_data,data_time from sp_owner_status where device_id='%1' and point_code>%2 order by point_code limit 0,1").arg(syncdev.OwnerCode).arg((syncdev.StartPort>0)?(syncdev.StartPort+63):3);
-                      QString sql12 = QString("select insert_id from aypdis_time where id=%1").arg(205);
-                      qry = mdb.exec(sql);
-                      qry12 = mdb.exec(sql12);
-                      if(qry.next()){
-                          while(qry12.next()){
-                             uint cTime = qry.value(3).toDateTime().toTime_t();
-                             if((myt-cTime)>=qry12.value(0).toInt()){
-                                 LiquidLevel = qry.value(2).toString();
-                                 mdb.exec(QString("update sp_yangpu_share set rec_cur=%1 where object_code='%2'").arg(myt).arg(syncdev.ObjCode));
-                                 QString jsonstr = QString("{\"dataCode\":\"DATA_LIQUIDLE\",\"deviceId\":\"%1\",\"postTime\":\"%2\",\"data\":{\"LiquidLevel\":%3}}")
-                                         .arg(syncdev.ObjCode).arg(QDateTime::fromTime_t(myt).toString("yyyy-MM-dd HH:mm:ss")).arg(LiquidLevel);
-                                 SyncDisData(QUuid::createUuid().toString().replace("{","").replace("}",""), jsonstr);
-                             }
-                          }
-                      }
-                  }
+                    }
         }
     }
-
 //    if((!isSending2)&&(cnSyncdataLiet.length()>0)){
 //        isSending2 = true;
 //        cnCount=cnCount+1;
@@ -4028,6 +4121,9 @@ void Core::time_out()
         }else if(rep.Xh==3){
             req->setUrl(QUrl("http://ypaqpt.edu.sh.cn/schoolSafe-yp/AlarmStatus"));
         }
+//        else if(rep.Xh==4){
+//            req->setUrl(QUrl("http://iot.usky.cn/ytapi/admin/Manage/ceShiUrl"));
+//        }
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         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')")
@@ -4041,43 +4137,43 @@ void Core::time_out()
         connect(pTimeout, SIGNAL(net_timeout()),this,SLOT(reply_timeout5()));
     }
 
-//    if((!isSending6)&&(hpSyncdataLiet.length()>0)){
-//        isSending6 = true;
-//        hpCount=hpCount+1;
-//        HpSyncRep rep = hpSyncdataLiet.first();
-//        QByteArray Report = rep.JsonStr.toUtf8();
-//        QNetworkRequest *req = new QNetworkRequest();
-//        if(rep.Xh==1){
-//            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/matrix/position"));
-//        }else if(rep.Xh==0){
-//            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/matrix/receiveAll"));
-//        }else if(rep.Xh==2){
-//            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/operation/handleEvent"));
-////            req->setUrl(QUrl("http://www.jd-ioe.com:80/ytapi/admin/order/jingan"));
-//        }else if(rep.Xh==3){
-//            req->setUrl(QUrl("http://receive.119.net/fireapi/matrix/receiveAll"));
-//        }else if(rep.Xh==4){
-//            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/matrix/receiveAll"));
-//        }else if(rep.Xh==5){
-//            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/operation/handleArtificial"));
-////            req->setUrl(QUrl("http://172.16.120.183:5001"));
-//        }else if(rep.Xh==6){
-//            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/operation/handleSupervise"));
-//            logThread->appendData(QString("ceshidianziduchadan12[%1]").arg("http://jareceive.119.net/fireapi/operation/handleSupervise"));
-//        }
-////        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::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')")
-//                        .arg(rep.Id).arg(
-//                            req->url().toString()+"\r\n"+
-////                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
-////                            req->header(QNetworkRequest::ContentLengthHeader).toString()+"\r\n"+
-//                            rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
-//        QNetworkReply *reply = hpnetAccessManager->post(*req,Report);
-//        QReplayTimeout *pTimeout = new QReplayTimeout(reply,10000);
-//        connect(pTimeout, SIGNAL(net_timeout()),this,SLOT(reply_timeout6()));
-//    }
+    if((!isSending6)&&(hpSyncdataLiet.length()>0)){
+        isSending6 = true;
+        hpCount=hpCount+1;
+        HpSyncRep rep = hpSyncdataLiet.first();
+        QByteArray Report = rep.JsonStr.toUtf8();
+        QNetworkRequest *req = new QNetworkRequest();
+        if(rep.Xh==1){
+            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/matrix/position"));
+        }else if(rep.Xh==0){
+            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/matrix/receiveAll"));
+        }else if(rep.Xh==2){
+            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/operation/handleEvent"));
+//            req->setUrl(QUrl("http://www.jd-ioe.com:80/ytapi/admin/order/jingan"));
+        }else if(rep.Xh==3){
+            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/matrix/receiveAll"));
+        }else if(rep.Xh==4){
+            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/matrix/receiveAll"));
+        }else if(rep.Xh==5){
+            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/operation/handleArtificial"));
+//            req->setUrl(QUrl("http://172.16.120.183:5001"));
+        }else if(rep.Xh==6){
+            req->setUrl(QUrl("http://hpreceive.119.net/fireapi/operation/handleSupervise"));
+            logThread->appendData(QString("ceshidianziduchadan12[%1]").arg("http://jareceive.119.net/fireapi/operation/handleSupervise"));
+        }
+//        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::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')")
+                        .arg(rep.Id).arg(
+                            req->url().toString()+"\r\n"+
+//                            req->header(QNetworkRequest::ContentTypeHeader).toString()+"\r\n"+
+//                            req->header(QNetworkRequest::ContentLengthHeader).toString()+"\r\n"+
+                            rep.JsonStr).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
+        QNetworkReply *reply = hpnetAccessManager->post(*req,Report);
+        QReplayTimeout *pTimeout = new QReplayTimeout(reply,10000);
+        connect(pTimeout, SIGNAL(net_timeout()),this,SLOT(reply_timeout6()));
+    }
 
     if((!isSending7)&&(NewcnSyncdataLiet.length()>0)){
         isSending7 = true;
@@ -4175,6 +4271,14 @@ void Core::time_out()
             req->setUrl(QUrl("http://iot.shxf-119.com/access/devlog/alarm/reset"));
         }else if(rep.Xh==11){
             req->setUrl(QUrl("http://iot.shxf-119.com/access/event/action/alarm/linkagefeedback"));
+        }else if(rep.Xh==12){
+            req->setUrl(QUrl("http://iot.shxf-119.com/access/devlog/smoke/smokefan"));
+        }else if(rep.Xh==13){
+            req->setUrl(QUrl("http://iot.shxf-119.com/access/devlog/hydrant/endpressure"));
+        }else if(rep.Xh==14){
+            req->setUrl(QUrl("http://iot.shxf-119.com/access/devlog/sprinkler/endpressure"));
+        }else if(rep.Xh==15){
+            req->setUrl(QUrl("http://iot.shxf-119.com/access/devlog/transmission/devicestatus"));
         }
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/json; charset=UTF-8");
         req->setRawHeader("appKey","850404889644236801");
@@ -4335,6 +4439,7 @@ void Core::time_out()
     isRunning = false;
     mdb.close();
     mdbOpened = false;
+
 }
 
 QList<JaPno> Core::getJaPnoValue(QString pnoset)

+ 1 - 1
ytServiceCore/core.h

@@ -178,7 +178,7 @@ public slots:
     void subReport2(quint16 subType, QString artificial_id, quint16 area_status, QString reason, QString handler, QString mobile);
 private:
     QSqlDatabase db,mdb;
-    time_t work_time,jaworktime,ypdisworktime,ypxyworktime;
+    time_t work_time,jaworktime,ypdisworktime,ypxyworktime,xfzdworktime;
     bool isRunning,isSending,isSending2,isSending3,isSending4,isSending5,isSending6,isSending7,isSending8,isSending9,mdbOpened;
     int ypCount,ypdisCount,ypxyCount,cnCount,jaCount,hpCount;
     QTimer *timer;

+ 159 - 139
ytServiceCore/db_syncthread.cpp

@@ -1,4 +1,4 @@
-#include "db_syncthread.h"
+#include "db_syncthread.h"
 #include "ytservicecore.h"
 #include <time.h>
 #include <openssl/md5.h>
@@ -652,124 +652,133 @@ bool DB_SyncThread::rtuInfoSync(QString devid, QString deviceCode, uint sync_id,
         updated = true;
         if(qry2.value(1).toString().compare("44")==0)
         {
-            if(count==0)
-                sql = QString("insert into sp_owner_sync_data (id, native_id, device_id, point_code, point_data, data_time, content) values (NULL,%1,'%2','%3','%4','%5','%6 %7')")
-                        .arg(qry2.value(0).toUInt()).arg(devid).arg(0).arg(1).arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                        .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
-            else
-                sql += QString(",  (NULL,%1,'%2','%3','%4','%5','%6 %7')")
-                        .arg(qry2.value(0).toUInt()).arg(devid).arg(0).arg(1).arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                        .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
-            upsql = QString::fromUtf8("update sp_owner_status set point_data='%1', data_time='%2', content='%3 %4', point_name='通信报警',dwtype=%5 where device_id='%6' and point_code='%7';")
-                    .arg(0).arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                    .arg(qry2.value(5).toString()).arg(qry2.value(6).toString()).arg(6).arg(devid).arg(0);
-            mdb.exec(upsql);
+//            if(count==0)
+//                sql = QString("insert into sp_owner_sync_data (id, native_id, device_id, point_code, point_data, data_time, content) values (NULL,%1,'%2','%3','%4','%5','%6 %7')")
+//                        .arg(qry2.value(0).toUInt()).arg(devid).arg(0).arg(1).arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                        .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
+//            else
+//                sql += QString(",  (NULL,%1,'%2','%3','%4','%5','%6 %7')")
+//                        .arg(qry2.value(0).toUInt()).arg(devid).arg(0).arg(1).arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                        .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
+//            upsql = QString::fromUtf8("update sp_owner_status set point_data='%1', data_time='%2', content='%3 %4', point_name='通信报警',dwtype=%5 where device_id='%6' and point_code='%7';")
+//                    .arg(0).arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                    .arg(qry2.value(5).toString()).arg(qry2.value(6).toString()).arg(6).arg(devid).arg(0);
+//            mdb.exec(upsql);
         }else{
             setCompanyAlarmSet(deviceCode, AlarmSet(0xffffffff,"",QString::fromUtf8("%1,%2").arg(qry2.value(5).toString()).arg(qry2.value(6).toString()),6,qry2.value(7).toDateTime().toTime_t(),1));
-            upsql = QString::fromUtf8("update sp_owner_status set point_data='',content='' where device_id='%1' and point_code='0'").arg(devid);
-            mdb.exec(upsql);
-            if(!qry2.value(2).isNull()){
-                if(qry2.value(2).toString().compare("E3")==0){
-                    int tmpIdx = qry2.value(3).toString().toInt(nullptr,16);
-                    if(tmpIdx>0){
-                        QString pv = "0";
-                        QString pname = "", vname="";
-                        for(int Idx=0;Idx<vonameList.length();Idx++){
-                            if((typeList.at(Idx)==1)&&(portList.at(Idx)==tmpIdx)){
-                                pname = nameList.at(Idx);
-                                vname = vonameList.at(Idx);
-                                break;
-                            }
-                        }
-                        if((vname.compare(QString::fromUtf8("故障"))==0)
-                                ||(vname.compare(QString::fromUtf8("手动"))==0)
-                                ||(vname.compare(QString::fromUtf8("运行"))==0)
-                                ||(vname.compare(QString::fromUtf8("接线"))==0)
-                                ||(vname.compare(QString::fromUtf8("正常"))==0)){
-                            if(qry2.value(1).toInt()==0)
-                                pv="0";
-                            else
-                                pv="1";
-                        }else{
-                            if(qry2.value(1).toInt()==0)
-                                pv="1";
-                            else
-                                pv="0";
-                        }
-                        if(count==0)
-                            sql = QString("insert into sp_owner_sync_data (id, native_id, device_id, point_code, point_data, data_time, content) values (NULL,%1,'%2','%3','%4','%5','%6 %7')")
-                                    .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()).arg(pv)
-                                    .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                                   .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
-                        else
-                            sql += QString(",  (NULL,%1,'%2','%3','%4','%5','%6 %7')")
-                                    .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()).arg(pv)
-                                    .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                                   .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
-                        upsql = QString::fromUtf8("update sp_owner_status set point_data='%1', data_time='%2', content='%3 %4', point_name='%5',dwtype=%6 where device_id='%7' and point_code='%8';")
-                                .arg(pv)
-                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                                .arg(qry2.value(5).toString()).arg(qry2.value(6).toString()).arg(pname)
-                                .arg(6).arg(devid).arg(tmpIdx);
-                        mdb.exec(upsql);
-                    }
-                }else if(qry2.value(2).toString().compare("E6")==0){
-                    if(count==0)
-                        sql = QString("insert into sp_owner_sync_data (id, native_id, device_id, point_code, point_data, data_time, content) values (NULL,%1,'%2','%3','%4','%5','%6 %7')")
-                                .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()+64).arg(qry2.value(8).toString())
-                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                               .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
-                    else
-                        sql += QString(", (NULL,%1,'%2','%3','%4','%5','%6 %7')")
-                                .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()+64).arg(qry2.value(8).toString())
-                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                               .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
-                    int tmpIdx = qry2.value(3).toInt();
-                    if(tmpIdx>0){
-                        QString pname = "";
-                        for(int Idx=0;Idx<nameList.length();Idx++){
-                            if((typeList.at(Idx)==2)&&(portList.at(Idx)==tmpIdx)){
-                                pname = nameList.at(Idx);
-                                break;
-                            }
-                        }
-                        upsql = QString::fromUtf8("update sp_owner_status set point_data='%1', data_time='%2', content='%3 %4 %5',dwtype=%6 where device_id='%7' and point_code='%8';")
-                                .arg(qry2.value(8).toString())
-                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
-                                .arg(pname).arg(qry2.value(5).toString())
-                                .arg(qry2.value(6).toString())
-                                .arg(6)
-                                .arg(devid)
-                                .arg(tmpIdx+64);
-                        mdb.exec(upsql);
-                    }
-                }
-            }
+
+
+
+
+
+//            upsql = QString::fromUtf8("update sp_owner_status set point_data='',content='' where device_id='%1' and point_code='0'").arg(devid);
+//            mdb.exec(upsql);
+//            if(!qry2.value(2).isNull()){
+//                if(qry2.value(2).toString().compare("E3")==0){
+//                    int tmpIdx = qry2.value(3).toString().toInt(nullptr,16);
+//                    if(tmpIdx>0){
+//                        QString pv = "0";
+//                        QString pname = "", vname="";
+//                        for(int Idx=0;Idx<vonameList.length();Idx++){
+//                            if((typeList.at(Idx)==1)&&(portList.at(Idx)==tmpIdx)){
+//                                pname = nameList.at(Idx);
+//                                vname = vonameList.at(Idx);
+//                                break;
+//                            }
+//                        }
+//                        if((vname.compare(QString::fromUtf8("故障"))==0)
+//                                ||(vname.compare(QString::fromUtf8("手动"))==0)
+//                                ||(vname.compare(QString::fromUtf8("运行"))==0)
+//                                ||(vname.compare(QString::fromUtf8("接线"))==0)
+//                                ||(vname.compare(QString::fromUtf8("正常"))==0)){
+//                            if(qry2.value(1).toInt()==0)
+//                                pv="0";
+//                            else
+//                                pv="1";
+//                        }else{
+//                            if(qry2.value(1).toInt()==0)
+//                                pv="1";
+//                            else
+//                                pv="0";
+//                        }
+//                        if(count==0)
+//                            sql = QString("insert into sp_owner_sync_data (id, native_id, device_id, point_code, point_data, data_time, content) values (NULL,%1,'%2','%3','%4','%5','%6 %7')")
+//                                    .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()).arg(pv)
+//                                    .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                                   .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
+//                        else
+//                            sql += QString(",  (NULL,%1,'%2','%3','%4','%5','%6 %7')")
+//                                    .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()).arg(pv)
+//                                    .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                                   .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
+//                        upsql = QString::fromUtf8("update sp_owner_status set point_data='%1', data_time='%2', content='%3 %4', point_name='%5',dwtype=%6 where device_id='%7' and point_code='%8';")
+//                                .arg(pv)
+//                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                                .arg(qry2.value(5).toString()).arg(qry2.value(6).toString()).arg(pname)
+//                                .arg(6).arg(devid).arg(tmpIdx);
+//                        mdb.exec(upsql);
+//                    }
+//                }else if(qry2.value(2).toString().compare("E6")==0){
+//                    if(count==0)
+//                        sql = QString("insert into sp_owner_sync_data (id, native_id, device_id, point_code, point_data, data_time, content) values (NULL,%1,'%2','%3','%4','%5','%6 %7')")
+//                                .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()+64).arg(qry2.value(8).toString())
+//                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                               .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
+//                    else
+//                        sql += QString(", (NULL,%1,'%2','%3','%4','%5','%6 %7')")
+//                                .arg(qry2.value(0).toUInt()).arg(devid).arg(qry2.value(3).toInt()+64).arg(qry2.value(8).toString())
+//                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                               .arg(qry2.value(5).toString()).arg(qry2.value(6).toString());
+//                    int tmpIdx = qry2.value(3).toInt();
+//                    if(tmpIdx>0){
+//                        QString pname = "";
+//                        for(int Idx=0;Idx<nameList.length();Idx++){
+//                            if((typeList.at(Idx)==2)&&(portList.at(Idx)==tmpIdx)){
+//                                pname = nameList.at(Idx);
+//                                break;
+//                            }
+//                        }
+//                        upsql = QString::fromUtf8("update sp_owner_status set point_data='%1', data_time='%2', content='%3 %4 %5',dwtype=%6 where device_id='%7' and point_code='%8';")
+//                                .arg(qry2.value(8).toString())
+//                                .arg(qry2.value(7).isNull()?"1970-01-01 00:00:00":qry2.value(7).toDateTime().toString("yyyy-MM-dd HH:mm:ss"))
+//                                .arg(pname).arg(qry2.value(5).toString())
+//                                .arg(qry2.value(6).toString())
+//                                .arg(6)
+//                                .arg(devid)
+//                                .arg(tmpIdx+64);
+//                        mdb.exec(upsql);
+//                    }
+//                }
+//            }
         }
+
+
+
+
         count++;
         sync_id = qry2.value(0).toUInt();
         if(count>=100){
             time_t tmp_time = time(static_cast<time_t *>(Q_NULLPTR));
             ytShm->updatetime[DB_THREAD] = tmp_time;
-            sql.append(";");
-            mdb.exec(sql);
+//            sql.append(";");
+//            mdb.exec(sql);
             mdb.exec(QString("update sp_owner_sync set sync_id=%1 where id=%2").arg(sync_id).arg(ID));
 //            mdb.exec(upsql);
             count=0;
-            sql="";
-            upsql="";
+//            sql="";
+//            upsql="";
         }
     }
     if(count>0){
         time_t tmp_time = time(static_cast<time_t *>(Q_NULLPTR));
         ytShm->updatetime[DB_THREAD] = tmp_time;
-        sql.append(";");
-        mdb.exec(sql);
+//        sql.append(";");
+//        mdb.exec(sql);
         mdb.exec(QString("update sp_owner_sync set sync_id=%1 where id=%2").arg(sync_id).arg(ID));
 //        mdb.exec(upsql);
         count=0;
-        sql="";
-        upsql="";
+//        sql="";
+//        upsql="";
     }
     return updated;
 }
@@ -862,7 +871,7 @@ bool DB_SyncThread::videoalarmSync(QString devid, QString deviceCode, uint sync_
     return updated;
 }
 
-bool DB_SyncThread::efireInfoSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, QString companyCode)
+bool DB_SyncThread::efireInfoSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, QString companyCode, QString owner_xh)
 {
     QString upsql1, upsql2, upsql3, upsql4,upsql5,upsql6,sql;
     int count=0;
@@ -887,41 +896,52 @@ bool DB_SyncThread::efireInfoSync(QString devid, QString deviceCode, uint sync_i
     qry2.clear();
     qry2 =mdb.exec(QString("select count(*) from sp_owner_status where device_id='%1'").arg(devid));
     if(qry2.next()){
-        if(qry2.value(0).toInt()==0){
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过压',1,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电低压',2,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过流',3,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'漏电报警',4,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度超高',5,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度超高',6,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度超高',7,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电压',65,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电压',66,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电压',67,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电流',68,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电流',69,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电流',70,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度',71,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度',72,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度',73,0,'1970-01-01 08:00:00','')").arg(devid));
-        }else if(qry2.value(0).toInt()==6){
-            mdb.exec(QString::fromUtf8("delete from sp_owner_status where device_id='%1'").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过压',1,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电低压',2,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过流',3,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'漏电报警',4,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度超高',5,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度超高',6,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度超高',7,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电压',65,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电压',66,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电压',67,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电流',68,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电流',69,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电流',70,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度',71,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度',72,0,'1970-01-01 08:00:00','')").arg(devid));
-            mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度',73,0,'1970-01-01 08:00:00','')").arg(devid));
+
+        if(owner_xh.compare("ARCM300D")==0){
+             mdb.exec(QString::fromUtf8("delete from sp_owner_status where device_id='%1'").arg(devid));
+             mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过压',1,0,'1970-01-01 08:00:00','')").arg(devid));
+             mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电低压',2,0,'1970-01-01 08:00:00','')").arg(devid));
+             mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过流',3,0,'1970-01-01 08:00:00','')").arg(devid));
+             mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'电压',65,0,'1970-01-01 08:00:00','')").arg(devid));
+             mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'电流',68,0,'1970-01-01 08:00:00','')").arg(devid));
+             mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'电能',71,0,'1970-01-01 08:00:00','')").arg(devid));
+         }else{
+            if(qry2.value(0).toInt()==0){
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过压',1,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电低压',2,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过流',3,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'漏电报警',4,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度超高',5,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度超高',6,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度超高',7,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电压',65,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电压',66,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电压',67,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电流',68,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电流',69,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电流',70,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度',71,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度',72,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度',73,0,'1970-01-01 08:00:00','')").arg(devid));
+            }else if(qry2.value(0).toInt()==6){
+                mdb.exec(QString::fromUtf8("delete from sp_owner_status where device_id='%1'").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过压',1,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电低压',2,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'供电过流',3,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'漏电报警',4,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度超高',5,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度超高',6,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度超高',7,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电压',65,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电压',66,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电压',67,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相电流',68,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相电流',69,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相电流',70,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'A相线缆温度',71,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'B相线缆温度',72,0,'1970-01-01 08:00:00','')").arg(devid));
+                mdb.exec(QString::fromUtf8("insert into sp_owner_status (id, device_id, dwtype, point_name, point_code, point_data, data_time, content) values (NULL,'%1',7,'C相线缆温度',73,0,'1970-01-01 08:00:00','')").arg(devid));
+            }
         }
     }
     qry2.clear();
@@ -1564,7 +1584,7 @@ void DB_SyncThread::time_out()
         }
         else
         {
-            if(((times++)&0x0f)==0x0f){
+            if(((times++)&0x0f)==0x0f){//智慧大屏
                 UpdateTime = QDateTime::currentDateTime().toTime_t();
                 checkUsers();
                 checkCompany();
@@ -1607,7 +1627,7 @@ void DB_SyncThread::time_out()
                 pcList.append(qry2.value(1).toInt());
             }
             qry2.clear();
-            qry = mdb.exec("select id, owner_code, owner_name, unitinfo, install_time, dwtype, company, rtmp from sp_owner");
+            qry = mdb.exec("select id, owner_code, owner_name, unitinfo, install_time, dwtype, company, rtmp, owner_xh from sp_owner");
             while(qry.next())
             {
                 time_t tmp_time = time(static_cast<time_t *>(Q_NULLPTR));
@@ -1659,7 +1679,7 @@ void DB_SyncThread::time_out()
                         need_sync = rtuInfoSync(qry.value(1).toString(),deviceCode,sync_id,tbname,chkday,ID,companyCode);
                         break;
                     case 7:
-                        need_sync = efireInfoSync(qry.value(1).toString(),deviceCode,sync_id,tbname,chkday,ID,companyCode);
+                        need_sync = efireInfoSync(qry.value(1).toString(),deviceCode,sync_id,tbname,chkday,ID,companyCode,qry.value(8).toString());
                         break;
                     case 16:
                         need_sync = videoalarmSync(qry.value(1).toString(),deviceCode,sync_id,tbname,chkday,ID,companyCode);

+ 4 - 2
ytServiceCore/db_syncthread.h

@@ -235,7 +235,7 @@ public:
 
 class XfzdSyncDev{
 public:
-    explicit XfzdSyncDev(QString deviceCode="", QString deviceName="", QString descript="",int deviceType=0, QString deviceTypeName="", QString openProjectId="", int devtype=0, QString data="",QString port="")
+    explicit XfzdSyncDev(QString deviceCode="", QString deviceName="", QString descript="",int deviceType=0, QString deviceTypeName="", QString openProjectId="", int devtype=0, QString data="",QString port="",QString deviceFloor="")
     {
         DeviceCode = deviceCode;
         DeviceName = deviceName;
@@ -246,6 +246,7 @@ public:
         devCategory = devtype;
         Data = data;
         Port = port;
+        DeviceFloor = deviceFloor;
     }
 
     QString DeviceCode;
@@ -257,6 +258,7 @@ public:
     int devCategory;
     QString Data;
     QString Port;
+    QString DeviceFloor;
 };
 
 class SyncDataSet{
@@ -314,7 +316,7 @@ public:
     bool manholeCoverSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, int dwtype, QString companyCode);
     bool smokerInfoSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, QString companyCode);
     bool rtuInfoSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, QString companyCode);
-    bool efireInfoSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, QString companyCode);
+    bool efireInfoSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, QString companyCode,QString owner_xh);
     bool videoalarmSync(QString devid, QString deviceCode, uint sync_id, QString tbname, QDate chkday, uint ID, QString companyCode);
     void chkInList(QString devid);
     void webShmInit();

+ 117 - 0
ytServiceCore/redis.h

@@ -0,0 +1,117 @@
+#ifndef REDIS_H
+#define REDIS_H
+
+#include <stdio.h>
+#include <QString>
+#include <string.h>
+#include <stddef.h>
+#include <stdarg.h>
+#include <string.h>
+#include <assert.h>
+#include <hiredis/hiredis.h>
+
+
+#define REDIS_HOST        "127.0.0.1"
+#define REDIS_PORT        6379
+
+redisContext *c = NULL;
+
+int redisconnected;
+
+int redis_init()
+{
+    c = redisConnect(REDIS_HOST, REDIS_PORT);
+    if (NULL == c || c->err) {
+        if(c) {
+            printf("Redis [%s:%d], Error:[%s]\n", REDIS_HOST, REDIS_PORT, c->errstr);
+            redisFree(c);
+        } else {
+            printf("Redis [%s:%d] failure\n", REDIS_HOST, REDIS_PORT);
+        }
+        return -1;
+    }
+
+    return 0;
+}
+
+void redis_free()
+{
+    if (c) {
+        redisFree(c);
+    }
+    c = NULL;
+}
+
+int redis_save(const char *cmd)
+{
+    int i = 0;
+    redisReply *r = NULL;
+    if (NULL == cmd) {
+        return -1;
+    }
+
+    printf("%s\n", cmd);
+
+    r = (redisReply *)redisCommand(c, cmd);
+    if (NULL == r) {
+        printf("Error[%d:%s]", c->err, c->errstr);
+        return -1;
+    }
+
+    switch(r->type) {
+    case REDIS_REPLY_STATUS:
+        printf("type:%s, reply->len:%ld reply->str:%s\n", "REDIS_REPLY_STATUS", r->len, r->str);
+        break;
+    case REDIS_REPLY_ERROR:
+        printf("type:%s, reply->len:%ld reply->str:%s\n", "REDIS_REPLY_ERROR", r->len, r->str);
+        break;
+    case REDIS_REPLY_INTEGER:
+        printf("type:%s, reply->integer:%lld\n", "REDIS_REPLY_INTEGER", r->integer);
+        break;
+    case REDIS_REPLY_NIL:
+        printf("type:%s, no data\n", "REDIS_REPLY_NIL");
+        break;
+    case REDIS_REPLY_STRING:
+        printf("type:%s, reply->len:%ld reply->str:%s\n", "REDIS_REPLY_STRING", r->len, r->str);
+        break;
+    case REDIS_REPLY_ARRAY:
+        printf("type:%s, reply->elements:%ld\n", "REDIS_REPLY_ARRAY", r->elements);
+        for (i = 0; i < r->elements; i++) {
+            printf("%d: %s\n", i, r->element[i]->str);
+        }
+        break;
+    default:
+        printf("unkonwn type:%d\n", r->type);
+        break;
+    }
+
+    /*release reply and context */
+    freeReplyObject(r);
+    return 0;
+}
+
+QString redis_qstring(const char *cmd)
+{
+    redisReply *r = NULL;
+    if (NULL == cmd) {
+        return "error";
+    }
+
+    printf("%s\n", cmd);
+
+    r = (redisReply *)redisCommand(c, cmd);
+    if (NULL == r) {
+        printf("Error[%d:%s]", c->err, c->errstr);
+        return "error";
+    }
+
+    QString data = r->str;
+
+    /*release reply and context */
+    freeReplyObject(r);
+    return data;
+}
+
+
+
+#endif // REDIS_H

+ 3 - 1
ytServiceCore/ytServiceCore.pro

@@ -36,6 +36,8 @@ HEADERS += \
     wsclient.h \
     logthread.h \
     subreportthread.h \
-    subsysreport.h
+    subsysreport.h \
+    redis.h
 
 LIBS += -ljson-c -lssl -lcrypto
+LIBS += "/usr/local/lib/libhiredis.a"