数据追踪增加接线方式和来源
This commit is contained in:
@@ -316,15 +316,19 @@ static QString build_mms_json_object(const json_block_data* data)
|
||||
return json;
|
||||
}
|
||||
|
||||
static QString build_trace_json(const json_block_data* data)
|
||||
static QString build_trace_json(const json_block_data* data, const char *v_wiring_type, const char *source_name)
|
||||
{
|
||||
if (!data) return "{}";
|
||||
|
||||
QString mms_json = build_mms_json_object(data);
|
||||
QString wiring_type = v_wiring_type ? QString::fromLocal8Bit(v_wiring_type) : "";
|
||||
QString source = source_name ? QString::fromLocal8Bit(source_name) : "";
|
||||
|
||||
QString json;
|
||||
json += "{";
|
||||
json += QString("\"mp_id\":\"%1\",").arg(escape_json_string(data->mp_id));
|
||||
json += QString("\"v_wiring_type\":\"%1\",").arg(escape_json_string(wiring_type));
|
||||
json += QString("\"source_name\":\"%1\",").arg(escape_json_string(source));
|
||||
json += QString("\"func_type\":%1,").arg(data->func_type);
|
||||
json += QString("\"data_time\":%1,").arg(QString::number((qlonglong)data->time));
|
||||
json += QString("\"voltage_level\":\"%1\",").arg(QString::number(data->voltage_level, 'f', 6));
|
||||
@@ -335,13 +339,13 @@ static QString build_trace_json(const json_block_data* data)
|
||||
return json;
|
||||
}
|
||||
|
||||
static void send_trace_if_needed(json_block_data* pdata)
|
||||
static void send_trace_if_needed(json_block_data* pdata, const char *v_wiring_type, const char *source_name)
|
||||
{
|
||||
const QString mp_id_q = pdata->mp_id;
|
||||
if (trace_is_enabled(mp_id_q)) {
|
||||
|
||||
// 1) 组 json
|
||||
QString jsonText = build_trace_json(pdata);
|
||||
QString jsonText = build_trace_json(pdata, v_wiring_type, source_name);
|
||||
|
||||
// 2) 组 KafkaData
|
||||
Ckafka_data_t KafkaData;
|
||||
@@ -1210,7 +1214,7 @@ static void print_mms_str_map(const json_block_data* data)
|
||||
}
|
||||
|
||||
//20250214添加角型接线处理
|
||||
int transfer_json_block_data(char v_wiring_type[], json_block_data *data) //json生成函数 zw修改 2023-8-11 调整传送json结构 目前仅限历史稳态数据
|
||||
int transfer_json_block_data(char v_wiring_type[], json_block_data *data, const char *source_name) //json生成函数 zw修改 2023-8-11 调整传送json结构 目前仅限历史稳态数据
|
||||
{
|
||||
// 刚进函数就打印 mms_str_map
|
||||
if (DEBUGOPEN) {
|
||||
@@ -1218,7 +1222,7 @@ int transfer_json_block_data(char v_wiring_type[], json_block_data *data) //json
|
||||
}
|
||||
|
||||
//数据追踪上送
|
||||
send_trace_if_needed(data);
|
||||
send_trace_if_needed(data, v_wiring_type, source_name);
|
||||
|
||||
list<CTopic*> ctopic_list;
|
||||
|
||||
@@ -3763,4 +3767,3 @@ void Set_xml_nodeinfo_one(char* dev_type)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
int list_num;
|
||||
};
|
||||
|
||||
int transfer_json_block_data(char v_wiring_type[], json_block_data* data);//lnk2024-8-16添加参数
|
||||
int transfer_json_block_data(char v_wiring_type[], json_block_data* data, const char *source_name);//lnk2024-8-16添加参数
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -95,4 +95,4 @@ void connectlog_pgsql(char* id,char* datetime,int status);
|
||||
#endif
|
||||
|
||||
|
||||
#endif //MMS_JSON_INTER_92327hyhy0923r_H
|
||||
#endif //MMS_JSON_INTER_92327hyhy0923r_H
|
||||
|
||||
@@ -3635,13 +3635,14 @@ int json_block_create_data(char monid_char[], char* mms_str, double v, int flick
|
||||
|
||||
|
||||
//lnk2024-8-16添加接线参数
|
||||
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag)//WW 2023年3月13日16:38:41 多ICD修改
|
||||
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag, const char *source_name)//WW 2023年3月13日16:38:41 多ICD修改
|
||||
{
|
||||
const char *end_source = (source_name && source_name[0]) ? source_name : "unknown";
|
||||
json_block_data* pdata;
|
||||
if (flicker_flag == 1) {
|
||||
if (!json_flicker_data_map.contains(monid_char))//未查到数据
|
||||
{
|
||||
printf("---------- json_block_create_end: mp_id= %s json_flicker_data_map can't find MonitorId----------\n", monid_char);
|
||||
printf("---------- json_block_create_end: source=%s mp_id= %s json_flicker_data_map can't find MonitorId----------\n", end_source, monid_char);
|
||||
return 1;
|
||||
}
|
||||
pdata = json_flicker_data_map.value(monid_char);
|
||||
@@ -3650,7 +3651,7 @@ int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_f
|
||||
{
|
||||
if (!json_data_map.contains(monid_char))//未查到数据
|
||||
{
|
||||
printf("---------- json_block_create_end: mp_id= %s json_data_map can't find MonitorId----------\n", monid_char);
|
||||
printf("---------- json_block_create_end: source=%s mp_id= %s json_data_map can't find MonitorId----------\n", end_source, monid_char);
|
||||
return 1;
|
||||
}
|
||||
pdata = json_data_map.value(monid_char);
|
||||
@@ -3659,7 +3660,7 @@ int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_f
|
||||
{
|
||||
if (!json_pst_data_map.contains(monid_char))//未查到数据
|
||||
{
|
||||
printf("---------- json_block_create_end: mp_id= %s json_pst_data_map can't find MonitorId----------\n", monid_char);
|
||||
printf("---------- json_block_create_end: source=%s mp_id= %s json_pst_data_map can't find MonitorId----------\n", end_source, monid_char);
|
||||
return 1;
|
||||
}
|
||||
pdata = json_pst_data_map.value(monid_char);
|
||||
@@ -3693,11 +3694,11 @@ int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_f
|
||||
json_pst_data_map.remove(monid_char);
|
||||
|
||||
}
|
||||
printf("---------- json_block_create_end: pdata->mms_str_map.count() == 0 ----------\n");
|
||||
printf("---------- json_block_create_end: source=%s mp_id= %s pdata->mms_str_map.count() == 0 ----------\n", end_source, monid_char);
|
||||
return 1;
|
||||
}
|
||||
//lnk2024-8-16添加接线参数
|
||||
int ret = transfer_json_block_data(v_wiring_type, pdata);
|
||||
int ret = transfer_json_block_data(v_wiring_type, pdata, end_source);
|
||||
|
||||
if (pdata != NULL)
|
||||
delete pdata;
|
||||
@@ -3714,7 +3715,7 @@ int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_f
|
||||
json_pst_data_map.remove(monid_char);
|
||||
|
||||
}
|
||||
printf("---------- json_block_create_end: MonitorId= %s ----------\n", monid_char);
|
||||
printf("---------- json_block_create_end: source=%s MonitorId= %s ----------\n", end_source, monid_char);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3878,4 +3879,4 @@ int sel_mvl_type_ctrl_flag(char doname[])
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//ZW 2024-01-31 end
|
||||
//ZW 2024-01-31 end
|
||||
|
||||
Reference in New Issue
Block a user