|
@@ -671,4 +671,128 @@ bool ToEQMDataBase::getDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo, std
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+/* 获取设备和算法关联信息,重载版,只获取关联关系 */
|
|
|
+bool ToEQMDataBase::getDeviceAlgorithmInfo(std::multimap<int, std::string>& mapCameraActionID)
|
|
|
+{
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ mapCameraActionID.clear();
|
|
|
+ nJson json0;
|
|
|
+ json0["opName"] = "SPSS_SelectFromActionCamer";
|
|
|
+ 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,"获取ActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ /* 解析信息 */
|
|
|
+ try
|
|
|
+ {
|
|
|
+ nJson json1 = nJson::parse(strRet.toStdString());
|
|
|
+ int retCode = json1["code"].get<int>();
|
|
|
+ if(retCode != 0)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"获取ActionCamer失败");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ nJson result = json1["result"];
|
|
|
+ if(result.empty())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ /* 取出所有的设备算法信息 */
|
|
|
+ for(const auto& it : result)
|
|
|
+ {
|
|
|
+ int cameraID = it["camerId"].get<int>();
|
|
|
+ std::string actionID = it["actionId"].is_null() ? "" : it["actionId"].get<std::string>();
|
|
|
+ mapCameraActionID.insert(std::make_pair(cameraID, actionID));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (const nJson::parse_error& e) {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"解析ActionCamer数据失败:{}, 错误ID:{}",e.what(), e.id);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ catch (const nJson::type_error& e) {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"解析ActionCamer数据失败:{}, 错误ID:{}",e.what(), e.id);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/* 获取摄像机和房间关联信息 */
|
|
|
+bool ToEQMDataBase::getRoomCameraInfo(std::list<RoomCameraInfo>& vecInfo)
|
|
|
+{
|
|
|
+ if(m_httpApi == nullptr)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ vecInfo.clear();
|
|
|
+ nJson json0;
|
|
|
+ json0["opName"] = "SPSS_SelectRoomCamer";
|
|
|
+ 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,"获取RoomCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ nJson json1 = nJson::parse(strRet.toStdString());
|
|
|
+ int retCode = json1["code"].get<int>();
|
|
|
+ if(retCode != 0)
|
|
|
+ {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"获取RoomCamer失败");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ nJson result = json1["result"];
|
|
|
+ if(result.empty())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for(const auto& it : result)
|
|
|
+ {
|
|
|
+ auto roomID = it["roomId"].get<int>();
|
|
|
+ auto cameraID = it["camerId"].is_null() ? -1 : it["camerId"].get<int>();
|
|
|
+ /* 先检查RoomID是否已经在列表中了 */
|
|
|
+ bool isExist = false;
|
|
|
+ for(auto& it0 : vecInfo)
|
|
|
+ {
|
|
|
+ if(it0.RoomID == roomID)
|
|
|
+ {
|
|
|
+ it0.listCameraID.push_back(cameraID);
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* 没有找到RoomID,创建一个新的 */
|
|
|
+ if(!isExist)
|
|
|
+ {
|
|
|
+ RoomCameraInfo info;
|
|
|
+ info.RoomID = roomID;
|
|
|
+ info.listCameraID.push_back(cameraID);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (const nJson::parse_error& e) {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"解析ActionCamer数据失败:{}, 错误ID:{}",e.what(), e.id);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ catch (const nJson::type_error& e) {
|
|
|
+ SPDLOG_LOGGER_ERROR(m_logger,"解析ActionCamer数据失败:{}, 错误ID:{}",e.what(), e.id);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
|