fix coredump error

This commit is contained in:
lnk
2025-12-23 15:09:28 +08:00
parent 1014aeafbc
commit dd01a31a77
5 changed files with 32 additions and 15 deletions

View File

@@ -271,7 +271,7 @@ void SendFileWeb(const std::string& strUrl, const std::string& localpath, const
if (res != CURLE_OK) {
const char* em = errbuf[0] ? errbuf : curl_easy_strerror(res);
std::cerr << "http web failed: " << em << std::endl;
DIY_ERRORLOG("process","【ERROR】前置上传暂态录波文件 %s 失败,请检查文件上传接口配置",localpath);
DIY_ERRORLOG("process","【ERROR】前置上传暂态录波文件 %s 失败,请检查文件上传接口配置",localpath.c_str());
} else {
std::cout << "http web success, response: " << resPost0 << std::endl;
handleUploadResponse(resPost0, wavepath); // 处理响应
@@ -389,7 +389,7 @@ void download_xml_for_icd(const std::string& MODEL_ID,
std::cout << "remote file name:" << remote_file_name << "local save name:" << save_name << std::endl;
// mq日志
DIY_WARNLOG("process","【WARN】前置获取到终端类型%s,该终端类型对应的映射文件为%s,映射文件将下载并保存在本地为%s",TMNL_TYPE,FILE_PATH,save_name);
DIY_WARNLOG("process","【WARN】前置获取到终端类型%s,该终端类型对应的映射文件为%s,映射文件将下载并保存在本地为%s",TMNL_TYPE.c_str(),FILE_PATH.c_str(),save_name.c_str());
std::string fileContent;
std::string fullPath = std::string("filePath=") + filepath; //填写远端路径作为入参
@@ -409,14 +409,14 @@ void download_xml_for_icd(const std::string& MODEL_ID,
outFile.close();
std::cout << "File saved successfully!" << std::endl;
DIY_WARNLOG("process","【WARN】前置下载映射文件%s成功",save_name);
DIY_WARNLOG("process","【WARN】前置下载映射文件%s成功",save_name.c_str());
} else {
std::cerr << "Error: Unable to open file for writing." << std::endl;
DIY_ERRORLOG("process","【ERROR】前置写入本地映射文件%s失败",save_name);
DIY_ERRORLOG("process","【ERROR】前置写入本地映射文件%s失败",save_name.c_str());
}
} else {
std::cerr << "Error: Unable to download file." << std::endl;
DIY_ERRORLOG("process","【ERROR】前置调用文件下载接口下载远端文件文件%s失败",FILE_PATH);
DIY_ERRORLOG("process","【ERROR】前置调用文件下载接口下载远端文件文件%s失败",FILE_PATH.c_str());
}
}
@@ -1244,10 +1244,18 @@ int transfer_json_qvvr_data(const std::string& dev_id, ushort monitor_id,
root["eventType"] = dis_kind;
// 时间处理
time_t start_sec = start_tm / 1000; //毫秒级取秒
/*time_t start_sec = start_tm / 1000; //毫秒级取秒
struct tm* time_info = localtime(&start_sec);
char time_buf[32];
strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", time_info);
strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", time_info);*/
time_t start_sec = start_tm / 1000;
struct tm tm_info;
localtime_r(&start_sec, &tm_info);
char time_buf[32];
strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", &tm_info);
std::ostringstream start_time_stream;
start_time_stream << time_buf << "." << std::setfill('0') << std::setw(3) << (start_tm % 1000);//构造成年月日时分秒.毫秒
std::string start_time_str = start_time_stream.str();
@@ -1271,7 +1279,7 @@ int transfer_json_qvvr_data(const std::string& dev_id, ushort monitor_id,
// 有效响应,略过
} catch (...) {
// 响应异常,保存 json
DIY_ERRORLOG(mpid.c_str(), "【ERROR】暂态接口响应异常,无法上送装置%s监测点%s的暂态事件",dev_id, monitor_id);
DIY_ERRORLOG(mpid.c_str(), "【ERROR】暂态接口响应异常,无法上送装置%s监测点%u的暂态事件",dev_id.c_str(), (unsigned)monitor_id);
std::cout << "qvvr send fail ,store in local" << std::endl;
std::string qvvrDir = FRONT_PATH + "/dat/qvvr/";
@@ -1281,7 +1289,7 @@ int transfer_json_qvvr_data(const std::string& dev_id, ushort monitor_id,
}
} else {
// 无响应,保存 json
DIY_ERRORLOG(mpid.c_str(), "【ERROR】暂态接口无响应,无法上送装置%s监测点%s的暂态事件",dev_id, monitor_id);
DIY_ERRORLOG(mpid.c_str(), "【ERROR】暂态接口无响应,无法上送装置%s监测点%u的暂态事件",dev_id.c_str(), (unsigned)monitor_id);
std::cout << "qvvr send fail ,store in local" << std::endl;
std::string qvvrDir = FRONT_PATH + "/dat/qvvr/";