From e8a27bb203fe2aff70390a5eca002d7438da9b0f Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期三, 22 十月 2025 14:24:34 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang

---
 SourceCode/Bond/Servo/SECSRuntimeManager.h |  532 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 523 insertions(+), 9 deletions(-)

diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.h b/SourceCode/Bond/Servo/SECSRuntimeManager.h
index 5c41733..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,36 +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);
+
+	/**
+    * 鍒濆鍖朣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);
+
+	/**
+     * 鏇存柊鎵�鏈� 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();
+
+	/**
+	 * 娣诲姞 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 琛�
+    */ 
+    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();
+
+	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 琛�
+    */ 
+    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