#ifndef SECS_RUNTIME_MANAGER_H
|
#define SECS_RUNTIME_MANAGER_H
|
|
#include <string>
|
#include <vector>
|
#include <mutex>
|
#include "Database.h"
|
|
class SECSRuntimeManager {
|
public:
|
/**
|
* 获取单例实例
|
* @return SECSRuntimeManager实例的引用
|
*/
|
static SECSRuntimeManager& getInstance();
|
|
/**
|
* 设置数据库连接
|
* @param db 数据库连接的指针
|
*/
|
void setDatabase(BL::Database* db);
|
|
/**
|
* 初始化SECS运行设置管理库
|
* @return 成功返回true,失败返回false
|
*/
|
bool initRuntimeSetting();
|
|
/**
|
* 销毁SECS运行设置管理库
|
*/
|
void termRuntimeSetting();
|
|
/**
|
* 初始化指定的 SystemV 表
|
* @param tableName: 要初始化的表名(如 "SystemSV" 或 "SystemDV")。
|
*
|
* 此函数用于初始化指定名称的 SystemV 表。如果表不存在,将会创建该表。
|
* - 表结构包括:ID、Name、DataType、Length、Unit、Remark、SystemID。
|
* - 如果表已经存在,则不进行任何操作。
|
*/
|
void initSystemVTable(const std::string& tableName);
|
|
int addSystemVData(const std::string& tableName, int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
std::vector<std::vector<std::string>> getSystemVByID(const std::string& tableName, int nID);
|
|
std::vector<std::vector<std::string>> getAllSystemV(const std::string& tableName);
|
|
int updateIDSystemV(const std::string& tableName, int nID, int sNewID);
|
|
int updateAllSystemV(const std::string& tableName, int nID, int sNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
void initEqpVTable(const std::string& tableName);
|
|
int addEqpVData(const std::string& tableName, int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo);
|
|
std::vector<std::vector<std::string>> getEqpVDataByID(const std::string& tableName, int nID);
|
|
int updateEqpV(const std::string& tableName, int nID, int nNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo);
|
|
/**
|
* 初始化SystemSV表
|
*/
|
void initSystemSVTable();
|
|
/**
|
* 添加 SystemSV 数据
|
* @param nID: 需要添加的 SystemSV 的 ID,必须是唯一的。
|
* @param sName: 需要添加的 SystemSV 的名称,必须是唯一的。
|
* @param sDataType: 数据类型,表示该系统值的类型,例如 "ASCII"、"UINT_1" 等。
|
* @param nLength: 系统值的数据长度,通常为一个正整数,用于表示该数据的长度。
|
* @param sUnit: 系统值的单位。如果为空或者为 "NULL",则插入数据库中的 NULL 值。
|
* @param sRemark: 备注信息,描述该系统值的其他信息,可用于说明该字段的用途或特性。
|
* @param nSystemID: 该数据所属的系统 ID,用于与其他表进行关联。
|
* @return 1: 数据库未连接。
|
* @return 2: ID 重复,无法插入数据。
|
* @return 3: Name 重复,无法插入数据。
|
* @return 4: 插入数据失败。
|
* @return 0: 插入成功,数据已添加到 SystemSV 表中。
|
*
|
* 此函数用于将一条新的数据插入到 SystemSV 表中。它首先会检查传入的 `ID` 和 `Name` 是否已存在于表中,
|
* 如果存在则返回相应的错误代码。如果 `Unit` 参数为 "NULL" 或者为空,函数会将其转换为数据库中的 NULL 值。
|
* 然后,构造一个 SQL 插入语句并执行插入操作。如果插入失败,则抛出异常。
|
* 如果一切顺利,返回 0 表示数据成功插入。
|
*/
|
int addSystemSV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
/**
|
* 获取指定 ID 的 SystemSV 数据
|
* @param nID: 需要查找的 SystemSV 的 ID。
|
* @return std::vector<std::vector<std::string>>: 返回一个二维字符串向量,表示查询结果。每行代表一条记录,每列代表该记录的一个字段值。
|
* 如果指定的 ID 存在,则返回该 ID 对应的记录;如果不存在,则返回空的二维向量。
|
*
|
* 此函数用于通过指定的 `ID` 从 SystemSV 表中查找对应的数据。首先根据传入的 `ID` 构造查询 SQL 语句,
|
* 然后执行查询操作,返回查询结果。查询结果是一个二维字符串向量,表示查询到的记录。每行是一个
|
* 字符串向量,每个元素是该行中的一列数据。如果找不到对应的数据,函数将返回一个空的二维向量。
|
*/
|
std::vector<std::vector<std::string>> getSystemSVByID(int nID);
|
|
/**
|
* 获取所有 SystemSV 数据
|
* @return std::vector<std::vector<std::string>>: 返回一个二维字符串向量,表示查询结果。每行代表一条记录,每列代表该记录的一个字段值。
|
* 如果表中有数据,则返回所有记录;如果表为空,则返回空的二维向量。
|
*
|
* 此函数用于从 SystemSV 表中获取所有的数据。通过构造 SQL 查询语句来选择所有记录,并执行查询操作。
|
* 返回的结果是一个二维字符串向量,表示表中的所有记录。每行数据是一个字符串向量,其中包含该记录的各个字段。
|
* 如果表中没有数据,函数将返回一个空的二维向量。
|
*/
|
std::vector<std::vector<std::string>> getAllSystemSV();
|
|
/**
|
* 更新指定 ID 的 SystemSV 数据
|
* @param nID: 需要更新的 SystemSV 的当前 ID。
|
* @param sNewID: 要更新为的新 ID。
|
* @return 1: 数据库未连接。
|
* @return 2: 未找到指定的 ID。
|
* @return 3: 新的 ID 已经存在,无法更新。
|
* @return 4: 更新操作失败。
|
* @return 0: 更新成功。
|
*
|
* 此函数用于更新 `SystemSV` 表中指定 `nID` 的记录,将其 `ID` 字段更新为 `sNewID`。
|
* 在执行更新前,函数会检查:
|
* 1. 当前的 `nID` 是否存在于表中。
|
* 2. 新的 `sNewID` 是否已经存在于表中,如果存在,则无法进行更新。
|
*
|
* 如果 `nID` 不存在,则返回错误代码 2。如果 `sNewID` 已经存在,则返回错误代码 3。
|
* 如果数据库更新失败,则返回错误代码 4。成功时,返回 0 表示操作成功。
|
*/
|
int updateIDSystemSV(int nID, int sNewID);
|
|
/**
|
* 更新所有 SystemSV 数据
|
* @param nID: 需要更新的 SystemSV 的当前 ID。
|
* @param sNewID: 要更新为的新 ID,如果为空或为 -1,则不更新 ID。
|
* @param sName: 新的名称,如果为空,则不更新。
|
* @param sDataType: 新的数据类型,如果为空,则不更新。
|
* @param nLength: 新的数据长度,如果为负值或零,则不更新。
|
* @param sUnit: 新的单位,如果为空或 "NULL",则不更新。
|
* @param sRemark: 新的备注,如果为空,则不更新。
|
* @param nSystemID: 新的系统 ID,如果为负值,则不更新。
|
* @return 1: 数据库未连接。
|
* @return 2: 没有找到该 ID 对应的记录。
|
* @return 3: 新的 ID 已经存在,无法更新。
|
* @return 4: 更新操作失败。
|
* @return 0: 更新成功。
|
*
|
* 此函数用于更新指定 `ID` 的 `SystemSV` 数据。如果某个字段为空,则跳过该字段的更新。
|
* 如果给定的 `ID` 不存在,则返回错误代码 2。如果新的 `ID` 已经存在,则返回错误代码 3。
|
*
|
* 如果字段为空,跳过该字段的更新。
|
*/
|
int updateAllSystemSV(int nID, int sNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
/**
|
* 删除指定 ID 的 SystemSV 数据
|
* @param nID: 需要删除的 SystemSV 的 ID。
|
* @return 1: 数据库未连接。
|
* @return 2: 未找到指定的 ID 对应的记录。
|
* @return 3: 删除操作失败。
|
* @return 0: 删除成功。
|
*
|
* 此函数用于删除 `SystemSV` 表中指定 `nID` 的记录。如果给定的 `nID` 不存在,则返回错误代码 2。
|
* 删除操作成功后,返回 0 表示删除成功。
|
*/
|
int deleteSystemSVByID(int nID);
|
|
/**
|
* 删除所有 SystemSV 数据
|
* @return 1: 数据库未连接。
|
* @return 2: 删除操作失败。
|
* @return 0: 删除成功。
|
*
|
* 此函数用于删除 `SystemSV` 表中的所有记录。如果数据库未连接,则返回错误代码 1。
|
* 如果删除操作失败,则返回错误代码 2。删除成功后,返回 0 表示删除成功。
|
*/
|
int deleteAllSystemSV();
|
|
/**
|
* 初始化 EqpSV 表
|
*/
|
void initEqpSVTable();
|
|
/**
|
* 添加 EqpSV 数据
|
* @param nID: 需要添加的 EqpSV 的 ID,必须是唯一的。
|
* @param sName: 需要添加的 EqpSV 的名称,必须是唯一的。
|
* @param sDataType: 数据类型,表示该设备值的类型,例如 "ASCII"、"UINT_1" 等。
|
* @param nLength: 设备值的数据长度,通常为一个正整数,用于表示该数据的长度。
|
* @param sUnit: 设备值的单位。如果为空或者为 "NULL",则插入数据库中的 NULL 值。
|
* @param sRemark: 备注信息,描述该设备值的其他信息,可用于说明该字段的用途或特性。
|
* @param nSeqNo: 该数据的序号,用于排序。
|
* @return 1: 数据库未连接。
|
* @return 2: ID 重复,无法插入数据。
|
* @return 3: Name 重复,无法插入数据。
|
* @return 4: 插入数据失败。
|
* @return 0: 插入成功,数据已添加到 EqpSV 表中。
|
*
|
* 此函数用于将一条新的数据插入到 EqpSV 表中。它首先会检查传入的 `ID` 和 `Name` 是否已存在于表中,
|
* 如果存在则返回相应的错误代码。如果 `Unit` 参数为 "NULL" 或者为空,函数会将其转换为数据库中的 NULL 值。
|
* 然后,构造一个 SQL 插入语句并执行插入操作。如果插入失败,则抛出异常。
|
* 如果一切顺利,返回 0 表示数据成功插入。
|
*/
|
int addEqpSV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo);
|
|
|
/**
|
* 获取指定 ID 的 EqpSV 数据
|
* @param nID: 需要查找的 EqpSV 的 ID。
|
* @return std::vector<std::vector<std::string>>: 返回一个二维字符串向量,表示查询结果。每行代表一条记录,每列代表该记录的一个字段值。
|
* 如果指定的 ID 存在,则返回该 ID 对应的记录;如果不存在,则返回空的二维向量。
|
*
|
* 此函数用于通过指定的 `ID` 从 EqpSV 表中查找对应的数据。首先根据传入的 `ID` 构造查询 SQL 语句,
|
* 然后执行查询操作,返回查询结果。查询结果是一个二维字符串向量,表示查询到的记录。每行是一个
|
* 字符串向量,每个元素是该行中的一列数据。如果找不到对应的数据,函数将返回一个空的二维向量。
|
*/
|
std::vector<std::vector<std::string>> SECSRuntimeManager::getEqpSVByID(int nID);
|
|
/**
|
* 获取所有 EqpSV 数据
|
*/
|
bool getAllEqpSV(std::vector<std::vector<std::string>>& outEqpSV);
|
|
/**
|
* 更新指定 ID 的 EqpSV 数据
|
* @param nID: 需要更新的 EqpSV 的 ID,必须是已存在的 ID。
|
* @param nNewID: 更新后的 ID,必须是唯一的。
|
* @param sName: 更新后的 EqpSV 名称,必须是唯一的。
|
* @param sDataType: 更新后的数据类型,表示该设备值的类型,例如 "ASCII"、"UINT_1" 等。
|
* @param nLength: 更新后的设备值的数据长度,通常为一个正整数,用于表示该数据的长度。
|
* @param sUnit: 更新后的设备值的单位。如果为空或者为 "NULL",则插入数据库中的 NULL 值。
|
* @param sRemark: 更新后的备注信息,描述该设备值的其他信息,可用于说明该字段的用途或特性。
|
* @param nSeqNo: 更新后的该数据的序号,用于排序。
|
* @return 1: 数据库未连接。
|
* @return 2: ID 不存在,无法更新数据。
|
* @return 3: 新 ID 重复,无法更新数据。
|
* @return 4: 更新数据失败。
|
* @return 0: 更新成功,数据已更新到 EqpSV 表中。
|
*
|
* 此函数用于更新指定 ID 的 EqpSV 数据。首先检查 `ID` 是否存在,如果不存在则返回错误代码 2。
|
* 然后检查新的 `ID` 是否已存在,如果已存在则返回错误代码 3。接下来,构造更新 SQL 语句,包含
|
* 需要更新的字段,并执行更新操作。如果更新失败,则返回错误代码 4。如果一切顺利,返回 0 表示
|
* 数据成功更新。
|
*/
|
int updateEqpSV(int nID, int nNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo);
|
|
/**
|
* 更新指定 ID 的 EqpSV 数据
|
* @param nID: 需要更新的 EqpSV 的当前 ID。
|
* @param sNewID: 要更新为的新 ID。
|
* @return 1: 数据库未连接。
|
* @return 2: 未找到指定的 ID。
|
* @return 3: 新的 ID 已经存在,无法更新。
|
* @return 4: 更新操作失败。
|
* @return 0: 更新成功。
|
*
|
* 此函数用于更新 `EqpSV` 表中指定 `nID` 的记录,将其 `ID` 字段更新为 `sNewID`。
|
* 在执行更新前,函数会检查:
|
* 1. 当前的 `nID` 是否存在于表中。
|
* 2. 新的 `sNewID` 是否已经存在于表中,如果存在,则无法进行更新。
|
*
|
* 如果 `nID` 不存在,则返回错误代码 2。如果 `sNewID` 已经存在,则返回错误代码 3。
|
* 如果数据库更新失败,则返回错误代码 4。成功时,返回 0 表示操作成功。
|
*/
|
int deleteEqpSVByID(int nID);
|
|
/**
|
* 删除所有 EqpSV 数据
|
* @return 1: 数据库未连接。
|
* @return 2: 删除操作失败。
|
* @return 0: 删除成功。
|
*
|
* 此函数用于删除 `EqpSV` 表中的所有记录。如果数据库未连接,则返回错误代码 1。
|
* 如果删除操作失败,则返回错误代码 2。删除成功后,返回 0 表示删除成功。
|
*/
|
int deleteAllEqpSV();
|
|
/**
|
* 初始化 SystemDV 表
|
*/
|
void initSystemDVTable();
|
|
int addSystemDV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
std::vector<std::vector<std::string>> getSystemDVByID(int nID);
|
|
std::vector<std::vector<std::string>> getAllSystemDV();
|
|
int updateIDSystemDV(int nID, int sNewID);
|
|
int updateAllSystemDV(int nID, int sNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
int deleteSystemDVByID(int nID);
|
|
int deleteAllSystemDV();
|
|
/**
|
* 初始化 EqpDV 表
|
*/
|
void initEqpDVTable();
|
|
int addEqpDV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo);
|
|
std::vector<std::vector<std::string>> getEqpDVByID(int nID);
|
|
bool getAllEqpDV(std::vector<std::vector<std::string>>& outEqpDV);
|
|
int updateEqpDV(int nID, int nNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo);
|
|
int deleteEqpDVByID(int nID);
|
|
int deleteAllEqpDV();
|
|
/**
|
* 初始化 SystemEC 表
|
*/
|
void initSystemECTable();
|
|
int addSystemEC(int nID, const std::string& sName, const std::string& sDataType, int nMinValue, int nMaxValue, int nDefaultVal, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
std::vector<std::vector<std::string>> getSystemECByID(int nID);
|
|
std::vector<std::vector<std::string>> getAllSystemEC();
|
|
int updateSystemEC(int nID, int nNewID, const std::string& sName, const std::string& sDataType, int nMinValue, int nMaxValue, int nDefaultVal, const std::string& sUnit, const std::string& sRemark, int nSystemID);
|
|
int deleteSystemECByID(int nID);
|
|
int deleteAllSystemEC();
|
|
/**
|
* 初始化 EqpEC 表
|
*/
|
void initEqpECTable();
|
|
int addEqpEC(int nID, const std::string& sName, const std::string& sDataType, int nMinValue, int nMaxValue, int nDefaultValue, const std::string& sUnit, const std::string& sRemark, int nSeqNo, int nLength, int bCanUpdateByHost);
|
|
std::vector<std::vector<std::string>> getEqpECByID(int nID);
|
|
std::vector<std::vector<std::string>> getAllEqpEC();
|
|
int updateEqpEC(int nID, int nNewID, const std::string& sName, const std::string& sDataType, int nMinValue, int nMaxValue, int nDefaultValue, const std::string& sUnit, const std::string& sRemark, int nSeqNo, int nLength, int bCanUpdateByHost);
|
|
int deleteEqpECByID(int nID);
|
|
int deleteAllEqpEC();
|
|
/**
|
* 初始化 SystemEvent 表
|
*/
|
void initSystemEventTable();
|
|
int addSystemEvent(int nCEID, const std::string& sName, const std::string& sRemark, int nSystemID);
|
|
std::vector<std::vector<std::string>> getSystemEventByID(int nCEID);
|
|
std::vector<std::vector<std::string>> getAllSystemEvents();
|
|
int updateSystemEvent(int nCEID, int nNewCEID, const std::string& sName, const std::string& sRemark, int nSystemID);
|
|
int deleteSystemEventByID(int nCEID);
|
|
int deleteAllSystemEvents();
|
|
/**
|
* 初始化 EqpEvent 表
|
*/
|
void initEqpEventTable();
|
|
int addEqpEvent(const std::string& sName, const std::string& sRemark, int nBitNo);
|
|
std::vector<std::vector<std::string>> getEqpEventByID(int nCEID);
|
|
std::vector<std::vector<std::string>> getAllEqpEvents();
|
|
int updateEqpEvent(int nCEID, const std::string& sName, const std::string& sRemark, int nBitNo);
|
|
int deleteEqpEventByID(int nCEID);
|
|
int deleteAllEqpEvents();
|
|
/**
|
* 初始化 EventLink 表
|
*/
|
void initEventLinkTable();
|
|
/**
|
* 初始化 PPID 表
|
*/
|
void initPPIDTable();
|
|
/**
|
* 初始化 RPTID 表
|
*/
|
void initRPTIDTable();
|
|
/**
|
* 添加 RPTID 和 VID 的关系
|
* @param nRPTID: 需要关联的 RPTID。
|
* @param nVID: 需要关联的 VID,可以是 SystemSV 或 EqpSV 的 ID。
|
* @return 1: 数据库未连接。
|
* @return 2: RPTID 和 VID 的关系已存在,无法插入。
|
* @return 3: Report 表插入数据失败。
|
* @return 4: ReportVIDs 表插入数据失败。
|
* @return 0: 插入成功,数据已添加到 ReportVIDs 表中。
|
*
|
* 此函数用于添加一个新的 RPTID 和 VID 的关联关系。如果该 RPTID 和 VID 的组合已存在于数据库中,
|
* 则返回错误代码 2。否则,函数会插入新的关系,并返回 0 表示插入成功。
|
*/
|
int addRPTIDVID(int nRPTID, int nVID);
|
|
/**
|
* 添加多个 VID 与一个 RPTID 的关系
|
* @param nRPTID: 需要关联的 RPTID。
|
* @param vecVID: 需要关联的多个 VID,可以是 SystemSV 或 EqpSV 的 ID 的集合。
|
* @return 1: 数据库未连接。
|
* @return 2: Report 表插入数据失败。
|
* @return 3: ReportVIDs 表插入数据失败。
|
* @return 0: 插入成功,数据已添加到 ReportVIDs 表中。
|
*
|
* 此函数用于将多个 VID 与 RPTID 关联。首先检查 `RPTID` 是否已经存在于 `Report` 表中,
|
* 如果不存在,则先插入该 `RPTID`。然后,批量插入 `RPTID` 和 `VID` 的关系,确保同一个 `RPTID`
|
* 下的 `VID` 不重复。
|
*/
|
int addRPTIDVIDs(int nRPTID, const std::vector<int>& vecVID);
|
|
/**
|
* 删除指定 RPTID 和 VID 的关系
|
* @param nRPTID: 需要删除的 RPTID。
|
* @param nVID: 需要删除的 VID。
|
* @return 1: 数据库未连接。
|
* @return 2: RPTID 和 VID 的关系不存在,无法删除。
|
* @return 3: 删除操作失败。
|
* @return 0: 删除成功。
|
*
|
* 此函数用于删除指定的 RPTID 和 VID 的关联关系。如果该关系不存在,则返回错误代码 2。
|
* 如果删除操作失败,则返回错误代码 3。删除成功后,返回 0 表示删除成功。
|
*/
|
int deleteRPTIDVID(int nRPTID, int nVID);
|
|
/**
|
* 删除指定 RPTID 关联的所有记录
|
* @param nRPTID: 需要删除的 RPTID。
|
*
|
* @return 1: 数据库未连接。
|
* @return 2: 删除 ReportVIDs 表中的记录失败。
|
* @return 3: 删除 Report 表中的 RPTID 失败。
|
* @return 0: 删除成功,所有与该 RPTID 关联的记录已被删除。
|
*
|
* 此函数用于删除 ReportVIDs 表中所有与指定 RPTID 关联的记录,并根据需要删除 Report 表中的 RPTID。
|
* - 首先,删除 ReportVIDs 表中所有与该 RPTID 关联的记录。
|
* - 然后,可以选择是否删除 Report 表中对应的 RPTID。
|
*
|
* 若删除失败,则返回相应的错误代码。如果成功删除所有记录,则返回 0。
|
*/
|
int deleteRPTID(int nRPTID);
|
|
/**
|
* 更新指定 RPTID 的 VID 关联记录
|
* @param nRPTID: 需要更新的 RPTID。
|
* @param nOldVID: 需要更新的旧 VID。
|
* @param nNewVID: 新的 VID,替代旧的 VID。
|
*
|
* @return 1: 数据库未连接。
|
* @return 2: 找不到指定的 RPTID 和旧 VID 组合。
|
* @return 3: 新的 VID 已经存在于该 RPTID 下。
|
* @return 4: 更新操作失败。
|
* @return 0: 更新成功,VID 已被替换为新的 VID。
|
*
|
* 此函数用于更新 `ReportVIDs` 表中指定 `RPTID` 的旧 `VID` 为新的 `VID`。
|
* - 首先,检查是否存在指定的 `RPTID` 和 `OldVID` 组合。
|
* - 然后检查新的 `VID` 是否已经存在于相同的 `RPTID` 下,防止重复。
|
* - 如果检查通过,则执行更新操作。
|
*/
|
int updateRPTIDVID(int nRPTID, int nOldVID, int nNewVID);
|
|
/**
|
* 删除并重新添加指定 RPTID 下的多个 VID 关联记录
|
* @param nRPTID: 需要更新记录的 RPTID。
|
* @param vecVID: 需要重新添加的 VID 列表。
|
*
|
* @return 1: 数据库未连接。
|
* @return 2: 删除操作失败,可能是某些 VID 不存在或数据库操作失败。
|
* @return 3: 插入操作失败,可能是某些 VID 已经存在。
|
* @return 0: 删除并重新添加成功,所有 VID 记录已更新。
|
*
|
* 此函数用于删除指定 `RPTID` 下的所有旧 VID 记录,然后重新添加新的 VID 记录。
|
* - 首先,删除指定 `RPTID` 下的所有 VID 关联记录。
|
* - 然后,检查新 `VID` 是否存在,若不存在则插入新记录。
|
*
|
* 如果操作成功,返回 0;如果删除或插入过程中遇到问题,返回相应的错误代码。
|
*/
|
int updateRPTIDVIDs(int nRPTID, const std::vector<int>& vecVID);
|
|
/**
|
* 查询指定 RPTID 下的所有 VID
|
* @param nRPTID: 需要查询的 RPTID。
|
* @return std::vector<int>: 存储所有与 RPTID 关联的 VID。
|
*
|
* 此函数用于根据指定的 `RPTID` 查询所有与之关联的 `VID`。
|
* - 查询 `ReportVIDs` 表,根据 `RPTID` 获取所有相关的 `VID`。
|
* - 返回的结果是一个 `std::vector<int>`,包含所有对应的 `VID`。
|
*/
|
std::vector<int> getVIDsByRPTID(int nRPTID);
|
|
/**
|
* 查询所有 Report 表中的 RPTID
|
* @return std::vector<int>: 存储所有的 RPTID。
|
*
|
* 此函数用于查询 `Report` 表中的所有 `RPTID`。
|
* - 查询 `Report` 表中的所有 `RPTID`。
|
* - 返回的结果是一个 `std::vector<int>`,包含所有的 `RPTID`。
|
*/
|
std::vector<int> getAllRPTIDs();
|
|
private:
|
SECSRuntimeManager();
|
~SECSRuntimeManager();
|
|
// 禁止拷贝和赋值
|
SECSRuntimeManager(const SECSRuntimeManager&) = delete;
|
SECSRuntimeManager& operator=(const SECSRuntimeManager&) = delete;
|
|
// 从数据库中获取整数
|
int getIntFromDB(const std::string& query);
|
|
// 判断VID是否重复
|
bool isIDDuplicate(int nID);
|
|
// 判断名称是否重复
|
bool isNameDuplicate(const std::string& sName);
|
|
// 删除指定表中的所有数据
|
int deleteAllDataFromTable(const std::string& tableName);
|
|
// 查询指定表所有数据(通用函数)
|
bool getAllDataFromTable(const std::string& tableName, std::vector<std::vector<std::string>>& outData);
|
|
// 删除指定表中指定 ID 的数据
|
int deleteDataByID(const std::string& tableName, int nID);
|
|
BL::Database* m_pDB;
|
static std::mutex m_mutex;
|
};
|
|
#endif // SECS_RUNTIME_MANAGER_H
|