fix single recall wave
This commit is contained in:
BIN
LFtid1056.rar
BIN
LFtid1056.rar
Binary file not shown.
@@ -1333,8 +1333,8 @@ int recall_json_handle_from_mq(const std::string& body)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dt == 2) { //一个测点一个guid对应多个文件
|
if (dt == 2) { //一个测点一个guid对应多个文件
|
||||||
// ▲直下文件:timeList -> fun1/fun2 -> enqueue_direct_download
|
// ▲直下文件:timeInterval -> fun1/fun2 -> enqueue_direct_download
|
||||||
if (!rec.contains("timeList") || !rec["timeList"].is_array()) continue;
|
if (!rec.contains("timeInterval") || !rec["timeInterval"].is_array()) continue;
|
||||||
|
|
||||||
for (const auto& monId : monitors) {
|
for (const auto& monId : monitors) {
|
||||||
// fun1:提取 monitor 数字
|
// fun1:提取 monitor 数字
|
||||||
@@ -1345,7 +1345,7 @@ int recall_json_handle_from_mq(const std::string& body)
|
|||||||
init_recall_record_file(guid, terminalId, monId, "", "");
|
init_recall_record_file(guid, terminalId, monId, "", "");
|
||||||
|
|
||||||
//根据时间戳单独补招事件
|
//根据时间戳单独补招事件
|
||||||
// ★新增(dt==2 同步生成“按小时”的事件补招到 recall_list,与 dt==1 逻辑一致)——开始
|
if(0)// ★新增(dt==2 同步生成“按小时”的事件补招到 recall_list,与 dt==1 逻辑一致)——开始
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock2(ledgermtx); // 复用与 dt==1 相同的加锁粒度
|
std::lock_guard<std::mutex> 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; }
|
if (!lm) { std::cout << "monitorId未在terminal内找到(直下事件回灌): " << monId << " @ " << terminalId << std::endl; continue; }
|
||||||
|
|
||||||
// 将 timeList 的每个时间点映射为 [该整点, 下一整点) 的一小时窗口
|
// 将 timeList 的每个时间点映射为 [该整点, 下一整点) 的一小时窗口
|
||||||
for (const auto& t : rec["timeList"]) {
|
for (const auto& t : rec["timeInterval"]) {
|
||||||
if (!t.is_string()) continue;
|
if (!t.is_string()) continue;
|
||||||
std::string tstr = t.get<std::string>();
|
std::string tstr = t.get<std::string>();
|
||||||
|
|
||||||
@@ -1387,7 +1387,7 @@ int recall_json_handle_from_mq(const std::string& body)
|
|||||||
// ★新增(dt==2 同步生成“按小时”的事件补招到 recall_list,与 dt==1 逻辑一致)——结束
|
// ★新增(dt==2 同步生成“按小时”的事件补招到 recall_list,与 dt==1 逻辑一致)——结束
|
||||||
//根据时间戳单独补招事件
|
//根据时间戳单独补招事件
|
||||||
|
|
||||||
for (const auto& t : rec["timeList"]) {
|
for (const auto& t : rec["timeInterval"]) {
|
||||||
if (!t.is_string()) continue;
|
if (!t.is_string()) continue;
|
||||||
|
|
||||||
std::string ts_compact = compact_ts_for_filename(t.get<std::string>());
|
std::string ts_compact = compact_ts_for_filename(t.get<std::string>());
|
||||||
@@ -4290,7 +4290,7 @@ void check_recall_event() {
|
|||||||
bool has_file_running = false;
|
bool has_file_running = false;
|
||||||
for (const auto& lm2 : dev.line) {
|
for (const auto& lm2 : dev.line) {
|
||||||
if (!lm2.recall_list_static.empty() &&
|
if (!lm2.recall_list_static.empty() &&
|
||||||
lm2.recall_list_static.front().recall_status == static_cast<int>(RecallStatus::RUNNING)) {
|
lm2.recall_list_static.front().recall_status != static_cast<int>(RecallStatus::NOT_STARTED)) {
|
||||||
has_file_running = true; break;
|
has_file_running = true; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4687,6 +4687,7 @@ static bool make_target_key_from_filename(const std::string& fname, std::string&
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////补招文件匹配事件
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////补招文件匹配事件
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////补招文件逻辑
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////补招文件逻辑
|
||||||
|
|
||||||
// ====== ★修改:check_recall_stat —— 加入“两步法”状态机 ======
|
// ====== ★修改:check_recall_stat —— 加入“两步法”状态机 ======
|
||||||
void check_recall_file() {
|
void check_recall_file() {
|
||||||
|
|
||||||
@@ -4698,6 +4699,7 @@ void check_recall_file() {
|
|||||||
unsigned short logical_seq = 0;
|
unsigned short logical_seq = 0;
|
||||||
std::vector<std::string> files_to_send; // 完整路径(含MAC目录)
|
std::vector<std::string> files_to_send; // 完整路径(含MAC目录)
|
||||||
qvvr_data matched{}; // 与 .cfg 匹配到的事件(如有)
|
qvvr_data matched{}; // 与 .cfg 匹配到的事件(如有)
|
||||||
|
qvvr_data mismatched{}; // 未匹配到的事件(如有)
|
||||||
bool has_matched = false;
|
bool has_matched = false;
|
||||||
// 用于回锁后在台账中定位并删掉对应 qvvr_file 组
|
// 用于回锁后在台账中定位并删掉对应 qvvr_file 组
|
||||||
std::set<std::string> sig_names; // 仅文件名集合
|
std::set<std::string> sig_names; // 仅文件名集合
|
||||||
@@ -5236,6 +5238,7 @@ void check_recall_file() {
|
|||||||
|
|
||||||
// 寻找第一个 .cfg 做匹配
|
// 寻找第一个 .cfg 做匹配
|
||||||
qvvr_data matched{};
|
qvvr_data matched{};
|
||||||
|
qvvr_data mismatched{};
|
||||||
bool has_matched = false;
|
bool has_matched = false;
|
||||||
for (const auto& p : it_qf->file_download) {
|
for (const auto& p : it_qf->file_download) {
|
||||||
auto s = sanitize(p);
|
auto s = sanitize(p);
|
||||||
@@ -5248,6 +5251,22 @@ void check_recall_file() {
|
|||||||
it_qf->is_pair = true;
|
it_qf->is_pair = true;
|
||||||
has_matched = 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
|
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.files_to_send.assign(it_qf->file_download.begin(), it_qf->file_download.end()); // ★修复:list -> vector
|
||||||
pu.has_matched = has_matched;
|
pu.has_matched = has_matched;
|
||||||
pu.matched = matched;
|
pu.matched = matched;
|
||||||
|
pu.mismatched = mismatched;
|
||||||
pu.sig_names = want_names;
|
pu.sig_names = want_names;
|
||||||
pu.sig_downs = std::set<std::string>(pu.files_to_send.begin(), pu.files_to_send.end());
|
pu.sig_downs = std::set<std::string>(pu.files_to_send.begin(), pu.files_to_send.end());
|
||||||
pending_uploads.push_back(std::move(pu));
|
pending_uploads.push_back(std::move(pu));
|
||||||
@@ -5424,6 +5444,22 @@ void check_recall_file() {
|
|||||||
pu.matched.phase,
|
pu.matched.phase,
|
||||||
wavepath);
|
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) 删除本地文件
|
// 3) 删除本地文件
|
||||||
for (const auto& f : pu.files_to_send) {
|
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;
|
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;
|
std::cout << "[recall_file] 读取成功: " << filepath << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user