Quellcode durchsuchen

V0.1.3
1、添加了写入EQM数据的类,但是没有插入数据成功

Apple vor 7 Monaten
Ursprung
Commit
f07b92ff3f

+ 4 - 2
SecurePlayAuxServer/CMakeLists.txt

@@ -54,6 +54,8 @@ target_link_libraries(${execName1} PRIVATE
 
 #连接stdc++fs库,如果编译器版本低于GCC9.0,则需要连接这个库
 #GCC9.0以上包含进了标准库
-if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
-    target_link_libraries(${execName1} PRIVATE stdc++fs)
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+        target_link_libraries(${execName1} PRIVATE stdc++fs)
+    endif()
 endif()

+ 33 - 0
SecurePlayAuxServer/GlobalInfo.h

@@ -0,0 +1,33 @@
+#ifndef GLOBALINFO_H
+#define GLOBALINFO_H
+
+#include <QString>
+
+#/**
+ * @brief 全局信息
+ * 
+ */
+
+/* 算法相关信息 */
+struct AlgorithmInfo
+{
+    QString ActionID;       /* 算法ID */
+    QString ActionName;     /* 算法名称 */
+    int ActionTaskID;   /* 算法任务ID */
+
+    AlgorithmInfo() = default;
+    AlgorithmInfo(const AlgorithmInfo& other)
+        : ActionID(other.ActionID), ActionName(other.ActionName), ActionTaskID(other.ActionTaskID) {}
+    AlgorithmInfo& operator=(const AlgorithmInfo& other) {
+        if (this != &other) {
+            ActionID = other.ActionID;
+            ActionName = other.ActionName;
+            ActionTaskID = other.ActionTaskID;
+        }
+        return *this;
+    }
+};
+
+
+
+#endif /* GLOBALINFO_H */

+ 11 - 27
SecurePlayAuxServer/SPAServer.cpp

@@ -2,11 +2,11 @@
 
 #include "spdlog/spdlog.h"
 #include "CurlHttp.h"
-
 #include <filesystem>
-
 #include "CurlFtp.h"
 
+#include <QVector>
+
 
 SPAServer::SPAServer()
 {
@@ -28,33 +28,17 @@ SPAServer::SPAServer()
     // m_fromRedis.disConnectRedis();
 
     //|FTP|192.1.2.178:32021|lh|DWw7V9u0|
-    CurlFtp ftp;
-    ftp.setFtpIPAndPort("192.1.2.178", 32021);
-    ftp.setFtpUsernameAndPassword("lh", "DWw7V9u0");
 
-    std::string ftpPath = "lh";
-    std::vector<std::string> vecFile;
-    std::vector<std::string> vecDir;
-    ftp.getFileList(ftpPath, vecFile);
-    ftp.getDirList(ftpPath, vecDir);
-
-    for(auto& file : vecFile)
-    {
-        SPDLOG_LOGGER_INFO(m_logger, "{}", file);
-    }
-    for(auto& dir : vecDir)
-    {
-        SPDLOG_LOGGER_INFO(m_logger, "{}", dir);
-    }
+    m_toEQMDataBase.initWebApi("http://192.1.3.133:31000/v6/", "", "4c2f9fc91c22dd98331e47af2e2964f4");
 
-    if(ftp.isDirExist(ftpPath))
-    {
-        SPDLOG_LOGGER_INFO(m_logger, "文件夹存在");
-    }
-    else
-    {
-        SPDLOG_LOGGER_INFO(m_logger, "文件夹不存在");
-    }
+    AlgorithmInfo info;
+    info.ActionID = "123";
+    info.ActionName = "test";
+    info.ActionTaskID = 456;
+    QVector<AlgorithmInfo> vecInfo;
+    vecInfo.push_back(info);
+    m_toEQMDataBase.writeAlgorithmInfo(vecInfo);
+    
 }
 
 SPAServer::~SPAServer()

+ 2 - 1
SecurePlayAuxServer/SPAServer.h

@@ -3,7 +3,7 @@
 
 #include "FromSuperBrain.h"
 #include "FromRedis.h"
-
+#include "ToEQMDataBase.h"
 
 /**
  * 安播辅助提示系统服务类
@@ -20,6 +20,7 @@ private:
 
     FromSuperBrain m_fromSuperBrain;
     FromRedis m_fromRedis;
+    ToEQMDataBase m_toEQMDataBase;
 };
 
 #endif /* SPASERVER_H */

+ 39 - 3
SecurePlayAuxServer/communication/ToEQMDataBase.cpp

@@ -1,6 +1,8 @@
 #include "ToEQMDataBase.h"
 
-
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QVector>
 
 ToEQMDataBase::ToEQMDataBase()
 {
@@ -23,7 +25,7 @@ ToEQMDataBase::~ToEQMDataBase()
 
 
 /* 初始化WebApi */
-bool ToEQMDataBase::initWebApi(const QString& url,const QString& serverIP,const QString& serID)
+bool ToEQMDataBase::initWebApi(const QString& url, const QString& serverIP, const QString& serID)
 {
     if(m_httpApi == nullptr)
     {
@@ -48,7 +50,7 @@ bool ToEQMDataBase::initWebApi(const QString& url,const QString& serverIP,const
     SPDLOG_LOGGER_TRACE(m_logger,"Server list:{}",serverList.toStdString());
     SPDLOG_LOGGER_DEBUG(m_logger,"WebAPI Sucess!");
     /* 登录 */
-    ret = m_httpApi->DBQLogin(serverIP, serID, "EQM_MG", m_userToken);
+    ret = m_httpApi->DBQLogin(serverIP, serID, "SPSS", m_userToken);
     if(ret < 0)
     {
         SPDLOG_LOGGER_ERROR(m_logger,"Login failed:{}, error info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -59,3 +61,37 @@ bool ToEQMDataBase::initWebApi(const QString& url,const QString& serverIP,const
     return true;
 }
 
+
+/* 写入算法信息,写入tAction表 */
+bool ToEQMDataBase::writeAlgorithmInfo(QVector<AlgorithmInfo>& vecInfo)
+{
+    if(m_httpApi == nullptr)
+    {
+        SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
+        return false;
+    }
+
+    for(const auto& it : vecInfo)
+    {
+        QJsonDocument doc;
+        QJsonObject obj0;
+        QString retStr;
+        /* 操作名称,现在一次性将设备位置和线条信息都下载下来 */
+        obj0.insert("opName", "SPSS_InsertToAction");
+        QJsonObject obj1;
+        obj1.insert("actionID", it.ActionID);           /* 算法ID */
+        obj1.insert("actionName", it.ActionName);       /* 算法名称 */
+        obj1.insert("actionTaskID", it.ActionTaskID);   /* 算法类型 */
+        obj0.insert("paramList", obj1);         /* SQL语句的参数列表 */
+        auto strCmd = QJsonDocument(obj0).toJson(QJsonDocument::Compact);
+        int ret = m_httpApi->DBQDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, retStr);
+        if(ret < 0)
+        {
+            SPDLOG_LOGGER_DEBUG(m_logger,"写入tAction失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
+        }
+        // SPDLOG_LOGGER_DEBUG(m_logger,"写入tAction成功!");
+    }
+
+    return true;
+}
+

+ 3 - 0
SecurePlayAuxServer/communication/ToEQMDataBase.h

@@ -3,6 +3,7 @@
 
 #include "spdlog/spdlog.h"
 #include "lhhttpapi.h"
+#include "GlobalInfo.h"
 
 class ToEQMDataBase
 {
@@ -12,6 +13,8 @@ public:
 
     /* 初始化WebAPI */
     bool initWebApi(const QString& url,const QString& serverIP,const QString& serID);
+    /* 写入算法信息,写入tAction表 */
+    bool writeAlgorithmInfo(QVector<AlgorithmInfo>& vecInfo);
 
 private:
     std::shared_ptr<spdlog::logger> m_logger = nullptr;

+ 113 - 0
json.json

@@ -0,0 +1,113 @@
+{
+    "code": 0,
+    "data": [
+        {
+            "id": "e9ae71e6d68ef79a5569b7e30eced077",
+            "name": "DM_192.1.2.44_EQM",
+            "busiType": "EQM",
+            "dbType": "Dm"
+        },
+        {
+            "id": "cb19819fb8eb5f27c1d909ed6b4faa7c",
+            "name": "sqlserver_192.1.3.142_prodsv2",
+            "busiType": "",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "eb16d1ca7669a48261756eda567a2a83",
+            "name": "sqlserver_192.1.3.153_Superlink_LYLB",
+            "busiType": "Prolink_Superlink",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "6c634bdc4975e4b73f8307df706bd7b3",
+            "name": "sqlserver_192.1.3.142_prolink_xm",
+            "busiType": "Prolink_Superlink",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "f21512c566358300943b194f7e850ad7",
+            "name": "192.1.3.153_Prolink_FJ_BC",
+            "busiType": "ProMusic",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "5a897bbdb8d9585b2a7093a87711d5b7",
+            "name": "61(Superlink_LYLB_B)",
+            "busiType": "Prolink_Superlink",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "4ecdc473a485148f0a3a127672b63820",
+            "name": "DM_192.1.2.10_EQM",
+            "busiType": "EQM",
+            "dbType": "Dm"
+        },
+        {
+            "id": "a0e44ef1cb650d2e1fc2ab5857b9277f",
+            "name": "49(Promusic_z4_b)",
+            "busiType": "ProMusic",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "6f3e5707785e2689130d5be880361a12",
+            "name": "61(Prolink_TY)",
+            "busiType": "Prolink_Superlink",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "019fac32befb831c60f3df76018ba360",
+            "name": "153(Prolink_CNR_20210611)",
+            "busiType": "Prolink_Superlink",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "aac6ca614ed4888dca36e11abadb12d8",
+            "name": "DM_192.1.2.44_EQM_ZBT",
+            "busiType": "EQM",
+            "dbType": "Dm"
+        },
+        {
+            "id": "60979a8faf99f16053540f9d7e990300",
+            "name": "61(EQM)",
+            "busiType": "EQM",
+            "dbType": "Dm"
+        },
+        {
+            "id": "4d91d3b9394343053e818a0d7790f7b4",
+            "name": "GBase_192.1.2.44_EQM",
+            "busiType": "EQM",
+            "dbType": "GBase"
+        },
+        {
+            "id": "c0723e144c8f3674b45d9903a03019c0",
+            "name": "DM_192.1.2.44_EQM_BJ",
+            "busiType": "EQM",
+            "dbType": "Dm"
+        },
+        {
+            "id": "4c2f9fc91c22dd98331e47af2e2964f4",
+            "name": "SQL_SERVER_192.1.3.105_EQM_BJ",
+            "busiType": "EQM",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "ee045e6eb09a9e7f344ecb87e6d49afd",
+            "name": "61(DBO)",
+            "busiType": "Prolink_Superlink",
+            "dbType": "Dm"
+        },
+        {
+            "id": "c1acfd2615f58826fe0dc93267bd6d5f",
+            "name": "105(Prolink_z9_ceshi)",
+            "busiType": "Prolink_Superlink",
+            "dbType": "SqlServer"
+        },
+        {
+            "id": "372f33529b10651d6c96523cfac77bcf",
+            "name": "DM_192.1.2.178_EQM",
+            "busiType": "EQM",
+            "dbType": "Dm"
+        }
+    ]
+}

+ 6 - 1
安播辅助服务程序说明.md

@@ -38,4 +38,9 @@
 
 ## 从Redis获取数据
 1. `Key`的组成:`%d : %s`, `DeviceID`, `算子编号`
-2. 算子编号通过获取摄像头算法列表获取到这个设备的算法编号,目前不知道是哪个值
+2. `算子编号`通过获取摄像头算法列表获取到这个设备的算法编号,从EQM数据库的tCamerinfo表格中获取到
+
+## EQM数据库表格说明
+1. `tAction`是算法信息表,从超脑获取到的算法信息写入这个表格
+2. 
+