fix recall

This commit is contained in:
lnk
2025-10-30 20:57:19 +08:00
parent 06a2f3a75b
commit 5e63adc8f9
5 changed files with 509 additions and 69 deletions

View File

@@ -85,6 +85,18 @@ std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
// 把“今天”做成年月日整数YYYYMMDD用于“每天只清理一次”的判定
static inline int local_ymd_today() {
std::time_t now = std::time(nullptr);
std::tm local_tm{};
#if defined(_WIN32) || defined(_WIN64)
localtime_s(&local_tm, &now);
#else
local_tm = *std::localtime(&now);
#endif
return (local_tm.tm_year + 1900) * 10000 + (local_tm.tm_mon + 1) * 100 + local_tm.tm_mday;
}
//处理参数
bool parse_param(int argc, char* argv[]) {
for (int i = 1; i < argc; ++i) {
@@ -138,35 +150,6 @@ bool parse_param(int argc, char* argv[]) {
return true;
}
//获取前置类型
/*void init_global_function_enable() {
if (subdir == "cfg_stat_data") { // 历史稳态
g_node_id = STAT_DATA_BASE_NODE_ID;
auto_register_report_enabled = 1;
} else if (subdir == "cfg_3s_data") { // 实时
g_node_id = THREE_SECS_DATA_BASE_NODE_ID;
three_secs_enabled = 1;
} else if (subdir == "cfg_soe_comtrade") { // 告警、录波、暂态
g_node_id = SOE_COMTRADE_BASE_NODE_ID;
} else if (subdir == "cfg_recallhis_data") { // 补招
g_node_id = RECALL_HIS_DATA_BASE_NODE_ID;
}
}*/
//获取功能名称
/*std::string get_front_msg_from_subdir() {
if (subdir.find("cfg_3s_data") != std::string::npos)
return "实时数据进程";
else if (subdir.find("cfg_soe_comtrade") != std::string::npos)
return "暂态和告警进程";
else if (subdir.find("cfg_recallhis_data") != std::string::npos)
return "稳态补招进程";
else if (subdir.find("cfg_stat_data") != std::string::npos)
return "稳态统计进程";
else
return "unknown";
}*/
//获取前置路径
std::string get_parent_directory() {
// 获取当前工作目录
@@ -456,10 +439,9 @@ void Front::FrontThread() {
try {
while (!m_bIsFrontThreadCancle) {
check_recall_file(); //处理补招文件-稳态和暂态
check_recall_event(); // 处理补招事件从list中读取然后直接调用接口,每一条可能都不同测点,每个测点自己做好记录
//check_ledger_update(); // 触发台账更新
check_recall_file(); //处理补招文件-稳态和暂态
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
} catch (const std::exception& e) {
@@ -490,6 +472,9 @@ void Front::OnTimerThread()
send_heartbeat_to_queue("1");
//记录“上次做日清理”的日期YYYYMMDD确保每天只做一次
static int s_lastCleanupYMD = -1;
while (!m_IsTimerCancel)
{
update_log_entries_countdown();
@@ -509,6 +494,18 @@ void Front::OnTimerThread()
backupCounter = 0;
}
// 按天清理 —— 发现“日期变更”则执行一次清理
{
const int todayYMD = local_ymd_today(); // YYYYMMDD本地时区
if (todayYMD != s_lastCleanupYMD) {
// 说明进入了新的一天:执行清理(删除前日及更早的未配对事件)
std::cout << "[OnTimerThread] daily cleanup start, today=" << todayYMD << std::endl;
cleanup_old_unpaired_qvvr_events(); // 调用清理内存的暂态事件
s_lastCleanupYMD = todayYMD;
std::cout << "[OnTimerThread] daily cleanup done" << std::endl;
}
}
hbCounter++;
backupCounter++;