From a886343fc6eaecb4eccd35dc2a5b95fc84212dd5 Mon Sep 17 00:00:00 2001
From: darker <mr.darker@163.com>
Date: 星期二, 18 二月 2025 16:21:36 +0800
Subject: [PATCH] 1. 添加ReportVIDs表的相关操作
---
SourceCode/Bond/Servo/SECSRuntimeManager.cpp | 235 ++++++++++++++++++++++++++++++++++++++
SourceCode/Bond/Servo/SECSRuntimeManager.h | 119 +++++++++++++++++++
2 files changed, 351 insertions(+), 3 deletions(-)
diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.cpp b/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
index bb382a2..0af3a89 100644
--- a/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
+++ b/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
@@ -829,22 +829,251 @@
throw std::runtime_error("Database not connected.");
}
- // 创建 RPTID 相关表
+ // 创建 Report 表
std::string createReportTableSQL =
"CREATE TABLE IF NOT EXISTS Report ("
"RPTID INTEGER PRIMARY KEY);";
+ // 创建 ReportVIDs 表,保证同一个 RPTID 下的 VID 唯一
std::string createReportVIDsTableSQL =
"CREATE TABLE IF NOT EXISTS ReportVIDs ("
- "ID INTEGER PRIMARY KEY AUTOINCREMENT, "
"RPTID INTEGER NOT NULL, "
"VID INTEGER NOT NULL, "
- "FOREIGN KEY (RPTID) REFERENCES Report(RPTID));";
+ "FOREIGN KEY (RPTID) REFERENCES Report(RPTID), "
+ "UNIQUE(RPTID, VID));";
+ // 执行创建表操作
if (!m_pDB->executeQuery(createReportTableSQL)) {
throw std::runtime_error("Failed to create Report table.");
}
if (!m_pDB->executeQuery(createReportVIDsTableSQL)) {
throw std::runtime_error("Failed to create ReportVIDs table.");
}
+}
+
+// 添加 RPTID 数据
+int SECSRuntimeManager::addRPTIDVID(int nRPTID, int nVID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ // 检查 RPTID 和 VID 的组合是否已经存在
+ std::string checkExistSQL = "SELECT COUNT(*) FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + " AND VID = " + std::to_string(nVID) + ";";
+ int count = getIntFromDB(checkExistSQL);
+ if (count > 0) {
+ return 2; // 如果关系已存在,返回错误代码 2
+ }
+
+ // 检查 Report 表中是否存在该 RPTID
+ std::string checkReportExistSQL = "SELECT COUNT(*) FROM Report WHERE RPTID = " + std::to_string(nRPTID) + ";";
+ int reportCount = getIntFromDB(checkReportExistSQL);
+
+ if (reportCount == 0) {
+ // 如果 RPTID 不存在,插入 RPTID
+ std::string insertReportSQL = "INSERT INTO Report (RPTID) VALUES (" + std::to_string(nRPTID) + ");";
+ if (!m_pDB->executeQuery(insertReportSQL)) {
+ return 3; // 插入失败,返回错误代码 3
+ }
+ }
+
+ // 构造插入 SQL 语句
+ std::string insertSQL = "INSERT INTO ReportVIDs (RPTID, VID) VALUES ("
+ + std::to_string(nRPTID) + ", "
+ + std::to_string(nVID) + ");";
+
+ // 执行插入操作
+ if (!m_pDB->executeQuery(insertSQL)) {
+ return 4; // 插入失败,返回错误代码 4
+ }
+
+ return 0; // 插入成功,返回 0
+}
+
+// 获取指定 RPTID 的所有 VID
+int SECSRuntimeManager::addRPTIDVIDs(int nRPTID, const std::vector<int>& vecVID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ // 检查 Report 表中是否存在该 RPTID
+ std::string checkReportExistSQL = "SELECT COUNT(*) FROM Report WHERE RPTID = " + std::to_string(nRPTID) + ";";
+ int reportCount = getIntFromDB(checkReportExistSQL);
+
+ if (reportCount == 0) {
+ // 如果 RPTID 不存在,插入 RPTID
+ std::string insertReportSQL = "INSERT INTO Report (RPTID) VALUES (" + std::to_string(nRPTID) + ");";
+ if (!m_pDB->executeQuery(insertReportSQL)) {
+ return 2; // 插入失败,返回错误代码 3
+ }
+ }
+
+ // 批量插入 VID 和 RPTID 关系
+ for (int nVID : vecVID) {
+ // 检查当前 RPTID 和 VID 的组合是否已经存在
+ std::string checkExistSQL = "SELECT COUNT(*) FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + " AND VID = " + std::to_string(nVID) + ";";
+ int count = getIntFromDB(checkExistSQL);
+ if (count == 0) {
+ // 如果关系不存在,插入
+ std::string insertSQL = "INSERT INTO ReportVIDs (RPTID, VID) VALUES ("
+ + std::to_string(nRPTID) + ", "
+ + std::to_string(nVID) + ");";
+
+ if (!m_pDB->executeQuery(insertSQL)) {
+ return 3; // 插入失败,返回错误代码 3
+ }
+ }
+ }
+
+ return 0; // 插入成功,返回 0
+}
+
+// 获取指定 RPTID 的所有 VID
+int SECSRuntimeManager::deleteRPTIDVID(int nRPTID, int nVID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1; // 数据库未连接
+ }
+
+ // 检查 ReportVIDs 表中是否存在该 RPTID 和 VID 组合
+ std::string checkExistSQL = "SELECT COUNT(*) FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + " AND VID = " + std::to_string(nVID) + ";";
+ int count = getIntFromDB(checkExistSQL);
+ if (count == 0) {
+ return 2; // 记录不存在
+ }
+
+ // 删除 ReportVIDs 表中指定 RPTID 和 VID 的关系
+ std::string deleteSQL = "DELETE FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + " AND VID = " + std::to_string(nVID) + ";";
+ if (!m_pDB->executeQuery(deleteSQL)) {
+ return 3; // 删除失败
+ }
+
+ return 0; // 删除成功
+}
+
+// 删除指定 RPTID 的所有 VID6
+int SECSRuntimeManager::deleteRPTID(int nRPTID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1; // 数据库未连接
+ }
+
+ // 删除 ReportVIDs 表中所有与该 RPTID 相关的记录
+ std::string deleteReportVIDsSQL = "DELETE FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + ";";
+ if (!m_pDB->executeQuery(deleteReportVIDsSQL)) {
+ return 2; // 删除失败
+ }
+
+ // 可选择是否删除 Report 表中的 RPTID,以下是删除 Report 表中的 RPTID 的 SQL
+ std::string deleteReportSQL = "DELETE FROM Report WHERE RPTID = " + std::to_string(nRPTID) + ";";
+ if (!m_pDB->executeQuery(deleteReportSQL)) {
+ return 3; // 删除失败
+ }
+
+ return 0; // 删除成功
+}
+
+// 更新指定 RPTID 的 VID
+int SECSRuntimeManager::updateRPTIDVID(int nRPTID, int nOldVID, int nNewVID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1; // 数据库未连接
+ }
+
+ // 检查指定的 RPTID 和 OldVID 是否存在
+ std::string checkExistSQL = "SELECT COUNT(*) FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + " AND VID = " + std::to_string(nOldVID) + ";";
+ int count = getIntFromDB(checkExistSQL);
+ if (count == 0) {
+ return 2; // 记录不存在,不能更新
+ }
+
+ // 检查新的 VID 是否已经存在于相同的 RPTID 下,防止重复
+ std::string checkNewVIDExistSQL = "SELECT COUNT(*) FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + " AND VID = " + std::to_string(nNewVID) + ";";
+ int newVIDCount = getIntFromDB(checkNewVIDExistSQL);
+ if (newVIDCount > 0) {
+ return 3; // 新的 VID 已经存在,不能重复
+ }
+
+ // 执行更新操作,替换 OldVID 为 NewVID
+ std::string updateSQL = "UPDATE ReportVIDs SET VID = " + std::to_string(nNewVID) + " WHERE RPTID = " + std::to_string(nRPTID) + " AND VID = " + std::to_string(nOldVID) + ";";
+ if (!m_pDB->executeQuery(updateSQL)) {
+ return 4; // 更新失败
+ }
+
+ return 0; // 更新成功
+}
+
+// 更新指定 RPTID 的所有 VID
+int SECSRuntimeManager::updateRPTIDVIDs(int nRPTID, const std::vector<int>& vecVID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1; // 数据库未连接
+ }
+
+ // 1. 先删除 RPTID 下所有的 VID 关联记录
+ int deleteResult = deleteRPTID(nRPTID);
+ if (deleteResult != 0) {
+ return deleteResult; // 删除失败,返回删除的错误码
+ }
+
+ // 2. 添加新的 VID 关联记录
+ int addResult = addRPTIDVIDs(nRPTID, vecVID);
+ if (addResult != 0) {
+ return 3; // 插入失败
+ }
+
+ return 0; // 删除并添加成功
+}
+
+// 获取指定 RPTID 的所有 VID
+std::vector<int> SECSRuntimeManager::getVIDsByRPTID(int nRPTID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ std::vector<int> vecVIDs;
+
+ if (m_pDB == nullptr) {
+ return {};
+ }
+
+ // 构建查询 SQL,查询指定 RPTID 下的所有 VID
+ std::string querySQL = "SELECT VID FROM ReportVIDs WHERE RPTID = " + std::to_string(nRPTID) + ";";
+
+ // 执行查询
+ std::vector<std::vector<std::string>> results = m_pDB->fetchResults(querySQL);
+
+ // 处理查询结果并填充到 vecVIDs 中
+ for (const auto& row : results) {
+ if (!row.empty()) {
+ int nVID = std::stoi(row[0]); // 将字符串类型的 VID 转换为 int
+ vecVIDs.push_back(nVID); // 将 VID 加入结果向量
+ }
+ }
+
+ return vecVIDs;
+}
+
+// 获取所有 RPTID
+std::vector<int> SECSRuntimeManager::getAllRPTIDs() {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ std::vector<int> vecRPTIDs;
+
+ if (m_pDB == nullptr) {
+ throw std::runtime_error("Database not connected.");
+ }
+
+ // 构建查询 SQL,查询 Report 表中的所有 RPTID
+ std::string querySQL = "SELECT RPTID FROM Report;";
+
+ // 执行查询
+ std::vector<std::vector<std::string>> results = m_pDB->fetchResults(querySQL);
+
+ // 处理查询结果并填充到 vecRPTIDs 中
+ for (const auto& row : results) {
+ if (!row.empty()) {
+ int nRPTID = std::stoi(row[0]); // 将字符串类型的 RPTID 转换为 int
+ vecRPTIDs.push_back(nRPTID); // 将 RPTID 加入结果向量
+ }
+ }
+
+ return vecRPTIDs;
}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.h b/SourceCode/Bond/Servo/SECSRuntimeManager.h
index 8c11a96..f0a722d 100644
--- a/SourceCode/Bond/Servo/SECSRuntimeManager.h
+++ b/SourceCode/Bond/Servo/SECSRuntimeManager.h
@@ -298,6 +298,125 @@
*/
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銆�
+ * 濡傛灉鍒犻櫎鎿嶄綔澶辫触锛屽垯杩斿洖閿欒浠g爜 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銆�
+ *
+ * 鑻ュ垹闄ゅけ璐ワ紝鍒欒繑鍥炵浉搴旂殑閿欒浠g爜銆傚鏋滄垚鍔熷垹闄ゆ墍鏈夎褰曪紝鍒欒繑鍥� 0銆�
+ */
+ int deleteRPTID(int nRPTID);
+
+ /**
+ * 鏇存柊鎸囧畾 RPTID 鐨� VID 鍏宠仈璁板綍
+ * @param nRPTID: 闇�瑕佹洿鏂扮殑 RPTID銆�
+ * @param nOldVID: 闇�瑕佹洿鏂扮殑鏃� VID銆�
+ * @param nNewVID: 鏂扮殑 VID锛屾浛浠f棫鐨� VID銆�
+ *
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: 鎵句笉鍒版寚瀹氱殑 RPTID 鍜屾棫 VID 缁勫悎銆�
+ * @return 3: 鏂扮殑 VID 宸茬粡瀛樺湪浜庤 RPTID 涓嬨��
+ * @return 4: 鏇存柊鎿嶄綔澶辫触銆�
+ * @return 0: 鏇存柊鎴愬姛锛孷ID 宸茶鏇挎崲涓烘柊鐨� 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();
--
Gitblit v1.9.3