fix qvvr
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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<std::mutex> 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<unsigned short>(v);
|
||||
if (seq == logical_seq) {
|
||||
out_monitor_id = mon.monitor_id;
|
||||
return true;
|
||||
}
|
||||
} catch (...) {
|
||||
|
||||
// 非法数值(空/非数字等)直接跳过
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break; // 已找到对应装置,没必要再看其它装置
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user