modify ledger

This commit is contained in:
lnk
2025-06-26 14:39:34 +08:00
parent 3dc54a9b75
commit 4e6ba12b25
7 changed files with 295 additions and 28 deletions

View File

@@ -754,7 +754,7 @@ bool parseJsonMessageUD(const std::string& json_str, const std::string& output_d
terminal_dev json_data;
json_data.terminal_id = item.value("id", "");
json_data.terminal_code = item.value("name", "");
json_data.terminal_name = item.value("name", "");
json_data.org_name = item.value("org_name", "");
json_data.maint_name = item.value("maint_name", "");
json_data.station_name = item.value("stationName", "");
@@ -783,7 +783,7 @@ bool parseJsonMessageUD(const std::string& json_str, const std::string& output_d
m.logical_device_seq = monitor_item.value("lineNo", "");
m.terminal_connect = monitor_item.value("ptType", "");
m.timestamp = json_data.timestamp;
m.terminal_code = json_data.terminal_code;
m.terminal_id = json_data.terminal_id;
}
}
@@ -1180,7 +1180,7 @@ std::string prepare_update(const std::string& code_str, const terminal_dev& json
xmlStream << "<stationName>" << json_data.station_name << "</stationName>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<terminalCode>" << json_data.terminal_code << "</terminalCode>" << std::endl;
xmlStream << "<terminalCode>" << json_data.terminal_name << "</terminalCode>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<updateTime>" << json_data.timestamp << "</updateTime>" << std::endl; // Assuming `timestamp`
@@ -1201,6 +1201,9 @@ std::string prepare_update(const std::string& code_str, const terminal_dev& json
add_indent(xmlStream, indentLevel);
xmlStream << "<devKey>" << json_data.dev_key << "</devKey>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<mac>" << json_data.mac << "</mac>" << std::endl;
// monitorData 部分
for (int i = 0; json_data.line[i].monitor_id[0] != '\0'; i++) {
const ledger_monitor& monitor = json_data.line[i];
@@ -1228,9 +1231,21 @@ std::string prepare_update(const std::string& code_str, const terminal_dev& json
xmlStream << "<timestamp>" << monitor.timestamp << "</timestamp>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<terminal_code>" << monitor.terminal_code << "</terminal_code>" << std::endl;
xmlStream << "<terminal_id>" << monitor.terminal_id << "</terminal_id>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<CT1>" << monitor.CT1 << "</CT1>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<CT2>" << monitor.CT2 << "</CT2>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<PT1>" << monitor.PT1 << "</PT1>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<PT2>" << monitor.PT2 << "</PT2>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<status>" << monitor.status << "</status>" << std::endl;
indentLevel--;