2025-08-20 19:00:22 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
|
|
|
|
class Station;
|
|
|
|
|
|
class Device;
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
using VecPairSS = std::vector<std::pair<std::string, std::string>>;
|
|
|
|
|
|
|
|
|
|
|
|
struct DeviceType
|
|
|
|
|
|
{
|
|
|
|
|
|
int typeId {};
|
|
|
|
|
|
std::string name;
|
|
|
|
|
|
std::string attrs;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Role
|
|
|
|
|
|
{
|
|
|
|
|
|
int roleId {};
|
|
|
|
|
|
std::string name;
|
|
|
|
|
|
bool isOpen {false};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
class AppData
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
2025-08-22 19:06:50 +08:00
|
|
|
|
void init();
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
std::shared_ptr<Station> getStation(int stationId);
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Station> getStationByName(std::string name);
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Device> getDevice(int stationId, int deviceId);
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// 获取角色名称列表
|
|
|
|
|
|
std::vector<std::string> getRoleNames();
|
|
|
|
|
|
// 获取场站名称列表
|
|
|
|
|
|
std::vector<std::string> getStationNames();
|
|
|
|
|
|
// 获取设备类型
|
|
|
|
|
|
std::vector<std::string> getDeviceTypes();
|
|
|
|
|
|
|
|
|
|
|
|
// 获取设备类型定义
|
|
|
|
|
|
std::unordered_map<int, std::shared_ptr<DeviceType>>& getDeviceTypeDef();
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
// 读取统计数据: 今日统计数据,累计统计数据
|
|
|
|
|
|
void loadStatData();
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
void initUser();
|
2025-08-20 19:00:22 +08:00
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// === 系统 ===
|
|
|
|
|
|
int64_t sysActivationTime {};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// === 数据库 ===
|
|
|
|
|
|
struct {
|
|
|
|
|
|
std::string host;
|
|
|
|
|
|
int port;
|
|
|
|
|
|
std::string user;
|
|
|
|
|
|
std::string passwd;
|
|
|
|
|
|
} db;
|
|
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
struct {
|
|
|
|
|
|
VecPairSS isopen {{"0", "禁用"}, {"1", "启用"}};
|
|
|
|
|
|
VecPairSS gender {{"0", "女"}, {"1", "男"}};
|
|
|
|
|
|
// 角色 Mapping (id->name)
|
|
|
|
|
|
VecPairSS role;
|
|
|
|
|
|
|
|
|
|
|
|
VecPairSS deviceType;
|
|
|
|
|
|
|
|
|
|
|
|
} mapping;
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 19:00:22 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// === 场站信息 ===
|
|
|
|
|
|
std::unordered_map<int, std::shared_ptr<Station>> mapStation;
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// === 角色定义 ===
|
2025-08-22 19:06:50 +08:00
|
|
|
|
std::unordered_map<int, std::shared_ptr<Role>> mapRole;
|
2025-08-20 19:00:22 +08:00
|
|
|
|
|
2025-08-22 19:06:50 +08:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// === 设备类型定义 ===
|
|
|
|
|
|
std::unordered_map<int, std::shared_ptr<DeviceType>> mapDeviceType;
|
2025-08-20 19:00:22 +08:00
|
|
|
|
};
|