From 5342a1cae37be29e733f9763177a140a93a86b8f Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Sat, 10 May 2025 11:43:22 +0800 Subject: [PATCH] fix bugs --- jsonparse/web_cmd_parse3.cpp | 111 ++++++++--------------------------- localserver/web_cmd.cpp | 1 - 2 files changed, 23 insertions(+), 89 deletions(-) diff --git a/jsonparse/web_cmd_parse3.cpp b/jsonparse/web_cmd_parse3.cpp index 5caef1c..1d7ac40 100644 --- a/jsonparse/web_cmd_parse3.cpp +++ b/jsonparse/web_cmd_parse3.cpp @@ -1098,36 +1098,15 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){ std::string MeasurementID = ""; char szTableName[100] = {0x00}, whereCon[256] = {0x00}; if (nSize > 0) { - int packgeNo = param.mPackageFlag; - int packgeMax = 0; - int packgeNum = 0; - jsonVal["package"] = packgeNo; - int lastSize = nSize % 5; - int index = nSize / 5; - if (lastSize > 0 && index > 0) { - packgeMax = index + 1; - if (packgeNo + 1 == packgeMax) { - packgeNum = nSize; - jsonVal["packageMax"] = index + 1; - } else { - packgeNum = (packgeNo + 1)*5; - jsonVal["packageMax"] = index + 1; - } - } else if (lastSize == 0 && index > 0) { - packgeNum = (packgeNo + 1) * 5; - packgeMax = index; - jsonVal["packageMax"] = index; - } else if (lastSize > 0 && index == 0) { - packgeNum = 0; - packgeMax = index + 1; - jsonVal["packageMax"] = index; - } + int interval = atol(param.timeEnd.c_str()) - atol(param.timeStart.c_str()); int featureInterVal = 0,waveInterVal = 0,featureInterTime = 0,waveInterTime = 0,maxSensorNum = 0; scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum); Json::Value jsBody; - zlog_info(zct, "packgeNo = %d,packgeMax = %d,packgeNum = %d", packgeNo, packgeMax, packgeNum); char count_sql[1024] = {0}; + int recive_feature = 0, send_feature = 0; + int recive_x = 0, recive_y = 0, recive_z = 0; + int send_x = 0, send_y = 0, send_z = 0; for (size_t i = 0; i < nSize; i++) { Json::Value iTem; @@ -1138,8 +1117,7 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){ sprintf(szTableName,"t_data_%s",vetRes[i][1].c_str()); sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' ", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - //int recive_feature = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - int recive_feature = 0, send_feature = 0; + memset(count_sql,0,sizeof(count_sql)); snprintf(count_sql,sizeof(count_sql), "SELECT " @@ -1155,25 +1133,7 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){ send_feature = atoi(vecResult1[1].c_str()); } iTem.append(MeasurementID); - // memset(szTableName,0,sizeof(szTableName)); - // memset(whereCon,0,sizeof(whereCon)); - // sprintf(szTableName,"receive_wave_status"); - // sprintf(whereCon, " data_nodeno = '%s-X' and timeStamp < '%s' and timeStamp > '%s' ", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - - // int recive_x = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - // memset(szTableName,0,sizeof(szTableName)); - // memset(whereCon,0,sizeof(whereCon)); - // sprintf(szTableName,"receive_wave_status"); - // sprintf(whereCon, " data_nodeno = '%s-Y' and timeStamp < '%s' and timeStamp > '%s' ", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - - // int recive_y = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - // memset(szTableName,0,sizeof(szTableName)); - // memset(whereCon,0,sizeof(whereCon)); - // sprintf(szTableName,"receive_wave_status"); - // sprintf(whereCon, " data_nodeno = '%s-Z' and timeStamp < '%s' and timeStamp > '%s' ", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - - // int recive_z = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - int recive_x = 0, recive_y = 0, recive_z = 0; + memset(count_sql,0,sizeof(count_sql)); snprintf(count_sql,sizeof(count_sql), "SELECT " @@ -1189,40 +1149,16 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){ recive_x = atoi(vecResult2[0].c_str()); recive_y = atoi(vecResult2[1].c_str()); recive_z = atoi(vecResult2[2].c_str()); + iTem.append((float(recive_feature)/(interval/featureInterVal))); + iTem.append(recive_feature); + iTem.append((float( recive_x)/(interval/waveInterVal))); + iTem.append(recive_x); + iTem.append((float(recive_y)/(interval/waveInterVal))); + iTem.append(recive_y); + iTem.append((float(recive_z)/(interval/waveInterVal))); + iTem.append(recive_z); } - iTem.append((float(recive_feature)/(interval/featureInterVal))); - iTem.append(recive_feature); - iTem.append((float( recive_x)/(interval/waveInterVal))); - iTem.append(recive_x); - iTem.append((float(recive_y)/(interval/waveInterVal))); - iTem.append(recive_y); - iTem.append((float(recive_z)/(interval/waveInterVal))); - iTem.append(recive_z); - // memset(szTableName,0,sizeof(szTableName)); - // memset(whereCon,0,sizeof(whereCon)); - // sprintf(szTableName,"t_data_%s",vetRes[i][1].c_str()); - // sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' and sendMsg = 1", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - // int send_feature = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - - // memset(szTableName,0,sizeof(szTableName)); - // memset(whereCon,0,sizeof(whereCon)); - // sprintf(szTableName," t_data_waveSend "); - // sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' and sendMsg = 1", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - // int send_x = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - - // memset(szTableName,0,sizeof(szTableName)); - // memset(whereCon,0,sizeof(whereCon)); - // sprintf(szTableName," t_data_waveSend "); - // sprintf(whereCon, " channelID = '%s-Y' and timeStamp < '%s' and timeStamp > '%s' and sendMsg = 1", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - // int send_y = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - - // memset(szTableName,0,sizeof(szTableName)); - // memset(whereCon,0,sizeof(whereCon)); - // sprintf(szTableName," t_data_waveSend "); - // sprintf(whereCon, " channelID = '%s-Z' and timeStamp < '%s' and timeStamp > '%s' and sendMsg = 1", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); - // int send_z = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); - int send_x = 0, send_y = 0, send_z = 0; memset(count_sql,0,sizeof(count_sql)); snprintf(count_sql,sizeof(count_sql), "SELECT " @@ -1238,18 +1174,17 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 ¶m){ send_x = atoi(vecResult3[0].c_str()); send_y = atoi(vecResult3[1].c_str()); send_z = atoi(vecResult3[2].c_str()); + iTem.append((float(send_feature)/(interval/featureInterVal))); + iTem.append(send_feature); + iTem.append((float(send_x)/(interval/waveInterVal))); + iTem.append(send_x); + iTem.append((float(send_y)/(interval/waveInterVal))); + iTem.append(send_y); + iTem.append((float(send_z)/(interval/waveInterVal))); + iTem.append(send_z); } - - iTem.append((float(send_feature)/(interval/featureInterVal))); - iTem.append(send_feature); - iTem.append((float(send_x)/(interval/waveInterVal))); - iTem.append(send_x); - iTem.append((float(send_y)/(interval/waveInterVal))); - iTem.append(send_y); - iTem.append((float(send_z)/(interval/waveInterVal))); - iTem.append(send_z); - jsBody.append(iTem); + } if (jsBody.size() == 0) { jsonVal["success"] = false; diff --git a/localserver/web_cmd.cpp b/localserver/web_cmd.cpp index 02f8b3f..dbc77c3 100644 --- a/localserver/web_cmd.cpp +++ b/localserver/web_cmd.cpp @@ -519,7 +519,6 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) { param.timeStart = recvBody["timeStart"].asString(); param.timeEnd = recvBody["timeEnd"].asString(); std::string data = jd.JsonCmd_Cgi_65(param); - printf("return data = %s\n", data.c_str()); return data; } break;