diff --git a/LFtid1056.rar b/LFtid1056.rar index b9b223a..3444c11 100644 Binary files a/LFtid1056.rar and b/LFtid1056.rar differ diff --git a/LFtid1056/cloudfront/code/cfg_parser.cpp b/LFtid1056/cloudfront/code/cfg_parser.cpp index e29d493..c566cce 100644 --- a/LFtid1056/cloudfront/code/cfg_parser.cpp +++ b/LFtid1056/cloudfront/code/cfg_parser.cpp @@ -1333,8 +1333,8 @@ int recall_json_handle_from_mq(const std::string& body) } if (dt == 2) { //一个测点一个guid对应多个文件 - // ▲直下文件:timeList -> fun1/fun2 -> enqueue_direct_download - if (!rec.contains("timeList") || !rec["timeList"].is_array()) continue; + // ▲直下文件:timeInterval -> fun1/fun2 -> enqueue_direct_download + if (!rec.contains("timeInterval") || !rec["timeInterval"].is_array()) continue; for (const auto& monId : monitors) { // fun1:提取 monitor 数字 @@ -1345,7 +1345,7 @@ int recall_json_handle_from_mq(const std::string& body) init_recall_record_file(guid, terminalId, monId, "", ""); //根据时间戳单独补招事件 - // ★新增(dt==2 同步生成“按小时”的事件补招到 recall_list,与 dt==1 逻辑一致)——开始 + if(0)// ★新增(dt==2 同步生成“按小时”的事件补招到 recall_list,与 dt==1 逻辑一致)——开始 { std::lock_guard lock2(ledgermtx); // 复用与 dt==1 相同的加锁粒度 // 找终端 @@ -1361,7 +1361,7 @@ int recall_json_handle_from_mq(const std::string& body) if (!lm) { std::cout << "monitorId未在terminal内找到(直下事件回灌): " << monId << " @ " << terminalId << std::endl; continue; } // 将 timeList 的每个时间点映射为 [该整点, 下一整点) 的一小时窗口 - for (const auto& t : rec["timeList"]) { + for (const auto& t : rec["timeInterval"]) { if (!t.is_string()) continue; std::string tstr = t.get(); @@ -1387,7 +1387,7 @@ int recall_json_handle_from_mq(const std::string& body) // ★新增(dt==2 同步生成“按小时”的事件补招到 recall_list,与 dt==1 逻辑一致)——结束 //根据时间戳单独补招事件 - for (const auto& t : rec["timeList"]) { + for (const auto& t : rec["timeInterval"]) { if (!t.is_string()) continue; std::string ts_compact = compact_ts_for_filename(t.get()); @@ -4284,19 +4284,19 @@ void check_recall_event() { bool allow_check = dev.busytype == static_cast(DeviceState::IDLE) || dev.busytype == static_cast(DeviceState::READING_EVENTLOG); - + // 如果你允许“事件抢占文件”,并且当前没有文件 RUNNING,则也允许评估事件: if (!allow_check && dev.busytype == static_cast(DeviceState::READING_STATSFILE)) { bool has_file_running = false; for (const auto& lm2 : dev.line) { if (!lm2.recall_list_static.empty() && - lm2.recall_list_static.front().recall_status == static_cast(RecallStatus::RUNNING)) { + lm2.recall_list_static.front().recall_status != static_cast(RecallStatus::NOT_STARTED)) { has_file_running = true; break; } } if (!has_file_running) allow_check = true; // 没有文件正在跑,允许事件优先 } - + if (!allow_check) { std::cout << "[check_recall_event] skip dev=" << dev.terminal_id << " busytype=" << dev.busytype << std::endl; @@ -4687,6 +4687,7 @@ static bool make_target_key_from_filename(const std::string& fname, std::string& //////////////////////////////////////////////////////////////////////////////////////////////////////////////补招文件匹配事件 //////////////////////////////////////////////////////////////////////////////////////////////////////////////补招文件逻辑 + // ====== ★修改:check_recall_stat —— 加入“两步法”状态机 ====== void check_recall_file() { @@ -4698,6 +4699,7 @@ void check_recall_file() { unsigned short logical_seq = 0; std::vector files_to_send; // 完整路径(含MAC目录) qvvr_data matched{}; // 与 .cfg 匹配到的事件(如有) + qvvr_data mismatched{}; // 未匹配到的事件(如有) bool has_matched = false; // 用于回锁后在台账中定位并删掉对应 qvvr_file 组 std::set sig_names; // 仅文件名集合 @@ -5236,6 +5238,7 @@ void check_recall_file() { // 寻找第一个 .cfg 做匹配 qvvr_data matched{}; + qvvr_data mismatched{}; bool has_matched = false; for (const auto& p : it_qf->file_download) { auto s = sanitize(p); @@ -5248,6 +5251,22 @@ void check_recall_file() { it_qf->is_pair = true; has_matched = true; } + else { + it_qf->is_pair = false; + + long long start_t; + long long trigger_t; + if (extract_timestamp_from_cfg_file(p, start_t, trigger_t)) { + mismatched.QVVR_time = trigger_t; + } else { + mismatched.QVVR_time = 0; // 未能提取时间 + } + // 其他字段置空/置零 + mismatched.QVVR_Amg = 0.0; + mismatched.QVVR_PerTime = 0.0; + mismatched.QVVR_type = 0; + mismatched.phase = 0; + } break; // 只看一个 .cfg } } @@ -5263,6 +5282,7 @@ void check_recall_file() { pu.files_to_send.assign(it_qf->file_download.begin(), it_qf->file_download.end()); // ★修复:list -> vector pu.has_matched = has_matched; pu.matched = matched; + pu.mismatched = mismatched; pu.sig_names = want_names; pu.sig_downs = std::set(pu.files_to_send.begin(), pu.files_to_send.end()); pending_uploads.push_back(std::move(pu)); @@ -5424,6 +5444,22 @@ void check_recall_file() { pu.matched.phase, wavepath); } + else{ + //打印提示:没有从装置读到匹配的事件,使用文件中的数据进行更新 + std::cout << "[Upload] No matched QVVR event from device for terminal=" + << pu.terminal_id << " seq=" << pu.logical_seq + << ", using data extracted from .cfg file for JSON update.\n"; + + transfer_json_qvvr_data(pu.terminal_id, + pu.logical_seq, + //从文件中获取 + pu.mismatched.QVVR_Amg, + pu.mismatched.QVVR_PerTime, + pu.mismatched.QVVR_time, + pu.mismatched.QVVR_type, + pu.mismatched.phase, + wavepath); + } // 3) 删除本地文件 for (const auto& f : pu.files_to_send) { @@ -6611,6 +6647,24 @@ bool get_recall_record_fields_by_guid_monitor(const std::string& guid, return false; } + //将 msg 内的换行符替换为逗号,避免 JSON 解析出错 + { + for (auto& ch : msg) { + if (ch == '\n' || ch == '\r') { + ch = ','; // 统一替换为逗号 + } + } + + // 连续逗号去重(例如 "\n\n" -> ",," -> ",") + while (msg.find(",,") != std::string::npos) { + msg.replace(msg.find(",,"), 2, ","); + } + + // 去除首尾多余的逗号 + if (!msg.empty() && msg.front() == ',') msg.erase(msg.begin()); + if (!msg.empty() && msg.back() == ',') msg.pop_back(); + } + std::cout << "[recall_file] 读取成功: " << filepath << std::endl; return true; }