module_area.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_person.h"
  13. #include"module_area_timeout_person.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. module_area_over_person::instance()->on_enter(card_ptr, c);
  35. //区域人卡超时
  36. module_area_timeout_person::instance()->on_enter(card_ptr, c);
  37. }
  38. if(card_ptr->is_vehicle())//统计车卡
  39. {
  40. c->m_area->m_vehicle_count++;
  41. //车卡考勤
  42. module_attendance_vehicle::instance()->on_enter(card_ptr, c);
  43. }
  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. module_area_timeout_person::instance()->on_hover(card_ptr, c);
  57. }
  58. if(card_ptr->is_vehicle())//车卡
  59. {
  60. }
  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. module_area_over_person::instance()->on_leave(card_ptr, c);
  75. //区域人卡超时
  76. module_area_timeout_person::instance()->on_leave(card_ptr, c);
  77. }
  78. if(card_ptr->is_vehicle())//统计车卡
  79. {
  80. c->m_area->m_vehicle_count--;
  81. }
  82. }
  83. };
  84. #endif // MODULE_AREA_H