From 829fe6c6bc33d53fda9c31fd45a37e1df87befff Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 30 一月 2026 11:16:24 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang
---
SourceCode/Bond/Servo/SECSRuntimeManager.h | 498 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 477 insertions(+), 21 deletions(-)
diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.h b/SourceCode/Bond/Servo/SECSRuntimeManager.h
index 4562c39..a3bc39d 100644
--- a/SourceCode/Bond/Servo/SECSRuntimeManager.h
+++ b/SourceCode/Bond/Servo/SECSRuntimeManager.h
@@ -1,4 +1,4 @@
-#ifndef SECS_RUNTIME_MANAGER_H
+锘�#ifndef SECS_RUNTIME_MANAGER_H
#define SECS_RUNTIME_MANAGER_H
#include <string>
@@ -9,94 +9,550 @@
class SECSRuntimeManager {
public:
/**
- * 获取单例实例
- * @return SECSRuntimeManager实例的引用
+ * 鑾峰彇鍗曚緥瀹炰緥
+ * @return SECSRuntimeManager瀹炰緥鐨勫紩鐢�
*/
static SECSRuntimeManager& getInstance();
/**
- * 设置数据库连接
- * @param db 数据库连接的指针
+ * 璁剧疆鏁版嵁搴撹繛鎺�
+ * @param db 鏁版嵁搴撹繛鎺ョ殑鎸囬拡
*/
void setDatabase(BL::Database* db);
/**
- * 初始化SECS运行设置管理库
- * @return 成功返回true,失败返回false
+ * 鍒濆鍖朣ECS杩愯璁剧疆绠$悊搴�
+ * @return 鎴愬姛杩斿洖true锛屽け璐ヨ繑鍥瀎alse
*/
bool initRuntimeSetting();
/**
- * 销毁SECS运行设置管理库
+ * 閿�姣丼ECS杩愯璁剧疆绠$悊搴�
*/
void termRuntimeSetting();
+ /**
+ * 鍒濆鍖栨寚瀹氱殑 SystemV 琛�
+ * @param tableName: 瑕佸垵濮嬪寲鐨勮〃鍚嶏紙濡� "SystemSV" 鎴� "SystemDV"锛夈��
+ *
+ * 姝ゅ嚱鏁扮敤浜庡垵濮嬪寲鎸囧畾鍚嶇О鐨� SystemV 琛ㄣ�傚鏋滆〃涓嶅瓨鍦紝灏嗕細鍒涘缓璇ヨ〃銆�
+ * - 琛ㄧ粨鏋勫寘鎷細ID銆丯ame銆丏ataType銆丩ength銆乁nit銆丷emark銆丼ystemID銆�
+ * - 濡傛灉琛ㄥ凡缁忓瓨鍦紝鍒欎笉杩涜浠讳綍鎿嶄綔銆�
+ */
+ 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表
+ * 鍒濆鍖朣ystemSV琛�
*/
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` 鏄惁宸插瓨鍦ㄤ簬琛ㄤ腑锛�
+ * 濡傛灉瀛樺湪鍒欒繑鍥炵浉搴旂殑閿欒浠g爜銆傚鏋� `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>>: 杩斿洖涓�涓簩缁村瓧绗︿覆鍚戦噺锛岃〃绀烘煡璇㈢粨鏋溿�傛瘡琛屼唬琛ㄤ竴鏉¤褰曪紝姣忓垪浠h〃璇ヨ褰曠殑涓�涓瓧娈靛�笺��
+ * 濡傛灉鎸囧畾鐨� ID 瀛樺湪锛屽垯杩斿洖璇� ID 瀵瑰簲鐨勮褰曪紱濡傛灉涓嶅瓨鍦紝鍒欒繑鍥炵┖鐨勪簩缁村悜閲忋��
+ *
+ * 姝ゅ嚱鏁扮敤浜庨�氳繃鎸囧畾鐨� `ID` 浠� SystemSV 琛ㄤ腑鏌ユ壘瀵瑰簲鐨勬暟鎹�傞鍏堟牴鎹紶鍏ョ殑 `ID` 鏋勯�犳煡璇� SQL 璇彞锛�
+ * 鐒跺悗鎵ц鏌ヨ鎿嶄綔锛岃繑鍥炴煡璇㈢粨鏋溿�傛煡璇㈢粨鏋滄槸涓�涓簩缁村瓧绗︿覆鍚戦噺锛岃〃绀烘煡璇㈠埌鐨勮褰曘�傛瘡琛屾槸涓�涓�
+ * 瀛楃涓插悜閲忥紝姣忎釜鍏冪礌鏄琛屼腑鐨勪竴鍒楁暟鎹�傚鏋滄壘涓嶅埌瀵瑰簲鐨勬暟鎹紝鍑芥暟灏嗚繑鍥炰竴涓┖鐨勪簩缁村悜閲忋��
+ */
+ std::vector<std::vector<std::string>> getSystemSVByID(int nID);
+
+ /**
+ * 鑾峰彇鎵�鏈� SystemSV 鏁版嵁
+ * @return std::vector<std::vector<std::string>>: 杩斿洖涓�涓簩缁村瓧绗︿覆鍚戦噺锛岃〃绀烘煡璇㈢粨鏋溿�傛瘡琛屼唬琛ㄤ竴鏉¤褰曪紝姣忓垪浠h〃璇ヨ褰曠殑涓�涓瓧娈靛�笺��
+ * 濡傛灉琛ㄤ腑鏈夋暟鎹紝鍒欒繑鍥炴墍鏈夎褰曪紱濡傛灉琛ㄤ负绌猴紝鍒欒繑鍥炵┖鐨勪簩缁村悜閲忋��
+ *
+ * 姝ゅ嚱鏁扮敤浜庝粠 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` 宸茬粡瀛樺湪锛屽垯杩斿洖閿欒浠g爜 3銆�
+ * 濡傛灉鏁版嵁搴撴洿鏂板け璐ワ紝鍒欒繑鍥為敊璇唬鐮� 4銆傛垚鍔熸椂锛岃繑鍥� 0 琛ㄧず鎿嶄綔鎴愬姛銆�
+ */
+ int updateIDSystemSV(int nID, int sNewID);
+
/**
- * 初始化Eqp表
+ * 鏇存柊鎵�鏈� 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` 宸茬粡瀛樺湪锛屽垯杩斿洖閿欒浠g爜 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銆�
+ * 濡傛灉鍒犻櫎鎿嶄綔澶辫触锛屽垯杩斿洖閿欒浠g爜 2銆傚垹闄ゆ垚鍔熷悗锛岃繑鍥� 0 琛ㄧず鍒犻櫎鎴愬姛銆�
+ */
+ int deleteAllSystemSV();
+
+ /**
+ * 鍒濆鍖� EqpSV 琛�
*/
void initEqpSVTable();
/**
- * 初始化SystemDV表
+ * 娣诲姞 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` 鏄惁宸插瓨鍦ㄤ簬琛ㄤ腑锛�
+ * 濡傛灉瀛樺湪鍒欒繑鍥炵浉搴旂殑閿欒浠g爜銆傚鏋� `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>>: 杩斿洖涓�涓簩缁村瓧绗︿覆鍚戦噺锛岃〃绀烘煡璇㈢粨鏋溿�傛瘡琛屼唬琛ㄤ竴鏉¤褰曪紝姣忓垪浠h〃璇ヨ褰曠殑涓�涓瓧娈靛�笺��
+ * 濡傛灉鎸囧畾鐨� 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` 鏄惁宸插瓨鍦紝濡傛灉宸插瓨鍦ㄥ垯杩斿洖閿欒浠g爜 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` 宸茬粡瀛樺湪锛屽垯杩斿洖閿欒浠g爜 3銆�
+ * 濡傛灉鏁版嵁搴撴洿鏂板け璐ワ紝鍒欒繑鍥為敊璇唬鐮� 4銆傛垚鍔熸椂锛岃繑鍥� 0 琛ㄧず鎿嶄綔鎴愬姛銆�
+ */
+ int deleteEqpSVByID(int nID);
+
+ /**
+ * 鍒犻櫎鎵�鏈� EqpSV 鏁版嵁
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: 鍒犻櫎鎿嶄綔澶辫触銆�
+ * @return 0: 鍒犻櫎鎴愬姛銆�
+ *
+ * 姝ゅ嚱鏁扮敤浜庡垹闄� `EqpSV` 琛ㄤ腑鐨勬墍鏈夎褰曘�傚鏋滄暟鎹簱鏈繛鎺ワ紝鍒欒繑鍥為敊璇唬鐮� 1銆�
+ * 濡傛灉鍒犻櫎鎿嶄綔澶辫触锛屽垯杩斿洖閿欒浠g爜 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表
+ * 鍒濆鍖� 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表
+ * 鍒濆鍖� 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表
+ * 鍒濆鍖� 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表
+ * 鍒濆鍖� 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表
+ * 鍒濆鍖� 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表
+ * 鍒濆鍖� EventLink 琛�
*/
void initEventLinkTable();
/**
- * 初始化PPID表
+ * 鍒濆鍖� PPID 琛�
*/
void initPPIDTable();
+ std::vector<std::string> getAllPPID();
+
+ void setAllPPID(const std::vector<std::string>& vecPPIDList);
+
+ bool updatePPIDForRecipe(int nRecipeNo, const std::string& strPPID);
+
+ std::string getPPIDForRecipe(int nRecipeNo);
+
+ int getRecipeForPPID(std::string strPPID);
+
+ bool deletePPIDForRecipe(int nRecipeNo);
+
+ bool deletePPIDForAllRecipes();
+
/**
- * 初始化RPTID表
+ * 鍒濆鍖� 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銆�
+ * 濡傛灉鍒犻櫎鎿嶄綔澶辫触锛屽垯杩斿洖閿欒浠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();
- // 禁止拷贝和赋值
+ // 绂佹鎷疯礉鍜岃祴鍊�
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;
};
--
Gitblit v1.9.3