From 825315440d923899696a953705b6183159ec11ea Mon Sep 17 00:00:00 2001 From: lnk Date: Tue, 16 Sep 2025 16:42:15 +0800 Subject: [PATCH] fix qvvr --- .vscode/settings.json | 3 +- LFtid1056/cloudfront/code/cfg_parser.cpp | 9 ++++- LFtid1056/cloudfront/code/interface.cpp | 48 +++++++++++++++++++++++- LFtid1056/cloudfront/code/interface.h | 5 +++ 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d74d88c..9380919 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -128,5 +128,6 @@ "typeinfo": "cpp", "valarray": "cpp", "variant": "cpp" - } + }, + "cmake.sourceDirectory": "D:/canneng/云前置移植项目/zw/Linux_Front1056/LFtid1056/lib/libuv-v1.51.0" } \ No newline at end of file diff --git a/LFtid1056/cloudfront/code/cfg_parser.cpp b/LFtid1056/cloudfront/code/cfg_parser.cpp index a3341a7..f89354d 100644 --- a/LFtid1056/cloudfront/code/cfg_parser.cpp +++ b/LFtid1056/cloudfront/code/cfg_parser.cpp @@ -3092,8 +3092,13 @@ bool update_qvvr_file_download(const std::string& filename_with_mac, const std:: //找终端 for (auto& dev : terminal_devlist) { - if (dev.terminal_id != terminal_id) continue; - + if (dev.terminal_id != terminal_id) { + std::cout << "[cmp-terminal-id][NOT-MATCH]" + << " dev_id=" << dev.terminal_id + << " target_id=" << terminal_id + << std::endl; + continue; + } //找监测点 for (auto& monitor : dev.line) { try { diff --git a/LFtid1056/cloudfront/code/interface.cpp b/LFtid1056/cloudfront/code/interface.cpp index cd2d288..06a3e9a 100644 --- a/LFtid1056/cloudfront/code/interface.cpp +++ b/LFtid1056/cloudfront/code/interface.cpp @@ -1186,12 +1186,23 @@ int transfer_json_qvvr_data(const std::string& dev_id, ushort monitor_id, // 监测点日志的 key, lnk20250526 if (dev_id.empty()) { - std::cout << "dev_id is null" << std::endl; - return 0; + std::cout << "qvvr send error ,dev_id is null" << std::endl; + return 1; } // 构造 JSON 对象 json root; + + //找监测点id + std::string mpid; + + get_monitor_id_by_dev_and_seq(dev_id, monitor_id, mpid); + if(mpid.empty()) { + std::cout << "qvvr send error ,monitorId is null" << std::endl; + return 1; + } + + root["monitorId"] = mpid; root["devId"] = dev_id; root["CpuNo"] = monitor_id; root["amplitude"] = mag; @@ -1301,3 +1312,36 @@ void handleCommentResponse(const std::string& response) { } } +/////////////////////////////////////////////////////////////////////////////////////////////////////找监测点id +bool get_monitor_id_by_dev_and_seq(const std::string& terminal_id, + unsigned short logical_seq, + std::string& out_monitor_id) +{ + std::lock_guard lk(ledgermtx); // 若你的工程里有全局 ledgermtx/terminal_devlist + + for (const auto& dev : terminal_devlist) { + if (dev.terminal_id != terminal_id) continue; + + // 命中该装置后,仅遍历它的监测点 + for (const auto& mon : dev.line) { + try { + // logical_device_seq 存在台账里是字符串,转成数值再比对 + unsigned long v = std::stoul(mon.logical_device_seq); + unsigned short seq = static_cast(v); + if (seq == logical_seq) { + out_monitor_id = mon.monitor_id; + return true; + } + } catch (...) { + + // 非法数值(空/非数字等)直接跳过 + continue; + } + } + break; // 已找到对应装置,没必要再看其它装置 + } + return false; +} + + + diff --git a/LFtid1056/cloudfront/code/interface.h b/LFtid1056/cloudfront/code/interface.h index 818b603..ae8b485 100644 --- a/LFtid1056/cloudfront/code/interface.h +++ b/LFtid1056/cloudfront/code/interface.h @@ -650,6 +650,11 @@ void on_device_response_minimal(int response_code, unsigned char cid, int device_state_int); +//找监测点id +bool get_monitor_id_by_dev_and_seq(const std::string& terminal_id, + unsigned short logical_seq, + std::string& out_monitor_id); + //处理补招的任务 void check_recall_event(); void check_recall_file();