Selaa lähdekoodia

1、修改17系列topic名称,在topic中增加 /ubdp;

James 3 vuotta sitten
vanhempi
commit
d7873f0403

+ 9 - 1
ytWG/ytWGElectric/databasethread.cpp

@@ -1,4 +1,4 @@
-#include "databasethread.h"
+#include "databasethread.h"
 
 //#define HostName "124.71.145.219"
 //#define HostPort 3306
@@ -18,6 +18,12 @@
 #define PassWord "Y48hD&Eg"
 #define DatabaseName "smart_electricity"
 
+//#define HostName "101.133.214.75"
+//#define HostPort 3306
+//#define UserName "usky"
+//#define PassWord "Yt#75Usky"
+//#define DatabaseName "usky-electricity"
+
 #include "wgelectricshm.h"
 #include "../WGDog/dataprecess.h"
 
@@ -110,6 +116,7 @@ DatabaseThread::DatabaseThread(QObject *parent) :
     minute = 255;
 
     sqlList.clear();
+    alarmRepList.clear();
 
     db=QSqlDatabase::addDatabase("QMYSQL","wg_db");
     db.setHostName(QString(HostName));
@@ -418,6 +425,7 @@ void DatabaseThread::run()
            db.close();
        }
 
+
        if(sqlList.length()>0 || alarmRepList.length()>0){
            if(!db.open())
            {

+ 5 - 3
ytWG/ytWGElectric/elcommthread.cpp

@@ -7,9 +7,10 @@ ELCommThread::ELCommThread(QObject *parent) : QThread(parent)
     connect(timer,&QTimer::timeout,this,&ELCommThread::time_out);
     timer->start(1000);
 
-    m_client = new QMQTT::Client(QHostAddress("124.70.160.158"), 1883, this);
+    //m_client = new QMQTT::Client(QHostAddress("124.70.160.158"), 1883, this);
+    m_client = new QMQTT::Client(QHostAddress("123.60.11.86"), 1883, this);
     m_client->setUsername("admin");
-    m_client->setPassword("public");
+    m_client->setPassword("a10vE0s73g5");
 
     connect(m_client, &QMQTT::Client::connected, this, &ELCommThread::onConnected);
     connect(m_client, &QMQTT::Client::received, this, &ELCommThread::onReceived);
@@ -40,7 +41,8 @@ void ELCommThread::time_out()
 void ELCommThread::onConnected()
 {
     printf("wgelectcore::onConnected() \n");
-    m_client->subscribe("/anyoee/data/+/+/property",0);
+    //m_client->subscribe("/anyoee/data/+/+/property",0);
+    m_client->subscribe("/ewoogi/data/+/+/property",0);
 }
 
 

+ 8 - 7
ytWG/ytWGElectric/elcommthread171.cpp

@@ -8,9 +8,10 @@ ELCommThread171::ELCommThread171(QObject *parent) : QThread(parent)
     connect(timer,&QTimer::timeout,this,&ELCommThread171::time_out);
     timer->start(1000);
 
-    m_client = new QMQTT::Client(QHostAddress("124.70.160.158"),1883,this);
+    //m_client = new QMQTT::Client(QHostAddress("124.70.160.158"), 1883, this);
+    m_client = new QMQTT::Client(QHostAddress("123.60.11.86"), 1883, this);
     m_client->setUsername("admin");
-    m_client->setPassword("public");
+    m_client->setPassword("a10vE0s73g5");
     connect(m_client,&QMQTT::Client::connected,this,&ELCommThread171::onConnected);
     connect(m_client,&QMQTT::Client::received,this,&ELCommThread171::onReceived);
     m_client->connectToHost();
@@ -36,8 +37,8 @@ void ELCommThread171::time_out()
 
 void ELCommThread171::onConnected()
 {
-    m_client->subscribe("/ewoogi/data/a1TdT9qm7vu/+/property",0);
-    m_client->subscribe("/ewoogi/session/a1RFQGoAewM/+/combine/login",0);
+    m_client->subscribe("/ewoogi/ubqd/data/Hz171EwoogiD/+/property",0);
+    m_client->subscribe("/ewoogi/ubqd/session/Hz158EwoogiD/+/combine/login",0);
 }
 
 void ELCommThread171::onReceived(const QMQTT::Message &message)
@@ -54,9 +55,9 @@ void ELCommThread171::onReceived(const QMQTT::Message &message)
     //subSOE login->login_reply->down_raw
     QString login = topic.split("/").last();
     if(login.compare("login")==0){
-        QString company = topic.split("/").at(3);
-        QString deviceCode = topic.split("/").at(4);
-        QString loginTopic = QString("/ewoogi/session/%1/%2/combine/login_reply").arg(company).arg(deviceCode);
+        QString company = topic.split("/").at(4);
+        QString deviceCode = topic.split("/").at(5);
+        QString loginTopic = QString("/ewoogi/ubqd/session/%1/%2/combine/login_reply").arg(company).arg(deviceCode);
         QString data1 = QString("{\"code\":200}");
         m_client->publish(QMQTT::Message(loginIdx++,loginTopic,data1.toUtf8()));
         if(loginIdx>9999)

+ 8 - 7
ytWG/ytWGElectric/elcommthread173.cpp

@@ -9,9 +9,10 @@ ELCommThread173::ELCommThread173(QObject *parent) : QThread(parent)
     connect(timer,&QTimer::timeout,this,&ELCommThread173::time_out);
     timer->start(1000);
 
-    m_client = new QMQTT::Client(QHostAddress("124.70.160.158"),1883,this);
+    //m_client = new QMQTT::Client(QHostAddress("124.70.160.158"), 1883, this);
+    m_client = new QMQTT::Client(QHostAddress("123.60.11.86"), 1883, this);
     m_client->setUsername("admin");
-    m_client->setPassword("public");
+    m_client->setPassword("a10vE0s73g5");
     connect(m_client,&QMQTT::Client::connected,this,&ELCommThread173::onConnected);
     connect(m_client,&QMQTT::Client::received,this,&ELCommThread173::onReceived);
 
@@ -40,8 +41,8 @@ void ELCommThread173::time_out()
 
 void ELCommThread173::onConnected()
 {
-    m_client->subscribe("/ewoogi/data/a1I0ruPggeM/+/property",0);
-    m_client->subscribe("/ewoogi/session/a1RFQGoAewM/+/combine/login",0);
+    m_client->subscribe("/ewoogi/ubqd/data/Hz173EwoogiD/+/property",0);
+    m_client->subscribe("/ewoogi/ubqd/session/Hz158EwoogiD/+/combine/login",0);
 }
 
 
@@ -58,10 +59,10 @@ void ELCommThread173::onReceived(const QMQTT::Message& message)
     //subSOE login->login_reply->down_raw
     QString login = (topic.split("/")).last();
     if(QString::compare(login,"login")==0){
-        QString company = (topic.split("/").at(3));
-        QString deviceCode = (topic.split("/").at(4));
+        QString company = (topic.split("/").at(4));
+        QString deviceCode = (topic.split("/").at(5));
 
-        QString loginTopic = QString("/ewoogi/session/%1/%2/combine/login_reply").arg(company).arg(deviceCode);
+        QString loginTopic = QString("/ewoogi/ubqd/session/%1/%2/combine/login_reply").arg(company).arg(deviceCode);
         QString data1;
         data1.append(QString("{\"code\":200}"));
         m_client->publish(QMQTT::Message(loginIdx++,loginTopic,data1.toUtf8()));

+ 2 - 2
ytWG/ytWGElectric/elcommthreadpub.cpp

@@ -4,9 +4,9 @@ ELCommThreadPub::ELCommThreadPub(QObject *parent) : QThread(parent)
 {
     mqttIdx=1;
 
-    client = new QMQTT::Client(QHostAddress("124.70.160.158"), 1883, this);
+    client = new QMQTT::Client(QHostAddress("123.60.11.86"), 1883, this);
     client->setUsername("admin");
-    client->setPassword("public");
+    client->setPassword("a10vE0s73g5");
     connect(client,&QMQTT::Client::connected,this,&ELCommThreadPub::onConnected);
     client->connectToHost();
 

+ 3 - 3
ytWG/ytWGElectric/elcommthreadsub.cpp

@@ -9,9 +9,9 @@ ELCommThreadSub::ELCommThreadSub(QObject *parent) : QThread(parent)
     mqttinfoIdx=1;
 
 
-    clientsub = new QMQTT::Client(QHostAddress("124.70.160.158"), 1883, this);
+    clientsub = new QMQTT::Client(QHostAddress("123.60.11.86"), 1883, this);
     clientsub->setUsername("admin");
-    clientsub->setPassword("public");
+    clientsub->setPassword("a10vE0s73g5");
     connect(clientsub,&QMQTT::Client::connected,this,&ELCommThreadSub::onConnectedSub);
     connect(clientsub,&QMQTT::Client::received,this,&ELCommThreadSub::onReceivedSub);
     clientsub->connectToHost();
@@ -239,7 +239,7 @@ quint8 ELCommThreadSub::hexstr_to_byte(QString dat)
 
 void ELCommThreadSub::para(QString devicename,QString method,QString starttime,QString endtime)
 {
-    clientsub->subscribe(QString("/anyoee/data/a10vE0s73g5/%1/user/ump").arg(devicecode),0);
+    clientsub->subscribe(QString("/ewoogi/data/a10vE0s73g5/%1/user/ump").arg(devicecode),0);
 
     if(!dir.exists(devicename)){
         dir.mkdir(devicename);

+ 1 - 1
ytWG/ytWGElectric/electdata171.cpp

@@ -106,7 +106,7 @@ void Electdata171::arraydataToJson(QString topic,QByteArray data)
     QString sql;
     int startpos=0,Idx = 0;
 
-    QString deviceCode = (topic.split("/")).at(4);
+    QString deviceCode = (topic.split("/")).at(5);
     printf("deviceCode = %s\n",deviceCode.toUtf8().data());
 
     QString commData;

+ 1 - 1
ytWG/ytWGElectric/electdata173.cpp

@@ -146,7 +146,7 @@ void Electdata173::arraydataToJason(QString topic,QByteArray data)
     QString sql;
     int startpos=0,Idx = 0;
 
-    QString deviceCode = (topic.split("/")).at(4);
+    QString deviceCode = (topic.split("/")).at(5);
     printf("deviceCode = %s\n",deviceCode.toUtf8().data());
 
     QString commData;

+ 16 - 4
ytWG/ytWGElectric/logthread.cpp

@@ -9,11 +9,11 @@ LogThread::LogThread(QObject *parent) :
     printf("logthread init\n");
 
     QDir dir;
-    if(!dir.exists("log"))
-        dir.mkdir("log");
+    if(!dir.exists("/usky/wgdev/log"))
+        system("mkdir -p /usky/wgdev/log");
 
 
-    file = new QFile("log/wg-"+QDate::currentDate().toString("yyyyMMdd")+".log");
+    file = new QFile("/usky/wgdev/log/wg-"+QDate::currentDate().toString("yyyyMMdd")+".log");
 
     day = QDate::currentDate().day();
 }
@@ -46,8 +46,20 @@ void LogThread::run()
         if(dataList.length()>0){
             if(day!=QDate::currentDate().day()){
                 day = QDate::currentDate().day();
-                file = new QFile("log/wg-"+QDate::currentDate().toString("yyyyMMdd")+".log");
+                file = new QFile("/usky/wgdev/log/wg-"+QDate::currentDate().toString("yyyyMMdd")+".log");
+
+                uint l_time = QDateTime::currentDateTime().toTime_t()-7*86400;
+                QDir dir("/usky/wgdev/log");
+                QFileInfoList file_list = dir.entryInfoList(QDir::Files);
+                for(int i=0;i<file_list.size();i++){
+                    QFileInfo f_info = file_list.at(i);
+                    if(f_info.lastModified().toTime_t()<l_time){
+                        QFile(f_info.canonicalFilePath()).remove();
+                    }
+                }
+
             }
+
             if(file->open(QIODevice::ReadWrite|QIODevice::Append|QIODevice::Text)){
                 while(dataList.length()>0){
                     file->write(dataList.first().toUtf8());

+ 6 - 5
ytWG/ytWGElectric/wgelectcore.cpp

@@ -121,7 +121,7 @@ void wgelectcore::time_out()
         req->setUrl(QUrl("https://iot.usky.cn/ytapi/admin/Manage/wooGiApi"));
         req->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
         req->setHeader(QNetworkRequest::ContentLengthHeader,post_data.length());
-        QNetworkReply* reply = netAccessManager->post(*req,post_data);
+        QNetworkReply* reply = netAccessManager1->post(*req,post_data);
     }
 }
 
@@ -289,6 +289,7 @@ void wgelectcore::AlarmReport(QString DeviceCode,QString lastid,QString SETime,Q
                         }
                     }
                 }
+
                 break;
             }
         }
@@ -481,8 +482,8 @@ void wgelectcore::sendData171()
     post_data.append(QString("bz=%1").arg("测试阶段"));
 
     QNetworkRequest *req = new QNetworkRequest();
-    //req->setUrl(QUrl("https://iot.usky.cn/jdxf/wxapp7.php/Home/Powerwarn/message_dl"));
-    req->setUrl(QUrl("https://iot.usky.cn/ytapi/admin/Manage/ceShiUrl"));
+    req->setUrl(QUrl("https://wx.ewoogi.com/USKYOF/USKYOF.php/Home/Powerwarn/message_dl"));
+    //req->setUrl(QUrl("https://iot.usky.cn/ytapi/admin/Manage/ceShiUrl"));
     req->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
     req->setHeader(QNetworkRequest::ContentLengthHeader,post_data.length());
     QNetworkReply* reply = netAccessManager3->post(*req,post_data);
@@ -505,8 +506,8 @@ void wgelectcore::sendData173()
     post_data.append(QString("bz=%1").arg("测试阶段"));
 
     QNetworkRequest *req = new QNetworkRequest();
-    //req->setUrl(QUrl("https://iot.usky.cn/jdxf/wxapp7.php/Home/Powerwarn/message_dl"));
-    req->setUrl(QUrl("https://iot.usky.cn/ytapi/admin/Manage/ceShiUrl"));
+    req->setUrl(QUrl("https://wx.ewoogi.com/USKYOF/USKYOF.php/Home/Powerwarn/message_dl"));
+    //req->setUrl(QUrl("https://iot.usky.cn/ytapi/admin/Manage/ceShiUrl"));
     req->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
     req->setHeader(QNetworkRequest::ContentLengthHeader,post_data.length());
     QNetworkReply* reply = netAccessManager2->post(*req,post_data);