台账更新添加comtype
This commit is contained in:
@@ -1704,6 +1704,8 @@ void add_terminal_to_trigger_update(trigger_update_xml_t* trigger_update_xml, co
|
||||
}
|
||||
}
|
||||
|
||||
static bool terminal_update_should_bind_to_current_process(const terminal* dev);
|
||||
|
||||
// 解析 XML 数据并提取 terminal 信息
|
||||
void parse_terminal_from_data(trigger_update_xml_t* trigger_update_xml, const std::string& str_tag, const std::string& data,const std::string& guid_value) {
|
||||
terminal work_terminal = {}; // 创建新的 terminal 对象
|
||||
@@ -1719,6 +1721,13 @@ void parse_terminal_from_data(trigger_update_xml_t* trigger_update_xml, const st
|
||||
strcpy(work_terminal.dev_type, extract_value(data, "devType").c_str());
|
||||
strcpy(work_terminal.dev_key, extract_value(data, "devKey").c_str());
|
||||
strcpy(work_terminal.dev_series, extract_value(data, "series").c_str());
|
||||
std::string com_type = extract_value(data, "comType");
|
||||
if (com_type.empty())
|
||||
com_type = extract_value(data, "com_type");
|
||||
if (com_type.empty())
|
||||
com_type = "MMS";
|
||||
strncpy(work_terminal.com_type, com_type.c_str(), sizeof(work_terminal.com_type) - 1);
|
||||
work_terminal.com_type[sizeof(work_terminal.com_type) - 1] = '\0';
|
||||
strcpy(work_terminal.processNo, extract_value(data, "processNo").c_str());
|
||||
strcpy(work_terminal.addr_str, extract_value(data, "ip").c_str());
|
||||
strcpy(work_terminal.port, extract_value(data, "port").c_str());
|
||||
@@ -1805,6 +1814,13 @@ void parse_terminal_from_data(trigger_update_xml_t* trigger_update_xml, const st
|
||||
|
||||
|
||||
// 根据 str_tag 将 terminal 添加到相应的数组
|
||||
if (!terminal_update_should_bind_to_current_process(&work_terminal)) {
|
||||
std::cout << "skip ledger update xml by comType:" << work_terminal.com_type
|
||||
<< " terminal:" << work_terminal.terminal_id
|
||||
<< " process:" << subdir << g_front_seg_index << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
add_terminal_to_trigger_update(trigger_update_xml, str_tag, work_terminal);
|
||||
}
|
||||
|
||||
@@ -1825,11 +1841,25 @@ void parse_ledger_update(trigger_update_xml_t* trigger_update_xml, const std::st
|
||||
if (strTag == "delete") {
|
||||
// 填充终端信息
|
||||
strcpy(delete_terminal.terminal_id, extract_value(data, "id").c_str());
|
||||
std::string com_type = extract_value(data, "comType");
|
||||
if (com_type.empty())
|
||||
com_type = extract_value(data, "com_type");
|
||||
if (com_type.empty())
|
||||
com_type = "MMS";
|
||||
strncpy(delete_terminal.com_type, com_type.c_str(), sizeof(delete_terminal.com_type) - 1);
|
||||
delete_terminal.com_type[sizeof(delete_terminal.com_type) - 1] = '\0';
|
||||
|
||||
//添加guid20250506
|
||||
strncpy(delete_terminal.guid, guid_value.c_str(), sizeof(delete_terminal.guid) - 1);
|
||||
delete_terminal.guid[sizeof(delete_terminal.guid) - 1] = '\0';
|
||||
|
||||
if (!terminal_update_should_bind_to_current_process(&delete_terminal)) {
|
||||
std::cout << "skip delete ledger update xml by comType:" << delete_terminal.com_type
|
||||
<< " terminal:" << delete_terminal.terminal_id
|
||||
<< " process:" << subdir << g_front_seg_index << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// 将删除信息写入 delete_updates
|
||||
std::cout << "delete ledger!!!!!"<<std::endl;
|
||||
if (trigger_update_xml->delete_update_num < MAX_UPDATEA_NUM) {
|
||||
@@ -3400,7 +3430,7 @@ static bool is_cfg_pqdif_process()
|
||||
static bool is_pqdif_com_type(const char* com_type)
|
||||
{
|
||||
QString type = com_type ? QString::fromLocal8Bit(com_type).trimmed() : QString();
|
||||
return type.compare("pqdif", Qt::CaseInsensitive) == 0;
|
||||
return type.compare("PQDIF", Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
|
||||
static bool terminal_should_bind_to_current_process(const terminal_dev* dev)
|
||||
@@ -3417,6 +3447,20 @@ static bool terminal_should_bind_to_current_process(const terminal_dev* dev)
|
||||
return (atoi(dev->processNo) == g_front_seg_index || g_front_seg_index == 0);
|
||||
}
|
||||
|
||||
static bool terminal_update_should_bind_to_current_process(const terminal* dev)
|
||||
{
|
||||
if (dev == NULL)
|
||||
return false;
|
||||
|
||||
if (is_pqdif_com_type(dev->com_type))
|
||||
return is_cfg_pqdif_process();
|
||||
|
||||
if (is_cfg_pqdif_process())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void printTerminalDevMap(const QMap<QString, terminal_dev*>& terminal_dev_map) {
|
||||
QMap<QString, terminal_dev*>::const_iterator it;
|
||||
for (it = terminal_dev_map.constBegin(); it != terminal_dev_map.constEnd(); ++it) {
|
||||
@@ -3470,6 +3514,7 @@ void printLedger(const ied_usr_t& ied_usr) {
|
||||
std::cout << "|-- dev_type: " << ied_usr.dev_type << std::endl;
|
||||
std::cout << "|-- dev_key: " << ied_usr.dev_key << std::endl;
|
||||
std::cout << "|-- dev_series: " << ied_usr.dev_series << std::endl;
|
||||
std::cout << "|-- com_type: " << ied_usr.com_type << std::endl;
|
||||
std::cout << "|-- dev_flag: " << ied_usr.dev_flag << std::endl;
|
||||
|
||||
std::cout << "|-- last_call_wavelist_time: " << ied_usr.last_call_wavelist_time << std::endl;
|
||||
@@ -3564,6 +3609,7 @@ void printLedgerinshell(const ied_usr_t& ied_usr, QIODevice* outputDevice) {
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- dev_type: " + QByteArray(ied_usr.dev_type) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- dev_key: " + QByteArray(ied_usr.dev_key) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- dev_series: " + QByteArray(ied_usr.dev_series) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- com_type: " + QByteArray(ied_usr.com_type) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- dev_processNo: " + QByteArray(ied_usr.processNo) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- dev_flag: " + QByteArray::number(ied_usr.dev_flag) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- last_call_wavelist_time: " + QByteArray::number(ied_usr.last_call_wavelist_time) + "\n");
|
||||
@@ -4119,7 +4165,7 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
|
||||
if (comType == NULL)
|
||||
comType = cJSON_GetObjectItem(item, "com_type");
|
||||
if (comType && comType->type == cJSON_String) strncpy(dev->com_type, comType->valuestring, sizeof(dev->com_type) - 1);
|
||||
else strncpy(dev->com_type, "mms", sizeof(dev->com_type) - 1);
|
||||
else strncpy(dev->com_type, "MMS", sizeof(dev->com_type) - 1);
|
||||
dev->com_type[sizeof(dev->com_type) - 1] = '\0';
|
||||
|
||||
//lnk20250210台账进程号
|
||||
@@ -4409,6 +4455,7 @@ int parse_device_cfg_web()
|
||||
char dev_type[64];
|
||||
char dev_key[255];
|
||||
char dev_series[255];
|
||||
char com_type[32];
|
||||
char addr_str[64];
|
||||
char port_char[64];
|
||||
|
||||
@@ -4438,6 +4485,8 @@ int parse_device_cfg_web()
|
||||
strncpy(dev_type, value->dev_type, sizeof(dev_type) - 1);
|
||||
strncpy(dev_key, value->dev_key, sizeof(dev_key) - 1);
|
||||
strncpy(dev_series, value->dev_series, sizeof(dev_series) - 1);
|
||||
strncpy(com_type, value->com_type, sizeof(com_type) - 1);
|
||||
com_type[sizeof(com_type) - 1] = '\0';
|
||||
strncpy(addr_str, value->addr_str, sizeof(addr_str) - 1);
|
||||
strncpy(port_char, value->port, sizeof(port_char) - 1);
|
||||
strncpy(processNo, value->processNo, sizeof(processNo) - 1);//进程号
|
||||
@@ -4503,6 +4552,14 @@ int parse_device_cfg_web()
|
||||
cout << "ied_usr->dev_type:" << ied_usr->dev_type << endl;
|
||||
}
|
||||
//lnk20250210台账进程号
|
||||
if (com_type != NULL && com_type[0] != '\0') {
|
||||
apr_snprintf(ied_usr->com_type, sizeof(ied_usr->com_type), "%s", com_type);//comType
|
||||
cout << "ied_usr->com_type:" << ied_usr->com_type << endl;
|
||||
}
|
||||
else {
|
||||
apr_snprintf(ied_usr->com_type, sizeof(ied_usr->com_type), "%s", "MMS");
|
||||
cout << "ied_usr->com_type(default):" << ied_usr->com_type << endl;
|
||||
}
|
||||
if (processNo != NULL) {
|
||||
apr_snprintf(ied_usr->processNo, sizeof(ied_usr->processNo), "%s", processNo);//processNo
|
||||
cout << "ied_usr->processNo:" << ied_usr->processNo << endl;
|
||||
@@ -5772,6 +5829,13 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i
|
||||
apr_snprintf(ied_usr->dev_type, sizeof(ied_usr->dev_type), "%s", update[i].dev_type);
|
||||
printf("ied_usr->dev_type: %s\n", ied_usr->dev_type);
|
||||
}
|
||||
if (update[i].com_type != NULL && update[i].com_type[0] != '\0') {
|
||||
apr_snprintf(ied_usr->com_type, sizeof(ied_usr->com_type), "%s", update[i].com_type);
|
||||
printf("ied_usr->com_type: %s\n", ied_usr->com_type);
|
||||
} else {
|
||||
apr_snprintf(ied_usr->com_type, sizeof(ied_usr->com_type), "%s", "MMS");
|
||||
printf("ied_usr->com_type (default): %s\n", ied_usr->com_type);
|
||||
}
|
||||
if (update[i].processNo != NULL) {
|
||||
apr_snprintf(ied_usr->processNo, sizeof(ied_usr->processNo), "%s", update[i].processNo);
|
||||
printf("ied_usr->processNo: %s\n", ied_usr->processNo);
|
||||
@@ -6602,6 +6666,7 @@ void clearIedUsr(ied_usr_t *ied_usr) {
|
||||
memset(ied_usr->dev_type, 0, sizeof(ied_usr->dev_type));
|
||||
memset(ied_usr->dev_key, 0, sizeof(ied_usr->dev_key));
|
||||
memset(ied_usr->dev_series, 0, sizeof(ied_usr->dev_series));
|
||||
memset(ied_usr->com_type, 0, sizeof(ied_usr->com_type));
|
||||
memset(ied_usr->terminal_id, 0, sizeof(ied_usr->terminal_id));
|
||||
memset(ied_usr->org_name, 0, sizeof(ied_usr->org_name));
|
||||
memset(ied_usr->maint_name, 0, sizeof(ied_usr->maint_name));
|
||||
|
||||
Reference in New Issue
Block a user