现场更新备份
This commit is contained in:
@@ -70,20 +70,29 @@ sqlTableDatas sqlManager::selectSingleData(std::string selectStr, std::string SN
|
||||
{
|
||||
mutex.lock();
|
||||
sqlTableDatas selectResult;
|
||||
dbPtr->Select(getCurrentDate(), { selectStr }, "SN", SN, selectResult);
|
||||
dbPtr->Select(getCurrentDate(), { selectStr }, selectResult , "SN", SN);
|
||||
if (selectResult.rowDatas.size() == 0)//无指定数据 查找前一天
|
||||
dbPtr->Select(getPreviousDate(), { selectStr }, "SN", SN, selectResult);
|
||||
dbPtr->Select(getPreviousDate(), { selectStr }, selectResult, "SN", SN);
|
||||
mutex.unlock();
|
||||
return selectResult;
|
||||
}
|
||||
sqlTableDatas sqlManager::selectAllData(std::string SN)
|
||||
sqlTableDatas sqlManager::selectRowData(std::string SN)
|
||||
{
|
||||
mutex.lock();
|
||||
//dbPtr->Update(getCurrentTableName(), { {"send","1" } }, "sn", SN);
|
||||
sqlTableDatas selectResult;
|
||||
dbPtr->Select(getCurrentDate(), {}, "SN", SN, selectResult);
|
||||
dbPtr->Select(getCurrentDate(), {}, selectResult, "SN", SN);
|
||||
if(selectResult.rowDatas.size()==0)//无指定数据 查找前一天
|
||||
dbPtr->Select(getPreviousDate(), {}, "SN", SN, selectResult);
|
||||
dbPtr->Select(getPreviousDate(), {}, selectResult, "SN", SN);
|
||||
mutex.unlock();
|
||||
return selectResult;
|
||||
}
|
||||
sqlTableDatas sqlManager::selectAllData(std::string tableName)
|
||||
{
|
||||
mutex.lock();
|
||||
//dbPtr->Update(getCurrentTableName(), { {"send","1" } }, "sn", SN);
|
||||
sqlTableDatas selectResult;
|
||||
dbPtr->Select(tableName, {}, selectResult);
|
||||
mutex.unlock();
|
||||
return selectResult;
|
||||
}
|
||||
@@ -100,11 +109,11 @@ void sqlManager::initialization(appConfig* _appConfig,std::string dataBasePath,
|
||||
for (auto data : _appConfig->_sqlConfigStruct.datas)
|
||||
dataStr.push_back(data.first);
|
||||
|
||||
//创建未来180天的表格
|
||||
//创建未来的表格
|
||||
for (auto table : tables)
|
||||
dbPtr->createTable(table, dataStr);
|
||||
|
||||
//查询是否有后期添加未创建的表格
|
||||
//查询是否有后期添加未创建的列
|
||||
for (auto table : tables)
|
||||
{
|
||||
std::vector<std::string> res = dbPtr->getColumn(table);
|
||||
@@ -117,7 +126,7 @@ void sqlManager::initialization(appConfig* _appConfig,std::string dataBasePath,
|
||||
auto iter = map.find(str);//寻找
|
||||
if (iter == map.end())//找不到
|
||||
{
|
||||
dbPtr->addColumn(table, str, "REAL");//插入
|
||||
dbPtr->addColumn(table, str, "TEXT");//插入
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,7 +148,7 @@ bool sqlManager::addData(std::string SN,std::vector<sqlData> data)
|
||||
}
|
||||
sqlTableDatas selectResult;
|
||||
std::string currentTableName = getCurrentDate();
|
||||
sqlErr res=dbPtr->Select(currentTableName, {},"sn", SN, selectResult);
|
||||
sqlErr res=dbPtr->Select(currentTableName, {}, selectResult, "SN", SN);
|
||||
//查询出错
|
||||
if (res.customType != sqlOK)
|
||||
{
|
||||
@@ -150,7 +159,7 @@ bool sqlManager::addData(std::string SN,std::vector<sqlData> data)
|
||||
//找到SN,进行更新操作
|
||||
if (selectResult.rowDatas.size() != 0)
|
||||
{
|
||||
dbPtr->Update(currentTableName, data, "sn", SN);
|
||||
dbPtr->Update(currentTableName, data, "SN", SN);
|
||||
mutex.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user