the heartbeat reply ledgerupdate is ok

This commit is contained in:
lnk
2025-05-12 16:43:42 +08:00
parent 8a2e6ea537
commit a6685ca801
9 changed files with 171 additions and 192 deletions

View File

@@ -221,7 +221,7 @@ char* UDS_DELETE_URL;
int FILE_FLAG;
int SEND_FLAG;
int FRONT_INST;
std::string FRONT_INST;//lnk20250512改为string
char* FRONT_IP;
int CITY_FLAG;
@@ -331,10 +331,16 @@ extern pthread_mutex_t mtx;
/*lnk 2024-10-21 */
std::string intToString(int number);
//lnk20250512
void send_heartbeat_to_kafka(const std::string& status);
//////////////////////////////////////////////////////////////////////////
extern int server_socket; //Web Socket服务端实例
extern unsigned int g_node_id; //前置程序类型(100-500)
extern QMutex kafka_data_list_mutex; //Kafka发送数据锁
extern QList<Ckafka_data_t> kafka_data_list; //kafka发送数据链表
//WW 2023-08-20 end
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -401,8 +407,13 @@ void init_config() {
qDebug() << "Read SEND_FLAG:" << SEND_FLAG << endl;
FILE_FLAG = settings.value("Flag/FileFlag", 0).toInt();
qDebug() << "Read FILE_FLAG:" << FILE_FLAG << endl;
FRONT_INST = settings.value("Flag/FrontInst", 0).toInt();
qDebug() << "Read FRONT_INST:" << FRONT_INST << endl;
//FRONT_INST = settings.value("Flag/FrontInst", 0).toInt();
//qDebug() << "Read FRONT_INST:" << FRONT_INST << endl;
ba = settings.value("Flag/FrontInst", "").toString().toLatin1();
FRONT_INST = strdup(ba.data());
std::cout << "Read FRONT_INST:" << FRONT_INST << endl;
ba = settings.value("Flag/FrontIP", "").toString().toLatin1();
FRONT_IP = strdup(ba.data());
qDebug() << "Read FRONT_IP:" << FRONT_IP << endl;
@@ -686,6 +697,12 @@ void init_config() {
std::cout << "Read G_CONNECT_TOPIC:" << G_CONNECT_TOPIC << std::endl;
std::cout << "Read G_CONNECT_TAG:" << G_CONNECT_TAG << std::endl;
std::cout << "Read G_CONNECT_KEY:" << G_CONNECT_KEY << std::endl;
std::cout << "Read Heart_Beat_Topic:" << Heart_Beat_Topic << std::endl;
std::cout << "Read Heart_Beat_Tag:" << Heart_Beat_Tag << std::endl;
std::cout << "Read Heart_Beat_Key:" << Heart_Beat_Key << std::endl;
std::cout << "Read Topic_Reply_Topic:" << Topic_Reply_Topic << std::endl;
std::cout << "Read Topic_Reply_Tag:" << Topic_Reply_Tag << std::endl;
std::cout << "Read Topic_Reply_Key:" << Topic_Reply_Key << std::endl;
//消费者相关打印
std::cout << "Read G_ROCKETMQ_CONSUMER:" << G_ROCKETMQ_CONSUMER << std::endl;
std::cout << "Read G_MQCONSUMER_IPPORT:" << G_MQCONSUMER_IPPORT << std::endl;
@@ -3525,28 +3542,6 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
return 1;
}
//后续修改为根据index来获取对应的台账将不再均分获取所有台账并判断进程号
#if 0
int base_size = 0;
int remainder = 0;
int start_index = 0;
int end_index = data_size;
if(1 == MULTIPLE_NODE_FLAG){
// 计算每份的大小
base_size = data_size / num;
remainder = data_size % num;
// 计算当前份的起始和结束索引
start_index = index * base_size + (index < remainder ? index : remainder);
end_index = start_index + base_size + (index < remainder ? 1 : 0);
// 确保结束索引不超过数组大小
if (end_index > data_size) {
end_index = data_size;
}
}
#endif
int start_index = 0;
int end_index = data_size;
@@ -4287,7 +4282,7 @@ int parse_model_cfg_web()
}
}
////////////////////////////////////////////////////////////icd模型重构函数lnk20250116
char* parse_model_cfg_web_one(ied_t* ied)
char* parse_model_cfg_web_one(ied_t* ied, char* out_model)
{
std::vector<std::string> codes;//入参集合
QMap<QString, icd_model*> icd_model_map;
@@ -4323,19 +4318,28 @@ char* parse_model_cfg_web_one(ied_t* ied)
if (value != nullptr) {
// 找到容器中对应名称并取值
strncpy(model_id, value->model_id, sizeof(model_id) - 1);
model_id[sizeof(model_id) - 1] = '\0';
strncpy(tmnl_type, value->tmnl_type, sizeof(tmnl_type) - 1);
strncpy(file_path, value->file_path, sizeof(file_path) - 1);
strncpy(file_name, value->file_name, sizeof(file_name) - 1);
std::cout << "model_id" << model_id << std::endl;
std::cout << "tmnl_type" << tmnl_type << std::endl;
std::cout << "filepath" << file_path << std::endl;
std::cout << "filename" << file_name << std::endl;
std::cout << "model_id:" << model_id << std::endl;
std::cout << "tmnl_type:" << tmnl_type << std::endl;
std::cout << "filepath:" << file_path << std::endl;
std::cout << "filename:" << file_name << std::endl;
Set_xml_databaseinfo(model_id, tmnl_type, file_path, file_name, timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second);
}
if (out_model != NULL) {
strncpy(out_model, model_id, 64);
out_model[63] = '\0';
}
return model_id;
}
}
return model_id;
}
catch (otl_exception& e)
{
@@ -4377,8 +4381,11 @@ void OnTimerThread::run()
int pgmin = 0;
int mp_num_hour = 0;
//添加入参容器
std::vector<std::string> codes;
//时间计数用
int counter = 0;
//初始化发送一次心跳
send_heartbeat_to_kafka("1");
while (1)
{
@@ -4408,6 +4415,13 @@ void OnTimerThread::run()
//添加日志开关控制lnk20250508
update_log_entries_countdown();
//添加进程心跳
if (counter >= 30) {
send_heartbeat_to_kafka("1"); // 每30秒发送一次心跳
counter = 0;
}
counter++;
msleep(1000);
}
printf(">>>OnTimerThread::run() is end!!!\n");
@@ -4611,37 +4625,7 @@ bool threadmsghttp(int fun);
#ifdef __cplusplus
}
#endif
#if 0
void RecallJsonResponse(int result) {
char* ptr=NULL;
// 创建 JSON 对象
cJSON* json_response = cJSON_CreateObject();
// 添加字段
if(result == 000000){
cJSON_AddStringToObject(json_response, "code", "A0000");
cJSON_AddStringToObject(json_response, "msg", "数据补招执行成功");
}
else{
cJSON_AddStringToObject(json_response, "code", "A0002");
cJSON_AddStringToObject(json_response, "msg", "数据补招执行失败");
}
cJSON_AddNullToObject(json_response, "data"); // 设置为 null
// 将 JSON 对象转换为字符串
char* json_string = cJSON_Print(json_response);
std::cout << json_string << std::endl;
//发送回复给对方,只发一次
SendJsonAPI_web("调用方", "", json_string ,&ptr);
// 清理
cJSON_Delete(json_response);
free(json_string); // 释放打印字符串的内存
}
#endif
void WebhttpThread::run()
{