ソースを参照

V0.5.4
1、替换成了WebAPI的源文件,但是还未编译通过

Apple 2 ヶ月 前
コミット
13c458799f

+ 24 - 0
.vscode/launch.json

@@ -0,0 +1,24 @@
+{
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "C++ Debug",
+            "type": "cppdbg",
+            "request": "launch",
+            "program": "${workspaceFolder}/../bin_Debug/SecurePlayAuxServer", // 替换为你的可执行文件路径
+            "args": [],
+            "stopAtEntry": false,
+            "cwd": "${workspaceFolder}",
+            "environment": [],
+            "externalConsole": false,
+            "MIMode": "gdb",
+            "setupCommands": [
+                {
+                    "description": "启用多线程调试",
+                    "text": "-enable-pretty-printing",
+                    "ignoreFailures": true
+                }
+            ]
+        }
+    ]
+}

+ 1 - 0
External

@@ -0,0 +1 @@
+Subproject commit 4dce7891c269f3967853f778a57726939eacd63a

+ 12 - 3
SQL/SecurePlay.sqlbook

@@ -13,6 +13,11 @@ VALUES ('OD210_022_001835_029-CYl65jlE', 8, '人员计数');
 INSERT INTO "tAction" ("ActionId","ActionTaskid","ActionName")
 VALUES (:actionID, :actionTaskID, :actionName);
 
+#更新信息
+UPDATE "tAction"
+SET "ActionId" = 'OD447_022_000070_001'
+WHERE "PKID" = '11';
+
 #删除信息
 DELETE FROM "tAction"
 WHERE "ActionId" = '123';
@@ -178,11 +183,15 @@ LEFT JOIN "tPeriod" ON "tRuleInfo"."PKID" = "tPeriod"."RuleID";
 SELECT *
 FROM "tPeriod";
 
-#获取功能信息,同时包含所在的频率信息
-SELECT "tPeriod".*, "tChannel"."ChnName"
+#获取功能信息,同时包含所在的频率信息,和应用信息
+SELECT "tPeriod"."ChnId", "tPeriod"."AppType", "tChannel"."ChnName", "tAppInfo"."AppName"
 FROM "tPeriod"
 LEFT JOIN "tChannel"
-ON "tPeriod"."ChnId" = "tChannel"."chnId";
+ON "tPeriod"."ChnId" = "tChannel"."ChnId"
+LEFT JOIN "tAppInfo"
+ON "tPeriod"."AppType" = "tAppInfo"."AppType"
+GROUP BY "tPeriod"."ChnId", "tPeriod"."AppType", "tChannel"."ChnName", "tAppInfo"."AppName";
+
 
 SELECT *
 FROM "tChannel";

+ 12 - 0
SecurePlayAuxServer/Application/FuncBase.cpp

@@ -223,3 +223,15 @@ bool FuncBase::isInDetectTime(const DetectPeriodInfo& periodInfo)
     return false;
 }
 
+/* 判断报警数据有效时间,超过600秒可能是超脑那边挂了 */
+bool FuncBase::isEventTimeVaild(const QDateTime& eventTime)
+{
+    /* 判断时间差 */
+    qint64 diff = m_nowTime.toSecsSinceEpoch() - eventTime.toSecsSinceEpoch();
+    if(diff > 600)
+    {
+        return false;
+    }
+    return true;
+}
+

+ 3 - 0
SecurePlayAuxServer/Application/FuncBase.h

@@ -47,6 +47,9 @@ protected:
     inline bool updateDetectTime(DetectPeriodInfo& periodInfo);
     /* 判断是否在检测时间内,重载版,会自动打印日志 */
     bool isInDetectTime(const DetectPeriodInfo& periodInfo);
+
+    /* 判断报警数据有效时间 */
+    bool isEventTimeVaild(const QDateTime& eventTime);
     
 
 protected:

+ 4 - 4
SecurePlayAuxServer/Application/FuncIllegalInvasion.cpp

@@ -255,7 +255,7 @@ void FuncIllegalInvasion::task()
                     /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
                     if(isEventTimeVaild(alarmInfo.EventTime))
                     {
-                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
+                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime.toString("yyyy-MM-dd hh:mm:ss").toStdString());
                         std::this_thread::sleep_for(std::chrono::milliseconds(100));
                         continue;
                     }
@@ -380,9 +380,9 @@ void FuncIllegalInvasion::task()
                         ai.ActionID = GVariable.ActPersonCount;
                         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.StartTime = pIll->FirstTime;
+                        ai.EndTime = currTime;
+                        ai.EventTime = pIll->FirstTime;
                         ai.listPersonInfo = room.listPersonInfo;
                         ai.listBbox = room.strBoxList;
                         bool insertRet  = m_fromWebAPI->insertAlarmInfo(ai);

+ 4 - 4
SecurePlayAuxServer/Application/FuncOnAndOffJob.cpp

@@ -318,7 +318,7 @@ void FuncOnAndOffJob::task()
                     /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
                     if(isEventTimeVaild(alarmInfo.EventTime))
                     {
-                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
+                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime.toString("yyyy-MM-dd hh:mm:ss").toStdString());
                         std::this_thread::sleep_for(std::chrono::milliseconds(100));
                         continue;
                     }
@@ -526,7 +526,7 @@ void FuncOnAndOffJob::onWorkProcess(RoomOnWorkInfo* pRoomOnWorkInfo, std::pair<c
             }
             alarmInfo.listBbox = getCameraNameList(roomInfo.second.mapCameraAction);    /* 直播间摄像机列表 */
             alarmInfo.ImageInfo = pRoomOnWorkInfo->strImagePath;
-            alarmInfo.EventTime = pRoomOnWorkInfo->StartTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+            alarmInfo.EventTime = pRoomOnWorkInfo->StartTime;
             alarmInfo.ActionID = "";
             alarmInfo.Is_OnWork = true;
             alarmInfo.listPersonInfo = pRoomOnWorkInfo->listPersonInfo;
@@ -652,7 +652,7 @@ void FuncOnAndOffJob::offWorkProcess(RoomOnWorkInfo* pRoomOnWorkInfo, std::pair<
             }
             alarmInfo.listBbox = getCameraNameList(roomInfo.second.mapCameraAction);    /* 直播间摄像机列表 */
             alarmInfo.ImageInfo = pRoomOnWorkInfo->strImagePath;
-            alarmInfo.EventTime = pRoomOnWorkInfo->StartTime.toString("yyyy-MM-dd hh:mm:ss").toStdString();
+            alarmInfo.EventTime = pRoomOnWorkInfo->StartTime;
             alarmInfo.ActionID = "";
             alarmInfo.Is_OnWork = false;
             alarmInfo.listPersonInfo = pRoomOnWorkInfo->listPersonInfo;
@@ -707,7 +707,7 @@ void FuncOnAndOffJob::offWorkProcess(RoomOnWorkInfo* pRoomOnWorkInfo, std::pair<
                 }
                 alarmInfo.listBbox = getCameraNameList(roomInfo.second.mapCameraAction);    /* 直播间摄像机列表 */
                 alarmInfo.ImageInfo = pRoomOnWorkInfo->strImagePath;
-                alarmInfo.EventTime = pRoomOnWorkInfo->listLeaveTime.front().toString("yyyy-MM-dd hh:mm:ss").toStdString();
+                alarmInfo.EventTime = pRoomOnWorkInfo->listLeaveTime.front();
                 alarmInfo.ActionID = "";
                 alarmInfo.Is_OnWork = false;
                 alarmInfo.listPersonInfo = pRoomOnWorkInfo->listPersonInfo;

+ 237 - 139
SecurePlayAuxServer/Application/FuncOrdinary.cpp

@@ -31,6 +31,9 @@ void FuncOrdinary::task()
     }
     /* 保存上次获取时间段的时间 */
     QDateTime lastTime = QDateTime::fromString("2025-05-07 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    /* 创建临时的报警信息 */
+    std::list<AlarmInfo> listAlarmTemp;
+
     while (GThreadInfo.getRunning())
     {
         /* 休眠设置的时间 */
@@ -52,17 +55,19 @@ void FuncOrdinary::task()
         }
         // SPDLOG_LOGGER_DEBUG(m_logger, "{} 在检测时间段内", m_baseLog);
 
+        /* ========================= 读取Redis数据 ========================= */
+        listAlarmTemp.clear();
         /* 读取Redis数据 */
         for(const auto& roomInfo : m_funcThreadInfo.listRoomCamActInfo)
         {
-            for(const auto& it : roomInfo.mapCameraAction)
+            for(const auto& cam : roomInfo.mapCameraAction)
             {
-                for(const auto act : it.second)
+                for(const auto act : cam.second)
                 {
                     /* 读取Redis数据 */
-                    std::string strKey = std::to_string(it.first) + ":" + act;
+                    std::string strKey = std::to_string(cam.first) + ":" + act;
                     std::string strRetValue;
-                    SPDLOG_LOGGER_DEBUG(m_logger, "读取Redis数据, Key:{}", strKey);
+                    // SPDLOG_LOGGER_DEBUG(m_logger, "读取Redis数据, Key:{}", strKey);
                     if(!m_fromRedis->getRedisString(strKey, strRetValue))
                     {
                         SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
@@ -72,200 +77,293 @@ void FuncOrdinary::task()
 
                     /* 解析数据,先设置基础数据 */
                     AlarmInfo newAlarmInfo;
-                    newAlarmInfo.ActionID = act;
+                    newAlarmInfo.ChannelID = m_funcThreadInfo.ChannelID;
                     newAlarmInfo.appFunction = m_funcThreadInfo.appFunction;
+                    newAlarmInfo.RoomID = roomInfo.RoomID;
+                    newAlarmInfo.DeviceID = cam.first;
+                    newAlarmInfo.ActionID = act;
+                    
 
                     parseRedisBaseData(strRetValue, newAlarmInfo);
-                    // parseRedisBBoxesData(strRetValue, newAlarmInfo);
+                    parseRedisBBoxesData(strRetValue, newAlarmInfo);
                     /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
-                    // if(isEventTimeVaild(newAlarmInfo.EventTime))
-                    // {
-                    //     SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, newAlarmInfo.EventTime);
-                    //     std::this_thread::sleep_for(std::chrono::milliseconds(100));
-                    //     continue;
-                    // }
-
+                    if(!isEventTimeVaild(newAlarmInfo.EventTime))
+                    {
+                        /* 事件时间超过600秒,可能是超脑挂了 */
+                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, newAlarmInfo.EventTime.toString("yyyy-MM-dd hh:mm:ss").toStdString());
+                        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+                        continue;
+                    }
+                    listAlarmTemp.push_back(newAlarmInfo);
                 }
             }
         }
+        SPDLOG_LOGGER_DEBUG(m_logger, "读取Redis数据成功, 报警数据数目: {}", m_listAlarm.listAlarmInfo.size());
         
-        
-        continue;
-        /* 读取Redis信息,处理数据,第一层循环是根据房间读取,第二个循环是根据房间内的摄像机读取 */
-        for(const auto& roomInfo : m_funcThreadInfo.listRoomCamActInfo)
+        // continue;
+
+        /* ========================= 处理报警数据 ========================= */
+
+        for(auto newAlarm : listAlarmTemp)
         {
-            for(const auto& it : roomInfo.mapCameraAction)
+            /* 找到该报警相关的房间信息 */
+            auto roomInfo = m_funcThreadInfo.findRoomInfo(newAlarm.RoomID);
+            if(roomInfo.RoomID == -1)
+            {
+                SPDLOG_LOGGER_ERROR(m_logger, "{} 房间ID: {} 不存在", m_baseLog, newAlarm.RoomID);
+                continue;
+            }
+            /* 创建基础日志信息 */
+            std::string tmpBaseLog = fmt::format("{} 房间: {}, 摄像机ID: {}, 算法ID: {}", m_baseLog, roomInfo.strRoomName, newAlarm.DeviceID, newAlarm.ActionID);
+            /* -------------------------------------------------------------------------------
+            * 判断有无报警记录,新的报警就先创建一个报警信息,写入报警列表,超过报警的最小误报时间后,
+            * 再写入到EQM的tAlarmInfo表中,正在报警的记录就判断和更新,结束报警就更新tAlarmInfo的
+            * 报警数据的结束时间,并清空pAlarmInfo 
+            * ------------------------------------------------------------------------------- */
+            /* 找出数组中与当前报警ID相同的的报警信息 */
+            auto pAlarmInfo = m_listAlarm.findAlarmInfo(newAlarm);
+            /* 没有找到报警记录,就新建一个 */
+            if(pAlarmInfo == nullptr)
             {
-                for(const auto act : it.second)
+                /* 新记录有报警,新建报警记录 */
+                if(newAlarm.Is_Alarm)
                 {
-                    /* 读取Redis数据 */
-                    std::string strKey = std::to_string(it.first) + ":" + act;
-                    std::string strRetValue;
-                    if(!m_fromRedis->getRedisString(strKey, strRetValue))
+                    /* 图片不能是空,如果是空的,就不写入数据库 */
+                    if(!newAlarm.ImageInfo.empty())
                     {
-                        SPDLOG_LOGGER_ERROR(m_logger, "读取Redis数据失败, Key:{}", strKey);
-                        std::this_thread::sleep_for(std::chrono::milliseconds(10));
-                        continue;
-                    }
-                    /* 解析数据,先设置基础数据 */
-                    AlarmInfo newAlarmInfo;
-                    newAlarmInfo.ActionID = act;
-                    newAlarmInfo.appFunction = m_funcThreadInfo.appFunction;
-
-                    parseRedisBaseData(strRetValue, newAlarmInfo);
-                    parseRedisBBoxesData(strRetValue, newAlarmInfo);
-                    /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
-                    if(isEventTimeVaild(newAlarmInfo.EventTime))
+                        /* 违禁品检测,开始时间是事件时间 */
+                        newAlarm.StartTime = newAlarm.EventTime;
+                        newAlarm.EndTime = GVariable.nullTime;
+                        /* 保存新的报警记录 */
+                        newAlarm.Is_InsertEQM = false;
+                        m_listAlarm.addAlarmInfo(newAlarm);
+                        SPDLOG_LOGGER_DEBUG(m_logger, "{} 新的报警,加入到缓存中", tmpBaseLog);
+                    }else 
                     {
-                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, newAlarmInfo.EventTime);
-                        std::this_thread::sleep_for(std::chrono::milliseconds(100));
-                        continue;
+                        SPDLOG_LOGGER_WARN(m_logger, "{}, 有报警区域, 但是没有图片信息", tmpBaseLog);
                     }
-
-                    /* -------------------------------------------------------------------------------
-                    * 判断有无报警记录,新的报警就先创建一个报警信息,写入报警列表,超过报警的最小误报时间后,
-                    * 再写入到EQM的tAlarmInfo表中,正在报警的记录就判断和更新,结束报警就更新tAlarmInfo的
-                    * 报警数据的结束时间,并清空pAlarmInfo 
-                    * ------------------------------------------------------------------------------- */
-
-                    /* 找出数组中与当前报警ID相同的的报警信息 */
-                    auto pAlarmInfo = m_listAlarm.findAlarmInfo(newAlarmInfo);
-                    /* 没有找到报警记录,就新建一个 */
-                    if(pAlarmInfo == nullptr)
+                }
+            } else 
+            {
+                /* 已有报警记录 */
+                /* 更新图片信息 */
+                if(!newAlarm.ImageInfo.empty())
+                {
+                    pAlarmInfo->ImageInfo = newAlarm.ImageInfo;
+                }
+                /* 判断是否还在报警中 */
+                if(newAlarm.Is_Alarm)
+                {
+                    /* 正在报警中,检查是否已经写入到数据库中 */
+                    if(pAlarmInfo->Is_InsertEQM)
                     {
-                        /* 新记录有报警,新建报警记录 */
-                        if(newAlarmInfo.Is_Alarm)
-                        {
-                            /* 图片不能是空,如果是空的,就不写入数据库 */
-                            if(!newAlarmInfo.ImageInfo.empty())
-                            {
-                                /* 违禁品检测,开始时间是事件时间 */
-                                newAlarmInfo.StartTime = newAlarmInfo.EventTime;
-                                newAlarmInfo.EndTime = "";
-                                /* 保存新的报警记录 */
-                                newAlarmInfo.Is_InsertEQM = false;
-                                m_listAlarm.addAlarmInfo(newAlarmInfo);
-                            }else 
-                            {
-                                SPDLOG_LOGGER_WARN(m_logger, "频道:{}, 房间:{}, 摄像机:{}, 算法:{}, 有报警区域, 但是没有图片信息", m_funcThreadInfo.ChannelID, roomInfo.RoomID, it.first, act);
-                            }
-                        }
-                    } 
-                    /* 已有报警记录 */
-                    else 
+                        /* 已经写入到数据库中,不做处理 */
+                    }else 
                     {
-                        /* 更新图片信息 */
-                        if(!newAlarmInfo.ImageInfo.empty())
+                        /* 判断报警时长间隔是否足够 */
+                        if(!isAlarmTimeVaild(*pAlarmInfo))
                         {
-                            pAlarmInfo->ImageInfo = newAlarmInfo.ImageInfo;
+                            /* 不够报警时间,直接进行下一个循环 */
+                            continue;
                         }
-                        /* 判断是否还在报警中 */
-                        if(newAlarmInfo.Is_Alarm)
+                        /* 写入到数据库 */
+                        pAlarmInfo->Is_InsertEQM = false;
+                        if(m_fromWebAPI->insertAlarmInfo(*pAlarmInfo))
                         {
-                            /* 正在报警中,检查是否已经写入到数据库中 */
-                            if(pAlarmInfo->Is_InsertEQM)
-                            {
-                                /* 已经写入到数据库中,不做处理 */
-                            }else 
-                            {
-                                /* 判断报警时长间隔是否足够 */
-                                if(!isAlarmTimeVaild(*pAlarmInfo))
-                                {
-                                    /* 不够报警时间,直接进行下一个循环 */
-                                    continue;
-                                }
-
-                                /* 写入到数据库 */
-                                pAlarmInfo->Is_InsertEQM = false;
-                                if(m_fromWebAPI->insertAlarmInfo(*pAlarmInfo))
-                                {
-                                    pAlarmInfo->Is_InsertEQM = true;
-                                }else {
-                                    SPDLOG_LOGGER_ERROR(m_logger, "写入tAlarmInfo报警数据失败, 频率:{}, 房间:{}, 算法:{} ", m_funcThreadInfo.ChannelID, roomInfo.RoomID, act);
-                                }
-                            }
-                            
-                        } else 
+                            pAlarmInfo->Is_InsertEQM = true;
+                        }else {
+                            SPDLOG_LOGGER_ERROR(m_logger, "{} 写入tAlarmInfo报警数据失败! ", tmpBaseLog);
+                        }
+                        SPDLOG_LOGGER_INFO(m_logger, "{}, 报警开始,写入数据库", tmpBaseLog);
+                    }
+                    
+                } else 
+                {
+                    /* 报警结束,判断时长,如果小于设置的最小间隔,可能是误报警
+                    * 更新数据库结束时间,结束时间是此时电脑时间 */
+                    if(isAlarmTimeVaild(*pAlarmInfo))
+                    {
+                        pAlarmInfo->EndTime = m_nowTime;
+                        /* 判断是否已经写入到数据库中 */
+                        if(pAlarmInfo->Is_InsertEQM)
                         {
-                            /* 报警结束,判断时长,如果小于设置的最小间隔,可能是误报警
-                            * 更新数据库结束时间,结束时间是此时电脑时间 */
-                            if(isAlarmTimeVaild(*pAlarmInfo))
-                            {
-                                pAlarmInfo->EndTime = chronoToStrTime(std::chrono::system_clock::now());
-                                /* 判断是否已经写入到数据库中 */
-                                if(pAlarmInfo->Is_InsertEQM)
-                                {
-                                    /* 已经写入到数据库中,更新结束时间 */
-                                    m_fromWebAPI->updateAlarmEndTime(*pAlarmInfo);
-                                }else {
-                                    /* 没有写入到数据库中,写入到数据库中 */
-                                    m_fromWebAPI->insertAlarmInfo(*pAlarmInfo);
-                                }
-                                SPDLOG_LOGGER_INFO(m_logger, "频率:{}, 房间:{}, 摄像机:{}, 算法:{}, 报警结束", m_funcThreadInfo.ChannelID, roomInfo.RoomID, it.first, act);
-                            }
-
-                            /* 删除这个报警信息 */
-                            m_listAlarm.deleteAlarmInfo(*pAlarmInfo);
+                            /* 已经写入到数据库中,更新结束时间 */
+                            m_fromWebAPI->updateAlarmEndTime(*pAlarmInfo);
+                        }else {
+                            /* 没有写入到数据库中,写入到数据库中 */
+                            m_fromWebAPI->insertAlarmInfo(*pAlarmInfo);
                         }
+                        SPDLOG_LOGGER_INFO(m_logger, "{}, 报警结束", tmpBaseLog);
                     }
+                    /* 删除这个报警信息 */
+                    m_listAlarm.deleteAlarmInfo(*pAlarmInfo);
                 }
             }
         }
-        
     }
 }
 
+/* old处理方法 */
+void FuncOrdinary::oldTask()
+{
+    // /* 读取Redis信息,处理数据,第一层循环是根据房间读取,第二个循环是根据房间内的摄像机读取 */
+    // for(const auto& roomInfo : m_funcThreadInfo.listRoomCamActInfo)
+    // {
+    //     for(const auto& it : roomInfo.mapCameraAction)
+    //     {
+    //         for(const auto act : it.second)
+    //         {
+    //             /* 读取Redis数据 */
+    //             std::string strKey = std::to_string(it.first) + ":" + act;
+    //             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(10));
+    //                 continue;
+    //             }
+    //             /* 解析数据,先设置基础数据 */
+    //             AlarmInfo newAlarmInfo;
+    //             newAlarmInfo.ActionID = act;
+    //             newAlarmInfo.appFunction = m_funcThreadInfo.appFunction;
+    //             parseRedisBaseData(strRetValue, newAlarmInfo);
+    //             parseRedisBBoxesData(strRetValue, newAlarmInfo);
+    //             /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
+    //             if(isEventTimeVaild(newAlarmInfo.EventTime))
+    //             {
+    //                 SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, newAlarmInfo.EventTime);
+    //                 std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    //                 continue;
+    //             }
+    //             /* -------------------------------------------------------------------------------
+    //             * 判断有无报警记录,新的报警就先创建一个报警信息,写入报警列表,超过报警的最小误报时间后,
+    //             * 再写入到EQM的tAlarmInfo表中,正在报警的记录就判断和更新,结束报警就更新tAlarmInfo的
+    //             * 报警数据的结束时间,并清空pAlarmInfo 
+    //             * ------------------------------------------------------------------------------- */
+    //             /* 找出数组中与当前报警ID相同的的报警信息 */
+    //             auto pAlarmInfo = m_listAlarm.findAlarmInfo(newAlarmInfo);
+    //             /* 没有找到报警记录,就新建一个 */
+    //             if(pAlarmInfo == nullptr)
+    //             {
+    //                 /* 新记录有报警,新建报警记录 */
+    //                 if(newAlarmInfo.Is_Alarm)
+    //                 {
+    //                     /* 图片不能是空,如果是空的,就不写入数据库 */
+    //                     if(!newAlarmInfo.ImageInfo.empty())
+    //                     {
+    //                         /* 违禁品检测,开始时间是事件时间 */
+    //                         newAlarmInfo.StartTime = newAlarmInfo.EventTime;
+    //                         newAlarmInfo.EndTime = "";
+    //                         /* 保存新的报警记录 */
+    //                         newAlarmInfo.Is_InsertEQM = false;
+    //                         m_listAlarm.addAlarmInfo(newAlarmInfo);
+    //                     }else 
+    //                     {
+    //                         SPDLOG_LOGGER_WARN(m_logger, "频道:{}, 房间:{}, 摄像机:{}, 算法:{}, 有报警区域, 但是没有图片信息", m_funcThreadInfo.ChannelID, roomInfo.RoomID, it.first, act);
+    //                     }
+    //                 }
+    //             } 
+    //             /* 已有报警记录 */
+    //             else 
+    //             {
+    //                 /* 更新图片信息 */
+    //                 if(!newAlarmInfo.ImageInfo.empty())
+    //                 {
+    //                     pAlarmInfo->ImageInfo = newAlarmInfo.ImageInfo;
+    //                 }
+    //                 /* 判断是否还在报警中 */
+    //                 if(newAlarmInfo.Is_Alarm)
+    //                 {
+    //                     /* 正在报警中,检查是否已经写入到数据库中 */
+    //                     if(pAlarmInfo->Is_InsertEQM)
+    //                     {
+    //                         /* 已经写入到数据库中,不做处理 */
+    //                     }else 
+    //                     {
+    //                         /* 判断报警时长间隔是否足够 */
+    //                         if(!isAlarmTimeVaild(*pAlarmInfo))
+    //                         {
+    //                             /* 不够报警时间,直接进行下一个循环 */
+    //                             continue;
+    //                         }
+    //                         /* 写入到数据库 */
+    //                         pAlarmInfo->Is_InsertEQM = false;
+    //                         if(m_fromWebAPI->insertAlarmInfo(*pAlarmInfo))
+    //                         {
+    //                             pAlarmInfo->Is_InsertEQM = true;
+    //                         }else {
+    //                             SPDLOG_LOGGER_ERROR(m_logger, "写入tAlarmInfo报警数据失败, 频率:{}, 房间:{}, 算法:{} ", m_funcThreadInfo.ChannelID, roomInfo.RoomID, act);
+    //                         }
+    //                     }
+                        
+    //                 } else 
+    //                 {
+    //                     /* 报警结束,判断时长,如果小于设置的最小间隔,可能是误报警
+    //                     * 更新数据库结束时间,结束时间是此时电脑时间 */
+    //                     if(isAlarmTimeVaild(*pAlarmInfo))
+    //                     {
+    //                         pAlarmInfo->EndTime = chronoToStrTime(std::chrono::system_clock::now());
+    //                         /* 判断是否已经写入到数据库中 */
+    //                         if(pAlarmInfo->Is_InsertEQM)
+    //                         {
+    //                             /* 已经写入到数据库中,更新结束时间 */
+    //                             m_fromWebAPI->updateAlarmEndTime(*pAlarmInfo);
+    //                         }else {
+    //                             /* 没有写入到数据库中,写入到数据库中 */
+    //                             m_fromWebAPI->insertAlarmInfo(*pAlarmInfo);
+    //                         }
+    //                         SPDLOG_LOGGER_INFO(m_logger, "频率:{}, 房间:{}, 摄像机:{}, 算法:{}, 报警结束", m_funcThreadInfo.ChannelID, roomInfo.RoomID, it.first, act);
+    //                     }
+    //                     /* 删除这个报警信息 */
+    //                     m_listAlarm.deleteAlarmInfo(*pAlarmInfo);
+    //                 }
+    //             }
+    //         }
+    //     }
+    // }
+}
 
 
 
 /* 判断报警时长是否符合不同应用的最小间隔 */
 bool FuncOrdinary::isAlarmTimeVaild(const AlarmInfo& info)
 {
+    int alarmTime = 0;
     /* 违禁品物品 */
     if(info.appFunction == AppFunction::APP_Contraband)
     {
-        if(timeDiffWithNow(info.EventTime) < GVariable.AppContraband_Time)
-        {
-            return false;
-        }
+        alarmTime = GVariable.AppContraband_Time;
     }
     /* 玩手机识别 */
     else if(info.appFunction == AppFunction::APP_PlayPhone)
     {
-        if(timeDiffWithNow(info.EventTime) < GVariable.AppPlayPhone)
-        {
-            return false;
-        }
+        alarmTime = GVariable.AppPlayPhone;
     }
     /* 老鼠识别 */
     else if(info.appFunction == AppFunction::APP_Mouse)
     {
-        if(timeDiffWithNow(info.EventTime) < GVariable.AppMouse)
-        {
-            return false;
-        }
+        alarmTime = GVariable.AppMouse;
     }
     /* 未戴口罩识别 */
     else if(info.appFunction == AppFunction::APP_NoMask)
     {
-        if(timeDiffWithNow(info.EventTime) < GVariable.AppMask)
-        {
-            return false;
-        }
+        alarmTime = GVariable.AppMask;
     }
     /* 疲劳检测 */
     else if(info.appFunction == AppFunction::APP_Fatigue)
     {
-        if(timeDiffWithNow(info.EventTime) < GVariable.AppTired_Time)
-        {
-            return false;
-        }
+        alarmTime = GVariable.AppTired_Time;
     }
     /* 摔倒识别 */
     else if(info.appFunction == AppFunction::APP_AllDown)
     {
         return true;
     }
+
+    if(info.EventTime.secsTo(m_nowTime) < alarmTime)
+    {
+        return false;
+    }
     
     return true;
 }

+ 3 - 0
SecurePlayAuxServer/Application/FuncOrdinary.h

@@ -28,6 +28,9 @@ protected:
     /* 任务线程 */
     void task() override;
 
+    /* old处理方法 */
+    void oldTask();
+
 private:
     /* 判断报警时长是否符合不同应用的最小间隔 */
     bool isAlarmTimeVaild(const AlarmInfo& info);

+ 1 - 1
SecurePlayAuxServer/Application/FuncPersonOnWork.cpp

@@ -82,7 +82,7 @@ void FuncPersonOnWork::task()
                     /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
                     if(isEventTimeVaild(alarmInfo.EventTime))
                     {
-                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime);
+                        SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,EventTime:{}",strKey, alarmInfo.EventTime.toString("yyyy-MM-dd hh:mm:ss").toStdString());
                         std::this_thread::sleep_for(std::chrono::milliseconds(100));
                         continue;
                     }

+ 7 - 7
SecurePlayAuxServer/Application/FuncRegionalPerson.cpp

@@ -273,10 +273,10 @@ void FuncRegionalPersonCount::task()
                     parseRedisBaseData(strRetValue, alarmInfo);
                     parseOtherDataPersonCount(strRetValue, alarmInfo);
                     /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
-                    if(!isEventTimeVaild(m_nowTime, alarmInfo.EventTime))
+                    if(!isEventTimeVaild(alarmInfo.EventTime))
                     {
                         SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,nowTime: {}, EventTime:{}",strKey,
-                                m_nowTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString(), alarmInfo.EventTime);
+                                m_nowTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString(), alarmInfo.EventTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString());
                         continue;
                     }
                     m_pListAlarm->addAlarmInfo(alarmInfo);
@@ -539,10 +539,10 @@ void FuncRegionalPersonCount::handleRoomMaxNum(const RoomPeopleInfo& peopleInfo)
             alarmInfo.appFunction = m_funcThreadInfo.appFunction;
             alarmInfo.RoomID = peopleInfo.RoomID;
             alarmInfo.DeviceID = roomInfo.mapCameraAction.begin()->first;
-            alarmInfo.PicUrl = peopleInfo.imagePath;
+            alarmInfo.ImageInfo = peopleInfo.imagePath;
             alarmInfo.ActionID = roomInfo.mapCameraAction.begin()->second.front();
-            alarmInfo.StartTime = m_nowTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
-            alarmInfo.EventTime = m_nowTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
+            alarmInfo.StartTime = m_nowTime;
+            alarmInfo.EventTime = m_nowTime;
             alarmInfo.Is_Alarm = true;
             alarmInfo.ActionDes = fmt::format("{}人数为{},已超过最大人数{}限制", 
                                                 roomName, peopleInfo.MaxNum, maxNum);
@@ -701,9 +701,9 @@ void FuncRegionalPersonCount::handleRoomMinNum(const RoomPeopleInfo& peopleInfo)
                     alarmInfo.appFunction = m_funcThreadInfo.appFunction;
                     alarmInfo.RoomID = peopleInfo.RoomID;
                     alarmInfo.DeviceID = roomInfo.mapCameraAction.begin()->first;
-                    alarmInfo.PicUrl = peopleInfo.imagePath;
+                    alarmInfo.ImageInfo = peopleInfo.imagePath;
                     alarmInfo.ActionID = roomInfo.mapCameraAction.begin()->second.front();
-                    alarmInfo.EventTime = m_nowTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
+                    alarmInfo.EventTime = m_nowTime;
                     alarmInfo.Is_Alarm = true;
                     alarmInfo.ActionDes = fmt::format("{}人数为{},已低于最小人数{}限制", 
                                                         roomName, peopleInfo.MaxNum, minNum);

+ 5 - 0
SecurePlayAuxServer/GlobalInfo/GlobalConfig.h

@@ -5,6 +5,8 @@
 #include <QReadWriteLock>
 #include <map>
 
+#include <QDateTime>
+
 #define GVariable GlobalVariable::getInstance()
 
 /**
@@ -74,6 +76,9 @@ public:
 
     /* 通过不带后缀的算法ID获取完整的算法ID,后缀通过“-”连接 */
     // std::string getFullActionID(const std::string& actionID);
+
+    /* 设置一个空时间,设置这个时间,在数据库里都是空 */
+    const QDateTime nullTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
     
 
 private:

+ 332 - 299
SecurePlayAuxServer/GlobalInfo/GlobalFuncThread.cpp

@@ -11,8 +11,8 @@ FuncThreadInfo::FuncThreadInfo()
     appFunction = AppFunction::APP_NONE;
     RunState = RunTimeState::RUN_STATE_NONE;
     strFunctionName = "";
-    StartTime = QDateTime::currentDateTime();
-    EndTime = QDateTime::currentDateTime();
+    // StartTime = QDateTime::currentDateTime();
+    // EndTime = QDateTime::currentDateTime();
     listRoomCamActInfo.clear();
     mapCameraName.clear();
 }
@@ -32,8 +32,8 @@ FuncThreadInfo& FuncThreadInfo::operator=(FuncThreadInfo& other)
         appFunction = other.appFunction;
         RunState = other.RunState;
         strFunctionName = other.strFunctionName;
-        StartTime = other.StartTime;
-        EndTime = other.EndTime;
+        // StartTime = other.StartTime;
+        // EndTime = other.EndTime;
         listRoomCamActInfo = other.listRoomCamActInfo;
         mapCameraName = other.mapCameraName;
     }
@@ -88,6 +88,21 @@ void FuncThreadInfo::clearActionList()
     listRoomCamActInfo.clear();
 }
 
+/* 根据房间ID查找房间信息 */
+RoomCamActInfo FuncThreadInfo::findRoomInfo(const int RoomID)
+{
+    for(auto& roomInfo : listRoomCamActInfo)
+    {
+        if(roomInfo.RoomID == RoomID)
+        {
+            return roomInfo;
+        }
+    }
+    RoomCamActInfo roomCamActInfo;
+    roomCamActInfo.RoomID = -1;
+    return roomCamActInfo;
+}
+
 /* 获取摄像机名称 */
 std::string FuncThreadInfo::getCameraName(int CameraID)
 {
@@ -107,183 +122,183 @@ std::string FuncThreadInfo::getCameraName(int CameraID)
  * @return true 
  * @return false 
  */
-bool ListFuncActInfo::addFuncThreadInfo(const AppAndTimeInfo& func)
-{
-    if(func.AppType == 0)
-    {
-        return false;
-    }
-    /* 解出这条信息里包含几个App,AppType按位计算,总共8个应用信息 */
-    for(int i = 0; i < 8; ++i)
-    {
-        if(func.AppType & 0x01)
-        {
-            /* 查找有没有这个应用 */
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_OnWork);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_OnWork;
-            fa->strFunctionName = "人员在岗识别";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if(func.AppType & 0x02)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Contraband);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_Contraband;
-            fa->strFunctionName = "违禁品识别";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if (func.AppType & 0x04)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Illegal);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_Illegal;
-            fa->strFunctionName = "非法入侵检测";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if (func.AppType & 0x08)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Fatigue);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_Fatigue;
-            fa->strFunctionName = "疲劳检测";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if (func.AppType & 0x10)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Regional);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_Regional;
-            fa->strFunctionName = "区域人员检测";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if (func.AppType & 0x20)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Mouse);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_Mouse;
-            fa->strFunctionName = "老鼠识别";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if (func.AppType & 0x40)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_PlayPhone);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_PlayPhone;
-            fa->strFunctionName = "玩手机识别";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if (func.AppType & 0x80)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_NoMask);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_NoMask;
-            fa->strFunctionName = "未戴口罩识别";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-        else if (func.AppType & 0x0100)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_AllDown);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                pFuncThreadInfo->StartTime = func.StartTime;
-                pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            FuncThreadInfo* fa = new FuncThreadInfo;
-            fa->ChannelID = func.ChannelID;
-            fa->appFunction = AppFunction::APP_AllDown;
-            fa->strFunctionName = "摔倒识别";
-            fa->StartTime = func.StartTime;
-            fa->EndTime = func.EndTime;
-            listFuncThreadInfo.push_back(fa);
-        }
-    }
-
-
-    return true;
-}
+// bool ListFuncActInfo::addFuncThreadInfo(const AppAndTimeInfo& func)
+// {
+//     if(func.AppType == 0)
+//     {
+//         return false;
+//     }
+//     /* 解出这条信息里包含几个App,AppType按位计算,总共8个应用信息 */
+//     for(int i = 0; i < 8; ++i)
+//     {
+//         if(func.AppType & 0x01)
+//         {
+//             /* 查找有没有这个应用 */
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_OnWork);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_OnWork;
+//             fa->strFunctionName = "人员在岗识别";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if(func.AppType & 0x02)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Contraband);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_Contraband;
+//             fa->strFunctionName = "违禁品识别";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if (func.AppType & 0x04)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Illegal);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_Illegal;
+//             fa->strFunctionName = "非法入侵检测";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if (func.AppType & 0x08)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Fatigue);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_Fatigue;
+//             fa->strFunctionName = "疲劳检测";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if (func.AppType & 0x10)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Regional);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_Regional;
+//             fa->strFunctionName = "区域人员检测";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if (func.AppType & 0x20)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Mouse);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_Mouse;
+//             fa->strFunctionName = "老鼠识别";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if (func.AppType & 0x40)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_PlayPhone);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_PlayPhone;
+//             fa->strFunctionName = "玩手机识别";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if (func.AppType & 0x80)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_NoMask);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_NoMask;
+//             fa->strFunctionName = "未戴口罩识别";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//         else if (func.AppType & 0x0100)
+//         {
+//             auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_AllDown);
+//             if(pFuncThreadInfo != nullptr)
+//             {
+//                 /* 更新时间信息 */
+//                 pFuncThreadInfo->StartTime = func.StartTime;
+//                 pFuncThreadInfo->EndTime = func.EndTime;
+//                 continue;
+//             }
+//             FuncThreadInfo* fa = new FuncThreadInfo;
+//             fa->ChannelID = func.ChannelID;
+//             fa->appFunction = AppFunction::APP_AllDown;
+//             fa->strFunctionName = "摔倒识别";
+//             fa->StartTime = func.StartTime;
+//             fa->EndTime = func.EndTime;
+//             listFuncThreadInfo.push_back(fa);
+//         }
+//     }
+
+
+//     return true;
+// }
 
 
 
@@ -510,132 +525,145 @@ void GlobalThreadInfo::unlockRunFAI()
  * @return true 
  * @return false 
  */
-bool GlobalThreadInfo::addFuncThreadInfo(const AppAndTimeInfo& func)
+bool GlobalThreadInfo::addFuncThreadInfo(const ChannelAppInfo& func)
 {
     if(func.AppType == 0)
     {
         return false;
     }
+    /* 转换成应用内使用的枚举值 */
+    AppFunction appFunc = getAppFunctionID(func.AppType);
+
     /* 解出这条信息里包含几个App,AppType按位计算,总共8个应用信息 */
-    for(int i = 0; i < 8; ++i)
-    {
-        FuncThreadInfo* fa = new FuncThreadInfo;
-        fa->ChannelID = func.ChannelID;
-        fa->StartTime = func.StartTime;
-        fa->EndTime = func.EndTime;
-        fa->RunState = RunTimeState::RUN_STATE_INIT;
-        
-        AppFunction appFunc = getAppFunctionID(func.AppType);
-        if(AppFunction::APP_OnWork == appFunc)
-        {
-            /* 查找有没有这个应用 */
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_OnWork);
-            if(pFuncThreadInfo != nullptr)
-            {
-                /* 更新时间信息 */
-                // pFuncThreadInfo->StartTime = func.StartTime;
-                // pFuncThreadInfo->EndTime = func.EndTime;
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "人员在岗识别";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if(AppFunction::APP_Contraband == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Contraband);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "违禁品识别";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if (AppFunction::APP_Illegal == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Illegal);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "非法入侵检测";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if (AppFunction::APP_Fatigue == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Fatigue);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "疲劳检测";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if (AppFunction::APP_Regional == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Regional);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "区域人员检测";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if (AppFunction::APP_Mouse == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Mouse);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "老鼠识别";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if (AppFunction::APP_PlayPhone == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_PlayPhone);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "玩手机识别";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if (AppFunction::APP_NoMask == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_NoMask);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "未戴口罩识别";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else if (AppFunction::APP_AllDown == appFunc)
-        {
-            auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_AllDown);
-            if(pFuncThreadInfo != nullptr)
-            {
-                continue;
-            }
-            fa->appFunction = appFunc;
-            fa->strFunctionName = "摔倒识别";
-            m_listFuncThreadInfo.push_back(fa);
-        }
-        else {
-            SPDLOG_WARN("未知的算法ID: {}", func.AppType);
-            delete fa;
-            return false;
-        }
+    FuncThreadInfo* fa = new FuncThreadInfo;
+    fa->ChannelID = func.ChannelID;
+    fa->appFunction = appFunc;
+    fa->strChannelName = func.strChannelName;
+    fa->strFunctionName = func.strAppName;
+    fa->RunState = RunTimeState::RUN_STATE_NONE;
+    
+    
+    // bool bFind = false;
+
+    auto pFuncThreadInfo = findAppFunction(func.ChannelID, appFunc);
+    if(pFuncThreadInfo == nullptr)
+    {
+        m_listFuncThreadInfo.push_back(fa);
+    } else 
+    {
+        /* 删除fa */
+        delete fa;
+        fa = nullptr;
     }
 
+    
+    // if(AppFunction::APP_OnWork == appFunc)
+    // {
+    //     /* 查找有没有这个应用 */
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_OnWork);
+    //     if(pFuncThreadInfo == nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "人员在岗识别";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if(AppFunction::APP_Contraband == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Contraband);
+    //     if(pFuncThreadInfo == nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "违禁品识别";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if (AppFunction::APP_Illegal == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Illegal);
+    //     if(pFuncThreadInfo == nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "非法入侵检测";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if (AppFunction::APP_Fatigue == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Fatigue);
+    //     if(pFuncThreadInfo != nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "疲劳检测";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if (AppFunction::APP_Regional == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Regional);
+    //     if(pFuncThreadInfo != nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "区域人员检测";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if (AppFunction::APP_Mouse == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_Mouse);
+    //     if(pFuncThreadInfo != nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "老鼠识别";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if (AppFunction::APP_PlayPhone == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_PlayPhone);
+    //     if(pFuncThreadInfo != nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "玩手机识别";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if (AppFunction::APP_NoMask == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_NoMask);
+    //     if(pFuncThreadInfo != nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "未戴口罩识别";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    // else if (AppFunction::APP_AllDown == appFunc)
+    // {
+    //     auto pFuncThreadInfo = findAppFunction(func.ChannelID, AppFunction::APP_AllDown);
+    //     if(pFuncThreadInfo != nullptr)
+    //     {
+    //         fa->appFunction = appFunc;
+    //         fa->strFunctionName = "摔倒识别";
+    //         m_listFuncThreadInfo.push_back(fa);
+    //         bFind = true;
+    //     }
+    // }
+    
+    // if(!bFind)
+    // {
+    //     delete fa;
+    //     fa = nullptr;
+    // }
+
 
     return true;
 }
@@ -820,6 +848,11 @@ void GlobalThreadInfo::setAppFunction(const ActionInfo& info, const AppFunction
     if(pFuncThreadInfo != nullptr)
     {
         pFuncThreadInfo->addActionInfo(info);
+        if(pFuncThreadInfo->RunState == RunTimeState::RUN_STATE_NONE)
+        {
+            /* 线程状态是RUN_STATE_NONE,说明是新创建的,设置成RUN_STATE_INIT,等会会创建线程 */
+            pFuncThreadInfo->RunState = RunTimeState::RUN_STATE_INIT;
+        }
     }
 }
 

+ 5 - 3
SecurePlayAuxServer/GlobalInfo/GlobalFuncThread.h

@@ -30,6 +30,8 @@
     bool addActionInfo(const ActionInfo& info);
     /* 清空算法信息 */
     void clearActionList();
+    /* 根据房间ID查找房间信息 */
+    RoomCamActInfo findRoomInfo(const int RoomID);
 
     /* 获取摄像机名称 */
     std::string getCameraName(int CameraID);
@@ -44,8 +46,8 @@
  {
     ListFuncActInfo() = default;
 
-    /* 添加功能信息 */
-    bool addFuncThreadInfo(const AppAndTimeInfo& func);
+    // /* 添加功能信息 */
+    // bool addFuncThreadInfo(const AppAndTimeInfo& func);
     /* 添加算法信息 */
     bool addActionInfo(const ActionInfo& info);
     /* 清空无用的功能信息 */
@@ -97,7 +99,7 @@ public:
     /* 手动解锁 */
     void unlockRunFAI();
     /* 添加功能信息 */
-    bool addFuncThreadInfo(const AppAndTimeInfo& func);
+    bool addFuncThreadInfo(const ChannelAppInfo& func);
     /* 添加算法信息 */
     bool addActionInfo(const ActionInfo& info);
     /* 清空无用的功能信息 */

+ 52 - 10
SecurePlayAuxServer/GlobalInfo/GlobalVariable.cpp

@@ -111,10 +111,10 @@ AlarmInfo::AlarmInfo()
     ChannelID = 0;
     State = 0;
     OnWork = 0;
-    StartTime = "";
-    EndTime = "";
-    EventTime = "";
-    PicUrl = "";
+    StartTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    EndTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    EventTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    // PicUrl = "";
     ImageInfo = "";
     // AppID = "";
     ActionID = "";
@@ -141,7 +141,7 @@ AlarmInfo::AlarmInfo(const AlarmInfo& other)
     StartTime = other.StartTime;
     EndTime = other.EndTime;
     EventTime = other.EventTime;
-    PicUrl = other.PicUrl;
+    // PicUrl = other.PicUrl;
     ImageInfo = other.ImageInfo;
     // AppID = other.AppID;
     ActionID = other.ActionID;
@@ -169,7 +169,7 @@ AlarmInfo& AlarmInfo::operator=(AlarmInfo& other)
         StartTime = other.StartTime;
         EndTime = other.EndTime;
         EventTime = other.EventTime;
-        PicUrl = other.PicUrl;
+        // PicUrl = other.PicUrl;
         ImageInfo = other.ImageInfo;
         // AppID = other.AppID;
         ActionID = other.ActionID;
@@ -195,10 +195,10 @@ void AlarmInfo::reInit()
     ChannelID = 0;
     State = 0;
     OnWork = 0;
-    StartTime = "";
-    EndTime = "";
-    EventTime = "";
-    PicUrl = "";
+    StartTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    EndTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    EventTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    // PicUrl = "";
     ImageInfo = "";
     // AppID = "";
     ActionID = "";
@@ -713,3 +713,45 @@ RoomActionInfo* ListRoomActionInfo::findActionIDInList(const int chnID, const in
     return nullptr;
 }
 
+
+RoomCamActInfo::RoomCamActInfo()
+{
+    RoomID = -1;
+    RoomType = Enum_RoomType::ROOM_NONE;
+    strRoomName = "";
+    mapCameraAction.clear();
+}
+
+RoomCamActInfo::RoomCamActInfo(const RoomCamActInfo& other) \
+{
+    if (this != &other) {
+        RoomID = other.RoomID;
+        RoomType = other.RoomType;
+        strRoomName = other.strRoomName;
+        mapCameraAction = other.mapCameraAction;
+    }
+}
+
+RoomCamActInfo& RoomCamActInfo::operator=(const RoomCamActInfo& other) 
+{
+    if (this != &other) {
+        RoomID = other.RoomID;
+        RoomType = other.RoomType;
+        strRoomName = other.strRoomName;
+        mapCameraAction = other.mapCameraAction;
+    }
+    return *this;
+}
+/* 添加摄像机算法 */
+void RoomCamActInfo::addCameraAction(int CameraID, const std::string& ActionID) 
+{
+    auto it = mapCameraAction.find(CameraID);
+    if(it == mapCameraAction.end()) {
+        std::list<std::string> list;
+        list.push_back(ActionID);
+        mapCameraAction.insert(std::make_pair(CameraID, list));
+    }else {
+        it->second.push_back(ActionID);
+    }
+}
+

+ 21 - 25
SecurePlayAuxServer/GlobalInfo/GlobalVariable.h

@@ -267,12 +267,14 @@ struct AlarmInfo
     int OnWork;                 /* 是否在工作 */
     AppFunction appFunction;    /* 应用功能 */
     std::string ActionID;       /* 算法ID */
-    std::string StartTime;      /* 报警开始时间 */
-    std::string EndTime;        /* 报警结束时间 */
-    std::string EventTime;      /* 事件时间(报警发生时间,在数据库里对应的是CreateTime) */
-    std::string PicUrl;         /* 报警图片URL */
+    QDateTime StartTime;        /* 报警开始时间 */
+    QDateTime EndTime;          /* 报警结束时间 */
+    QDateTime EventTime;        /* 事件时间(报警发生时间,在数据库里对应的是CreateTime) */
+    // std::string StartTime;      /* 报警开始时间 */
+    // std::string EndTime;        /* 报警结束时间 */
+    // std::string EventTime;      /* 事件时间(报警发生时间,在数据库里对应的是CreateTime) */
+    // std::string PicUrl;         /* 报警图片URL */
     std::string ImageInfo;      /* 图片信息 */
-    // std::string AppID;          /* 客户端应用ID */
     std::string ActionDes;      /* 算法描述信息 */
     std::string FaceIDList;     /* 人脸ID列表 */
     std::string FaceNameList;   /* 人脸名称列表 */
@@ -538,39 +540,33 @@ public:
     std::string strRoomName;            /* 房间名称 */
     std::map<int, std::list<std::string>> mapCameraAction;    /* 摄像机ID和算法ID关联信息,一个摄像机可以有多个算法列表 */
 
+    RoomCamActInfo();
+    RoomCamActInfo(const RoomCamActInfo& other);
+    RoomCamActInfo& operator=(const RoomCamActInfo& other);
     /* 添加摄像机算法 */
-    void addCameraAction(int CameraID, const std::string& ActionID) 
-    {
-        auto it = mapCameraAction.find(CameraID);
-        if(it == mapCameraAction.end()) {
-            std::list<std::string> list;
-            list.push_back(ActionID);
-            mapCameraAction.insert(std::make_pair(CameraID, list));
-        }else {
-            it->second.push_back(ActionID);
-        }
-    }
+    void addCameraAction(int CameraID, const std::string& ActionID);
+    
  };
 
 
 /**
- * @brief 读取到的应用信息和启用时段
+ * @brief 通道和应用信息
  * 
  */
- struct AppAndTimeInfo
+ struct ChannelAppInfo
  {
-    uint8_t AppType;                /* 应用信息,按位计算 */
+    uint32_t AppType;               /* 应用信息,按位计算 */
     int ChannelID;                  /* 通道ID */
-    QDateTime StartTime;    /* 开始时间 */
-    QDateTime EndTime;      /* 结束时间 */
+    std::string strChannelName;     /* 通道名称 */
+    std::string strAppName;         /* 应用名称 */
 
-    AppAndTimeInfo() = default;
-    AppAndTimeInfo& operator=(AppAndTimeInfo& other) {
+    ChannelAppInfo() = default;
+    ChannelAppInfo& operator=(ChannelAppInfo& other) {
         if (this != &other) {
             AppType = other.AppType;
             ChannelID = other.ChannelID;
-            StartTime = other.StartTime;
-            EndTime = other.EndTime;
+            strChannelName = other.strChannelName;
+            strAppName = other.strAppName;
         }
         return *this;
     }

+ 50 - 26
SecurePlayAuxServer/GlobalInfo/UniversalFunc.cpp

@@ -16,22 +16,25 @@ void parseRedisBaseData(const std::string& strData, AlarmInfo& alarmInfo)
     {
         nJson json0;
         json0 = nJson::parse(strData);
-        SPDLOG_DEBUG("解析Redis数据: \n{}", json0.dump(4));
+        // SPDLOG_DEBUG("解析Redis数据: \n{}", json0.dump(4));
 
         alarmInfo.AlarmID = json0["alarmId"].get<int>();
         alarmInfo.ActionID = json0["actionId"].get<std::string>();
         alarmInfo.ActionDes = json0["actionDes"].is_null() ? "" : json0["actionDes"].get<std::string>();
-        alarmInfo.PicUrl = json0["picUrl"].is_null() ? "" : json0["picUrl"].get<std::string>();
+        // alarmInfo.ImageInfo = json0["picUrl"].is_null() ? "" : json0["picUrl"].get<std::string>();
         alarmInfo.ImageInfo = json0["imageInfo"].is_null() ? "" : json0["imageInfo"].get<std::string>();
         
         /* 解析时间,需要将时间中的“T”换成空格 */
-        alarmInfo.StartTime = json0["beginTime"].get<std::string>();
-        std::replace(alarmInfo.StartTime.begin(), alarmInfo.StartTime.end(), 'T', ' ');
-        alarmInfo.EndTime = json0["endTime"].get<std::string>();
-        std::replace(alarmInfo.EndTime.begin(), alarmInfo.EndTime.end(), 'T', ' ');
-        alarmInfo.EventTime = json0["eventTime"].get<std::string>();
-        std::replace(alarmInfo.EventTime.begin(), alarmInfo.EventTime.end(), 'T', ' ');
-        
+        std::string startTime = json0["beginTime"].get<std::string>();
+        std::replace(startTime.begin(), startTime.end(), 'T', ' ');
+        std::string endTime = json0["endTime"].get<std::string>();
+        std::replace(endTime.begin(), endTime.end(), 'T', ' ');
+        std::string eventTime = json0["eventTime"].get<std::string>();
+        std::replace(eventTime.begin(), eventTime.end(), 'T', ' ');
+        alarmInfo.StartTime = strToDateTime(startTime);
+        alarmInfo.EndTime = strToDateTime(endTime);
+        alarmInfo.EventTime = strToDateTime(eventTime);
+
     }
     catch (const nJson::parse_error& e)
     {
@@ -79,10 +82,25 @@ void parseRedisBBoxesData(const std::string& strData, AlarmInfo& alarmInfo)
                 }
                 /* 这一条Box数据报警了将其内容存储起来 */
                 alarmInfo.Is_Alarm = true;
+                /* 解析bbox,在图像中方框的未知 */
+                nJson bbox = it0["bbox"];
+                std::string strBbox;
+                for(auto& it1 : bbox)
+                {
+                    strBbox += std::to_string(it1.get<int>()) + ",";
+                }
+                /* 去掉最后一个“,” */
+                if(!strBbox.empty())
+                {
+                    strBbox.pop_back();
+                }
+                listBbox.push_back(strBbox);
+
                 /* 解析label,违禁品关键字,先判断这个是不是违禁品检测的算法ID */
                 if(alarmInfo.ActionID == GVariable.ActContraband)
                 {
-                    /* 解析报警,取出报警类型 */
+                    /* 解析报警,取出报警类型,label是报警说明,如“玩手机的人”
+                     * 这里主要用于读取违禁品名称 */
                     nJson label = it0["label"];
                     for(auto& it1 : label)
                     {
@@ -96,26 +114,14 @@ void parseRedisBBoxesData(const std::string& strData, AlarmInfo& alarmInfo)
                         labelList += strLabel;
                     }
                 }
-                /* 解析bbox,貌似是在图像中的位置 */
-                nJson bbox = it0["bbox"];
-                std::string strBbox;
-                for(auto& it1 : bbox)
-                {
-                    strBbox += std::to_string(it1.get<int>()) + ",";
-                }
-                /* 去掉最后一个“,” */
-                if(!strBbox.empty())
-                {
-                    strBbox.pop_back();
-                }
-                listBbox.push_back(strBbox);
+                
             }
             /* 去掉最后一个“|” */
             if(!labelList.empty())
             {
                 labelList.pop_back();
             }
-            SPDLOG_DEBUG("违禁品列表:{}", labelList);
+            // SPDLOG_DEBUG("label列表:{}", labelList);
             
         }
         /* 如果有报警的Box,解析出报警的说明 */
@@ -127,7 +133,7 @@ void parseRedisBBoxesData(const std::string& strData, AlarmInfo& alarmInfo)
             if( (alarmInfo.ActionID == GVariable.ActContraband) && !labelList.empty() )
             {
                 alarmInfo.ActionDes = fmt::format("出现违禁品[{}]告警", labelList);
-                SPDLOG_INFO("{}", alarmInfo.ActionDes);
+                SPDLOG_DEBUG("{}", alarmInfo.ActionDes);
             }else {
                 /* 其他报警信息,直接获取 */
                 alarmInfo.ActionDes = json0["actionDes"].get<std::string>();
@@ -260,6 +266,24 @@ bool parseOtherDataPersonCount(const std::string& strData, AlarmInfo& alarmInfo)
 }
 
 
+/* 将字符串转换成QDateTime */
+QDateTime strToDateTime(const std::string& strTime)
+{
+    /* 将字符串转换成QDateTime,带有小数点 */
+    QDateTime eventTime = QDateTime::fromString(QString::fromStdString(strTime), "yyyy-MM-dd hh:mm:ss.zzz");
+    if(eventTime.isNull())
+    {
+        /* 尝试不带小数点的格式 */
+        eventTime = QDateTime::fromString(QString::fromStdString(strTime), "yyyy-MM-dd hh:mm:ss");
+        if(eventTime.isNull())
+        {
+            SPDLOG_WARN("时间格式错误:{}", strTime);
+            return QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+        }
+    }
+    return eventTime;
+}
+
 /**
  * @brief 判断时间是否长时间没有更新,默认的是600秒,超过这个时间Redis还未更新,可能是超脑挂了
  * 
@@ -331,7 +355,7 @@ std::chrono::system_clock::time_point strTimeToChrono(const std::string& strTime
 {
     std::istringstream iss(strTime);
     std::tm tmEvent = {};
-    iss >> std::get_time(&tmEvent, "%Y-%m-%d %H:%M:%S");
+    iss >> std::get_time(&tmEvent, "%Y-%m-%d %H:%M:%S.zzz");
 
     return std::chrono::system_clock::from_time_t(std::mktime(&tmEvent));
 }

+ 2 - 0
SecurePlayAuxServer/GlobalInfo/UniversalFunc.h

@@ -16,6 +16,8 @@ void parseRedisBBoxesData(const std::string& strData, AlarmInfo& alarmInfo);
 /* 解析Redis的其他数据,人员计数版,主要是BBoxes和PersonList */
 bool parseOtherDataPersonCount(const std::string& strData, AlarmInfo& alarmInfo);
 
+/* 将字符串转换成QDateTime */
+QDateTime strToDateTime(const std::string& strTime);
 
 /* 判断时间是否长时间没有更新 */
 bool isEventTimeVaild(const std::string& strTime);

+ 9 - 7
SecurePlayAuxServer/SPAServer.cpp

@@ -457,7 +457,7 @@ void SPAServer::threadDistribution()
     /* 房间相机关联信息 */
     std::list<RoomCameraInfo> listRC;
     /* 存储获取到的应用和启用时间的信息 */
-    std::list<AppAndTimeInfo> listAppAndTime;
+    std::list<ChannelAppInfo> listAppAndTime;
 
     /* 初始化WebAPI */
     std::shared_ptr<FromWebAPI> pFromWebAPI = std::make_shared<FromWebAPI>();
@@ -495,11 +495,11 @@ void SPAServer::threadDistribution()
 
         
         /* 设置应用对应的频率信息 */
-        for(auto& func : GThreadInfo.getList())
-        {
-            /* 设置频率名称 */
-            func->strChannelName = GConfig.getChannelName(func->ChannelID);
-        }
+        // for(auto& func : GThreadInfo.getList())
+        // {
+        //     /* 设置频率名称 */
+        //     func->strChannelName = GConfig.getChannelName(func->ChannelID);
+        // }
         
         /* 设置对应的摄像机名称列表 */
         GThreadInfo.setCameraInfo(GConfig.getCameraInfoMap());
@@ -507,7 +507,9 @@ void SPAServer::threadDistribution()
         /* 先获取EQM数据库信息,取出房间和摄像机关联信息,包括所在的频率 */
         m_mutexActionInfo.lock();
         pFromWebAPI->getActionInfo(m_listActionInfo);
-        /* 将算法信息加入到不同的功能列表中,先清空功能对应的算法设备列表 */
+        /* 将算法信息加入到不同的功能列表中,先清空功能对应的算法设备列表
+         * 算法信息带有摄像机和房间信息,在从数据库读取的时候就读取出来了
+         * 如果是新创建的应用,有房间信息就将状态由NONE转换成INIT */
         GThreadInfo.clearActionList();
         for(const auto& it : m_listActionInfo.getData())
         {

+ 53 - 49
SecurePlayAuxServer/communication/FromWebAPI.cpp

@@ -43,7 +43,7 @@ bool FromWebAPI::initWebApi(const QString& url,const QString& serID, const QStri
         return false;
     }
 
-    m_httpApi->DBInit(url.toStdString().c_str());
+    m_httpApi->DBInit(url.toStdString().c_str(), true);
     // if(ret != 0)
     // {
     //     SPDLOG_LOGGER_ERROR(m_logger,"Init WebApi failed:{}, error Info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -52,7 +52,7 @@ bool FromWebAPI::initWebApi(const QString& url,const QString& serID, const QStri
     // SPDLOG_LOGGER_TRACE(m_logger,"初始化WebApi成功!");
     /* 获取服务器列表 */
     char serverList[8192];
-    ret = m_httpApi->DBGetServerList(serverList, 8192);
+    ret = m_httpApi->DBGetServerList(serverList, 8192, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"Get server list failed:{}, error info:{}",ret, m_httpApi->DoGetLastError(&ret).toStdString());
@@ -61,7 +61,7 @@ bool FromWebAPI::initWebApi(const QString& url,const QString& serID, const QStri
     // SPDLOG_LOGGER_TRACE(m_logger,"Server list:{}", serverList);
     SPDLOG_LOGGER_DEBUG(m_logger,"WebAPI Load Sucess!");
     /* 登录,第二个参数是限制的服务 */
-    ret = m_httpApi->DBLogin(serverIP, serID, appType, m_userToken);
+    ret = m_httpApi->DBLogin(serverIP, serID, appType, m_userToken, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_ERROR(m_logger,"Login failed:{}, error info:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -123,7 +123,7 @@ bool FromWebAPI::writeAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo)
         }
         QString retStr;
         QString strCmd = QString::fromStdString(json0.dump());
-        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, retStr);
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, retStr, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"写入tAction失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -172,7 +172,7 @@ bool FromWebAPI::deleteAlgorithmInfo(std::vector<AlgorithmInfo>& vecDeleteInfo)
         }
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"删除tAction失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -211,7 +211,7 @@ bool FromWebAPI::getAlgorithmInfo(std::vector<AlgorithmInfo>& vecInfo)
     json0["opName"] = "SPSS_SelectFromAction";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取tAction失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -295,7 +295,7 @@ bool FromWebAPI::insertDeviceInfo(std::vector<DeviceInfo>& vecInfo)
         }
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"插入设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -323,7 +323,7 @@ bool FromWebAPI::insertDeviceInfo(std::vector<DeviceInfo>& vecInfo)
         // strRet.clear();
         // ret = 0;
         // strCmd = QString::fromStdString(json0.dump());
-        // ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
+        // ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet, true);
         // if(ret != 0)
         // {
         //     SPDLOG_LOGGER_DEBUG(m_logger,"插入设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -388,7 +388,7 @@ bool FromWebAPI::updateDeviceInfo(std::vector<DeviceInfo>& vecUpdateInfo)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"更新设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -445,7 +445,7 @@ bool FromWebAPI::deleteDeviceInfo(std::vector<DeviceInfo>& vecDeleteInfo)
         }
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"删除tCamerinfo设备信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -483,7 +483,7 @@ bool FromWebAPI::getDeviceInfo(std::vector<DeviceInfo>& vecInfo)
     json0["opName"] = "SPSS_SelectFromCamerInfo";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取CamerInfo失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -551,7 +551,7 @@ bool FromWebAPI::getChannelInfo(std::map<int, std::string>& mapChannelName)
     json0["opName"] = "SPSS_SelectChannelInfo";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取通道信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -606,7 +606,7 @@ std::string FromWebAPI::getChannelInfo(int chnID)
     json0["opName"] = "SPSS_SelectChannelInfo";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取通道信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -665,7 +665,7 @@ bool FromWebAPI::getCameraInfo(std::map<int, std::string>& mapCameraName)
     json0["opName"] = "SPSS_SelectCameraInfo";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取通道信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -738,7 +738,7 @@ bool FromWebAPI::insertDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo)
         }
         QString strRet;
         QString strCmd = QString::fromStdString(json0.dump());
-        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"插入设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -797,7 +797,7 @@ bool FromWebAPI::updateDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo)
         }
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"插入设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -850,7 +850,7 @@ bool FromWebAPI::deleteDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"删除设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -904,7 +904,7 @@ bool FromWebAPI::deleteDeviceAlgorithmInfo(std::list<int>& vecID)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_ERROR(m_logger,"删除设备信息到tActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -949,7 +949,7 @@ bool FromWebAPI::getDeviceAlgorithmInfo(std::vector<DeviceInfo>& vecInfo, std::l
     json0["opName"] = "SPSS_SelectFromActionCamer";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取ActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1047,7 +1047,7 @@ bool FromWebAPI::getActionInfo(ListActionInfo& listInfo)
     json0["opName"] = "SPSS_SelectFromActionInfo";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取ActionCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1113,7 +1113,7 @@ bool FromWebAPI::getRoomCameraInfo(std::list<RoomCameraInfo>& vecInfo)
     json0["opName"] = "SPSS_SelectRoomCamer";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取RoomCamer失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1200,7 +1200,7 @@ bool FromWebAPI::getFuncDetectTime(int ChannelID, AppFunction app, DetectPeriodI
         json0["paramList"] = json1;
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"获取Period信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1276,7 +1276,7 @@ bool FromWebAPI::insertAlarmInfo(const AlarmInfo& alarmInfo, int& PKID)
         return false;
     }
     /* 判断是否有图片,没有图片就取消报警 */
-    if(alarmInfo.PicUrl.empty())
+    if(alarmInfo.ImageInfo.empty())
     {
         SPDLOG_LOGGER_WARN(m_logger, "× 取消新增报警信息,因为没有图片,频道[{}],房间[{}],摄像头[{}],{},{},有{}个区域,有{}个人脸",
                             alarmInfo.ChannelID, alarmInfo.RoomID, alarmInfo.DeviceID, alarmInfo.ActionDes, alarmInfo.ImageInfo, alarmInfo.listBbox.size(), alarmInfo.listPersonInfo.size());
@@ -1299,11 +1299,17 @@ bool FromWebAPI::insertAlarmInfo(const AlarmInfo& alarmInfo, int& PKID)
         json0["opName"] = "SPSS_InsertToAlarm";
         nJson json1;
         json1["alarmID"] = alarmInfo.AlarmID;
-        json1["startTime"] = alarmInfo.StartTime.empty() ? "" : alarmInfo.StartTime;
-        json1["createTime"] = alarmInfo.EventTime.empty() ? "" : alarmInfo.EventTime;
-        json1["endTime"] = alarmInfo.EndTime;
+        json1["startTime"] = alarmInfo.StartTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
+        json1["createTime"] = alarmInfo.EventTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
+        std::string strEndTime = "";
+        /* 这里判断一下结束时间是否需要设置,如果不需要,则设置成小于2020年即可,写入数据库就是空 */
+        if(alarmInfo.EndTime > QDateTime::fromString("2020-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss"))
+        {
+            strEndTime = alarmInfo.EndTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
+        }
+        json1["endTime"] = strEndTime;
         json1["bbox"] = strBbox;
-        json1["picUrl"] = alarmInfo.PicUrl;
+        json1["picUrl"] = alarmInfo.ImageInfo;
         json1["appID"] = getAppFunctionID(alarmInfo.appFunction);
         json1["actionID"] = alarmInfo.ActionID;
         json1["actionDes"] = alarmInfo.ActionDes;
@@ -1319,7 +1325,7 @@ bool FromWebAPI::insertAlarmInfo(const AlarmInfo& alarmInfo, int& PKID)
         // SPDLOG_LOGGER_DEBUG(m_logger, "写入报警信息的字符串:{}\n", json0.dump(4));
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"插入报警信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1370,11 +1376,11 @@ void FromWebAPI::printAlarmInfo(const AlarmInfo& alarmInfo, std::string strBBox)
     std::string strLog;
     strLog += "写入报警信息:\n";
     strLog += fmt::format("alarmID: {}\n", alarmInfo.AlarmID);
-    strLog += fmt::format("startTime: {}\n", alarmInfo.StartTime);
-    strLog += fmt::format("createTime: {}\n", alarmInfo.EventTime);
-    strLog += fmt::format("endTime: {}\n", alarmInfo.EndTime);
+    strLog += fmt::format("startTime: {}\n", alarmInfo.StartTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString());
+    strLog += fmt::format("createTime: {}\n", alarmInfo.EventTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString());
+    strLog += fmt::format("endTime: {}\n", alarmInfo.EndTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString());
     strLog += fmt::format("bbox: {}\n", strBBox);
-    strLog += fmt::format("picUrl: {}\n", alarmInfo.PicUrl);
+    strLog += fmt::format("picUrl: {}\n", alarmInfo.ImageInfo);
     strLog += fmt::format("appID: {}\n", getAppFunctionID(alarmInfo.appFunction));
     strLog += fmt::format("actionID: {}\n", alarmInfo.ActionID);
     strLog += fmt::format("actionDes: {}\n", alarmInfo.ActionDes);
@@ -1401,7 +1407,7 @@ bool FromWebAPI::updateAlarmEndTime(const AlarmInfo& alarmInfo)
         nJson json0;
         json0["opName"] = "SPSS_UpdateAlarmEndTime";
         nJson json1;
-        json1["EndTime"] = alarmInfo.EndTime;
+        json1["EndTime"] = alarmInfo.EndTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
         json1["ChannelID"] = alarmInfo.ChannelID;
         json1["RoomID"] = alarmInfo.RoomID;
         json1["CamerID"] = alarmInfo.DeviceID;
@@ -1410,7 +1416,7 @@ bool FromWebAPI::updateAlarmEndTime(const AlarmInfo& alarmInfo)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"更新报警结束时间失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1458,7 +1464,7 @@ bool FromWebAPI::endAlarmInfoByPKID(const int PKID, const QDateTime dateTime)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"更新报警结束时间失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1505,7 +1511,7 @@ bool FromWebAPI::updatePersonInfo(RoomOnWorkInfo& roomInfo)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"更新报警结束时间失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1548,7 +1554,7 @@ bool FromWebAPI::getMaxAlarmPKID(const int ChannelID, const AppFunction AppID, i
 
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取Alarma max PKID失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1609,7 +1615,7 @@ bool FromWebAPI::clearOnWorkAlarmInfo(const int PKID, const bool onWork, const s
     json0["paramList"] = json1;
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"清空在岗离岗报警的在岗人员信息失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1634,7 +1640,7 @@ bool FromWebAPI::getPersonCountRuleInfo(std::list<PersonCountRuleInfo>& list)
     json0["opName"] = "SPSS_GetPersonCountRule";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取AlarmRule失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1696,13 +1702,13 @@ bool FromWebAPI::getPersonCountRuleInfo(std::list<PersonCountRuleInfo>& list)
 }
 
 /* 获取报警时段,也同时获取报警的应用信息,tPeriod表 */
-bool FromWebAPI::getAlarmAppInfo(std::list<AppAndTimeInfo>& listInfo)
+bool FromWebAPI::getAlarmAppInfo(std::list<ChannelAppInfo>& listInfo)
 {
     nJson json0;
-    json0["opName"] = "SPSS_SelectPeriod";
+    json0["opName"] = "SPSS_SelectChannelApp";
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet);
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
     if(ret != 0)
     {
         SPDLOG_LOGGER_DEBUG(m_logger,"获取AlarmApp失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1725,13 +1731,11 @@ bool FromWebAPI::getAlarmAppInfo(std::list<AppAndTimeInfo>& listInfo)
         listInfo.clear();
         for(const auto& it : result)
         {
-            AppAndTimeInfo info;
+            ChannelAppInfo info;
             info.ChannelID = it["chnId"].get<int>();
             info.AppType = it["appType"].get<int>();
-            QString strStart = QString::fromStdString(it["startTime"].get<std::string>());
-            QString strEnd = QString::fromStdString(it["endTime"].get<std::string>());
-            info.StartTime = QDateTime::fromString(strStart, "yyyy-MM-ss hh:mm:ss");
-            info.EndTime = QDateTime::fromString(strEnd, "yyyy-MM-ss hh:mm:ss");
+            info.strChannelName = it["chnName"].is_null() ? "" : it["chnName"].get<std::string>();
+            info.strAppName = it["appName"].is_null() ? "" : it["appName"].get<std::string>();
             
             listInfo.push_back(info);
         }
@@ -1774,7 +1778,7 @@ bool FromWebAPI::endPersonCountAlarm(int chnID, AppFunction appID)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet);
+        int ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Update, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"结束人员计数报警失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());
@@ -1840,7 +1844,7 @@ bool FromWebAPI::insertOnWorkInfo(const RoomFaceInfo& onWorkInfo)
 
         QString strCmd = QString::fromStdString(json0.dump());
         QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet);
+        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Insert, strCmd, strRet, true);
         if(ret != 0)
         {
             SPDLOG_LOGGER_WARN(m_logger,"插入 tWorkOnInfo 失败:{}, 错误信息:{}",ret,m_httpApi->DoGetLastError(&ret).toStdString());

+ 1 - 1
SecurePlayAuxServer/communication/FromWebAPI.h

@@ -83,7 +83,7 @@ public:
     /* 获取人员计数规则 */
     bool getPersonCountRuleInfo(std::list<PersonCountRuleInfo>& vecInfo);
     /* 获取报警时段,也同时获取报警的应用信息 */
-    bool getAlarmAppInfo(std::list<AppAndTimeInfo>& listInfo);
+    bool getAlarmAppInfo(std::list<ChannelAppInfo>& listInfo);
     /* 结束人员计数报警,通过频率ID和应用ID */
     bool endPersonCountAlarm(int chnID, AppFunction appID);
 

+ 0 - 688
json.json

@@ -1,688 +0,0 @@
-{
-  "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"
-    }
-  ]
-}
-
-/* 算法信息 */
-{
-  "code": "0",
-  "message": "成功",
-  "data": [
-    {
-      "aiName": "疲劳检测",
-      "muAiName": "疲劳检测",
-      "sceneName": null,
-      "muAiTypeId": 6,
-      "taskTypeId": 6,
-      "taskTypeCode": "TaskType89j46ace4bx",
-      "needMark": false,
-      "supportSequential": false,
-      "isGaoTie": false,
-      "frequency": [
-        "5s",
-        "10s",
-        "15s",
-        "30s",
-        "60s",
-        "5min",
-        "15min",
-        "60min"
-      ],
-      "calTypeName": "自建应用",
-      "abilityType": 5,
-      "baseConfig": true,
-      "osConfig": false,
-      "ability": "OD210_021_004790_001-l2MahE4v",
-      "appStatus": 0,
-      "status": 0,
-      "orderType": 0,
-      "errorMsg": "安装成功",
-      "isUsed": null
-    },
-    {
-      "aiName": "摔倒识别",
-      "muAiName": "摔倒识别",
-      "sceneName": null,
-      "muAiTypeId": 5,
-      "taskTypeId": 5,
-      "taskTypeCode": "TaskType9gusadr93ou",
-      "needMark": false,
-      "supportSequential": false,
-      "isGaoTie": false,
-      "frequency": [
-        "5s",
-        "10s",
-        "15s",
-        "30s",
-        "60s",
-        "5min",
-        "15min",
-        "60min"
-      ],
-      "calTypeName": "自建应用",
-      "abilityType": 5,
-      "baseConfig": true,
-      "osConfig": false,
-      "ability": "OD210_021_001871_051-l2MahE4v",
-      "appStatus": 0,
-      "status": 0,
-      "orderType": 0,
-      "errorMsg": "安装成功",
-      "isUsed": null
-    },
-    {
-      "aiName": "睡岗识别",
-      "muAiName": "睡岗识别",
-      "sceneName": null,
-      "muAiTypeId": 4,
-      "taskTypeId": 4,
-      "taskTypeCode": "TaskTypeahabqwzwl1x",
-      "needMark": false,
-      "supportSequential": false,
-      "isGaoTie": false,
-      "frequency": [
-        "5s",
-        "10s",
-        "15s",
-        "30s",
-        "60s",
-        "5min",
-        "15min",
-        "60min"
-      ],
-      "calTypeName": "自建应用",
-      "abilityType": 5,
-      "baseConfig": true,
-      "osConfig": false,
-      "ability": "OD210_021_001870_017-l2MahE4v",
-      "appStatus": 0,
-      "status": 0,
-      "orderType": 0,
-      "errorMsg": "安装成功",
-      "isUsed": null
-    },
-    {
-      "aiName": "玩手机识别",
-      "muAiName": "玩手机识别",
-      "sceneName": null,
-      "muAiTypeId": 3,
-      "taskTypeId": 3,
-      "taskTypeCode": "TaskTypec2e94flbyyq",
-      "needMark": false,
-      "supportSequential": false,
-      "isGaoTie": false,
-      "frequency": [
-        "5s",
-        "10s",
-        "15s",
-        "30s",
-        "60s",
-        "5min",
-        "15min",
-        "60min"
-      ],
-      "calTypeName": "自建应用",
-      "abilityType": 5,
-      "baseConfig": true,
-      "osConfig": false,
-      "ability": "OD210_021_001866_001-l2MahE4v",
-      "appStatus": 0,
-      "status": 0,
-      "orderType": 0,
-      "errorMsg": "安装成功",
-      "isUsed": null
-    },
-    {
-      "aiName": "违禁品检测",
-      "muAiName": "违禁品检测",
-      "sceneName": null,
-      "muAiTypeId": 2,
-      "taskTypeId": 2,
-      "taskTypeCode": "TaskType49rugxtp855",
-      "needMark": false,
-      "supportSequential": false,
-      "isGaoTie": false,
-      "frequency": [
-        "5s",
-        "10s",
-        "15s",
-        "30s",
-        "60s",
-        "5min",
-        "15min",
-        "60min"
-      ],
-      "calTypeName": "自建应用",
-      "abilityType": 5,
-      "baseConfig": true,
-      "osConfig": false,
-      "ability": "OD210_021_002162_002-l2MahE4v",
-      "appStatus": 0,
-      "status": 0,
-      "orderType": 0,
-      "errorMsg": "安装成功",
-      "isUsed": null
-    },
-    {
-      "aiName": "盯屏",
-      "muAiName": "盯屏",
-      "sceneName": null,
-      "muAiTypeId": 1,
-      "taskTypeId": 1,
-      "taskTypeCode": "TaskType5h3ifgna34s",
-      "needMark": false,
-      "supportSequential": false,
-      "isGaoTie": false,
-      "frequency": [
-        "5s",
-        "10s",
-        "15s",
-        "30s",
-        "60s",
-        "5min",
-        "15min",
-        "60min"
-      ],
-      "calTypeName": "自建应用",
-      "abilityType": 5,
-      "baseConfig": true,
-      "osConfig": false,
-      "ability": "OD210_101_004362_006-l2MahE4v",
-      "appStatus": 0,
-      "status": 0,
-      "orderType": 0,
-      "errorMsg": "安装成功",
-      "isUsed": null
-    }
-  ],
-  "success": true
-}
-/* 获取到的设备信息 */
-{
-  "code": "0",
-  "message": "成功",
-  "data": [
-    {
-      "deviceId": 2,
-      "deviceName": "111222333",
-      "deviceSerial": "VID9cwyv6fiv0x",
-      "port": null,
-      "userAccount": null,
-      "userPWD": null,
-      "deviceType": "本地视频",
-      "taskTypeList": [
-        {
-          "taskTypeId": 1,
-          "ability": "OD210_101_004362_006",
-          "taskTypeName": "盯屏"
-        }
-      ]
-    },
-    {
-      "deviceId": 6,
-      "deviceName": "广电研发",
-      "deviceSerial": "rtsp://admin:HZlh123456@172.16.3.229/Streaming/Channels/1601",
-      "port": null,
-      "userAccount": null,
-      "userPWD": null,
-      "deviceType": "视频流地址",
-      "taskTypeList": [
-        {
-          "taskTypeId": 3,
-          "ability": "OD210_021_001866_001",
-          "taskTypeName": "玩手机识别"
-        }
-      ]
-    }
-  ],
-  "success": true
-}
-/* Redis数据 */
-{
-  "actionId": "M100111000",
-  "actionName": "鑴卞矖绂诲矖璇嗗埆",
-  "actionResult": true,
-  "alarmId": 177157,
-  "bBoxes": [],
-  "beginTime": "2022-06-12T14:38:05",
-  "channel": 48,
-  "classifyId": 2,
-  "classifyName": "榛樿鍒嗙粍",
-  "deviceName": "test",
-  "deviceSerial": "172.16.3.229",
-  "endTime": "2022-06-12T14:39:05",
-  "eventTime": "2022-06-12T14:38:35",
-  "imageInfo": "",
-  "isKeyPoint": 0,
-  "picUrl": "1438351535874182926041088.jpg",
-  "taskId": 1,
-  "taskName": "1"
-}
-
-/* 117数据,应该和要读取的一样 */
-{
-  "actionDes": "",
-  "actionResult": true,
-  "alarmId": 73113,
-  "beginTime": "2024-09-01T16:52:38.426",
-  "channel": 1,
-  "classifyId": 64,
-  "classifyName": "培训教室-海康",
-  "deviceSerial": "172.16.9.31",
-  "endTime": "2024-09-01T16:53:38.426",
-  "eventTime": "2024-09-01T16:53:08.426",
-  "imageInfo": "http://webdav-read.default:80/webdav//GUI/1/PUMPING/2024/09/01//66d42b74e4b02066478c1ace.jpg",
-  "isKeyPoint": 0,
-  "personList": [],
-  "picUrl": "66d42b74e4b02066478c1ace.jpg",
-  "taskId": 452,
-  "taskName": "夜晚001",
-  "bBoxes": [
-    {
-      "bbox": [
-        1692,
-        369,
-        1791,
-        604
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.03"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        1755,
-        1402,
-        1975,
-        1539
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.02"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        1572,
-        1036,
-        1996,
-        1576
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.02"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        2257,
-        927,
-        2335,
-        1058
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.02"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        2052,
-        445,
-        2157,
-        650
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.01"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        2038,
-        716,
-        2099,
-        873
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.01"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        2250,
-        682,
-        2360,
-        1055
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.01"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        1521,
-        871,
-        1766,
-        1450
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.01"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        2104,
-        716,
-        2213,
-        907
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.01"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    },
-    {
-      "bbox": [
-        2063,
-        441,
-        2150,
-        532
-      ],
-      "colorFlag": 1,
-      "conf": [
-        "0.01"
-      ],
-      "label": [
-        "未成年人"
-      ],
-      "match_id": "",
-      "status": false
-    }
-  ]
-}
-
-/* 图片识别 */
-{
-  "code": 0,
-  "result": [
-    {
-      "pkid": 1,
-      "actionId": "M100121000",
-      "actionTaskid": 112,
-      "actionName": "疲劳检测"
-    },
-    {
-      "pkid": 2,
-      "actionId": "M100101000",
-      "actionTaskid": 104,
-      "actionName": "未戴口罩"
-    },
-    {
-      "pkid": 3,
-      "actionId": "M100107000",
-      "actionTaskid": 105,
-      "actionName": "吸烟识别"
-    },
-    {
-      "pkid": 4,
-      "actionId": "P100104000",
-      "actionTaskid": 106,
-      "actionName": "人员计数"
-    },
-    {
-      "pkid": 5,
-      "actionId": "C100107000",
-      "actionTaskid": 107,
-      "actionName": "违禁物品"
-    },
-    {
-      "pkid": 6,
-      "actionId": "E100111000",
-      "actionTaskid": 109,
-      "actionName": "动物识别"
-    },
-    {
-      "pkid": 7,
-      "actionId": "P100101000",
-      "actionTaskid": 111,
-      "actionName": "人脸识别"
-    },
-    {
-      "pkid": 8,
-      "actionId": "C100109000",
-      "actionTaskid": 110,
-      "actionName": "老鼠识别"
-    },
-    {
-      "pkid": 9,
-      "actionId": "M100105000",
-      "actionTaskid": 108,
-      "actionName": "睡岗识别"
-    },
-    {
-      "pkid": 10,
-      "actionId": "M100102000",
-      "actionTaskid": 103,
-      "actionName": "玩手机识别"
-    },
-    {
-      "pkid": 11,
-      "actionId": "002976",
-      "actionTaskid": 113,
-      "actionName": "摔倒识别"
-    },
-    {
-      "pkid": 12,
-      "actionId": "004160",
-      "actionTaskid": 118,
-      "actionName": "离岗识别"
-    },
-    {
-      "pkid": 21,
-      "actionId": "OD210_021_001879_001-IZRTKyEx",
-      "actionTaskid": 47,
-      "actionName": "未戴口罩识别"
-    },
-    {
-      "pkid": 22,
-      "actionId": "OD210_021_002162_002-IZRTKyEx",
-      "actionTaskid": 49,
-      "actionName": "违禁品检测"
-    },
-    {
-      "pkid": 23,
-      "actionId": "OD210_021_001871_051-IZRTKyEx",
-      "actionTaskid": 54,
-      "actionName": "摔倒识别"
-    },
-    {
-      "pkid": 24,
-      "actionId": "VC004_021_002601_026-IZRTKyEx",
-      "actionTaskid": 16,
-      "actionName": "人脸识别"
-    },
-    {
-      "pkid": 25,
-      "actionId": "OD210_021_001866_001",
-      "actionTaskid": 53,
-      "actionName": "玩手机识别"
-    },
-    {
-      "pkid": 26,
-      "actionId": "OD210_101_004533_002-IZRTKyEx",
-      "actionTaskid": 46,
-      "actionName": "港口异物识别"
-    },
-    {
-      "pkid": 27,
-      "actionId": "OD210_210_002111_001-IZRTKyEx",
-      "actionTaskid": 38,
-      "actionName": "人员识别"
-    },
-    {
-      "pkid": 28,
-      "actionId": "OD210_101_004362_006-IZRTKyEx",
-      "actionTaskid": 56,
-      "actionName": "盯屏"
-    }
-  ]
-}

+ 11 - 11
jsons/玩手机识别.json

@@ -3,18 +3,18 @@
     "actionId": "OD447_022_000070_001",
     "actionName": "k2玩手机",
     "actionResult": true,
-    "alarmId": 3415,
+    "alarmId": 3770,
     "bBoxes": [
         {
             "bbox": [
-                1149,
-                144,
-                1317,
-                355
+                1635,
+                253,
+                1770,
+                550
             ],
             "colorFlag": 1,
             "conf": [
-                "0.89"
+                "0.79"
             ],
             "label": [
                 "玩手机的人"
@@ -23,12 +23,12 @@
             "status": false
         }
     ],
-    "beginTime": "2025-05-08T19:37:02.433",
+    "beginTime": "2025-05-09T11:04:32.361",
     "classifyId": 64,
     "deviceSerial": "rtsp://admin:LH123456@172.16.9.31:554",
-    "endTime": "2025-05-08T19:38:02.433",
-    "eventTime": "2025-05-08T19:37:32.433",
-    "imageInfo": "http://nginx-webdav-out.mid:80/webdav////GUI/1/WATER/2025/05/08//1920442943592726528.jpg",
+    "endTime": "2025-05-09T11:05:32.361",
+    "eventTime": "2025-05-09T11:05:02.361",
+    "imageInfo": "http://nginx-webdav-out.mid:80/webdav////GUI/1/WATER/2025/05/09//1920676356283170816.jpg",
     "isKeyPoint": 0,
     "personList": [
         {
@@ -36,7 +36,7 @@
             "personId": "-1"
         }
     ],
-    "picUrl": "681c977ce4b076d9b370448d.jpg",
+    "picUrl": "681d70dee4b076d9b3704646.jpg",
     "taskId": 6,
     "taskName": "玩手机识别"
 }