FuncRegionalPerson.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. #include "FuncRegionalPerson.h"
  2. #include "FromWebAPI.h"
  3. #include "FromRedis.h"
  4. #include "GlobalConfig.h"
  5. #include "GlobalVariable.h"
  6. #include "UniversalFunc.h"
  7. #include "bundled/core.h"
  8. #include "spdlog.h"
  9. #include <string>
  10. PersonCountRuleInfo::PersonCountRuleInfo()
  11. {
  12. ChannelID = -1;
  13. // week = 0;
  14. // RuleType = Enum_PeriodType::PERIOD_ALL;
  15. LiveMinEnable = false;
  16. LiveMaxEnable = false;
  17. DicMinEnable = false;
  18. DicMaxEnable = false;
  19. LiveDicMinEnable = false;
  20. LiveDicMaxEnable = false;
  21. LiveMin = 0;
  22. LiveMax = 0;
  23. DicMin = 0;
  24. DicMax = 0;
  25. LiveDicMin = 0;
  26. LiveDicMax = 0;
  27. RuleName = "";
  28. }
  29. PersonCountRuleInfo& PersonCountRuleInfo::operator=(PersonCountRuleInfo& other)
  30. {
  31. if(this != &other)
  32. {
  33. ChannelID = other.ChannelID;
  34. // week = other.week;
  35. // RuleType = other.RuleType;
  36. // PeriodName = other.PeriodName;
  37. // StartTime = other.StartTime;
  38. // EndTime = other.EndTime;
  39. LiveMinEnable = other.LiveMinEnable;
  40. LiveMaxEnable = other.LiveMaxEnable;
  41. DicMinEnable = other.DicMinEnable;
  42. DicMaxEnable = other.DicMaxEnable;
  43. LiveDicMinEnable = other.LiveDicMinEnable;
  44. LiveDicMaxEnable = other.LiveDicMaxEnable;
  45. LiveMin = other.LiveMin;
  46. LiveMax = other.LiveMax;
  47. DicMin = other.DicMin;
  48. DicMax = other.DicMax;
  49. LiveDicMin = other.LiveDicMin;
  50. LiveDicMax = other.LiveDicMax;
  51. RuleName = other.RuleName;
  52. }
  53. return *this;
  54. }
  55. EndAlarmParam::EndAlarmParam()
  56. {
  57. ChannelID = -1;
  58. AppID = AppFunction::APP_NONE;
  59. CameraID = -1;
  60. insertAlarmNum = 0;
  61. }
  62. EndAlarmParam::EndAlarmParam(const EndAlarmParam& other)
  63. {
  64. ChannelID = other.ChannelID;
  65. AppID = other.AppID;
  66. CameraID = other.CameraID;
  67. insertAlarmNum = other.insertAlarmNum;
  68. }
  69. EndAlarmParam& EndAlarmParam::operator=(const EndAlarmParam& other)
  70. {
  71. if(this != &other)
  72. {
  73. ChannelID = other.ChannelID;
  74. AppID = other.AppID;
  75. CameraID = other.CameraID;
  76. insertAlarmNum = other.insertAlarmNum;
  77. }
  78. return *this;
  79. }
  80. bool EndAlarmParam::operator==(const EndAlarmParam& other)
  81. {
  82. if(this == &other)
  83. {
  84. return true;
  85. }
  86. if(ChannelID != other.ChannelID)
  87. {
  88. return false;
  89. }
  90. if(AppID != other.AppID)
  91. {
  92. return false;
  93. }
  94. if(CameraID != other.CameraID)
  95. {
  96. return false;
  97. }
  98. if(insertAlarmNum != other.insertAlarmNum)
  99. {
  100. return false;
  101. }
  102. return true;
  103. }
  104. RoomPeopleInfo::RoomPeopleInfo()
  105. {
  106. RoomID = -1;
  107. RoomType = Enum_RoomType::ROOM_NONE;
  108. RoomName = "";
  109. MaxNum = 0;
  110. imagePath = "";
  111. }
  112. RoomPeopleInfo::RoomPeopleInfo(const RoomPeopleInfo& other)
  113. {
  114. RoomID = other.RoomID;
  115. RoomType = other.RoomType;
  116. RoomName = other.RoomName;
  117. MaxNum = other.MaxNum;
  118. imagePath = other.imagePath;
  119. }
  120. RoomPeopleInfo& RoomPeopleInfo::operator=(const RoomPeopleInfo& other)
  121. {
  122. if (this != &other) {
  123. RoomID = other.RoomID;
  124. RoomType = other.RoomType;
  125. RoomName = other.RoomName;
  126. MaxNum = other.MaxNum;
  127. imagePath = other.imagePath;
  128. }
  129. return *this;
  130. }
  131. AlarmBuffer::AlarmBuffer()
  132. {
  133. isMax = false;
  134. // isInsertDB = false;
  135. ChannelID = -1;
  136. RoomID = -1;
  137. RoomType = Enum_RoomType::ROOM_NONE;
  138. PeopleNum = 0;
  139. PKID = 0;
  140. AlarmTime = QDateTime();
  141. imagePath = "";
  142. actionDecs = "";
  143. }
  144. AlarmBuffer::AlarmBuffer(const AlarmBuffer& other)
  145. {
  146. isMax = other.isMax;
  147. // isInsertDB = other.isInsertDB;
  148. ChannelID = other.ChannelID;
  149. RoomID = other.RoomID;
  150. RoomType = other.RoomType;
  151. PeopleNum = other.PeopleNum;
  152. PKID = other.PKID;
  153. AlarmTime = other.AlarmTime;
  154. imagePath = other.imagePath;
  155. actionDecs = other.actionDecs;
  156. }
  157. AlarmBuffer& AlarmBuffer::operator=(const AlarmBuffer& other)
  158. {
  159. if (this != &other) {
  160. isMax = other.isMax;
  161. // isInsertDB = other.isInsertDB;
  162. ChannelID = other.ChannelID;
  163. RoomID = other.RoomID;
  164. RoomType = other.RoomType;
  165. PeopleNum = other.PeopleNum;
  166. PKID = other.PKID;
  167. AlarmTime = other.AlarmTime;
  168. imagePath = other.imagePath;
  169. actionDecs = other.actionDecs;
  170. }
  171. return *this;
  172. }
  173. FuncRegionalPersonCount::FuncRegionalPersonCount()
  174. {
  175. m_logger = spdlog::get("SPAServer");
  176. if(m_logger == nullptr)
  177. {
  178. SPDLOG_ERROR("SPAServer logger is nullptr");
  179. return;
  180. }
  181. m_pListAlarm = new ListAlarmInfo();
  182. if(m_pListAlarm == nullptr)
  183. {
  184. SPDLOG_ERROR("FuncRegionalPersonDetection m_pListAlarm is nullptr");
  185. return;
  186. }
  187. }
  188. FuncRegionalPersonCount::~FuncRegionalPersonCount()
  189. {
  190. if(m_pListAlarm != nullptr)
  191. {
  192. delete m_pListAlarm;
  193. m_pListAlarm = nullptr;
  194. }
  195. }
  196. void FuncRegionalPersonCount::task()
  197. {
  198. /* 初始化WebAPI和Redis */
  199. if(!initDataInterface())
  200. {
  201. SPDLOG_LOGGER_ERROR(m_logger, "{} 初始化数据接口失败", m_baseLog);
  202. return;
  203. }
  204. while (m_bRunning)
  205. {
  206. std::this_thread::sleep_for(std::chrono::milliseconds(GVariable.ThreadSleepMS));
  207. /* 更新线程信息,并判断是否需要退出 */
  208. GThreadInfo.updateFuncInfo(m_funcThreadInfo);
  209. if( (m_funcThreadInfo.appFunction == AppFunction::APP_NONE) ||
  210. (m_funcThreadInfo.RunState == RunTimeState::RUN_STATE_STOP) )
  211. {
  212. break;
  213. }
  214. /* 判断是否在检测时间段内 */
  215. if(!isInDetectTime(m_periodInfo))
  216. {
  217. /* 判断报警是否已经结束,没有结束就结束报警 */
  218. autoEndAlarm();
  219. continue;
  220. }
  221. /* 更新报警规则 */
  222. if(!getPersonCountRuleInfo(m_personCountRule))
  223. {
  224. /* 判断报警是否已经结束,没有结束就结束报警 */
  225. autoEndAlarm();
  226. continue;
  227. }
  228. /* 更新房间列表 */
  229. updateRoomList();
  230. if(m_listRoomCamAct.empty())
  231. {
  232. SPDLOG_LOGGER_ERROR(m_logger, "★ 频道[{}][{}],{},房间列表为空",
  233. m_funcThreadInfo.ChannelID, m_funcThreadInfo.strChannelName,
  234. getAppFunctionName(m_funcThreadInfo.appFunction));
  235. /* 判断报警是否已经结束,没有结束就结束报警 */
  236. autoEndAlarm();
  237. continue;
  238. }
  239. /* -----------------------------------------------------------------------
  240. * 读取Redis数据
  241. * ----------------------------------------------------------------------- */
  242. m_pListAlarm->clearAlarmInfo();
  243. for(const auto& RoomInfo : m_listRoomCamAct)
  244. {
  245. for(const auto& it : RoomInfo.mapCameraAction)
  246. {
  247. for(const auto& act : it.second)
  248. {
  249. std::string strKey = std::to_string(it.first) + ":" + act;
  250. std::string strRetValue;
  251. if(!m_fromRedis->getRedisString(strKey, strRetValue))
  252. {
  253. SPDLOG_LOGGER_WARN(m_logger, "读取Redis数据失败, Key: {}", strKey);
  254. continue;
  255. }
  256. /* 解析数据 */
  257. AlarmInfo alarmInfo;
  258. parseRedisBaseData(strRetValue, alarmInfo);
  259. parseOtherDataPersonCount(strRetValue, alarmInfo);
  260. /* 判断事件的时效性,超过多少秒不更新就可能是超脑挂了 */
  261. if(!isEventTimeVaild(m_nowTime, alarmInfo.EventTime))
  262. {
  263. SPDLOG_LOGGER_WARN(m_logger, "Redis Key:{} 数据长时间没有更新,nowTime: {}, EventTime:{}",strKey,
  264. m_nowTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString(), alarmInfo.EventTime);
  265. continue;
  266. }
  267. m_pListAlarm->addAlarmInfo(alarmInfo);
  268. }
  269. }
  270. }
  271. /************ 挨个房间检测人数,取出每个房间内人数的最大值 ************/
  272. for(const auto& RoomInfo : m_listRoomCamAct)
  273. {
  274. /* 取出房间内的最大值 */
  275. RoomPeopleInfo peopleInfo;
  276. peopleInfo.RoomID = RoomInfo.RoomID;
  277. peopleInfo.RoomType = RoomInfo.RoomType;
  278. peopleInfo.RoomName = RoomInfo.strRoomName;
  279. /* 获取该房间内最大人数 */
  280. getRoomMaxNum(RoomInfo.RoomID, peopleInfo.MaxNum, peopleInfo.imagePath);
  281. m_mapRoomPeople.insert(std::make_pair(RoomInfo.RoomID, peopleInfo));
  282. }
  283. /************ 单独判断每个房间内人数的最大值和最小值 ************/
  284. for(const auto& it : m_mapRoomPeople)
  285. {
  286. /* 处理房间内的人数最大值 */
  287. handleRoomMaxNum(it.second);
  288. }
  289. /************ 检测频率直播间 + 导播间房间的人数 ************/
  290. }
  291. }
  292. /* 获取该频率的人员计数规则 */
  293. bool FuncRegionalPersonCount::getPersonCountRuleInfo(PersonCountRuleInfo& personCountRuleInfo)
  294. {
  295. std::list<PersonCountRuleInfo> listRule;
  296. if(!m_fromWebAPI->getPersonCountRuleInfo(listRule))
  297. {
  298. SPDLOG_LOGGER_ERROR(m_logger, "获取《人员计数》报警规则失败");
  299. return false;
  300. }
  301. if(listRule.size() == 0)
  302. {
  303. SPDLOG_LOGGER_ERROR(m_logger, "★ 频道[{}][{}],{},未配置人员计数规则",
  304. m_funcThreadInfo.ChannelID, m_funcThreadInfo.strChannelName,
  305. getAppFunctionName(m_funcThreadInfo.appFunction));
  306. return false;
  307. }
  308. /* 获取这个频率的报警信息 */
  309. m_personCountRule.ChannelID = -1;
  310. for(auto& it : listRule)
  311. {
  312. if(it.ChannelID == m_funcThreadInfo.ChannelID)
  313. {
  314. m_personCountRule = it;
  315. break;
  316. }
  317. }
  318. if(m_personCountRule.ChannelID == -1)
  319. {
  320. SPDLOG_LOGGER_ERROR(m_logger, "频率:{}《人员计数》无报警规则", m_funcThreadInfo.ChannelID);
  321. return false;
  322. }
  323. return true;
  324. }
  325. /* 判断是否在检测时间段内 */
  326. // bool FuncRegionalPersonCount::isInPeriodTime()
  327. // {
  328. // /* 所有时段 */
  329. // if(m_personCountRule.RuleType == Enum_PeriodType::PERIOD_ALL)
  330. // {
  331. // return true;
  332. // }
  333. // /* 按天检测 */
  334. // else if(m_personCountRule.RuleType == Enum_PeriodType::PERIOD_DAY)
  335. // {
  336. // if(m_personCountRule.StartTime <= m_nowTime && m_personCountRule.EndTime >= m_nowTime)
  337. // {
  338. // /* 在检测时间内 */
  339. // return true;
  340. // } else {
  341. // /* 不在检测时间内 */
  342. // return false;
  343. // }
  344. // }
  345. // /* 按周检测 */
  346. // else if (m_personCountRule.RuleType == Enum_PeriodType::PERIOD_WEEK)
  347. // {
  348. // if(m_personCountRule.week != m_nowTime.date().dayOfWeek())
  349. // {
  350. // /* 一周日期不相等 */
  351. // return false;
  352. // }
  353. // /* 判断周日期是否相等 */
  354. // if(m_personCountRule.StartTime.time() <= m_nowTime.time() && m_personCountRule.EndTime.time() >= m_nowTime.time())
  355. // {
  356. // return true;
  357. // } else {
  358. // /* 不在检测时间内 */
  359. // return false;
  360. // }
  361. // }
  362. // return true;
  363. // }
  364. /* 更新房间列表 */
  365. void FuncRegionalPersonCount::updateRoomList()
  366. {
  367. /* 清空房间列表 */
  368. m_listRoomCamAct.clear();
  369. for(const auto& it : m_funcThreadInfo.listRoomCamActInfo)
  370. {
  371. /* 只添加直播间和导播间 */
  372. if(it.RoomType == Enum_RoomType::ROOM_LIVE || it.RoomType == Enum_RoomType::ROOM_DIC)
  373. {
  374. m_listRoomCamAct.push_back(it);
  375. }
  376. }
  377. }
  378. /* 自动结束报警 */
  379. void FuncRegionalPersonCount::autoEndAlarm()
  380. {
  381. EndAlarmParam alarmParam;
  382. alarmParam.ChannelID = m_funcThreadInfo.ChannelID;
  383. alarmParam.AppID = m_funcThreadInfo.appFunction;
  384. /* 判断报警是否已经结束,没有结束就结束报警 */
  385. if(findAlarmEnd(alarmParam))
  386. {
  387. SPDLOG_LOGGER_DEBUG(m_logger, "频率:{}《人员计数》报警已经结束", m_funcThreadInfo.strChannelName);
  388. return;
  389. }
  390. if(!m_fromWebAPI->endPersonCountAlarm(alarmParam))
  391. {
  392. SPDLOG_LOGGER_ERROR(m_logger, "频率:{}《人员计数》结束报警失败", m_funcThreadInfo.strChannelName);
  393. return;
  394. }
  395. /* 记录已经结束报警的信息,限制一下记录列表的大小 */
  396. if(m_listEndAlarmPara.size() > 1024)
  397. {
  398. m_listEndAlarmPara.clear();
  399. }
  400. m_listEndAlarmPara.push_back(alarmParam);
  401. }
  402. /* 查找是否已经结束了报警 */
  403. bool FuncRegionalPersonCount::findAlarmEnd(EndAlarmParam& alarmParam)
  404. {
  405. if(m_listEndAlarmPara.empty())
  406. {
  407. return false;
  408. }
  409. for(auto& it : m_listEndAlarmPara)
  410. {
  411. if(it == alarmParam)
  412. {
  413. return true;
  414. }
  415. }
  416. return false;
  417. }
  418. /* 取出一个房间内的最大人数 */
  419. bool FuncRegionalPersonCount::getRoomMaxNum(int roomID, int& maxNum, std::string& strImagePath)
  420. {
  421. strImagePath.clear();
  422. for(auto it : m_pListAlarm->listAlarmInfo)
  423. {
  424. if(it->RoomID == roomID)
  425. {
  426. /* 取出最大人数 */
  427. int num = it->listPersonInfo.size();
  428. if(num > maxNum)
  429. {
  430. maxNum = num;
  431. strImagePath = it->ImageInfo;
  432. }
  433. if(strImagePath.empty())
  434. {
  435. strImagePath = it->ImageInfo;
  436. }
  437. }
  438. }
  439. return true;
  440. }
  441. /* 处理房间内的人数最大值 */
  442. void FuncRegionalPersonCount::handleRoomMaxNum(const RoomPeopleInfo& peopleInfo)
  443. {
  444. std::string roomName = "";
  445. int maxNum = 0;
  446. /* 判断当前房间是否开启了最大人员检测功能 */
  447. if(peopleInfo.RoomType == Enum_RoomType::ROOM_LIVE)
  448. {
  449. if(!m_personCountRule.LiveMaxEnable)
  450. {
  451. SPDLOG_LOGGER_DEBUG(m_logger, "{} 直播间最大人数检测功能未开启", m_baseLog);
  452. return;
  453. }
  454. /* 判断有没有名称 */
  455. if(peopleInfo.RoomName.empty())
  456. {
  457. roomName = "直播间";
  458. } else {
  459. roomName = peopleInfo.RoomName;
  460. }
  461. maxNum = m_personCountRule.LiveMax;
  462. }
  463. else if(peopleInfo.RoomType == Enum_RoomType::ROOM_DIC)
  464. {
  465. if(!m_personCountRule.DicMaxEnable)
  466. {
  467. SPDLOG_LOGGER_DEBUG(m_logger, "{} 导播间最大人数检测功能未开启", m_baseLog);
  468. return;
  469. }
  470. /* 判断有没有名称 */
  471. if(peopleInfo.RoomName.empty())
  472. {
  473. roomName = "导播间";
  474. } else {
  475. roomName = peopleInfo.RoomName;
  476. }
  477. maxNum = m_personCountRule.DicMax;
  478. }
  479. else if(peopleInfo.RoomType == Enum_RoomType::ROOM_ALL)
  480. {
  481. if(!m_personCountRule.LiveDicMaxEnable)
  482. {
  483. SPDLOG_LOGGER_DEBUG(m_logger, "{} 直播间+导播间最大人数检测功能未开启", m_baseLog);
  484. return;
  485. }
  486. /* 判断有没有名称 */
  487. if(peopleInfo.RoomName.empty())
  488. {
  489. roomName = "直播间+导播间";
  490. } else {
  491. roomName = peopleInfo.RoomName;
  492. }
  493. maxNum = m_personCountRule.LiveDicMax;
  494. }
  495. else
  496. {
  497. SPDLOG_LOGGER_WARN(m_logger, "{} 房间类型错误", m_baseLog);
  498. return;
  499. }
  500. /* 查找房间信息 */
  501. RoomCamActInfo roomInfo;
  502. if(!findRoomInfo(peopleInfo.RoomID, roomInfo))
  503. {
  504. SPDLOG_LOGGER_ERROR(m_logger, "房间ID:{},房间信息不存在", peopleInfo.RoomID);
  505. return;
  506. }
  507. /* 开启了最大人数的检测,判断是否超过最大人数 */
  508. if(peopleInfo.MaxNum > maxNum)
  509. {
  510. /* 超过了最大人数,判断是否已经加入了内存缓冲区 */
  511. AlarmBuffer alarmBuffer;
  512. if(findAlarmBuffer(peopleInfo.RoomID, alarmBuffer))
  513. {
  514. /* 更新时间,这里只更新时间吗?最大人数和图片不更新吗? */
  515. alarmBuffer.AlarmTime = m_nowTime;
  516. }else
  517. {
  518. /* 没有加入缓冲区,先写入数据库,再加入缓冲区 */
  519. AlarmInfo alarmInfo;
  520. alarmInfo.ChannelID = m_funcThreadInfo.ChannelID;
  521. alarmInfo.appFunction = m_funcThreadInfo.appFunction;
  522. alarmInfo.RoomID = peopleInfo.RoomID;
  523. alarmInfo.DeviceID = roomInfo.mapCameraAction.begin()->first;
  524. alarmInfo.ImageInfo = peopleInfo.imagePath;
  525. alarmInfo.ActionID = roomInfo.mapCameraAction.begin()->second.front();
  526. alarmInfo.EventTime = m_nowTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString();
  527. alarmInfo.Is_Alarm = true;
  528. alarmInfo.ActionDes = fmt::format("{}人数为{},已超过最大人数{}限制",
  529. roomName, peopleInfo.MaxNum, maxNum);
  530. for(auto& it : roomInfo.mapCameraAction)
  531. {
  532. alarmInfo.listBbox.push_back(GConfig.getCameraName(it.first));
  533. }
  534. int pkid = 0;
  535. if(!m_fromWebAPI->insertAlarmInfo(alarmInfo, pkid))
  536. {
  537. SPDLOG_LOGGER_ERROR(m_logger, "{} 写入报警信息失败", m_baseLog);
  538. return;
  539. }
  540. /* 将报警信息写入缓存中 */
  541. alarmBuffer.isMax = true;
  542. // alarmBuffer.isInsertDB = true;
  543. alarmBuffer.ChannelID = m_funcThreadInfo.ChannelID;
  544. alarmBuffer.RoomID = peopleInfo.RoomID;
  545. alarmBuffer.PKID = pkid;
  546. alarmBuffer.RoomType = peopleInfo.RoomType;
  547. alarmBuffer.PeopleNum = peopleInfo.MaxNum;
  548. alarmBuffer.AlarmTime = m_nowTime;
  549. alarmBuffer.imagePath = peopleInfo.imagePath;
  550. alarmBuffer.actionDecs = alarmInfo.ActionDes;
  551. m_mapAlarmBuffer.insert(std::make_pair(peopleInfo.RoomID, alarmBuffer));
  552. }
  553. }else
  554. {
  555. /* 未超过最大人数,判断是否已经写入的数据库,如果已经写入了数据库,就结束报警 */
  556. AlarmBuffer alarmBuffer;
  557. if(findAlarmBuffer(peopleInfo.RoomID, alarmBuffer))
  558. {
  559. /* 已写入数据库,结束报警,但是需要注意,人数少于一定时间后才结束报警,不会立马结束 */
  560. if(alarmBuffer.AlarmTime.secsTo(m_nowTime) > GVariable.AppPeopleCount_LessTime)
  561. {
  562. SPDLOG_LOGGER_INFO(m_logger, "{} 房间: {},超过最大人数{},报警结束",
  563. m_baseLog, roomName, maxNum);
  564. /* 结束报警 */
  565. if(!m_fromWebAPI->endAlarmInfoByPKID(alarmBuffer.PKID, m_nowTime))
  566. {
  567. SPDLOG_LOGGER_ERROR(m_logger, "{} 结束超过最大人数报警失败,PKID: {}", m_baseLog, alarmBuffer.PKID);
  568. return;
  569. }
  570. /* 删除报警缓冲区 */
  571. m_mapAlarmBuffer.erase(peopleInfo.RoomID);
  572. }
  573. }
  574. }
  575. }
  576. /* 根据房间ID查找报警缓冲区 */
  577. bool FuncRegionalPersonCount::findAlarmBuffer(int roomID, AlarmBuffer& alarmBuffer)
  578. {
  579. if(m_mapAlarmBuffer.empty())
  580. {
  581. return false;
  582. }
  583. for(auto& it : m_mapAlarmBuffer)
  584. {
  585. if(it.first == roomID)
  586. {
  587. alarmBuffer = it.second;
  588. return true;
  589. }
  590. }
  591. return false;
  592. }
  593. /* 根据房间ID查找房间信息 */
  594. bool FuncRegionalPersonCount::findRoomInfo(int roomID, RoomCamActInfo& roomInfo)
  595. {
  596. if(m_listRoomCamAct.empty())
  597. {
  598. return false;
  599. }
  600. for(auto& it : m_listRoomCamAct)
  601. {
  602. if(it.RoomID == roomID)
  603. {
  604. roomInfo = it;
  605. return true;
  606. }
  607. }
  608. return false;
  609. }