|
@@ -67,11 +67,11 @@ bool ToEQMDataBase::initWebApi(const QString& url, const QString& serverIP, cons
|
|
|
* @brief 写入算法信息,写入tAction表
|
|
|
*
|
|
|
* @param vecInfo 要写入的表格数据
|
|
|
- * @param vecNowInfo 现有的标配个数据,主要是为了重复利用已经删除的自增主键而传入的
|
|
|
+ * @param vecNowInfo 现有的表格数据,主要是为了重复利用已经删除的自增主键而传入的
|
|
|
* @return true
|
|
|
* @return false
|
|
|
*/
|
|
|
-bool ToEQMDataBase::writeAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo, std::vector<AlgorithmInfo>& vecNowInfo)
|
|
|
+bool ToEQMDataBase::writeAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo)
|
|
|
{
|
|
|
if(m_httpApi == nullptr)
|
|
|
{
|
|
@@ -79,12 +79,21 @@ bool ToEQMDataBase::writeAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo, std:
|
|
|
return false;
|
|
|
}
|
|
|
/* 取出可用的自增主键,从0开始计算 */
|
|
|
- std::list<int> listPKID;
|
|
|
- for(const auto& it : vecNowInfo)
|
|
|
- {
|
|
|
- listPKID.push_back(it.PKID);
|
|
|
- }
|
|
|
-
|
|
|
+ // std::list<int> listPKID;
|
|
|
+ // int nPKID = 0;
|
|
|
+ // for(const auto& it : vecNowInfo)
|
|
|
+ // {
|
|
|
+ // while(it.ActionTaskID == nPKID)
|
|
|
+ // {
|
|
|
+ // if(it.PKID != nPKID)
|
|
|
+ // {
|
|
|
+ // listPKID.push_back(nPKID);
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // nPKID ++;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ /* 循环写入数据 */
|
|
|
for(const auto& it : vecInfo)
|
|
|
{
|
|
|
QString retStr;
|
|
@@ -182,3 +191,187 @@ bool ToEQMDataBase::getAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/* 插入设备信息 */
|
|
|
+bool ToEQMDataBase::insertDeviceInfo(std::vector<DeviceInfo>& vecInfo)
|
|
|
+{
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(vecInfo.empty())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ bool isSuccess = true;
|
|
|
+ for(const auto& it : vecInfo)
|
|
|
+ {
|
|
|
+ nJson json0;
|
|
|
+ json0["opName"] = "SPSS_InsertToCamerInfo";
|
|
|
+ nJson json1;
|
|
|
+ json1["camerID"] = it.DeviceID;
|
|
|
+ json1["camerName"] = it.DeviceName.empty() ? nullptr : it.DeviceName;
|
|
|
+ json1["camerIP"] = it.DeviceIP.empty() ? nullptr : it.DeviceIP;
|
|
|
+ json1["camerPort"] = it.DevicePort;
|
|
|
+ json1["camerUser"] = it.UserAccount.empty() ? nullptr : it.UserAccount;
|
|
|
+ json1["camerPwd"] = it.UserPassword.empty() ? nullptr : it.UserPassword;
|
|
|
+ json1["camerType"] = it.DeviceType.empty() ? nullptr : it.DeviceType;
|
|
|
+ json1["camerSerial"] = it.DeviceSerial.empty() ? nullptr : it.DeviceSerial;
|
|
|
+ json1["camerChannel"] = nullptr;
|
|
|
+ json1["camerUrl"] = nullptr;
|
|
|
+
|
|
|
+ json0["paramList"] = json1;
|
|
|
+ QString strCmd = QString::fromStdString(json0.dump());
|
|
|
+ QString strRet;
|
|
|
+ auto ret = m_httpApi->DBQDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
|
|
|
+ if(ret < 0)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_DEBUG(m_logger,"插入设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ isSuccess = false;
|
|
|
+ }
|
|
|
+ SPDLOG_LOGGER_DEBUG(m_logger,"插入数据 {} 到 CamerInfo 成功!", it.DeviceID);
|
|
|
+ }
|
|
|
+
|
|
|
+ return isSuccess;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/* 更新设备信息 */
|
|
|
+bool ToEQMDataBase::updateDeviceInfo(std::vector<DeviceInfo>& vecUpdateInfo)
|
|
|
+{
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(vecUpdateInfo.empty())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ bool isSuccess = true;
|
|
|
+
|
|
|
+ for(const auto& it : vecUpdateInfo)
|
|
|
+ {
|
|
|
+ nJson json0;
|
|
|
+ json0["opName"] = "SPSS_UpdateToCamerInfo";
|
|
|
+ nJson json1;
|
|
|
+ json1["camerID"] = it.DeviceID;
|
|
|
+ json1["camerName"] = it.DeviceName.empty() ? nullptr : it.DeviceName;
|
|
|
+ json1["camerIP"] = it.DeviceIP.empty() ? nullptr : it.DeviceIP;
|
|
|
+ json1["camerPort"] = it.DevicePort;
|
|
|
+ json1["camerUser"] = it.UserAccount.empty() ? nullptr : it.UserAccount;
|
|
|
+ json1["camerPwd"] = it.UserPassword.empty() ? nullptr : it.UserPassword;
|
|
|
+ json1["camerType"] = it.DeviceType.empty() ? nullptr : it.DeviceType;
|
|
|
+ json1["camerSerial"] = it.DeviceSerial.empty() ? nullptr : it.DeviceSerial;
|
|
|
+ json1["camerChannel"] = nullptr;
|
|
|
+ json1["camerUrl"] = nullptr;
|
|
|
+
|
|
|
+ json0["paramList"] = json1;
|
|
|
+ QString strCmd = QString::fromStdString(json0.dump());
|
|
|
+ QString strRet;
|
|
|
+ auto ret = m_httpApi->DBQDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
|
|
|
+ if(ret < 0)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_DEBUG(m_logger,"更新设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ isSuccess = false;
|
|
|
+ }
|
|
|
+ SPDLOG_LOGGER_DEBUG(m_logger,"更新数据 {} 到 CamerInfo 成功!", it.DeviceID);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return isSuccess;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/* 删除设备信息 */
|
|
|
+bool ToEQMDataBase::deleteDeviceInfo(std::vector<DeviceInfo>& vecDeleteInfo)
|
|
|
+{
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(vecDeleteInfo.empty())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ bool isSuccess = true;
|
|
|
+
|
|
|
+ for(const auto& it : vecDeleteInfo)
|
|
|
+ {
|
|
|
+ nJson json0;
|
|
|
+ json0["opName"] = "SPSS_DeleteFromCamerInfo";
|
|
|
+ nJson json1;
|
|
|
+ json1["camerID"] = it.DeviceID;
|
|
|
+ json0["paramList"] = json1;
|
|
|
+ QString strCmd = QString::fromStdString(json0.dump());
|
|
|
+ QString strRet;
|
|
|
+ auto ret = m_httpApi->DBQDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
|
|
|
+ if(ret < 0)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_DEBUG(m_logger,"删除设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ isSuccess = false;
|
|
|
+ }
|
|
|
+ SPDLOG_LOGGER_DEBUG(m_logger,"删除数据 {} 到 CamerInfo 成功!", it.DeviceID);
|
|
|
+ }
|
|
|
+
|
|
|
+ return isSuccess;
|
|
|
+}
|
|
|
+
|
|
|
+/* 从EQM获取CamerInfo信息 */
|
|
|
+bool ToEQMDataBase::getDeviceInfo(std::vector<DeviceInfo>& vecInfo)
|
|
|
+{
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ vecInfo.clear();
|
|
|
+ nJson json0;
|
|
|
+ json0["opName"] = "SPSS_SelectFromCamerInfo";
|
|
|
+ QString strCmd = QString::fromStdString(json0.dump());
|
|
|
+ QString strRet;
|
|
|
+ auto ret = m_httpApi->DBQDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
|
|
|
+ if(ret < 0)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_DEBUG(m_logger,"获取CamerInfo失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 解析信息 */
|
|
|
+ nJson json1 = nJson::parse(strRet.toStdString());
|
|
|
+ int retCode = json1["code"].get<int>();
|
|
|
+ if(retCode != 0)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"获取CamerInfo失败");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ nJson result = json1["result"];
|
|
|
+ if(result.empty())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for(const auto& it : result)
|
|
|
+ {
|
|
|
+ // SPDLOG_LOGGER_DEBUG(m_logger,"camerID:{}",it["camerId"].get<int>());
|
|
|
+ DeviceInfo info;
|
|
|
+ info.DeviceID = it["camerId"].get<int>();
|
|
|
+ info.DeviceName = it["camerName"].is_null() ? "" : it["camerName"].get<std::string>();
|
|
|
+ info.DeviceIP = it["camerIp"].is_null() ? "" : it["camerIp"].get<std::string>();
|
|
|
+ info.DevicePort = it["camerPort"].is_null() ? 0 : it["camerPort"].get<int>();
|
|
|
+ info.UserAccount = it["camerUsr"].is_null() ? "" : it["camerUsr"].get<std::string>();
|
|
|
+ info.UserPassword = it["camerPwd"].is_null() ? "" : it["camerPwd"].get<std::string>();
|
|
|
+ info.DeviceType = it["camerType"].is_null() ? "" : it["camerType"].get<std::string>();
|
|
|
+ info.DeviceSerial = it["camerSerial"].is_null() ? "" : it["camerSerial"].get<std::string>();
|
|
|
+
|
|
|
+ vecInfo.push_back(info);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+
|