69 lines
1.9 KiB
C
69 lines
1.9 KiB
C
|
|
#pragma once
|
||
|
|
/**
|
||
|
|
* @file table_static.h
|
||
|
|
* @brief 报表统计 太原硅钢
|
||
|
|
* @author your name (you@domain.com)
|
||
|
|
* @version 0.1
|
||
|
|
* @date 2023-12-22
|
||
|
|
*
|
||
|
|
* Copyright: Baosight Co. Ltd.
|
||
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
#include <eqpalg/alg_base.h>
|
||
|
|
#include <eqpalg/define/dlib.h>
|
||
|
|
#include <eqpalg/define/public.h>
|
||
|
|
#include <eqpalg/define/sample.h>
|
||
|
|
#include <eqpalg/gb_item_memory.h>
|
||
|
|
#include <glob/SingletonTemplate.h>
|
||
|
|
#include <map>
|
||
|
|
#include <vector>
|
||
|
|
#include "mix_cc/sql.h"
|
||
|
|
#include "mix_cc/sql/database/db2_t.h"
|
||
|
|
|
||
|
|
class TableStatic : public AlgBase {
|
||
|
|
public:
|
||
|
|
TableStatic(const string name, const mix_cc::json& rule_json,
|
||
|
|
const string ruleId);
|
||
|
|
virtual ~TableStatic();
|
||
|
|
virtual int init() override;
|
||
|
|
AlarmInfo exec_mon() override;
|
||
|
|
virtual int mon_proc();
|
||
|
|
std::vector<AlarmInfo> exec_task(mix_cc::time_range_t time_range) override;
|
||
|
|
virtual void set_usable(bool usable) override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
TableData table_data_; ///<报表数据
|
||
|
|
map<int, TableData> mp_table_data_; ///<报表数据
|
||
|
|
int running_flag_; ///<运行时间
|
||
|
|
int alrm_flag_; ///报警次数
|
||
|
|
int fault_flag_; ///<故障次数
|
||
|
|
|
||
|
|
int select_alarm_by_ruleid(string ruleid);
|
||
|
|
double select_running_by_ruleid(string ruleid);
|
||
|
|
unsigned long select_times_by_ruleid(string ruleid);
|
||
|
|
|
||
|
|
protected:
|
||
|
|
string table_name_; ///<报表名
|
||
|
|
string table_key_; ///<报表英文名 用于memcache key
|
||
|
|
|
||
|
|
int main_flag_ = 0; ///<主 ruleid
|
||
|
|
int is_rules_empty_ = true;
|
||
|
|
TimePoint last_run_start_time_proc_;
|
||
|
|
TimeDur delay_time_proc_;
|
||
|
|
string Jvalue_;
|
||
|
|
string Jkey_ = string(CMemVar::Const()->UnitNo) + "_";
|
||
|
|
MemCachedClient m_memclient;
|
||
|
|
int insert_memcache(string Jkey, string Jvalue);
|
||
|
|
bool get_cycled_proc();
|
||
|
|
virtual bool get_clear_flag();
|
||
|
|
|
||
|
|
virtual int get_ruleid_by_int(int num);
|
||
|
|
virtual void get_ruleid();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief 公共配置加载
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
void init_config();
|
||
|
|
};
|