From f2ac06cd25abc8d69ceeb0b19abdb5051d9fcf41 Mon Sep 17 00:00:00 2001 From: xuxiuxi <554325746@qq.com> Date: 星期四, 07 三月 2019 11:40:18 +0800 Subject: [PATCH] find channel bug --- QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.cpp | 3 +++ QiaoJiaSystem/DataManagerServer/CMakeLists.txt | 2 +- QiaoJiaSystem/DataManagerServer/vss/dao/BaseSqliteDao.cpp | 7 +++++++ QiaoJiaSystem/DataManagerServer/vss/dao/VssDevTblDao.h | 6 ++++++ QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.h | 8 ++++++-- QiaoJiaSystem/DataManagerServer/vss/dao/VssChannelTblDao.h | 7 ++++++- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/CMakeLists.txt b/QiaoJiaSystem/DataManagerServer/CMakeLists.txt index e36f449..641363f 100644 --- a/QiaoJiaSystem/DataManagerServer/CMakeLists.txt +++ b/QiaoJiaSystem/DataManagerServer/CMakeLists.txt @@ -110,7 +110,7 @@ ../LocalDBTool/SqliteFaceEncap.cpp ../../../BasicPlatForm/basic/db/sqlite/sqliteEncapsulation.cpp ../../../BasicPlatForm/basic/db/sqlite/sqliteEncapsulation.h - ) + vss/dao/BaseDao.cpp) target_link_libraries(DataWebServer glog diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.cpp b/QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.cpp new file mode 100644 index 0000000..7246923 --- /dev/null +++ b/QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.cpp @@ -0,0 +1,3 @@ +#include "BaseDao.h" +mysqlpp::Connection* BaseDao::conn = nullptr; +QMutex BaseDao::m_mutexVisit; \ No newline at end of file diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.h b/QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.h index 636a246..e129903 100644 --- a/QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.h +++ b/QiaoJiaSystem/DataManagerServer/vss/dao/BaseDao.h @@ -8,11 +8,15 @@ #include <iostream> #include <mysql++.h> #include <AppConfig.h> +#include <QtCore/QMutex> using namespace std; -static mysqlpp::Connection* conn; class BaseDao { +public: + static QMutex m_mutexVisit; +private: + static mysqlpp::Connection* conn; public: static mysqlpp::SimpleResult add(std::map<std::string, std::string>& columns, string tableName) { initConnection(); @@ -135,7 +139,7 @@ // )) { if (conn->connect( "EGEyesForVSS", - "127.0.0.1", + "192.168.1.148", "root", "123456", 3306 diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/BaseSqliteDao.cpp b/QiaoJiaSystem/DataManagerServer/vss/dao/BaseSqliteDao.cpp new file mode 100644 index 0000000..7982039 --- /dev/null +++ b/QiaoJiaSystem/DataManagerServer/vss/dao/BaseSqliteDao.cpp @@ -0,0 +1,7 @@ +#include "BaseSqliteDao.h" + +LDBTool* BaseSqliteDao::lDBTool = nullptr; +QSqlDatabase* BaseSqliteDao::m_db = nullptr; +QSqlTableModel *BaseSqliteDao::m_pModel = nullptr; +QMutex* BaseSqliteDao::m_mutexVisit = nullptr; +ErlangTool::ErlangDbTool *BaseSqliteDao::erlangDbTool = nullptr; \ No newline at end of file diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/VssChannelTblDao.h b/QiaoJiaSystem/DataManagerServer/vss/dao/VssChannelTblDao.h index 9db3d3b..ed07dd7 100755 --- a/QiaoJiaSystem/DataManagerServer/vss/dao/VssChannelTblDao.h +++ b/QiaoJiaSystem/DataManagerServer/vss/dao/VssChannelTblDao.h @@ -23,6 +23,7 @@ /** 娣诲姞鍒涘缓浜岀骇璁惧琛� keyValuesToAdd 闇�瑕佹坊鍔犵殑鍒楀悕鍜屽垪鍊煎map*/ mysqlpp::SimpleResult addVssChannelTbl(std::map<std::string, std::string>& keyValuesToAdd) { + QMutexLocker mutexLocker(&m_mutexVisit); return add(keyValuesToAdd, VSSChannelTbl_TABLE_NAME); } @@ -35,12 +36,14 @@ /** 鍒犻櫎鍒涘缓浜岀骇璁惧琛� whereColumnNameValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ bool deleteVssChannelTbl(std::map<std::string, std::string>& whereKeyValues) { + QMutexLocker mutexLocker(&m_mutexVisit); return del(VSSChannelTbl_TABLE_NAME, whereKeyValues); } /** 鏇存柊鍒涘缓浜岀骇璁惧琛� keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ - bool updateVssChannelTbl(std::map<std::string, std::string>& keyValuesToUpdate, + bool updateVssChannelTbl(std::map<std::string, std::string>& keyValuesToUpdate, std::map<std::string, std::string>& whereKeyValues) { + QMutexLocker mutexLocker(&m_mutexVisit); return update(keyValuesToUpdate, VSSChannelTbl_TABLE_NAME, whereKeyValues); } @@ -55,6 +58,7 @@ /** 鏌ヨ鍒涘缓浜岀骇璁惧琛ㄥ垪琛� querySql 瑕佹煡璇㈢殑sql璇彞 */ vector<VssChannelTbl> findVssChannelTblList(string querySql) { + QMutexLocker mutexLocker(&m_mutexVisit); vector<VssChannelTbl> vssChannelTblVec; vector<map<string, string>> rowDatList = findList(querySql); vssChannelTblVec.reserve(rowDatList.size()); @@ -81,6 +85,7 @@ /** 鎵цsql璇彞 */ bool execute(string sql) { + QMutexLocker mutexLocker(&m_mutexVisit); return exec(move(sql)); } diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/VssDevTblDao.h b/QiaoJiaSystem/DataManagerServer/vss/dao/VssDevTblDao.h index ffcd6fe..87b5963 100755 --- a/QiaoJiaSystem/DataManagerServer/vss/dao/VssDevTblDao.h +++ b/QiaoJiaSystem/DataManagerServer/vss/dao/VssDevTblDao.h @@ -23,6 +23,7 @@ /** 娣诲姞鍒涘缓涓�绾ц澶囪〃 keyValuesToAdd 闇�瑕佹坊鍔犵殑鍒楀悕鍜屽垪鍊煎map*/ mysqlpp::SimpleResult addVssDevTbl(std::map<std::string, std::string>& keyValuesToAdd) { + QMutexLocker mutexLocker(&m_mutexVisit); return add(keyValuesToAdd, VSSDevTbl_TABLE_NAME); } @@ -35,12 +36,14 @@ /** 鍒犻櫎鍒涘缓涓�绾ц澶囪〃 whereColumnNameValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ bool deleteVssDevTbl(std::map<std::string, std::string>& whereKeyValues) { + QMutexLocker mutexLocker(&m_mutexVisit); return del(VSSDevTbl_TABLE_NAME, whereKeyValues); } /** 鏇存柊鍒涘缓涓�绾ц澶囪〃 keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ bool updateVssDevTbl(std::map<std::string, std::string>& keyValuesToUpdate, std::map<std::string, std::string>& whereKeyValues) { + QMutexLocker mutexLocker(&m_mutexVisit); return update(keyValuesToUpdate, VSSDevTbl_TABLE_NAME, whereKeyValues); } @@ -55,6 +58,7 @@ /** 鏌ヨ鍒涘缓涓�绾ц澶囪〃鍒楄〃 querySql 瑕佹煡璇㈢殑sql璇彞 */ vector<VssDevTbl> findVssDevTblList(string querySql) { + QMutexLocker mutexLocker(&m_mutexVisit); vector<VssDevTbl> vssDevTblVec; vector<map<string, string>> rowDatList = findList(querySql); vssDevTblVec.reserve(rowDatList.size()); @@ -76,11 +80,13 @@ /** 鏌ヨmap鍒楄〃 querySql 瑕佹煡璇㈢殑sql璇彞 */ vector<map<string, string>> findMapList(string querySql) { + QMutexLocker mutexLocker(&m_mutexVisit); return findList(querySql); } /** 鎵цsql璇彞 */ bool execute(string sql) { + QMutexLocker mutexLocker(&m_mutexVisit); return exec(move(sql)); } -- Gitblit v1.8.0