|
@@ -36,7 +36,7 @@ void DealMqttThread::run()
|
|
|
QJsonObject obj = doc.object();
|
|
|
QString deviceId = obj.value("device_id").toString();
|
|
|
QString deviceCode = obj.value("device_code").toString();
|
|
|
- QString companyCode = obj.value("product_id").toString();
|
|
|
+ QString productCode = obj.value("product_id").toString();
|
|
|
int timeStamp = obj.value("timestamp").toInt();
|
|
|
QString dataTime = QDateTime::fromTime_t(timeStamp).toString("yyyy-MM-dd HH:mm:ss");
|
|
|
QString deviceType = obj.value("device_type").toString();
|
|
@@ -48,24 +48,24 @@ void DealMqttThread::run()
|
|
|
devBrief = spit.at(1);
|
|
|
}
|
|
|
|
|
|
- if((devType.length()==3)&&(devType.startsWith("5"))){
|
|
|
+// if((devType.length()==3)&&(devType.startsWith("5"))){
|
|
|
QJsonValue metric_value = obj.value("metrics");
|
|
|
|
|
|
QJsonObject metric_obj = metric_value.toObject();
|
|
|
QVariantMap fd = metric_obj.toVariantMap();
|
|
|
QVariantMap::Iterator iter;
|
|
|
QString sql = "";
|
|
|
- QString sql1 = QString("insert into data_%1_history(id,device_id,device_code,device_type,attribute_name,attribute_data,data_time,insert_time) values").arg(devBrief);
|
|
|
+ QString sql1 = QString("insert into data_%1_history(id,device_id,product_code,device_type,attribute_name,attribute_data,data_time,insert_time) values").arg(devBrief);
|
|
|
for(iter=fd.begin();iter!=fd.end();iter++){
|
|
|
- sql.append(QString("insert into data_real_time (id, device_id, device_code, device_type, attribute_name, attribute_data, data_time, insert_time) values(null,'%1','%2',%3,'%4','%5','%6','%7') ON DUPLICATE KEY UPDATE attribute_data = values(attribute_data),data_time = values(data_time),insert_time = values(insert_time);")
|
|
|
- .arg(deviceId).arg(deviceCode).arg(devType).arg(iter.key()).arg(iter.value().toString()).arg(dataTime).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ sql.append(QString("insert into data_real_time (id, device_id, product_code, device_type, attribute_name, attribute_data, data_time, insert_time) values(null,'%1','%2',%3,'%4','%5','%6','%7') ON DUPLICATE KEY UPDATE attribute_data = values(attribute_data),data_time = values(data_time),insert_time = values(insert_time);")
|
|
|
+ .arg(deviceId).arg(productCode).arg(devType).arg(QString(iter.key()).toLower()).arg(iter.value().toString()).arg(dataTime).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
|
|
|
sql1.append(QString("(NULL,'%1','%2',%3,'%4','%5','%6','%7'),")
|
|
|
- .arg(deviceId).arg(deviceCode).arg(devType).arg(iter.key()).arg(iter.value().toString()).arg(dataTime).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
|
|
|
+ .arg(deviceId).arg(productCode).arg(devType).arg(QString(iter.key()).toLower()).arg(iter.value().toString()).arg(dataTime).arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
|
}
|
|
|
sql.append(sql1.left(sql1.length()-1).append(" ON DUPLICATE KEY UPDATE attribute_data = values(attribute_data),insert_time = values(insert_time);"));
|
|
|
emit dmqSql(sql);
|
|
|
- }
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|