优化代码

This commit is contained in:
zhangsheng 2025-05-12 17:26:09 +08:00
parent f5bc21ff9f
commit d86a2b1d7b
2 changed files with 19 additions and 3 deletions

View File

@ -1089,7 +1089,7 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
jsonVal[JSON_FIELD_CMD] = "65";
jsonVal["success"] = true;
jsonVal["message"] = " ";
array_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), " dataNodeName,MeasurementID ", NULL);
array_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), " dataNodeName,MeasurementID,RSSI ", NULL);
size_t nSize = vetRes.size();
std::string MeasurementID = "";
char szTableName[100] = {0x00}, whereCon[256] = {0x00};
@ -1138,7 +1138,7 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
"COUNT(*) FILTER (WHERE data_nodeno = '%s-Z') AS recive_z "
"FROM ( "
"SELECT * FROM receive_wave_status "
"WHERE timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),param.timeStart.c_str(),param.timeEnd.c_str());
"WHERE error_code = 1 and timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),param.timeStart.c_str(),param.timeEnd.c_str());
vec_t vecResult2 = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql);
if (vecResult2.size() > 0)
{
@ -1179,6 +1179,8 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
iTem.append((float(send_z)/(interval/waveInterVal)));
iTem.append(send_z);
}
std::vector<std::string> vRssi;
boost::split(vRssi, vetRes[i][2], boost::is_any_of(","), boost::token_compress_on);
jsBody.append(iTem);
}

View File

@ -588,7 +588,7 @@ int Uart::DealFeatureValue(const char *pData,uint16_t ushortAdd){
std::string nowTimetamp = std::string(localtimestamp);
long now_time = atol(nowTimetamp.c_str());
if(ushortAdd == last_short_addr && (now_time - last_time) < 5){
zlog_info(zct, "DealFeatureValue short_addr_last = %02x%02x,timestamp_last = %ld,nowTime = %ld",UINT16_HIGH(ushortAdd), UINT16_LOW(ushortAdd),last_time,now_time);
zlog_warn(zct, "DealFeatureValue short_addr_last = %02x%02x,timestamp_last = %ld,nowTime = %ld",UINT16_HIGH(ushortAdd), UINT16_LOW(ushortAdd),last_time,now_time);
int iRet = DealDataNodeFeature(pData, 0);
if (iRet != 0)
{
@ -613,6 +613,20 @@ void Uart::DealRecvData(const char *pData) {
int taskID = 0;
ScheduleTask scheduleTask;
zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command);
if (command == WAVE_COMPRESS || command == UPGRADE_ASK)
{
char localtimestamp[32] = {0};
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
long now_time = atol(nowTimetamp.c_str());
if(ushortAdd == last_short_addr && (now_time - last_time) < 5){
zlog_warn(zct, "WAVE_COMPRESS | UPGRADE_ASK short_addr_last = %02x%02x,timestamp_last = %ld,nowTime = %ld",UINT16_HIGH(ushortAdd), UINT16_LOW(ushortAdd),last_time,now_time);
return ;
}
GetTimeNet(localtimestamp, 1);
nowTimetamp = std::string(localtimestamp);
last_time = atol(nowTimetamp.c_str());
}
if (ushortAdd != last_short_addr){
mssleep(50000);
ModifyDistAddr(ushortAdd);