module_area.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef MODULE_AREA_H
  2. #define MODULE_AREA_H
  3. /**
  4. * @brief 与区域相关的业务模块总接口
  5. * @author 戴月腾
  6. * @date 2018-08-25
  7. */
  8. #include"area.h"
  9. #include"module_const.h"
  10. #include"module_web.h"
  11. #include"module_attendance_vehicle.h"
  12. #include"module_area_over_count.h"
  13. #include"module_area_timeout.h"
  14. class module_area: public singleton_base<module_area>
  15. {
  16. private:
  17. friend class singleton_base<module_area>;
  18. module_area()
  19. {
  20. }
  21. public:
  22. static void on_enter(uint32_t card_id,std::shared_ptr<area_hover>&c, int32_t type)
  23. {
  24. auto card_ptr=card_list::instance()->get(card_list::to_id64(type, card_id));
  25. if(!card_ptr)
  26. {
  27. log_error("卡不存在card_id=%d", card_id);
  28. return;
  29. }
  30. if(card_ptr->is_person())//统计人卡
  31. {
  32. c->m_area->m_person_count++;
  33. }
  34. if(card_ptr->is_vehicle())//统计车卡
  35. {
  36. c->m_area->m_vehicle_count++;
  37. //车卡考勤
  38. module_attendance_vehicle::instance()->on_enter(card_ptr, c);
  39. }
  40. //区域超员
  41. module_area_over_count::instance()->on_enter(card_ptr, c);
  42. //区域超时
  43. module_area_timeout::instance()->on_enter(card_ptr, c);
  44. }
  45. static void on_hover(uint32_t card_id,std::shared_ptr<area_hover>&c, int32_t type)
  46. {
  47. auto card_ptr=card_list::instance()->get(card_list::to_id64(type, card_id));
  48. if(!card_ptr)
  49. {
  50. log_error("卡不存在card_id=%d", card_id);
  51. return;
  52. }
  53. // if(card_ptr->is_person())//人卡
  54. // {
  55. // }
  56. // if(card_ptr->is_vehicle())//车卡
  57. // {
  58. // }
  59. //区域超时
  60. module_area_timeout::instance()->on_hover(card_ptr, c);
  61. }
  62. static void on_leave(uint32_t card_id, std::shared_ptr<area_hover>&c, int32_t type)
  63. {
  64. auto card_ptr=card_list::instance()->get(card_list::to_id64(type, card_id));
  65. if(!card_ptr)
  66. {
  67. log_error("卡不存在card_id=%d", card_id);
  68. return;
  69. }
  70. if(card_ptr->is_person())//统计人卡
  71. {
  72. c->m_area->m_person_count--;
  73. }
  74. if(card_ptr->is_vehicle())//统计车卡
  75. {
  76. c->m_area->m_vehicle_count--;
  77. }
  78. //区域人卡超员
  79. module_area_over_count::instance()->on_leave(card_ptr, c);
  80. //区域人卡超时
  81. module_area_timeout::instance()->on_leave(card_ptr, c);
  82. }
  83. };
  84. #endif // MODULE_AREA_H