Jelajahi Sumber

V0.4.5
1、完成了“在岗信息表”
2、完成了部分的在岗离岗检测

Apple 3 minggu lalu
induk
melakukan
cc0d77beba

+ 4 - 1
SQL/SecurePlay.sqlbook

@@ -144,4 +144,7 @@ VALUES (1, '-1;-1', '未知;未知', '2024-10-21 18:03:00', '2024-10-21 18:13:00
 -- SQLBook: Code
 #查看通道信息
 SELECT *
-FROM "tChannel";
+FROM "tChannel";
+-- SQLBook: Code
+SELECT *
+FROM "tAppInfo";

+ 0 - 0
SQL/tAction.sql


+ 49 - 2
SecurePlayAuxServer/Application/FuncBase.cpp

@@ -1,6 +1,7 @@
 #include "FuncBase.h"
 
-#include "spdlog/spdlog.h"
+#include "GlobalVariable.h"
+#include "GlobalConfig.h"
 #include "FromRedis.h"
 #include "ToEQMDataBase.h"
 
@@ -15,6 +16,36 @@ FuncBase::~FuncBase()
 
 }
 
+/* 任务线程 */
+void FuncBase::thread_task()
+{
+    /* 先做一些通用的初始化 */
+    if(m_logger == nullptr)
+    {
+        m_logger = spdlog::get("SPAServer");
+        if(m_logger == nullptr)
+        {
+            SPDLOG_ERROR("SPAServer logger is nullptr");
+            return;
+        }
+    }
+    /* 线程功能信息 */
+    if(m_funcAct.appFunction == AppFunction::APP_NONE)
+    {
+        SPDLOG_LOGGER_ERROR(m_logger, "未设置线程功能信息");
+        return;
+    }
+    SPDLOG_LOGGER_INFO(m_logger, "开启 {} 功能线程, ChannelID:{}",m_funcAct.strFunctionName, m_funcAct.ChannelID);
+    /* 设置线程运行状态 */
+    m_bRunning = true;
+    /* 执行线程功能,会一直阻塞,直到退出 */
+    task();
+    /* 设置线程退出的状态,设置成 RUN_STATE_EXITCOMPLET ,就会被管理线程回收 */
+    GThreadInfo.setThreadState(m_funcAct, RunTimeState::RUN_STATE_EXITCOMPLET);
+    SPDLOG_LOGGER_INFO(m_logger, "{} 功能线程退出,Channel:{}", m_funcAct.strFunctionName, m_funcAct.ChannelID);
+    m_bRunning = false;
+}
+
 /* 设置功能信息 */
 void FuncBase::setFuncActionInfo(FuncActionInfo* pFuncAct)
 {
@@ -35,4 +66,20 @@ AppFunction FuncBase::getApp()
 bool FuncBase::getThreadRunning() const
 {
     return m_bRunning;
-}
+}
+
+
+/* 判断是否在检测时间内 */
+bool FuncBase::isInDetectTime(const QDateTime& start, const QDateTime& end)
+{
+    QDateTime now = QDateTime::currentDateTime();
+    if(start.isValid() && end.isValid())
+    {
+        if(now >= start && now <= end)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+

+ 9 - 1
SecurePlayAuxServer/Application/FuncBase.h

@@ -3,6 +3,7 @@
 
 #include <memory>
 #include "GlobalVariable.h"
+#include "spdlog/spdlog.h"
 
 class FromRedis;
 class ToEQMDataBase;
@@ -20,7 +21,7 @@ public:
     ~FuncBase();
 
     /* 任务线程 */
-    virtual void thread_task() = 0;
+    void thread_task();
 
     /* 设置功能信息 */
     void setFuncActionInfo(FuncActionInfo* pFuncAct);
@@ -31,6 +32,13 @@ public:
     bool getThreadRunning() const;
 
 protected:
+    /* 真正执行任务的地方 */
+    virtual void task() = 0;
+    /* 判断是否在检测时间内 */
+    bool isInDetectTime(const QDateTime& start, const QDateTime& end);
+
+protected:
+    std::shared_ptr<spdlog::logger> m_logger = nullptr;
     /* 读取Redis的实例 */
     std::shared_ptr<FromRedis> m_fromRedis = nullptr;
     /* 写入EQM数据库的实例 */

+ 400 - 0
SecurePlayAuxServer/Application/FuncIllegalInvasion.cpp

@@ -0,0 +1,400 @@
+#include "FuncIllegalInvasion.h"
+#include "GlobalVariable.h"
+#include "GlobalConfig.h"
+#include "FromRedis.h"
+#include "ToEQMDataBase.h"
+#include "UniversalFunc.h"
+
+
+
+
+RoomIllegalInvasionInfo::RoomIllegalInvasionInfo(const RoomIllegalInvasionInfo& o)
+{
+    isAlarm = o.isAlarm;
+    RoomID = o.RoomID;
+    RoomType = o.RoomType;
+    numMaxFace = o.numMaxFace;
+    numMaxPerson = o.numMaxPerson;
+    strBoxList = o.strBoxList;
+    strMessage = o.strMessage;
+    strImage = o.strImage;
+    CameraID = o.CameraID;
+}
+RoomIllegalInvasionInfo& RoomIllegalInvasionInfo::operator=(const RoomIllegalInvasionInfo& o)
+{
+    if(this != &o) {
+        isAlarm = o.isAlarm;
+        RoomID = o.RoomID;
+        RoomType = o.RoomType;
+        numMaxFace = o.numMaxFace;
+        numMaxPerson = o.numMaxPerson;
+        strBoxList = o.strBoxList;
+        strMessage = o.strMessage;
+        strImage = o.strImage;
+        CameraID = o.CameraID;
+    }
+
+    return *this;
+}
+
+/* 添加房间 */
+void ListRoomIll::addRoom(int RoomID, int RoomType)
+{
+    auto p = findRoom(RoomID, RoomType);
+    if(p == nullptr)
+    {
+        RoomIllegalInvasionInfo ill;
+        ill.RoomID = RoomID;
+        ill.RoomType = RoomType;
+        listRoomIll.push_back(ill);
+    }
+}
+
+/* 查找是否有相同的房间 */
+RoomIllegalInvasionInfo* ListRoomIll::findRoom(int RoomID, int RoomType)
+{
+    for(auto& it : listRoomIll)
+    {
+        if(it.RoomID == RoomID && it.RoomType == RoomType)
+        {
+            return &it;
+        }
+    }
+    return nullptr;
+}
+
+
+IllegalInvasionInfo::IllegalInvasionInfo(const IllegalInvasionInfo& other)
+{
+    isInsertEQM = other.isInsertEQM;
+    PKID = other.PKID;
+    CameraID = other.CameraID;
+    RoomID = other.RoomID;
+    ChannelID = other.ChannelID;
+    RoomType = other.RoomType;
+    FirstTime = other.FirstTime;
+    strActionDec = other.strActionDec;
+    strImageInfo = other.strImageInfo;
+}
+
+IllegalInvasionInfo& IllegalInvasionInfo::operator=(const IllegalInvasionInfo& other)
+{
+    if(this != &other)
+    {
+        isInsertEQM = other.isInsertEQM;
+        PKID = other.PKID;
+        CameraID = other.CameraID;
+        RoomID = other.RoomID;
+        ChannelID = other.ChannelID;
+        RoomType = other.RoomType;
+        FirstTime = other.FirstTime;
+        strActionDec = other.strActionDec;
+        strImageInfo = other.strImageInfo;
+    }
+    return *this;
+}
+
+
+/* 添加信息 */
+void ListIllegalInvasionInfo::addIllInfo(IllegalInvasionInfo& info)
+{
+    if(findIllInfo(info) == nullptr)
+    {
+        listIll.push_back(info);
+    }
+}
+/* 查找相同的信息 */
+IllegalInvasionInfo* ListIllegalInvasionInfo::findIllInfo(IllegalInvasionInfo& info)
+{
+    for(auto& it : listIll)
+    {
+        if(it.RoomID == info.RoomID && it.RoomType == info.RoomType)
+        {
+            return &it;
+        }
+    }
+
+    return nullptr;
+}
+
+IllegalInvasionInfo* ListIllegalInvasionInfo::findIllInfo(int roomID, int roomType)
+{
+    for(auto& it : listIll)
+    {
+        if(it.RoomID == roomID && it.RoomType == roomType)
+        {
+            return &it;
+        }
+    }
+
+    return nullptr;
+}
+
+/* 删除报警信息 */
+void ListIllegalInvasionInfo::deleteIllInfo(IllegalInvasionInfo& info)
+{
+    for(auto it = listIll.begin(); it != listIll.end();)
+    {
+        if(it->RoomID == info.RoomID && it->RoomType == info.RoomType)
+        {
+            it = listIll.erase(it);
+        }else {
+            ++it;
+        }
+    }
+}
+
+void ListIllegalInvasionInfo::deleteIllInfo(int roomID, int roomType)
+{
+    for(auto it = listIll.begin(); it != listIll.end();)
+    {
+        if(it->RoomID == roomID && it->RoomType == roomType)
+        {
+            it = listIll.erase(it);
+        }else {
+            ++it;
+        }
+    }
+}
+
+
+/* ===================================================================================
+ * 功能类:FuncIllegalInvasion
+ * =================================================================================== */
+
+FuncIllegalInvasion::FuncIllegalInvasion()
+{
+    m_logger = spdlog::get("SPAServer");
+    if(m_logger == nullptr)
+    {
+        SPDLOG_ERROR("SPAServer logger is nullptr");
+        return;
+    }
+    m_pListAlarm = std::make_shared<std::list<AlarmInfo>>();
+    m_pListIllInfo = std::make_shared<ListIllegalInvasionInfo>();
+}
+
+FuncIllegalInvasion::~FuncIllegalInvasion()
+{
+
+}
+
+/* 是否报警 */
+bool FuncIllegalInvasion::isAlarm(const std::vector<PersonInfo>& vecPersion)
+{
+    for(const auto& it : vecPersion)
+    {
+        if(it.PersonID == "-1")
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+/* 线程功能 */
+void FuncIllegalInvasion::task()
+{
+    std::string strFaceActionID;            /* 人脸识别的Action */
+    std::string strCountActionID;           /* 人员计数的Action */
+
+    while (GThreadInfo.getRunning())
+    {   
+        /* 更新线程信息 */
+        GThreadInfo.updateFuncInfo(m_funcAct);
+        if(m_funcAct.RunState == RunTimeState::RUN_STATE_STOP)
+        {
+            break;
+        }
+
+        /* 判断是否在检测时间段内 */
+        if(!isInDetectTime(m_funcAct.StartTime, m_funcAct.EndTime))
+        {
+            std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
+            continue;
+        }
+
+        /* 更新算法ActionID */
+        {
+            g_actionList.mutexRW.lockForRead();
+            strFaceActionID = g_actionList.ActFace;
+            strCountActionID = g_actionList.ActPersonNumber;
+            g_actionList.mutexRW.unlock();
+        }
+
+        /* 读取Redis数据 */
+        m_pListAlarm->clear();
+        for(const auto& RoomInfo : m_funcAct.listRoomCamActInfo)
+        {
+            for(const auto& it : RoomInfo.mapCameraAction)
+            {
+                std::string strKey = std::to_string(it.first) + ":" + it.second;
+                std::string strRetValue;
+                if(!m_fromRedis->getRedisString(strKey, strRetValue))
+                {
+                    SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
+                    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+                    continue;
+                }
+                /* 解析数据 */
+                AlarmInfo alarmInfo;
+                // parseRedisData(strRetValue, alarmInfo);
+                parseRedisBaseData(strRetValue, alarmInfo);
+                parseRedisBBoxesData(strRetValue, alarmInfo);
+                /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
+                if(isEventTimeVaild(alarmInfo.EventTime))
+                {
+                    SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
+                    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+                    continue;
+                }
+                m_pListAlarm->push_back(alarmInfo);
+            }
+        }
+
+        /* 找出房间的个数,按照房间进行判断 */
+        ListRoomIll listRoomIll;
+        for(auto& it : m_funcAct.listRoomCamActInfo)
+        {
+            listRoomIll.addRoom(it.RoomID, it.RoomType);
+        }
+
+        /* 根据房间解析人脸识别的非法入侵,检测到了非法人脸,就可以直接报警了 */
+        for(auto& room : listRoomIll.getData())
+        {
+            for(const auto& alarm : *m_pListAlarm)
+            {
+                if(room.RoomID != alarm.RoomID)
+                {
+                    continue;
+                }
+                /* 统计这个房间内《人脸算法》检测到的最大人员数 */
+                if(alarm.ActionID == strFaceActionID)
+                {
+                    if(alarm.vecPersonInfo.size() > room.numMaxFace)
+                    {
+                        room.numMaxFace = alarm.vecPersonInfo.size();
+                        room.strBoxList = alarm.listBbox;
+                        room.vecPersonInfo = alarm.vecPersonInfo;
+                    }
+                }
+
+                /* 判断有没有非法入侵人员 */
+                if(isAlarm(alarm.vecPersonInfo))
+                {
+                    room.isAlarm = true;
+                    room.strMessage = "人员非法入侵(未知人员)";
+                    if( !alarm.ImageInfo.empty() )
+                    {
+                        room.strImage = alarm.ImageInfo;
+                    }
+                    room.CameraID = alarm.DeviceID;
+                }
+            }
+            
+        }
+
+        /* 判断《人脸算法》识别到的数目和《人员计数算法》识别到的人数是否相等,如果上面报警了,这里就不用检测了 */
+        for(auto& room : listRoomIll.getData())
+        {
+            if(room.isAlarm)
+            {
+                continue;
+            }
+            /* 这个房间的人脸算法没有识别到非法入侵 */
+            for(const auto& alarm : *m_pListAlarm)
+            {
+                if(room.RoomID != alarm.RoomID)
+                {
+                    continue;
+                }
+                /* 人员计数 */
+                if(alarm.ActionID == strCountActionID)
+                {
+                    /* 统计这个房间内《人员计数算法》检测到的最大人员数 */
+                    if(alarm.vecPersonInfo.size() > room.numMaxPerson)
+                    {
+                        room.numMaxPerson = alarm.vecPersonInfo.size();
+                        room.strBoxList = alarm.listBbox;
+                        if(!alarm.ImageInfo.empty())
+                        {
+                            room.strImage = alarm.ImageInfo;
+                        }
+                        room.CameraID = alarm.DeviceID;
+                    }
+                }
+            }
+            /* 判断人数是否一致 */
+            if(room.numMaxFace != room.numMaxPerson)
+            {
+                room.strMessage = fmt::format("非法入侵(人员计数 {} 和人脸数 {} 不一致)", room.numMaxPerson, room.numMaxFace);
+                room.isAlarm = true;
+            }
+        }
+
+        /* 将非法入侵的信息存储到数组缓存中,等待报警结束后判断是否需要写入EQM数据库 */
+        for(auto& room : listRoomIll.getData())
+        {
+            auto pIll = m_pListIllInfo->findIllInfo(room.RoomID, room.RoomType);
+            if(room.isAlarm)
+            {
+                /* 正在报警,检查缓存中是否有这个报警信息 */
+                if(pIll == nullptr)
+                {
+                    IllegalInvasionInfo info;
+                    info.ChannelID = m_funcAct.ChannelID;
+                    info.CameraID = room.CameraID;
+                    info.RoomID = room.RoomID;
+                    info.RoomType = room.RoomType;
+                    info.strActionDec = room.strMessage;
+                    info.strImageInfo = room.strImage;
+                    info.FirstTime = QDateTime::currentDateTime();;
+                    m_pListIllInfo->addIllInfo(info);
+                }
+            }
+            else 
+            {
+                /* 没有报警,检查是否是报警结束了,是否符合写入数据库的条件 */
+                QDateTime currTime = QDateTime::currentDateTime();
+                int secs = currTime.toSecsSinceEpoch() - pIll->FirstTime.toSecsSinceEpoch();
+                if(secs >= GConfig.AppBadMan_Time)
+                {
+                    if(!pIll->strImageInfo.empty())
+                    {
+                        /* 超过非法入侵的时间,写入数据库 */
+                        AlarmInfo ai;
+                        ai.ChannelID = m_funcAct.ChannelID;
+                        ai.RoomID = pIll->RoomID;
+                        ai.ActionID = g_actionList.ActPersonNumber;
+                        ai.ActionDes = pIll->strActionDec;
+                        ai.ImageInfo = pIll->strImageInfo;
+                        ai.StartTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+                        ai.EndTime = currTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+                        ai.EventTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+                        ai.vecPersonInfo = room.vecPersonInfo;
+                        ai.listBbox = room.strBoxList;
+                        bool insertRet  = m_toEQMDataBase->insertAlarmInfo(ai);
+                        if(insertRet)
+                        {
+                            std::string actionName = g_actionList.getActionName(ai.ActionID);
+                            SPDLOG_LOGGER_INFO(m_logger, "☆ 新增报警信息,频道[{}],房间[{}],摄像头[{}],{},{},有{}个区域,有{}个人脸,{}", 
+                            pIll->ChannelID, pIll->RoomID, pIll->CameraID, actionName, ai.ActionDes, ai.listBbox.size(), ai.FaceIDList.size(), ai.ImageInfo);
+                        }
+                    }
+                    else {
+                        SPDLOG_LOGGER_WARN(m_logger, "× 取消新增报警信息,因为没有图片,频道[{}],房间[{}],摄像头[{}],{},{},有{}个区域,有{}个人脸",
+                            pIll->ChannelID, pIll->RoomID, pIll->CameraID, pIll->strActionDec, pIll->strImageInfo, room.strBoxList.size(), room.vecPersonInfo.size());
+                    }
+                    /* 删除这个非法入侵信息 */
+                    m_pListIllInfo->deleteIllInfo(*pIll);
+                }
+            }
+        }
+        std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
+    }
+
+}
+
+
+
+

+ 133 - 0
SecurePlayAuxServer/Application/FuncIllegalInvasion.h

@@ -0,0 +1,133 @@
+#ifndef FUNCILLEGALINVASION_H
+#define FUNCILLEGALINVASION_H
+
+#include "FuncBase.h"
+#include "spdlog/spdlog.h"
+
+
+
+/**
+ * @brief 区域非法入侵检测
+            1、野猫、宠物识别:报警判断条件:机房内出现摄像头的宠物识别算法输出报警结果时,记为报警行为,直接
+              展示报警结果,这里好像没有检测动物的功能,这个功能可能在通用算法中实现的
+            2、无权限人员识别:报警判断条件:当判断出区域非法入侵行为时,依据人脸识别结果,判断是否为人脸库人
+              员,非人脸库的人员时判断为非法入侵行为(背影需要报警需要结合区域人员检测算法判断)
+            3、人员计数和人脸识别数不相等时,判断为非法入侵行为
+            4、报警后没有立即写入数据库,而是等到报警结束后才写入的,不知道后续会不会修改
+        
+        检测逻辑:
+            1、先检测非法的人脸信息
+            2、再检测人员计数和人脸识别数不相等
+ * 
+ */
+
+/**
+ * @brief 房间为单位的非法入侵信息
+ * 
+ */
+struct RoomIllegalInvasionInfo
+{
+    bool isAlarm = false;                   /* 是否在报警 */
+    int RoomID = 0;                         /* 房间ID */
+    int RoomType = 0;                       /* 房间类型 */
+    int numMaxFace = 0;                     /* 最大人脸数 */
+    int numMaxPerson = 0;                   /* 最大人员数 */
+    int CameraID = 0;                       /* 摄像机ID,这个存储的是使用的哪个报警信息的ID */
+    std::list<std::string> strBoxList;      /* box */
+    std::string strMessage;                 /* 报警信息字符串 */
+    std::string strImage;                   /* 报警图片 */
+    std::vector<PersonInfo> vecPersonInfo;  /* 人员信息 */
+
+    RoomIllegalInvasionInfo() = default;
+    RoomIllegalInvasionInfo(const RoomIllegalInvasionInfo& o);
+    RoomIllegalInvasionInfo& operator=(const RoomIllegalInvasionInfo& o);
+};
+
+/**
+ * @brief 房间报警数据,以房间为单位
+ * 
+ */
+struct ListRoomIll
+{
+    std::list<RoomIllegalInvasionInfo> listRoomIll;
+
+    std::list<RoomIllegalInvasionInfo>& getData() { return listRoomIll; }
+    /* 添加房间 */
+    void addRoom(int RoomID, int RoomType);
+    /* 查找是否有相同的房间 */
+    RoomIllegalInvasionInfo* findRoom(int RoomID, int RoomType);
+};
+
+/**
+ * @brief 非法入侵检测信息结构体,作为缓存存储正在报警的信息
+ * 
+ */
+struct IllegalInvasionInfo
+{
+    bool isInsertEQM = false;           /* 是否已经插入到EQM数据库的报警信息中 */
+    int PKID = 0;
+    int CameraID = 0;
+    int RoomID = 0;
+    int ChannelID = 0;
+    int RoomType = 0;                   /* 房间类型 */
+    QDateTime FirstTime;                /* 最开始的报警时间 */
+    std::string strActionDec;           /* 算法描述 */
+    std::string strImageInfo;           /* 图片信息 */
+
+    IllegalInvasionInfo() = default;
+    IllegalInvasionInfo(const IllegalInvasionInfo& other);
+    IllegalInvasionInfo& operator=(const IllegalInvasionInfo& other);
+};
+ 
+/**
+ * @brief 非法入侵报警列表
+ * 
+ */
+struct ListIllegalInvasionInfo
+{
+    std::list<IllegalInvasionInfo> listIll;
+
+    std::list<IllegalInvasionInfo>& getData() { return listIll; }
+    /* 添加信息 */
+    void addIllInfo(IllegalInvasionInfo& info);
+    /* 查找相同的信息 */
+    IllegalInvasionInfo* findIllInfo(IllegalInvasionInfo& info);
+    IllegalInvasionInfo* findIllInfo(int roomID, int roomType);
+    /* 删除报警信息 */
+    void deleteIllInfo(IllegalInvasionInfo& info);
+    void deleteIllInfo(int roomID, int roomType);
+};
+ 
+
+
+/* ===================================================================================
+ * 功能类:FuncIllegalInvasion
+ * =================================================================================== */
+
+class FuncIllegalInvasion : public FuncBase
+{
+
+public:
+    FuncIllegalInvasion();
+    ~FuncIllegalInvasion();
+
+private:
+    /* 是否报警 */
+    bool isAlarm(const std::vector<PersonInfo>& vecPersion);
+
+protected:
+    /* 线程功能 */
+    void task() override;
+
+private:
+    /* 保存每个摄像机的报警信息 */
+    std::shared_ptr<std::list<AlarmInfo>> m_pListAlarm = nullptr;
+    /* 保存非法入侵的信息 */
+    std::shared_ptr<ListIllegalInvasionInfo> m_pListIllInfo = nullptr;
+
+};
+
+
+
+
+#endif /* FUNCILLEGALINVASION_H */

+ 252 - 0
SecurePlayAuxServer/Application/FuncOnAndOffJob.cpp

@@ -0,0 +1,252 @@
+#include "FuncOnAndOffJob.h"
+#include "GlobalVariable.h"
+#include "GlobalConfig.h"
+#include "UniversalFunc.h"
+
+#include "FromRedis.h"
+#include "ToEQMDataBase.h"
+
+
+
+
+
+DecCondition::DecCondition()
+{
+    ChannelID = -1;
+    leaveNum = 0;
+    leaveNumOnTime = 0;
+    leaveOneTime = 0;
+}
+
+DecCondition::DecCondition(const DecCondition& other)
+{
+    ChannelID = other.ChannelID;
+    leaveNum = other.leaveNum;
+    leaveNumOnTime = other.leaveNumOnTime;
+    leaveOneTime = other.leaveOneTime;
+}
+
+DecCondition& DecCondition::operator=(const DecCondition& other)
+{
+    if (this != &other)
+    {
+        ChannelID = other.ChannelID;
+        leaveNum = other.leaveNum;
+        leaveNumOnTime = other.leaveNumOnTime;
+        leaveOneTime = other.leaveOneTime;
+    }
+    return *this;
+}
+
+
+RoomOnWorkInfo& RoomOnWorkInfo::operator=(const RoomOnWorkInfo& other)
+{
+    if (this != &other)
+    {
+        bOnWork = other.bOnWork;
+        RoomID = other.RoomID;
+        CameraID = other.CameraID;
+        RoomType = other.RoomType;
+        StartTime = other.StartTime;
+        EndTime = other.EndTime;
+        strImagePath = other.strImagePath;
+        listPersonInfo = other.listPersonInfo;
+    }
+    return *this;
+}
+
+RoomOnWorkInfo::RoomOnWorkInfo(const RoomOnWorkInfo& other)
+{
+    bOnWork = other.bOnWork;
+    RoomID = other.RoomID;
+    CameraID = other.CameraID;
+    RoomType = other.RoomType;
+    StartTime = other.StartTime;
+    EndTime = other.EndTime;
+    strImagePath = other.strImagePath;
+    listPersonInfo = other.listPersonInfo;
+}
+
+
+
+
+
+
+FuncOnAndOffJob::FuncOnAndOffJob()
+{
+    m_pListAlarm = new ListAlarmInfo();
+    m_logger = spdlog::get("SPAServer");
+    if(m_logger == nullptr)
+    {
+        SPDLOG_ERROR("FuncOnAndOffJob logger is nullptr");
+        return;
+    }
+
+}
+
+FuncOnAndOffJob::~FuncOnAndOffJob()
+{
+
+}
+
+/* 获取当前频率信息 */
+bool FuncOnAndOffJob::getCurrentFrequencyInfo(const int ChannelID, DecCondition& info)
+{
+    auto str = m_toEQMDataBase->getChannelName(ChannelID);
+    if(str == "")
+    {
+        SPDLOG_LOGGER_ERROR(m_logger, "获取通道信息失败, ChannelID:{}", ChannelID);
+        return false;
+    }
+    /* 解析数据 */
+    try
+    {
+        nJson json1 = nJson::parse(str);
+        info.ChannelID = ChannelID;
+        info.leaveNum = json1["leaveNum"].is_null() ? 0 : json1["leaveNum"].get<int>();
+        info.leaveNumOnTime = json1["leaveNumTime"].is_null() ? 0 : json1["leaveNumTime"].get<int>();
+        info.leaveOneTime = json1["leaveLongTime"].is_null() ? 0 : json1["leaveLongTime"].get<int>();
+    }
+    catch (const nJson::parse_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch (const nJson::type_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch(...) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败");
+        return false;
+    }
+
+    return true;
+}
+
+void FuncOnAndOffJob::task()
+{
+    while(GThreadInfo.getRunning())
+    {
+        /* 判断是否需要退出 */
+        if(m_funcAct.RunState == RunTimeState::RUN_STATE_STOP)
+        {
+            break;
+        }
+
+        /* 判断是否在检测时间段内 */
+        if(!isInDetectTime(m_funcAct.StartTime, m_funcAct.EndTime))
+        {
+            /* 休眠一段时间 */
+            std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
+            continue;
+        }
+
+        /* 先获取所有的直播间,这里不需要读取所有的房间数据 */
+        std::map<int, RoomCamActInfo> mapRoomCamActInfo;
+        for(auto& it : m_funcAct.listRoomCamActInfo)
+        {
+            /* 判断是不是直播间 */
+            if(it.RoomType == GConfig.liveRoomType)
+            {
+                mapRoomCamActInfo.insert(std::make_pair(it.RoomID, it));
+            }
+        }
+
+        /* 获取当前频率的在岗离岗信息,在表格“tChannel”中 */
+        DecCondition decCondition;
+        if(!getCurrentFrequencyInfo(m_funcAct.ChannelID, decCondition))
+        {
+            SPDLOG_LOGGER_ERROR(m_logger, "获取当前频率信息失败, ChannelID:{}", m_funcAct.ChannelID);
+            std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
+            continue;
+        }
+
+
+        /* 读取Redis数据 */
+        for(const auto& RoomInfo : mapRoomCamActInfo)
+        {
+            for(const auto& it : RoomInfo.second.mapCameraAction)
+            {
+                std::string strKey = std::to_string(it.first) + ":" + it.second;
+                std::string strRetValue;
+                if(!m_fromRedis->getRedisString(strKey, strRetValue))
+                {
+                    SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
+                    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+                    continue;
+                }
+                /* 解析数据 */
+                AlarmInfo alarmInfo;
+                parseRedisBaseData(strRetValue, alarmInfo);
+                parseRedisBBoxesData(strRetValue, alarmInfo);
+                /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
+                if(isEventTimeVaild(alarmInfo.EventTime))
+                {
+                    SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
+                    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+                    continue;
+                }
+                m_pListAlarm->addAlarmInfo(alarmInfo);
+            }
+        }
+
+        /* 对所有房间挨个判断 */
+        for(auto& roomInfo : mapRoomCamActInfo)
+        {
+            bool bHasPeople = false;
+            bool bHasFace = false;
+            /* 先使用人员计数判断直播间有没有人,如果直播间有人,再使用人脸识别算法判断是否是认识的人(是认识的人才会被识别到) */
+            for(auto& alarm : m_pListAlarm->listAlarmInfo)
+            {
+                if(alarm->RoomID == roomInfo.first)
+                {
+                    if(alarm->ActionID == g_actionList.ActPersonNumber)
+                    {
+                        if(alarm->listBbox.size() > 0)
+                        {
+                            bHasPeople = true;
+                            break;
+                        }
+                    }
+                }
+            }
+
+            /* 如果有人,再判断是不是认识的人 */
+            if(bHasPeople)
+            {
+                for(auto& alarm : m_pListAlarm->listAlarmInfo)
+                {
+                    if(alarm->RoomID == roomInfo.first)
+                    {
+                        if(alarm->ActionID == g_actionList.ActFace)
+                        {
+                            if(alarm->vecPersonInfo.size() > 0)
+                            {
+                                bHasFace = true;
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+
+            /* 查找这个房间对应的房间信息 */
+            RoomOnWorkInfo* pRoomOnWorkInfo = nullptr;
+            auto it0 = m_mapRoomOnWorkInfo.find(roomInfo.first);
+            if(it0 != m_mapRoomOnWorkInfo.end())
+            {
+                pRoomOnWorkInfo = it0->second;
+            }
+            else
+            {
+                /* 没找到,就创建一个 */
+                pRoomOnWorkInfo = new RoomOnWorkInfo();
+                pRoomOnWorkInfo->RoomID = roomInfo.first;
+
+            }
+        }
+
+
+    }
+
+}

+ 73 - 0
SecurePlayAuxServer/Application/FuncOnAndOffJob.h

@@ -0,0 +1,73 @@
+#ifndef FUNCONANDOFFJOB_H
+#define FUNCONANDOFFJOB_H
+
+#include "FuncBase.h"
+
+/**
+ * @brief 在岗离岗检测
+ * 
+ */
+
+
+ /**
+  * @brief 检测信息
+  * 
+  */
+struct DecCondition
+{
+    int ChannelID;                  /* 通道ID */
+    int leaveNum;                   /* 离岗次数 */
+    int leaveNumOnTime;             /* 一定时间内的离岗次数 */
+    int leaveOneTime;               /* 单次离开报警时间 */
+
+    DecCondition();
+    DecCondition(const DecCondition& other);
+    DecCondition& operator=(const DecCondition& other);
+};
+
+/**
+ * @brief 房间在岗信息
+ * 
+ */
+ struct RoomOnWorkInfo
+ {
+    bool bOnWork = false;          /* 是否在岗 */
+    int RoomID;                     /* 房间ID */
+    int CameraID;                   /* 摄像机ID */
+    int RoomType;                   /* 房间类型 */
+    QDateTime StartTime;            /* 开始时间 */
+    QDateTime EndTime;              /* 结束时间 */
+    std::string strImagePath;       /* 图片路径 */
+    std::list<PersonInfo> listPersonInfo; /* 人员信息 */
+
+    RoomOnWorkInfo() = default;
+    RoomOnWorkInfo& operator=(const RoomOnWorkInfo& other);
+    RoomOnWorkInfo(const RoomOnWorkInfo& other);
+};
+
+
+
+
+class FuncOnAndOffJob : public FuncBase
+{
+public:
+    FuncOnAndOffJob();
+    ~FuncOnAndOffJob();
+
+private:
+    /* 获取当前频率信息 */
+    bool getCurrentFrequencyInfo(const int ChannelID, DecCondition& info);
+    
+protected:
+    void task() override;
+
+private:
+    ListAlarmInfo* m_pListAlarm = nullptr;                  /* 报警信息 */
+    // std::map<int, ListAlarmInfo*> m_mapRoomPersonCount;     /* 人员计数返回的信息,int是房间ID号 */
+    // std::map<int, ListAlarmInfo*> m_mapRoomFaceInfo;        /* 人脸识别返回的信息,int是房间ID号 */
+    std::map<int, RoomOnWorkInfo*> m_mapRoomOnWorkInfo;      /* 房间在岗信息 */
+};
+
+
+
+#endif /* FUNCONANDOFFJOB_H */

+ 9 - 14
SecurePlayAuxServer/Application/FuncOrdinary.cpp

@@ -23,18 +23,10 @@ FuncOrdinary::~FuncOrdinary()
 }
 
 /* 任务线程 */
-void FuncOrdinary::thread_task()
+void FuncOrdinary::task()
 {
-    if(m_funcAct.appFunction == AppFunction::APP_NONE)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "未设置线程功能信息");
-        return;
-    }
-    SPDLOG_LOGGER_INFO(m_logger, "开启 {} 功能线程, ChannelID:{}",m_funcAct.strFunctionName, m_funcAct.ChannelID);
-    /* 设置线程运行状态 */
-    m_bRunning = true;
     while (GThreadInfo.getRunning())
-    {
+    {   
         /* 从全局的信息块中更新功能信息,如是否需要退出线程,主要是更新摄像机关联的算法信息 */
         GThreadInfo.updateFuncInfo(m_funcAct);
         /* 如果线程的运行状态为停止 */
@@ -44,6 +36,13 @@ void FuncOrdinary::thread_task()
             break;
         }
 
+        /* 判断是否在检测时间段内 */
+        if(!isInDetectTime(m_funcAct.StartTime, m_funcAct.EndTime))
+        {
+            std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
+            continue;
+        }
+
         /* 读取Redis信息,处理数据,第一层循环是根据房间读取,第二个循环是根据房间内的摄像机读取 */
         for(const auto& roomInfo : m_funcAct.listRoomCamActInfo)
         {
@@ -165,10 +164,6 @@ void FuncOrdinary::thread_task()
         /* 休眠设置的时间 */
         std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
     }
-    /* 设置线程退出的状态,设置成 RUN_STATE_EXITCOMPLET ,就会被管理线程回收 */
-    GThreadInfo.setThreadState(m_funcAct, RunTimeState::RUN_STATE_EXITCOMPLET);
-    SPDLOG_LOGGER_INFO(m_logger, "{} 功能线程退出,Channel:{}", m_funcAct.strFunctionName, m_funcAct.ChannelID);
-    m_bRunning = false;
 }
 
 /* 判断报警时长是否符合不同应用的最小间隔 */

+ 2 - 2
SecurePlayAuxServer/Application/FuncOrdinary.h

@@ -24,15 +24,15 @@ public:
     FuncOrdinary();
     ~FuncOrdinary();
 
+protected:
     /* 任务线程 */
-    void thread_task() override;
+    void task() override;
 
 private:
     /* 判断报警时长是否符合不同应用的最小间隔 */
     bool isAlarmTimeVaild(const AlarmInfo& info);
 
 private:
-    std::shared_ptr<spdlog::logger> m_logger = nullptr;
 
     ListAlarmInfo m_listAlarm;                  /* 报警列表 */
 };

+ 13 - 11
SecurePlayAuxServer/Application/FuncPersonOnWork.cpp

@@ -35,17 +35,11 @@ FuncPersonOnWork::~FuncPersonOnWork()
  * @brief 工作线程
  * 
  */
-void FuncPersonOnWork::thread_task()
+void FuncPersonOnWork::task()
 {
-    if(m_funcAct.appFunction == AppFunction::APP_NONE)
-    {
-        SPDLOG_LOGGER_ERROR(m_logger, "未设置线程功能信息");
-        return;
-    }
-    SPDLOG_LOGGER_INFO(m_logger, "开启 {} 线程,ChannelID:{} ,", m_funcAct.strFunctionName, m_funcAct.ChannelID);
     
     while (GThreadInfo.getRunning())
-    {
+    {   
         /* 更新线程信息 */
         GThreadInfo.updateFuncInfo(m_funcAct);
         if( (m_funcAct.appFunction == AppFunction::APP_NONE) ||
@@ -53,6 +47,13 @@ void FuncPersonOnWork::thread_task()
         {
             break;
         }
+        
+        /* 判断是否在检测时间段内 */
+        if(!isInDetectTime(m_funcAct.StartTime, m_funcAct.EndTime))
+        {
+            std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
+            continue;
+        }
 
         /* -----------------------------------------------------------------------
          * 读取Redis数据 
@@ -105,7 +106,7 @@ void FuncPersonOnWork::thread_task()
             {
                 it->MinNum = it->listPersonInfo.size();
             }
-            /* 判断是否需要写入数据库,离岗时间超过设置的时间就写入,默认是600秒 */
+            /* 判断是否需要写入数据库,一定时间写入一次,默认是10分钟写一次 */
             if(now.toSecsSinceEpoch() - it->StartTime.toSecsSinceEpoch() > GConfig.AppUpdateOnWorkTimeInterval_Time)
             {
                 /* 写入数据库 */
@@ -119,14 +120,15 @@ void FuncPersonOnWork::thread_task()
                     /* 删除这条信息 */
                     it = m_pListRoomFace->listRoomFaceInfo.erase(it);
                     continue;
+                }else {
+                    SPDLOG_LOGGER_ERROR(m_logger, "写入数据库tWorkOnInfo失败");
                 }
             }
             ++it;
         }
         std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
     }
-    GThreadInfo.setThreadState(m_funcAct, RunTimeState::RUN_STATE_EXITCOMPLET);
-    SPDLOG_LOGGER_INFO(m_logger, "{} 功能线程退出,Channel:{}", m_funcAct.strFunctionName, m_funcAct.ChannelID);
+
 }
 
 

+ 2 - 3
SecurePlayAuxServer/Application/FuncPersonOnWork.h

@@ -20,11 +20,10 @@ public:
     FuncPersonOnWork();
     ~FuncPersonOnWork();
 
-    void thread_task() override;
+protected:
+    void task() override;
 
 private:
-    std::shared_ptr<spdlog::logger> m_logger = nullptr;
-
     ListAlarmInfo m_listAlarm;                  /* 报警列表 */
     /* 保存每个摄像机的报警信息 */
     std::shared_ptr<std::list<AlarmInfo>> m_pListAlarm = nullptr;

+ 16 - 2
SecurePlayAuxServer/GlobalInfo/GlobalConfig.cpp

@@ -33,7 +33,7 @@ bool GlobalConfig::readConfig(const QString& strConfigFile)
     AppUpdateOnWorkTimeInterval_Time = settings.value("WorkOnInfoSecond", 600).toInt();  /* 更新在岗信息的时间间隔 */
     AppPeopleOnWork_Time = settings.value("APPPEPOLEONWORK", 300).toInt();         /* 离岗时间 */
     AppContraband_Time = settings.value("APPBADTHING", 50).toInt();                 /* 违禁物品出现的时间 */
-    AppBadMan = settings.value("APPBADMAN", 50).toInt();                     /* 非法入侵 */
+    AppBadMan_Time = settings.value("APPBADMAN", 50).toInt();                     /* 非法入侵 */
     AppTired_Time = settings.value("APPTIRED", 50).toInt();                       /* 疲劳检测时间 */
     AppPeopleCont = settings.value("APPPEPOLECONT", 50).toInt();             /* 人员聚集时间 */
     AppPlayPhone = settings.value("APPPLAYPHONE", 50).toInt();               /* 玩手机识别 */
@@ -63,7 +63,7 @@ void GlobalConfig::printValue()
 {
     SPDLOG_INFO("APPPEPOLEONWORK:   {}", AppPeopleOnWork_Time);
     SPDLOG_INFO("APPBADTHING:       {}", AppContraband_Time);
-    SPDLOG_INFO("APPBADMAN:         {}", AppBadMan);
+    SPDLOG_INFO("APPBADMAN:         {}", AppBadMan_Time);
     SPDLOG_INFO("APPTIRED:          {}", AppTired_Time);
     SPDLOG_INFO("APPPEOPLECONT:     {}", AppPeopleCont);
     SPDLOG_INFO("APPPLAYPHONE:      {}", AppPlayPhone);
@@ -378,11 +378,24 @@ bool GlobalThreadInfo::addActionInfo(const ActionInfo& info)
     /* 人员计数 */
     else if (info.ActionID == g_actionList.ActPersonNumber)
     {
+        /* 区域人员检测(人员计数?) */
         auto pFuncActionInfo = findAppFunction(info.ChannelID, AppFunction::APP_Regional);
         if(pFuncActionInfo != nullptr)
         {
             pFuncActionInfo->addActionInfo(info);
         }
+        /* 非法入侵检测 */
+        pFuncActionInfo = findAppFunction(info.ChannelID, AppFunction::APP_Illegal);
+        if(pFuncActionInfo != nullptr)
+        {
+            pFuncActionInfo->addActionInfo(info);
+        }
+        /* 人员在岗识别 */
+        pFuncActionInfo = findAppFunction(info.ChannelID, AppFunction::APP_OnWork);
+        if(pFuncActionInfo != nullptr)
+        {
+            pFuncActionInfo->addActionInfo(info);
+        }
     }
     /* 违禁物品 */
     else if (info.ActionID == g_actionList.ActContraband)
@@ -495,6 +508,7 @@ void GlobalThreadInfo::setNoneCameraFuncStop()
         if(it->listRoomCamActInfo.empty())
         {
             it->RunState = RunTimeState::RUN_STATE_STOP;
+            SPDLOG_INFO("《{}》房间信息为空,退出检测", it->strFunctionName);
         }
     }
 }

+ 4 - 1
SecurePlayAuxServer/GlobalInfo/GlobalConfig.h

@@ -29,6 +29,9 @@ public:
         return gc;
     }
 
+    const int liveRoomType = 1;             /* 直播间类型 */
+    const int dicRoomType = 2;              /* 导播间类型 */
+
     /* 读取配置文件 */
     bool readConfig(const QString& strConfigFile);
     /* 打印读取到的值 */
@@ -37,7 +40,7 @@ public:
     int AppUpdateOnWorkTimeInterval_Time;   /* 更新在岗信息的时间间隔 */
     int AppPeopleOnWork_Time;               /* 离岗时间 */
     int AppContraband_Time;                 /* 违禁物品出现的时间 */
-    int AppBadMan;                          /* 非法入侵 */
+    int AppBadMan_Time;                     /* 非法入侵超时时间 */
     int AppTired_Time;                      /* 疲劳检测时间 */
     int AppPeopleCont;                      /* 区域人员统计 */
     int AppPlayPhone;                       /* 玩手机识别 */

+ 0 - 148
SecurePlayAuxServer/GlobalInfo/GlobalVariable.cpp

@@ -309,154 +309,6 @@ RoomFaceInfo* ListRoomFaceInfo::findRoomFaceInfo(int ChannelID, int RoomID, int
     return nullptr;
 }
 
-IllegalInvasionInfo::IllegalInvasionInfo(const IllegalInvasionInfo& other)
-{
-    isInsertEQM = other.isInsertEQM;
-    PKID = other.PKID;
-    CameraID = other.CameraID;
-    RoomID = other.RoomID;
-    ChannelID = other.ChannelID;
-    RoomType = other.RoomType;
-    FirstTime = other.FirstTime;
-    strActionDec = other.strActionDec;
-    strImageInfo = other.strImageInfo;
-}
-
-IllegalInvasionInfo& IllegalInvasionInfo::operator=(const IllegalInvasionInfo& other)
-{
-    if(this != &other)
-    {
-        isInsertEQM = other.isInsertEQM;
-        PKID = other.PKID;
-        CameraID = other.CameraID;
-        RoomID = other.RoomID;
-        ChannelID = other.ChannelID;
-        RoomType = other.RoomType;
-        FirstTime = other.FirstTime;
-        strActionDec = other.strActionDec;
-        strImageInfo = other.strImageInfo;
-    }
-    return *this;
-}
-
-
-/* 添加信息 */
-void ListIllegalInvasionInfo::addIllInfo(IllegalInvasionInfo& info)
-{
-    if(findIllInfo(info) == nullptr)
-    {
-        listIll.push_back(info);
-    }
-}
-/* 查找相同的信息 */
-IllegalInvasionInfo* ListIllegalInvasionInfo::findIllInfo(IllegalInvasionInfo& info)
-{
-    for(auto& it : listIll)
-    {
-        if(it.RoomID == info.RoomID && it.RoomType == info.RoomType)
-        {
-            return &it;
-        }
-    }
-
-    return nullptr;
-}
-
-IllegalInvasionInfo* ListIllegalInvasionInfo::findIllInfo(int roomID, int roomType)
-{
-    for(auto& it : listIll)
-    {
-        if(it.RoomID == roomID && it.RoomType == roomType)
-        {
-            return &it;
-        }
-    }
-
-    return nullptr;
-}
-
-/* 删除报警信息 */
-void ListIllegalInvasionInfo::deleteIllInfo(IllegalInvasionInfo& info)
-{
-    for(auto it = listIll.begin(); it != listIll.end();)
-    {
-        if(it->RoomID == info.RoomID && it->RoomType == info.RoomType)
-        {
-            it = listIll.erase(it);
-        }else {
-            ++it;
-        }
-    }
-}
-
-void ListIllegalInvasionInfo::deleteIllInfo(int roomID, int roomType)
-{
-    for(auto it = listIll.begin(); it != listIll.end();)
-    {
-        if(it->RoomID == roomID && it->RoomType == roomType)
-        {
-            it = listIll.erase(it);
-        }else {
-            ++it;
-        }
-    }
-}
-
-
-RoomIllegalInvasionInfo::RoomIllegalInvasionInfo(const RoomIllegalInvasionInfo& o)
-{
-    isAlarm = o.isAlarm;
-    RoomID = o.RoomID;
-    RoomType = o.RoomType;
-    numMaxFace = o.numMaxFace;
-    numMaxPerson = o.numMaxPerson;
-    strBoxList = o.strBoxList;
-    strMessage = o.strMessage;
-    strImage = o.strImage;
-    CameraID = o.CameraID;
-}
-RoomIllegalInvasionInfo& RoomIllegalInvasionInfo::operator=(const RoomIllegalInvasionInfo& o)
-{
-    if(this != &o) {
-        isAlarm = o.isAlarm;
-        RoomID = o.RoomID;
-        RoomType = o.RoomType;
-        numMaxFace = o.numMaxFace;
-        numMaxPerson = o.numMaxPerson;
-        strBoxList = o.strBoxList;
-        strMessage = o.strMessage;
-        strImage = o.strImage;
-        CameraID = o.CameraID;
-    }
-
-    return *this;
-}
-
-/* 添加房间 */
-void ListRoomIll::addRoom(int RoomID, int RoomType)
-{
-    auto p = findRoom(RoomID, RoomType);
-    if(p == nullptr)
-    {
-        RoomIllegalInvasionInfo ill;
-        ill.RoomID = RoomID;
-        ill.RoomType = RoomType;
-        listRoomIll.push_back(ill);
-    }
-}
-
-/* 查找是否有相同的房间 */
-RoomIllegalInvasionInfo* ListRoomIll::findRoom(int RoomID, int RoomType)
-{
-    for(auto& it : listRoomIll)
-    {
-        if(it.RoomID == RoomID && it.RoomType == RoomType)
-        {
-            return &it;
-        }
-    }
-    return nullptr;
-}
 
 
 

+ 2 - 78
SecurePlayAuxServer/GlobalInfo/GlobalVariable.h

@@ -285,6 +285,7 @@ struct ListAlarmInfo
     void deleteAlarmInfo(AlarmInfo& info);
 };
 
+
 /**
  * @brief 房间内的人脸信息
  * 
@@ -332,83 +333,8 @@ struct ListRoomFaceInfo
     RoomFaceInfo* findRoomFaceInfo(int ChannelID, int RoomID, int CameraID);
 };
 
-/**
- * @brief 非法入侵检测信息结构体,作为缓存存储正在报警的信息
- * 
- */
-struct IllegalInvasionInfo
-{
-    bool isInsertEQM = false;           /* 是否已经插入到EQM数据库的报警信息中 */
-    int PKID = 0;
-    int CameraID = 0;
-    int RoomID = 0;
-    int ChannelID = 0;
-    int RoomType = 0;                   /* 房间类型 */
-    QDateTime FirstTime;                /* 最开始的报警时间 */
-    std::string strActionDec;           /* 算法描述 */
-    std::string strImageInfo;           /* 图片信息 */
-
-    IllegalInvasionInfo() = default;
-    IllegalInvasionInfo(const IllegalInvasionInfo& other);
-    IllegalInvasionInfo& operator=(const IllegalInvasionInfo& other);
-};
-
-/**
- * @brief 非法入侵报警列表
- * 
- */
-struct ListIllegalInvasionInfo
-{
-    std::list<IllegalInvasionInfo> listIll;
-
-    std::list<IllegalInvasionInfo>& getData() { return listIll; }
-    /* 添加信息 */
-    void addIllInfo(IllegalInvasionInfo& info);
-    /* 查找相同的信息 */
-    IllegalInvasionInfo* findIllInfo(IllegalInvasionInfo& info);
-    IllegalInvasionInfo* findIllInfo(int roomID, int roomType);
-    /* 删除报警信息 */
-    void deleteIllInfo(IllegalInvasionInfo& info);
-    void deleteIllInfo(int roomID, int roomType);
-};
-
 
-/**
- * @brief 房间为单位的非法入侵信息
- * 
- */
-struct RoomIllegalInvasionInfo
-{
-    bool isAlarm = false;                   /* 是否在报警 */
-    int RoomID = 0;                         /* 房间ID */
-    int RoomType = 0;                       /* 房间类型 */
-    int numMaxFace = 0;                     /* 最大人脸数 */
-    int numMaxPerson = 0;                   /* 最大人员数 */
-    int CameraID = 0;                       /* 摄像机ID,这个存储的是使用的哪个报警信息的ID */
-    std::list<std::string> strBoxList;      /* box */
-    std::string strMessage;                 /* 报警信息字符串 */
-    std::string strImage;                   /* 报警图片 */
-    std::vector<PersonInfo> vecPersonInfo;  /* 人员信息 */
-
-    RoomIllegalInvasionInfo() = default;
-    RoomIllegalInvasionInfo(const RoomIllegalInvasionInfo& o);
-    RoomIllegalInvasionInfo& operator=(const RoomIllegalInvasionInfo& o);
-};
 
-/**
- * @brief 房间报警数据,以房间为单位
- * 
- */
-struct ListRoomIll
-{
-    std::list<RoomIllegalInvasionInfo> listRoomIll;
-
-    std::list<RoomIllegalInvasionInfo>& getData() { return listRoomIll; }
-    /* 添加房间 */
-    void addRoom(int RoomID, int RoomType);
-    /* 查找是否有相同的房间 */
-    RoomIllegalInvasionInfo* findRoom(int RoomID, int RoomType);
-};
 
 /**
  * @brief 报警规则
@@ -650,7 +576,7 @@ public:
  */
  struct FuncActionInfo
  {
-    int ChannelID;                  /* 通道ID */
+    int ChannelID;                  /* 频率ID */
     AppFunction appFunction;        /* 任务功能 */
     RunTimeState RunState;          /* 线程运行状态 */
     std::string strFunctionName;    /* 功能名称 */
@@ -666,8 +592,6 @@ public:
     /* 清空算法信息 */
     void clearActionList();
 
-
-    
  };
 
 /**

+ 9 - 350
SecurePlayAuxServer/SPAServer.cpp

@@ -7,6 +7,7 @@
 #include "GlobalInfo/GlobalConfig.h"
 #include "UniversalFunc.h"
 #include "FuncOrdinary.h"
+#include "FuncIllegalInvasion.h"
 
 #include <QCoreApplication>
 
@@ -104,6 +105,11 @@ void SPAServer::threadFromSuperBrain()
         /* 更新通道名称和摄像机名称信息 */
         std::map<int, std::string> mapChannelName;
         m_toEQMDataBase.getChannelInfo(mapChannelName);
+        GConfig.setChannelInfo(mapChannelName);
+
+        std::map<int, std::string> mapCameraName;
+        m_toEQMDataBase.getCameraInfo(mapCameraName);
+        GConfig.setCameraInfo(mapCameraName);
 
         /* 10秒更新一次 */
         std::this_thread::sleep_for(std::chrono::seconds(10));
@@ -552,6 +558,9 @@ FuncBase* SPAServer::createFuncInstance(FuncActionInfo& info)
     else if(info.appFunction == AppFunction::APP_Illegal)
     {
         /* 非法入侵 */
+        auto tmpFunc = new FuncIllegalInvasion();
+        tmpFunc->setFuncActionInfo(info);
+        pFunc = tmpFunc;
     }
     else if(info.appFunction == AppFunction::APP_Regional)
     {
@@ -597,329 +606,6 @@ void SPAServer::clearNoneFuncActionInfo()
 
 
 
-
-/**
- * @brief 人员在岗识别线程,这个功能主要是给客户端提供实时的人脸识别信息
- *        1、这个写入tWorkOnInfo表格,十分钟写一次
- *        2、理论上这里需要实时更新数据库,但是实际上时每十分钟写入一次数据
- *        3、这个线程也会进行在岗离岗的识别报警
- * 
- * @param RFAInfo 传入房间ID和算法ID
- */
-// void SPAServer::threadActPersonWork(FuncActionInfo* RFAInfo)
-// {
-//     SPDLOG_LOGGER_INFO(m_logger, "开启 {} 线程,ChannelID:{} ,", RFAInfo->strFunctionName, RFAInfo->ChannelID);
-//     /* 创建读取Redis的实例 */
-//     std::shared_ptr<FromRedis> fromRedis = std::make_shared<FromRedis>();
-//     /* 创建写入数据库实例 */
-//     std::shared_ptr<ToEQMDataBase> toEQMDataBase = std::make_shared<ToEQMDataBase>();
-//     /* 局部变量 */
-//     std::shared_ptr<FuncActionInfo> pRFAInfo = std::make_shared<FuncActionInfo>();
-//     *pRFAInfo = *RFAInfo;
-
-//     /* 保存每个摄像机的报警信息 */
-//     std::shared_ptr<std::list<AlarmInfo>> pListAlarmInfo = std::make_shared<std::list<AlarmInfo>>();
-//     /* 保存人脸信息的数据 */
-//     std::shared_ptr<ListRoomFaceInfo> pListRoomFaceInfo = std::make_shared<ListRoomFaceInfo>();
-    
-//     while (m_threadRunning)
-//     {
-//         /* 更新线程信息 */
-//         GThreadInfo.updateFuncInfo(pRFAInfo.get());
-//         if(pRFAInfo->appFunction == AppFunction::APP_NONE)
-//         {
-//             break;
-//         }
-
-//         /* 读取Redis数据 */
-//         pListAlarmInfo->clear();
-//         for(const auto& RoomInfo : pRFAInfo->listRoomCamActInfo)
-//         {
-//             for(const auto& it : RoomInfo.mapCameraAction)
-//             {
-//                 std::string strKey = std::to_string(it.first) + ":" + it.second;
-//                 std::string strRetValue;
-//                 if(!fromRedis->getRedisString(strKey, strRetValue))
-//                 {
-//                     SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
-//                     std::this_thread::sleep_for(std::chrono::milliseconds(100));
-//                     continue;
-//                 }
-//                 /* 解析数据 */
-//                 AlarmInfo alarmInfo;
-//                 parseRedisBaseData(strRetValue, alarmInfo);
-//                 parseRedisBBoxesData(strRetValue, alarmInfo);
-//                 /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
-//                 if(isEventTimeVaild(alarmInfo.EventTime))
-//                 {
-//                     SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
-//                     std::this_thread::sleep_for(std::chrono::milliseconds(100));
-//                     continue;
-//                 }
-//                 pListAlarmInfo->push_back(alarmInfo);
-//             }
-//         }
-
-//         /* 处理数据,将报警信息的人脸信息取出来,放入到人脸信息列表中 */
-//         for(auto& alarmInfo : *pListAlarmInfo)
-//         {
-//             /* 添加到人脸列表中,会自动去重,自动创建对应的频道和房间信息 */
-//             pListRoomFaceInfo->addRoomFaceInfo(alarmInfo);
-//         }
-//         /* 计算人脸个数,并判断是否需要写入数据库 */
-//         QDateTime now = QDateTime::currentDateTime();
-//         for(auto it = pListRoomFaceInfo->listRoomFaceInfo.begin(); it != pListRoomFaceInfo->listRoomFaceInfo.end(); )
-//         {
-//             if(it->MaxNum < it->listPersonInfo.size())
-//             {
-//                 it->MaxNum = it->listPersonInfo.size();
-//             }
-//             if(it->MinNum > it->listPersonInfo.size())
-//             {
-//                 it->MinNum = it->listPersonInfo.size();
-//             }
-//             /* 判断是否需要写入数据库,超过设置的时间就写入,默认是600秒 */
-//             if(now.toSecsSinceEpoch() - it->StartTime.toSecsSinceEpoch() > GConfig.AppUpdateOnWorkTimeInterval_Time)
-//             {
-//                 /* 写入数据库 */
-//                 if(toEQMDataBase->insertOnWorkInfo(*it))
-//                 {
-//                     SPDLOG_LOGGER_INFO(m_logger, "ChannelID:{}, RoomID:{}, 在岗信息写入数据库成功, StartTime", it->ChannelID, it->RoomID, it->StartTime.toString("yyyy-MM-dd hh:mm:ss").toStdString());
-//                     /* 删除这条信息 */
-//                     it = pListRoomFaceInfo->listRoomFaceInfo.erase(it);
-//                     continue;
-//                 }
-//             }
-//             ++it;
-//         }
-//         std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
-//     }
-//     GThreadInfo.setThreadState(pRFAInfo.get(), RunTimeState::RUN_STATE_STOP);
-//     SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
-// }
-
-
-/**
- * @brief 区域非法入侵检测
-            1、野猫、宠物识别:报警判断条件:机房内出现摄像头的宠物识别算法输出报警结果时,记为报警行为,直接
-              展示报警结果
-            2、无权限人员识别:报警判断条件:当判断出区域非法入侵行为时,依据人脸识别结果,判断是否为人脸库人
-              员,非人脸库的人员时判断为非法入侵行为(背影需要报警需要结合区域人员检测算法判断)
-            3、人员计数和人脸识别数不相等时,判断为非法入侵行为
-        
-        检测逻辑:
-            1、先检测非法的人脸信息
-            2、再检测人员计数和人脸识别数不相等
- * 
- * @param info 
- */
-void SPAServer::threadActIllegalInvasion(FuncActionInfo* RFAInfo)
-{
-    SPDLOG_LOGGER_INFO(m_logger, "开启 {} 线程,ChannelID:{} ,", RFAInfo->strFunctionName, RFAInfo->ChannelID);
-    /* 创建读取Redis的实例 */
-    std::shared_ptr<FromRedis> fromRedis = std::make_shared<FromRedis>();
-    /* 创建写入数据库实例 */
-    std::shared_ptr<ToEQMDataBase> toEQMDataBase = std::make_shared<ToEQMDataBase>();
-    /* 局部变量 */
-    std::shared_ptr<FuncActionInfo> pRFAInfo = std::make_shared<FuncActionInfo>();
-    *pRFAInfo = *RFAInfo;
-    /* 保存每个摄像机的报警信息 */
-    std::shared_ptr<std::list<AlarmInfo>> pListAlarmInfo = std::make_shared<std::list<AlarmInfo>>();
-    /* 保存非法入侵的信息 */
-    std::shared_ptr<ListIllegalInvasionInfo> pListIllInfo = std::make_shared<ListIllegalInvasionInfo>();
-    
-    std::string strFaceActionID;            /* 人脸识别的Action */
-    std::string strCountActionID;           /* 人员计数的Action */
-
-    /* 封装lambda表达式 */
-    std::function<bool(const std::vector<PersonInfo>&)> funcIsAlarm = [](const std::vector<PersonInfo>& vecPersion) {
-        for(const auto& it : vecPersion)
-        {
-            if(it.PersonID == "-1")
-            {
-                return true;
-            }
-        }
-        return false;
-    };
-
-    while (m_threadRunning)
-    {
-        /* 更新线程信息 */
-        GThreadInfo.updateFuncInfo(pRFAInfo.get());
-        if(pRFAInfo->appFunction == AppFunction::APP_NONE)
-        {
-            break;
-        }
-        /* 更新算法ActionID */
-        {
-            g_actionList.mutexRW.lockForRead();
-            strFaceActionID = g_actionList.ActFace;
-            strCountActionID = g_actionList.ActPersonNumber;
-            g_actionList.mutexRW.unlock();
-        }
-
-        /* 读取Redis数据 */
-        pListAlarmInfo->clear();
-        for(const auto& RoomInfo : pRFAInfo->listRoomCamActInfo)
-        {
-            for(const auto& it : RoomInfo.mapCameraAction)
-            {
-                std::string strKey = std::to_string(it.first) + ":" + it.second;
-                std::string strRetValue;
-                if(!fromRedis->getRedisString(strKey, strRetValue))
-                {
-                    SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
-                    std::this_thread::sleep_for(std::chrono::milliseconds(100));
-                    continue;
-                }
-                /* 解析数据 */
-                AlarmInfo alarmInfo;
-                // parseRedisData(strRetValue, alarmInfo);
-                parseRedisBaseData(strRetValue, alarmInfo);
-                parseRedisBBoxesData(strRetValue, alarmInfo);
-                /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
-                if(isEventTimeVaild(alarmInfo.EventTime))
-                {
-                    SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
-                    std::this_thread::sleep_for(std::chrono::milliseconds(100));
-                    continue;
-                }
-                pListAlarmInfo->push_back(alarmInfo);
-            }
-        }
-
-        /* 找出房间的个数,按照房间进行判断 */
-        ListRoomIll listRoomIll;
-        for(auto& it : pRFAInfo->listRoomCamActInfo)
-        {
-            listRoomIll.addRoom(it.RoomID, it.RoomType);
-        }
-
-        /* 根据房间解析人脸识别的非法入侵,这个有了就不用判断后面的人员计数不相等了 */
-        for(auto& room : listRoomIll.getData())
-        {
-            for(const auto& it : *pListAlarmInfo)
-            {
-                /* 人俩识别算法 */
-                if(it.ActionID == strFaceActionID)
-                {
-                    if(it.vecPersonInfo.size() > room.numMaxFace)
-                    {
-                        room.numMaxFace = it.vecPersonInfo.size();
-                        room.strBoxList = it.listBbox;
-                        room.vecPersonInfo = it.vecPersonInfo;
-                    }
-                }
-                /* 判断有没有非法入侵人员 */
-                if(funcIsAlarm(it.vecPersonInfo))
-                {
-                    room.isAlarm = true;
-                    room.strMessage = "人员非法入侵(未知人员)";
-                    if( !it.ImageInfo.empty() )
-                    {
-                        room.strImage = it.ImageInfo;
-                    }
-                    room.CameraID = it.DeviceID;
-                }
-            }
-            
-        }
-
-        /* 判断人脸识别到的数目和人员计数算法识别到的人数是否相等,如果上面报警了,这里就不用检测了 */
-        for(auto& room : listRoomIll.getData())
-        {
-            if(room.isAlarm)
-            {
-                continue;
-            }
-            /* 这个房间的人脸算法没有识别到非法入侵 */
-            for(const auto& it : *pListAlarmInfo)
-            {
-                if(it.ActionID == strCountActionID)
-                {
-                    if(it.vecPersonInfo.size() > room.numMaxPerson)
-                    {
-                        room.numMaxPerson = it.vecPersonInfo.size();
-                        room.strBoxList = it.listBbox;
-                        if(!it.ImageInfo.empty())
-                        {
-                            room.strImage = it.ImageInfo;
-                        }
-                        room.CameraID = it.DeviceID;
-                    }
-                }
-            }
-            /* 判断人数是否一致 */
-            if(room.numMaxFace != room.numMaxPerson)
-            {
-                room.strMessage = fmt::format("非法入侵(人员计数 {} 和人脸数 {} 不一致)", room.numMaxPerson, room.numMaxFace);
-                room.isAlarm = true;
-            }
-        }
-
-        /* 将非法入侵的信息存储到数组缓存中,等待报警结束后判断是否需要写入EQM数据库 */
-        for(auto& room : listRoomIll.getData())
-        {
-            auto pIll = pListIllInfo->findIllInfo(room.RoomID, room.RoomType);
-            if(room.isAlarm)
-            {
-                /* 正在报警,检查是否有 */
-                if(pIll == nullptr)
-                {
-                    IllegalInvasionInfo info;
-                    info.ChannelID = pRFAInfo->ChannelID;
-                    info.CameraID = room.CameraID;
-                    info.RoomID = room.RoomID;
-                    info.RoomType = room.RoomType;
-                    info.strActionDec = room.strMessage;
-                    info.strImageInfo = room.strImage;
-                    info.FirstTime = QDateTime::currentDateTime();;
-                    pListIllInfo->addIllInfo(info);
-                }
-            }
-            else 
-            {
-                /* 没有报警,检查是否是报警结束了,是否符合写入数据库的条件 */
-                QDateTime currTime = QDateTime::currentDateTime();
-                int secs = currTime.toSecsSinceEpoch() - pIll->FirstTime.toSecsSinceEpoch();
-                if(secs >= GConfig.AppBadMan)
-                {
-                    if(!pIll->strImageInfo.empty())
-                    {
-                        /* 超过非法入侵的时间,写入数据库 */
-                        AlarmInfo ai;
-                        ai.ChannelID = pRFAInfo->ChannelID;
-                        ai.RoomID = pIll->RoomID;
-                        ai.ActionID = g_actionList.ActPersonNumber;
-                        ai.ActionDes = pIll->strActionDec;
-                        ai.ImageInfo = pIll->strImageInfo;
-                        ai.StartTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
-                        ai.EndTime = currTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
-                        ai.EventTime = pIll->FirstTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
-                        ai.vecPersonInfo = room.vecPersonInfo;
-                        ai.listBbox = room.strBoxList;
-                        bool insertRet  = toEQMDataBase->insertAlarmInfo(ai);
-                        if(insertRet)
-                        {
-                            std::string actionName = g_actionList.getActionName(ai.ActionID);
-                            SPDLOG_LOGGER_INFO(m_logger, "☆ 新增报警信息,频道[{}],房间[{}],摄像头[{}],{},{},有{}个区域,有{}个人脸,{}", 
-                            pIll->ChannelID, pIll->RoomID, pIll->CameraID, actionName, ai.ActionDes, ai.listBbox.size(), ai.FaceIDList.size(), ai.ImageInfo);
-                        }
-                    }
-                    /* 删除这个非法入侵信息 */
-                    pListIllInfo->deleteIllInfo(*pIll);
-                }
-            }
-        }
-        std::this_thread::sleep_for(std::chrono::milliseconds(GConfig.ThreadSleepMS));
-    }
-    GThreadInfo.setThreadState(pRFAInfo.get(), RunTimeState::RUN_STATE_STOP);
-    SPDLOG_LOGGER_INFO(m_logger, "关闭 {} 线程,ChannelID:{}", pRFAInfo->strFunctionName, pRFAInfo->ChannelID);
-}
-
-
-
 /**
  * @brief 区域人员检测,检测这个区域内的人数,不能少于多少人,不能多余多少人
  *          1、报警判断条件:直播间报警:当前频率所有直播间摄像头的区域人员检测算法输出结果均大于或小于设定人
@@ -1061,30 +747,3 @@ void SPAServer::threadActRegionalPersonnelDetection(FuncActionInfo* RFAInfo)
 }
 
 
-
-/* 将该算法对应的摄像机放入摄像机列表 */
-// bool SPAServer::insertCameraToAction(RoomActionInfo* pRAInfo, std::list<RoomCameraInfo>& listRC, std::multimap<int, std::string>& mapCameraActionID)
-// {
-//     for(const auto& rci : listRC)
-//     {
-//         if(rci.RoomID == pRAInfo->RoomID)
-//         {
-//             /* 这个摄像机在这个房间内,再判断这个摄像机有没有这个算法 */
-//             for(const auto& camID : rci.listCameraID)
-//             {
-//                 for(const auto& cai : mapCameraActionID)
-//                 {
-//                     if(camID == cai.first)
-//                     {
-//                         /* 再判断这个摄像机的算法是否是当前需要的 */
-//                         if(cai.second == pRAInfo->ActionID)
-//                         {
-//                             pRAInfo->listCameraID.push_back(camID);
-//                         }
-//                     }
-//                 }
-//             }
-//         }
-//     }
-//     return true;
-// }

+ 0 - 7
SecurePlayAuxServer/SPAServer.h

@@ -50,16 +50,9 @@ private:
     /* 清理没有在运行的线程实例 */
     void clearNoneFuncActionInfo();
     
-    /* 人员在岗识别线程,应该是人脸识别线程,这个需要房间内多个摄像机共同识别 */
-    // void threadActPersonWork(FuncActionInfo* RFAInfo);
-    /* 非法入侵检测 */
-    void threadActIllegalInvasion(FuncActionInfo* RFAInfo);
     /* 区域人员检测(人员计数),检测这个区域内的人数,不能少于多少人,不能多余多少人 */
     void threadActRegionalPersonnelDetection(FuncActionInfo* RFAInfo);
 
-    /* 将该算法对应的摄像机放入摄像机列表 */
-    // bool insertCameraToAction(RoomActionInfo* pRAInfo, std::list<RoomCameraInfo>& listRC, std::multimap<int, std::string>& mapCameraActionID);
-
 
 private:
     std::shared_ptr<spdlog::logger> m_logger = nullptr;

+ 248 - 65
SecurePlayAuxServer/communication/ToEQMDataBase.cpp

@@ -40,7 +40,7 @@ bool ToEQMDataBase::initWebApi(const QString& url, const QString& serverIP, cons
     }
 
     m_httpApi->DBInit(url.toStdString().c_str());
-    // if(ret < 0)
+    // if(ret != 0)
     // {
     //     SPDLOG_LOGGER_ERROR(m_logger,"Init WebApi failed:{}, error Info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
     //     return false;
@@ -49,7 +49,7 @@ bool ToEQMDataBase::initWebApi(const QString& url, const QString& serverIP, cons
     /* 获取服务器列表 */
     char serverList[8192];
     ret = m_httpApi->DBGetServerList(serverList, 8192);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"Get server list failed:{}, error info:{}",ret, m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -58,7 +58,7 @@ bool ToEQMDataBase::initWebApi(const QString& url, const QString& serverIP, cons
     SPDLOG_LOGGER_DEBUG(m_logger,"WebAPI Sucess!");
     /* 登录,第二个参数是限制的服务 */
     ret = m_httpApi->DBLogin(serverIP, serID, "SPSS", m_userToken);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_ERROR(m_logger,"Login failed:{}, error info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -120,7 +120,7 @@ bool ToEQMDataBase::writeAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo)
         QString retStr;
         QString strCmd = QString::fromStdString(json0.dump());
         int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, retStr);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"写入tAction失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         }
@@ -169,7 +169,7 @@ bool ToEQMDataBase::deleteAlgorithmInfo(std::vector<AlgorithmInfo>& vecDeleteInf
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"删除tAction失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             return false;
@@ -208,7 +208,7 @@ bool ToEQMDataBase::getAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo)
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取tAction失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -292,7 +292,7 @@ bool ToEQMDataBase::insertDeviceInfo(std::vector<DeviceInfo>& vecInfo)
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_DEBUG(m_logger,"插入设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             isSuccess = false;
@@ -320,7 +320,7 @@ bool ToEQMDataBase::insertDeviceInfo(std::vector<DeviceInfo>& vecInfo)
         // ret = 0;
         // strCmd = QString::fromStdString(json0.dump());
         // ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
-        // if(ret < 0)
+        // if(ret != 0)
         // {
         //     SPDLOG_LOGGER_DEBUG(m_logger,"插入设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         //     isSuccess = false;
@@ -385,7 +385,7 @@ bool ToEQMDataBase::updateDeviceInfo(std::vector<DeviceInfo>& vecUpdateInfo)
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_DEBUG(m_logger,"更新设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             isSuccess = false;
@@ -442,7 +442,7 @@ bool ToEQMDataBase::deleteDeviceInfo(std::vector<DeviceInfo>& vecDeleteInfo)
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_DEBUG(m_logger,"删除tCamerinfo设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             isSuccess = false;
@@ -480,7 +480,7 @@ bool ToEQMDataBase::getDeviceInfo(std::vector<DeviceInfo>& vecInfo)
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取CamerInfo失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -541,13 +541,166 @@ bool ToEQMDataBase::getChannelInfo(std::map<int, std::string>& mapChannelName)
         SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
         return false;
     }
-    
+    nJson json0;
+    json0["opName"] = "SPSS_SelectChannelInfo";
+    QString strCmd = QString::fromStdString(json0.dump());
+    QString strRet;
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    if(ret != 0)
+    {
+        SPDLOG_LOGGER_DEBUG(m_logger,"获取通道信息失败:{}, 错误信息:{}",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,"获取通道信息失败");
+            return false;
+        }
+        nJson result = json1["result"];
+        if(result.empty())
+        {
+            return false;
+        }
+        for(const auto& it : result)
+        {
+            int id = it["chnID"].get<int>();
+            std::string chnName = it["chnName"].is_null() ? "" : it["chnName"].get<std::string>();
+            mapChannelName.insert(std::make_pair(id, chnName));
+        }
+    }
+    catch (const nJson::parse_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch (const nJson::type_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch(...) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败");
+        return false;
+    }
+
+    return true;
+}
+
+std::string ToEQMDataBase::getChannelName(int chnID)
+{
+    if(m_httpApi == nullptr)
+    {
+        SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
+        return "";
+    }
+    nJson json0;
+    json0["opName"] = "SPSS_SelectChannelInfo";
+    QString strCmd = QString::fromStdString(json0.dump());
+    QString strRet;
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    if(ret != 0)
+    {
+        SPDLOG_LOGGER_DEBUG(m_logger,"获取通道信息失败:{}, 错误信息:{}",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,"获取通道信息失败");
+            return "";
+        }
+        nJson result = json1["result"];
+        if(result.empty())
+        {
+            return "";
+        }
+        for(const auto& it : result)
+        {
+            int id = it["chnID"].get<int>();
+            if(id == chnID)
+            {
+                return it.dump();
+            }
+        }
+        
+    }
+    catch (const nJson::parse_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return "";
+    }
+    catch (const nJson::type_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return "";
+    }
+    catch(...) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败");
+        return "";
+    }
+
+    return "";
 }
 
 /* 获取摄像机信息 */
 bool ToEQMDataBase::getCameraInfo(std::map<int, std::string>& mapCameraName)
 {
+    if(m_httpApi == nullptr)
+    {
+        SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
+        return false;
+    }
+    nJson json0;
+    json0["opName"] = "SPSS_SelectCameraInfo";
+    QString strCmd = QString::fromStdString(json0.dump());
+    QString strRet;
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    if(ret != 0)
+    {
+        SPDLOG_LOGGER_DEBUG(m_logger,"获取通道信息失败:{}, 错误信息:{}",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,"获取通道信息失败");
+            return false;
+        }
+        nJson result = json1["result"];
+        if(result.empty())
+        {
+            return false;
+        }
+        for(const auto& it : result)
+        {
+            int id = it["camerId"].get<int>();
+            std::string camerName = it["camerName"].is_null() ? "" : it["camerName"].get<std::string>();
+            mapCameraName.insert(std::make_pair(id, camerName));
+        }
+    }
+    catch (const nJson::parse_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch (const nJson::type_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch(...) {
+        SPDLOG_LOGGER_ERROR(m_logger,"解析 tChannel数据失败 数据失败");
+        return false;
+    }
 
+    return true;
 }
 
 /* 插入设备和算法关联信息 */
@@ -580,7 +733,7 @@ bool ToEQMDataBase::insertDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo)
         QString strRet;
         QString strCmd = QString::fromStdString(json0.dump());
         int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_DEBUG(m_logger,"插入设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             return false;
@@ -621,7 +774,7 @@ bool ToEQMDataBase::updateDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo)
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_DEBUG(m_logger,"删除设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             // return false;
@@ -643,7 +796,7 @@ bool ToEQMDataBase::updateDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo)
             QString strCmd = QString::fromStdString(json0.dump());
             QString strRet;
             auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
-            if(ret < 0)
+            if(ret != 0)
             {
                 SPDLOG_LOGGER_DEBUG(m_logger,"插入设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
                 isSuccess = false;
@@ -676,7 +829,7 @@ bool ToEQMDataBase::deleteDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo)
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_DEBUG(m_logger,"删除设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             // return false;
@@ -709,7 +862,7 @@ bool ToEQMDataBase::deleteDeviceAlgorithmInfo(std::list<int>& vecID)
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_DEBUG(m_logger,"删除设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             // return false;
@@ -741,7 +894,7 @@ bool ToEQMDataBase::getDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo, std
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取ActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -839,7 +992,7 @@ bool ToEQMDataBase::getActionInfo(ListActionInfo& listInfo)
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取ActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -904,7 +1057,7 @@ bool ToEQMDataBase::getRoomCameraInfo(std::list<RoomCameraInfo>& vecInfo)
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取RoomCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -995,36 +1148,51 @@ bool ToEQMDataBase::insertAlarmInfo(const AlarmInfo& alarmInfo)
     /* 去掉最后一个“|” */
     strBbox.pop_back();
 
-    nJson json0;
-    json0["opName"] = "SPSS_InsertToAlarmInfo";
-    nJson json1;
-    json1["AlarmID"] = alarmInfo.AlarmID;
-    json1["StartTime"] = alarmInfo.StartTime;
-    json1["CreateTime"] = alarmInfo.EventTime;
-    json1["EndTime"] = alarmInfo.EndTime;
-    json1["bBox"] = strBbox;
-    json1["PicUrl"] = alarmInfo.PicUrl;
-    json1["AppID"] = alarmInfo.AppID;
-    json1["ActionID"] = alarmInfo.ActionID;
-    json1["ActionDes"] = alarmInfo.ActionDes;
-    json1["CamerID"] = alarmInfo.DeviceID;
-    json1["RoomID"] = alarmInfo.RoomID;
-    json1["chnID"] = alarmInfo.ChannelID;
-    json1["Stat"] = alarmInfo.State;
-    json0["FaceIDList"] = alarmInfo.FaceIDList;
-    json0["FaceNameList"] = alarmInfo.FaceNameList;
-    json0["OnWork"] = alarmInfo.OnWork;
-
-    json0["paramList"] = json1;
-    QString strCmd = QString::fromStdString(json0.dump());
-    QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
-    if(ret < 0)
+    try
     {
-        SPDLOG_LOGGER_WARN(m_logger,"插入报警信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
+        nJson json0;
+        json0["opName"] = "SPSS_InsertToAlarmInfo";
+        nJson json1;
+        json1["AlarmID"] = alarmInfo.AlarmID;
+        json1["StartTime"] = alarmInfo.StartTime;
+        json1["CreateTime"] = alarmInfo.EventTime;
+        json1["EndTime"] = alarmInfo.EndTime;
+        json1["bBox"] = strBbox;
+        json1["PicUrl"] = alarmInfo.PicUrl;
+        json1["AppID"] = alarmInfo.AppID;
+        json1["ActionID"] = alarmInfo.ActionID;
+        json1["ActionDes"] = alarmInfo.ActionDes;
+        json1["CamerID"] = alarmInfo.DeviceID;
+        json1["RoomID"] = alarmInfo.RoomID;
+        json1["chnID"] = alarmInfo.ChannelID;
+        json1["Stat"] = alarmInfo.State;
+        json0["FaceIDList"] = alarmInfo.FaceIDList;
+        json0["FaceNameList"] = alarmInfo.FaceNameList;
+        json0["OnWork"] = alarmInfo.OnWork;
+
+        json0["paramList"] = json1;
+        QString strCmd = QString::fromStdString(json0.dump());
+        QString strRet;
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
+        if(ret != 0)
+        {
+            SPDLOG_LOGGER_WARN(m_logger,"插入报警信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
+            return false;
+        }
+        // SPDLOG_LOGGER_DEBUG(m_logger,"插入报警信息成功!");
+    }
+    catch (const nJson::parse_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"创建 写入报警信息 JSON失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch (const nJson::type_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"创建 写入报警信息 JSON失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch(...) {
+        SPDLOG_LOGGER_ERROR(m_logger,"创建 写入报警信息 JSON失败 数据失败");
         return false;
     }
-    SPDLOG_LOGGER_DEBUG(m_logger,"插入报警信息成功!");
 
     return true;
 }
@@ -1037,22 +1205,37 @@ bool ToEQMDataBase::updateAlarmEndTime(const AlarmInfo& alarmInfo)
         SPDLOG_LOGGER_ERROR(m_logger,"WebApi is nullptr");
         return false;
     }
-    nJson json0;
-    json0["opName"] = "SPSS_UpdateAlarmEndTime";
-    nJson json1;
-    json1["EndTime"] = alarmInfo.EndTime;
-    json1["ChannelID"] = alarmInfo.ChannelID;
-    json1["RoomID"] = alarmInfo.RoomID;
-    json1["CamerID"] = alarmInfo.DeviceID;
-    json1["ActionID"] = alarmInfo.ActionID;
-    json0["paramList"] = json1;
-
-    QString strCmd = QString::fromStdString(json0.dump());
-    QString strRet;
-    int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
-    if(ret < 0)
+    try
     {
-        SPDLOG_LOGGER_WARN(m_logger,"更新报警结束时间失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
+        nJson json0;
+        json0["opName"] = "SPSS_UpdateAlarmEndTime";
+        nJson json1;
+        json1["EndTime"] = alarmInfo.EndTime;
+        json1["ChannelID"] = alarmInfo.ChannelID;
+        json1["RoomID"] = alarmInfo.RoomID;
+        json1["CamerID"] = alarmInfo.DeviceID;
+        json1["ActionID"] = alarmInfo.ActionID;
+        json0["paramList"] = json1;
+
+        QString strCmd = QString::fromStdString(json0.dump());
+        QString strRet;
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
+        if(ret != 0)
+        {
+            SPDLOG_LOGGER_WARN(m_logger,"更新报警结束时间失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
+            return false;
+        }
+    }
+    catch (const nJson::parse_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"创建 更新报警结束时间 JSON失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch (const nJson::type_error& e) {
+        SPDLOG_LOGGER_ERROR(m_logger,"创建 更新报警结束时间 JSON失败 数据失败:{}, 错误ID:{}",e.what(), e.id);
+        return false;
+    }
+    catch(...) {
+        SPDLOG_LOGGER_ERROR(m_logger,"创建 更新报警结束时间 JSON失败 数据失败");
         return false;
     }
 
@@ -1067,7 +1250,7 @@ bool ToEQMDataBase::getPersonCountRuleInfo(std::vector<PersonCountRuleInfo>& vec
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取AlarmRule失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -1141,7 +1324,7 @@ bool ToEQMDataBase::getAlarmAppInfo(std::list<AppAndTimeInfo>& listInfo)
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
-    if(ret < 0)
+    if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取AlarmApp失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
         return false;
@@ -1235,7 +1418,7 @@ bool ToEQMDataBase::insertOnWorkInfo(const RoomFaceInfo& onWorkInfo)
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
         auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
-        if(ret < 0)
+        if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"插入 tWorkOnInfo 失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
             return false;

+ 1 - 0
SecurePlayAuxServer/communication/ToEQMDataBase.h

@@ -32,6 +32,7 @@ public:
 
     /* 获取通道信息 */
     bool getChannelInfo(std::map<int, std::string>& mapChannelName);
+    std::string getChannelName(int chnID);
     /* 获取摄像机信息 */
     bool getCameraInfo(std::map<int, std::string>& mapCameraName);