1
0

area_business_person_dwell_checker.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "area.h"
  2. #include "card_base.h"
  3. #include "event.h"
  4. #include "tool_time.h"
  5. #include "common_tool.h"
  6. #include "log.h"
  7. #include "area_business_person_dwell_checker.h"
  8. void area_business_person_dwell_checker::on_load_his(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr)
  9. {
  10. if(!c->is_person())
  11. return;
  12. EVENT_TYPE evType = a->m_area->is_mine() ? EVENT_TYPE::ET_CARD_OVER_TIME_PERSON : EVENT_TYPE::ET_CARD_AREA_OVER_TIME_PERSON;
  13. auto ev_ptr_temp = event_list::instance()->get_event_card(c->m_id,c->m_type,evType,DT_COMMON);
  14. if (ev_ptr_temp && !ev_ptr_temp->is_end())
  15. c->set_event_flag(evType);
  16. }
  17. //进入区域,记录进入时间
  18. void area_business_person_dwell_checker::on_enter(const std::shared_ptr<area_hover>&a,
  19. const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr)
  20. {
  21. log_info("area_business_person_dwell_checker::on_enter : In Area=%d Card = %d ",a->m_area->id(),c->m_id);
  22. }
  23. //判断是否超时
  24. void area_business_person_dwell_checker::on_hover(const std::shared_ptr<area_hover>&a,
  25. const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr)
  26. {
  27. if(!c->is_person()||a->m_enter_time==0)
  28. return;
  29. double limit_val = a->m_area->m_limit_person_second;
  30. double cur_val = ( tool_time::now_to_seconds() - a->m_enter_time / 1000);
  31. EVENT_TYPE evType = a->m_area->is_mine() ? EVENT_TYPE::ET_CARD_OVER_TIME_PERSON : EVENT_TYPE::ET_CARD_AREA_OVER_TIME_PERSON;
  32. if (limit_val < cur_val)
  33. {
  34. c->set_event_flag(evType);
  35. uint64_t id = tool_other::type_id_to_u64(c->m_type, c->m_id);
  36. event_tool::instance()->handle_event(OT_CARD,evType,id,limit_val,cur_val,true);
  37. }
  38. }
  39. //如果有超时告警,取消超时告警
  40. void area_business_person_dwell_checker::on_leave(const std::shared_ptr<area_hover>&a,
  41. const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr)
  42. {
  43. if(!c->is_person())
  44. return;
  45. EVENT_TYPE evType = a->m_area->is_mine() ? EVENT_TYPE::ET_CARD_OVER_TIME_PERSON:EVENT_TYPE::ET_CARD_AREA_OVER_TIME_PERSON;
  46. if(c->get_event_flag(evType))
  47. {
  48. c->set_event_flag(evType,0);
  49. uint64_t id = tool_other::type_id_to_u64(c->m_type, c->m_id);
  50. event_tool::instance()->handle_event(OT_CARD, evType, id, 0, 0, false);
  51. }
  52. }