FuncOnAndOffJob.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef FUNCONANDOFFJOB_H
  2. #define FUNCONANDOFFJOB_H
  3. #include "FuncBase.h"
  4. /**
  5. * @brief 在岗离岗检测
  6. * 理论上一个频率只有一个直播间,直播间内只要有人,且这个人是可以被人脸算法识别到的人,就是在岗
  7. *
  8. */
  9. /**
  10. * @brief 检测信息
  11. *
  12. */
  13. struct DecCondition
  14. {
  15. int ChannelID; /* 通道ID */
  16. std::string strChannelName; /* 通道名称 */
  17. int leaveTimeMaxNum; /* 离岗时间最大个数,给一个限制 */
  18. int leaveNumOnTime; /* 一定时间内的离岗次数 */
  19. int leaveOneTime; /* 单次离开报警时间 */
  20. DecCondition();
  21. DecCondition(const DecCondition& other);
  22. DecCondition& operator=(const DecCondition& other);
  23. };
  24. /**
  25. * @brief 房间在岗信息
  26. *
  27. */
  28. struct RoomOnWorkInfo
  29. {
  30. bool bOnWork = false; /* 是否在岗 */
  31. int PKID; /* 主键ID,主要用来判断是否已经写入数据库 */
  32. int ChannelID; /* 通道ID */
  33. int RoomID; /* 房间ID */
  34. int CameraID; /* 摄像机ID */
  35. int RoomType; /* 房间类型 */
  36. std::string strRoomName; /* 房间名称 */
  37. QDateTime StartTime; /* 开始时间 */
  38. QDateTime EndTime; /* 结束时间 */
  39. std::string strImagePath; /* 图片路径 */
  40. std::list<QDateTime> listLeaveTime; /* 离岗时间 */
  41. std::list<PersonInfo> listPersonInfo; /* 人员信息 */
  42. RoomOnWorkInfo();
  43. RoomOnWorkInfo& operator=(const RoomOnWorkInfo& other);
  44. RoomOnWorkInfo(const RoomOnWorkInfo& other);
  45. void clear();
  46. /* 添加人员信息,进行查重 */
  47. void addPersonInfo(const std::list<PersonInfo>& vecInfo);
  48. /* 更新在岗时间 */
  49. void updateOnWorkTime(const QDateTime& time);
  50. /* 获取人脸ID字符串 */
  51. std::string getFaceIDListString();
  52. /* 获取人脸名称字符串 */
  53. std::string getFaceNameListString();
  54. /* 获取离岗时间字符串 */
  55. std::string getLeaveTimeString();
  56. /* 获取人员最后在岗时间字符串 */
  57. std::string getLastOnWorkTimeString();
  58. /* 添加一次离岗时间 */
  59. void addOneLeaveTime(const QDateTime& time, int maxLeaveTime);
  60. /* 对离岗时间进行查重 */
  61. bool isLeaveTimeExist(const QDateTime& time);
  62. };
  63. class FuncOnAndOffJob : public FuncBase
  64. {
  65. public:
  66. FuncOnAndOffJob();
  67. ~FuncOnAndOffJob();
  68. protected:
  69. void task() override;
  70. private:
  71. /* 获取当前频率信息 */
  72. bool getCurrentFrequencyInfo(const int ChannelID, DecCondition& info);
  73. /* 人员在岗情况 */
  74. void onWorkProcess(RoomOnWorkInfo* pRoomOnWorkInfo, std::pair<const int, RoomCamActInfo>& roomInfo);
  75. /* 人员离岗情况 */
  76. void offWorkProcess(RoomOnWorkInfo* pRoomOnWorkInfo, std::pair<const int, RoomCamActInfo>& roomInfo);
  77. /* 删除离岗人员和未知人员信息 */
  78. void deleteNoWorkPerson(std::list<PersonInfo>& listPersonInfo);
  79. /* 获取当前直播间的摄像机名称列表 */
  80. std::list<std::string> getCameraNameList(const std::map<int, std::list<std::string>>& mapCameraAction);
  81. private:
  82. ListAlarmInfo* m_pListAlarm = nullptr; /* 报警信息 */
  83. // std::map<int, ListAlarmInfo*> m_mapRoomPersonCount; /* 人员计数返回的信息,int是房间ID号 */
  84. // std::map<int, ListAlarmInfo*> m_mapRoomFaceInfo; /* 人脸识别返回的信息,int是房间ID号 */
  85. std::map<int, RoomOnWorkInfo*> m_mapRoomOnWorkInfo; /* 房间在岗信息 */
  86. DecCondition m_nowChnDecCondition; /* 当前频率的在岗检测信息 */
  87. RoomOnWorkInfo m_nowRoomOnWorkInfo; /* 当前房间在岗信息 */
  88. std::string m_strBaseInfo; /* 基础信息,主要是频率ID和房间ID */
  89. QDateTime m_curTime; /* 当前时间 */
  90. };
  91. #endif /* FUNCONANDOFFJOB_H */