2025-01-16 16:17:01 +08:00
|
|
|
/**
|
|
|
|
|
* @file: $RCSfile: db_interface.h,v $
|
|
|
|
|
* @brief: $IEC 61850 Protocol
|
|
|
|
|
*
|
|
|
|
|
* @version: $Revision: 1.12 $
|
|
|
|
|
* @date: $Date: 2019/01/12 08:44:26 $
|
|
|
|
|
* @author: $Author: lizhongming $
|
|
|
|
|
* @state: $State: Exp $
|
|
|
|
|
*
|
|
|
|
|
* @latest: $Id: db_interface.h,v 1.12 2019/01/12 08:44:26 lizhongming Exp $
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef DB_INTERFACE_7ew2327hyhy0923r_H
|
|
|
|
|
#define DB_INTERFACE_7ew2327hyhy0923r_H
|
|
|
|
|
|
|
|
|
|
#include "apr_time.h"
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>//lnk20241022
|
|
|
|
|
|
|
|
|
|
#define LOG_IDX (0)
|
|
|
|
|
#define RPT_IDX (1)
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
#define INVALID_DEV_IDX -1
|
|
|
|
|
|
|
|
|
|
#define STAT_DATA_BASE_NODE_ID 100
|
|
|
|
|
#define THREE_SECS_DATA_BASE_NODE_ID 200
|
|
|
|
|
#define SOE_COMTRADE_BASE_NODE_ID 300
|
|
|
|
|
#define HIS_DATA_BASE_NODE_ID 400
|
|
|
|
|
#define NEW_HIS_DATA_BASE_NODE_ID 500
|
|
|
|
|
#define RECALL_HIS_DATA_BASE_NODE_ID 600
|
|
|
|
|
#define RECALL_ALL_DATA_BASE_NODE_ID 700
|
|
|
|
|
|
|
|
|
|
#define REPORT_TYPE_STAT 1
|
|
|
|
|
#define REPORT_TYPE_REAL 2
|
|
|
|
|
#define REPORT_TYPE_SOE 4
|
|
|
|
|
#define REPORT_TYPE_EVENT 8
|
|
|
|
|
|
|
|
|
|
#define SHOULD_DO_NOTHING 0
|
|
|
|
|
#define SHOULD_REGISTER 1
|
|
|
|
|
#define SHOULD_UNREGISTER 2
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif /* __cplusplus */
|
2026-04-03 16:03:25 +08:00
|
|
|
//extern char* OSS_ENDPOINT;
|
|
|
|
|
//extern char* ACCESS_KEY_ID;
|
|
|
|
|
//extern char* ACCESS_KEY_SECRET;
|
|
|
|
|
//extern char* BUCKET_NAME;
|
2025-01-16 16:17:01 +08:00
|
|
|
|
|
|
|
|
extern char* POSTGRES_SCHEMA;
|
|
|
|
|
extern char* POSTGRES_TABLEPREFIX;
|
|
|
|
|
|
|
|
|
|
void GetSM4Code(unsigned char* pSerise,char* pKey,char* output);
|
|
|
|
|
void MyGetSM4Code(char* input,unsigned char* szKey,char* output);
|
|
|
|
|
|
2025-07-28 10:40:00 +08:00
|
|
|
int sm4_ecb_decrypt_zeropad_base64(const char* base64_cipher, const char* key_str, char* plaintext_out);//lnk20250728
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
void try_start_kafka_thread();
|
|
|
|
|
|
|
|
|
|
void try_start_mqconsumer_thread();//lnk20241216
|
|
|
|
|
|
2025-05-09 16:53:07 +08:00
|
|
|
//0. json生成开始函数
|
2025-01-16 16:17:01 +08:00
|
|
|
int json_block_create_start( char voltage_level[],char monid_char[],int flicker_flag, char temcode[],int line_id);
|
2025-05-09 16:53:07 +08:00
|
|
|
//1. json生成设置时标函数
|
2025-01-16 16:17:01 +08:00
|
|
|
int json_block_create_time(char monid_char[], long long Time, int flicker_flag);
|
2025-05-09 16:53:07 +08:00
|
|
|
//1.5 json生成设置flag函数
|
2025-01-16 16:17:01 +08:00
|
|
|
int json_block_create_flag(char monid_char[], int flag, int flicker_flag);
|
2025-05-09 16:53:07 +08:00
|
|
|
//2. json生成数据回调函数
|
2025-01-16 16:17:01 +08:00
|
|
|
int json_block_create_data(char monid_char[], char* mms_str , double v, int flicker_flag);
|
2025-05-09 16:53:07 +08:00
|
|
|
//3. json生成结束函数
|
|
|
|
|
//lnk2024-8-16添加参数
|
|
|
|
|
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag); //CZY 2023-08-17 测试
|
2025-01-16 16:17:01 +08:00
|
|
|
|
2025-05-09 16:53:07 +08:00
|
|
|
//zw 2024-01-31 补招模式优化
|
2025-01-16 16:17:01 +08:00
|
|
|
void add_mvl_type_ctrl(char doname[], int ctrl);
|
|
|
|
|
int sel_mvl_type_ctrl_flag(char doname[]);
|
|
|
|
|
void del_mvl_type_ctrl();
|
2025-05-09 16:53:07 +08:00
|
|
|
//补招模式优化 end
|
2025-04-30 10:22:57 +08:00
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
#ifndef DB_INTERFACE_H
|
|
|
|
|
#define DB_INTERFACE_H
|
2025-05-09 16:53:07 +08:00
|
|
|
// 前向声明 LD_info_t
|
2025-01-16 16:17:01 +08:00
|
|
|
typedef struct LD_info_t LD_info_t;
|
2025-06-24 17:15:18 +08:00
|
|
|
int urcbRealDataHasReceived(int dev_index,int rptNo, LD_info_t* LD_info, long long Time); //lnk20241223 20250624
|
2025-01-16 16:17:01 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
apr_status_t app_get_private_config(const char *myfilename);
|
|
|
|
|
|
|
|
|
|
void parse_log_switch_ini(unsigned int* error,unsigned int* warn,unsigned int* info);
|
|
|
|
|
void init_config();
|
|
|
|
|
int GetServerIndexFromDB();
|
|
|
|
|
int parse_device_cfg();
|
|
|
|
|
int parse_line_cfg();
|
|
|
|
|
int parse_rpt_log_ini();
|
|
|
|
|
void clear_all_LD_real_soe_report_shoud_register();
|
|
|
|
|
void add_comm_log(char* log_str);
|
|
|
|
|
void clear_old_comtrade_files();
|
|
|
|
|
int process_login_verify();
|
|
|
|
|
|
2025-05-09 16:53:07 +08:00
|
|
|
//////////////////////////////WW 20230819增加数据库操作函数
|
2025-01-16 16:17:01 +08:00
|
|
|
void TestToken();
|
2025-05-09 16:53:07 +08:00
|
|
|
void TestBodyPost();//WW 测试qt post
|
|
|
|
|
void TestSMSPost();//WW 测试qt post
|
2025-01-16 16:17:01 +08:00
|
|
|
void TestJson(char* szJson);
|
2026-04-03 16:03:25 +08:00
|
|
|
//void TestOSS();//WW 测试
|
|
|
|
|
//void PutOSS(char* File_Name, char* data); //zw修改 2023-9-7 上送oss文件
|
|
|
|
|
//void GetOSS(char* File_Name, char* savepath); //zw修改 2023-9-7 获取oss文件
|
|
|
|
|
//void DelOSS(char* File_Name);
|
2025-01-16 16:17:01 +08:00
|
|
|
void delete_object_new(char* File_Name);
|
|
|
|
|
void coutTest();//CZY 2023-09-11 test
|
2026-04-07 10:18:44 +08:00
|
|
|
//void TestOBS();//WW 20230921 测试华为云服务器
|
|
|
|
|
//void OBSFile(char* localpath, char* cloudpath,const char* code);
|
|
|
|
|
//void OBSFile_del(char* cloudpath, const char* code);
|
|
|
|
|
//void DataHub_Send_Datahub(char* topic, char* data);//datahub通讯
|
2025-01-16 16:17:01 +08:00
|
|
|
void Nacos_GetParam(char* postgres_uid, char* postgres_pwd, char* web_clientid, char* web_clientsecret);//nacos
|
|
|
|
|
void Nacos_GetParam_Ptr(const char* code, char** ptr);
|
|
|
|
|
void Read_Nacos_Param_Postgres(char** database_ip, char** database_port, char** postgres_database, char** postgres_username, char** postgres_password, char** postgres_schema, char** postgres_dnsname, char** postgres_tableprefix);
|
|
|
|
|
void Read_Nacos_Param_Kafka(char** broker_list, char** topic_stat, char** topic_pst, char** topic_plt, char** topic_event, char** topic_alarm, char** topic_sng, char** protocol, char** mechanisms, char** service_name, char** principal, char** domain_name);
|
|
|
|
|
void Read_Nacos_Param_Web(char** client_id, char** client_secret, char** token_url, char** device_url, char** grant_type);
|
|
|
|
|
void Read_Nacos_Param_Flag(int* file_flag, int* send_flag, int* front_inst, char** front_ip);
|
|
|
|
|
void Read_Nacos_Param_Recall(int* recall_len, int* recall_sta, int* recall_daily);
|
2025-05-09 16:53:07 +08:00
|
|
|
void Read_Nacos_Param_Uds(char** uds_upload_url, char** uds_download_url, char** uds_delete_url);//nacos获取uds参数
|
2025-04-30 10:22:57 +08:00
|
|
|
int WebAPI_Uds_Upload(char* strUrl, char* loacl_path, char* uuid,char* filename);
|
2025-01-16 16:17:01 +08:00
|
|
|
void WebAPI_Uds_Download(char* strUrl, char* uuid, char* local_path,char* filename);
|
2025-04-30 10:22:57 +08:00
|
|
|
int base64_decode(const char* indata, int inlen, char* outdata, long* outlen);
|
|
|
|
|
int testbase64();
|
2025-01-16 16:17:01 +08:00
|
|
|
/////////////////////////////WW end
|
|
|
|
|
|
2025-05-09 16:53:07 +08:00
|
|
|
//////////////////////////////WW 20230822增加数据库和WebSocket线程
|
|
|
|
|
void try_start_socket_thread(); //启动Web Socket线程
|
|
|
|
|
void try_start_ontimer_thread();//启动定时线程s
|
2025-01-16 16:17:01 +08:00
|
|
|
/////////////////////////////WW end
|
|
|
|
|
|
2025-05-09 16:53:07 +08:00
|
|
|
//lnk20241029增加http线程////////////////////////////////////////
|
|
|
|
|
void try_start_web_http_thread(); //启动Webhttp线程
|
|
|
|
|
void try_start_http_thread(); //启动http线程
|
2025-01-16 16:17:01 +08:00
|
|
|
int try_start_mqtest_thread(int argc, char *argv[]); //20241202
|
|
|
|
|
void CreateRecallXml();
|
|
|
|
|
void DeletcRecallXml();
|
|
|
|
|
|
|
|
|
|
/*lnk10-11*////////////////////////////////////////////////////////////////////////
|
|
|
|
|
void rocketmq_test();
|
2025-05-28 16:09:15 +08:00
|
|
|
void rocketmq_test_300(int mpnum,int front_index,int type);
|
2025-01-16 16:17:01 +08:00
|
|
|
void SOEFileWeb_test();
|
|
|
|
|
void qvvr_test();
|
|
|
|
|
void comflag_test();
|
|
|
|
|
int parse_device_cfg_web();
|
|
|
|
|
int parse_model_cfg_web();
|
|
|
|
|
void SOEFileWeb(char* localpath,char* cloudpath,char* wavepath);
|
2025-05-09 16:53:07 +08:00
|
|
|
const char* get_front_msg_from_subdir();
|
2025-07-28 10:40:00 +08:00
|
|
|
|
2026-02-04 09:21:54 +08:00
|
|
|
char* find_mp_name_from_mp_id(const char* mp_id);
|
|
|
|
|
|
2025-07-28 10:40:00 +08:00
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
2025-05-20 16:31:12 +08:00
|
|
|
typedef struct {
|
|
|
|
|
char WavePhasicFlag[64];
|
|
|
|
|
char WavePhasicA[64];
|
|
|
|
|
char WavePhasicB[64];
|
|
|
|
|
char WavePhasicC[64];
|
|
|
|
|
char UnitOfTimeUnit[64];
|
2026-01-27 16:58:15 +08:00
|
|
|
char TypeOfData[64];
|
2025-05-20 16:31:12 +08:00
|
|
|
char ValueOfTimeUnit[64];
|
|
|
|
|
char WaveTimeFlag[64];
|
2026-05-14 16:16:16 +08:00
|
|
|
char IEDControl[64];
|
2025-05-20 16:31:12 +08:00
|
|
|
char IEDname[64];
|
|
|
|
|
char LDevicePrefix[64];
|
|
|
|
|
} XmlConfigC;
|
|
|
|
|
|
|
|
|
|
bool get_xml_config_by_dev_type(const char* dev_type, XmlConfigC* out_cfg);
|
2025-01-16 16:17:01 +08:00
|
|
|
|
2026-03-12 15:28:17 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////文件控制请求参数
|
|
|
|
|
typedef struct file_dir_req_t
|
|
|
|
|
{
|
|
|
|
|
struct file_dir_req_t *next;
|
|
|
|
|
struct file_dir_req_t *prev;
|
|
|
|
|
|
|
|
|
|
char guid[128];
|
|
|
|
|
char frontid[128];
|
|
|
|
|
int processNo;
|
|
|
|
|
char devid[128];
|
|
|
|
|
int type;
|
|
|
|
|
char path[256];
|
2026-04-30 15:45:34 +08:00
|
|
|
char remote_path[256];
|
|
|
|
|
|
2026-03-12 15:28:17 +08:00
|
|
|
time_t create_time;
|
|
|
|
|
} file_dir_req_t;
|
|
|
|
|
|
2025-01-16 16:17:01 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //DB_INTERFACE_7ew2327hyhy0923r_H
|