|
@@ -1,87 +1,92 @@
|
|
|
-#ifndef MODULE_AREA_H
|
|
|
-#define MODULE_AREA_H
|
|
|
+#include "module_area.h"
|
|
|
+#include"module_attendance_vehicle.h"
|
|
|
|
|
|
-/**
|
|
|
- * @brief 与区域相关的业务模块总接口
|
|
|
- * @author 戴月腾
|
|
|
- * @date 2018-08-25
|
|
|
- */
|
|
|
+//#include"module_area_overman.h"
|
|
|
+//#include"module_area_timeout.h"
|
|
|
+//#include"module_area_over_speed.h"
|
|
|
|
|
|
-#include"area.h"
|
|
|
-#include"module_const.h"
|
|
|
-//#include"module_web.h"
|
|
|
|
|
|
-class module_area:public i_thread, public singleton_base<module_area>
|
|
|
+void module_area::on_enter(uint64_t card_id,std::shared_ptr<area_hover>&c,double speed,uint64_t type)
|
|
|
{
|
|
|
-private:
|
|
|
- friend class singleton_base<module_area>;
|
|
|
- module_area()
|
|
|
+ auto card_ptr=card_list::instance()->get(tool_other::to_uint64_cardid(type, card_id));
|
|
|
+ if(!card_ptr)
|
|
|
{
|
|
|
+ log_error("卡不存在card_id=%d", card_id);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
-public:
|
|
|
- void on_hover(uint64_t card_id,std::shared_ptr<area_hover>&c,double speed,uint64_t type);
|
|
|
- void on_enter(uint64_t card_id,std::shared_ptr<area_hover>&c,double speed,uint64_t type);
|
|
|
- void on_leave(uint64_t card_id,std::shared_ptr<area_hover>&c,double speed,uint64_t type);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief 读取数据库中的告警,初始化告警列表
|
|
|
- */
|
|
|
- void init()
|
|
|
- {}
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief web前端有用户登录时,反馈给web所有信息
|
|
|
- */
|
|
|
- std::string response_login()
|
|
|
+ log_debug("module_area::on_enter card_ptr->m_type=%d", card_ptr->m_type);
|
|
|
+
|
|
|
+ if(tool_other::is_person(card_ptr->m_type))//统计人卡
|
|
|
{
|
|
|
- // std::vector<std::shared_ptr<ya_event>> arr;
|
|
|
- // get_all_events(arr);
|
|
|
+ c->m_area->m_person_count++;
|
|
|
|
|
|
- // if(!arr.empty())//发送给web端
|
|
|
- // {
|
|
|
- // return tool_json::evs_to_json(arr);
|
|
|
- // }
|
|
|
+ // //区域人卡超员
|
|
|
+ // module_area_overman::instance()->on_enter(card_ptr, c, speed);
|
|
|
+ // //区域人卡超时
|
|
|
+ // module_area_timeout::instance()->on_enter(card_ptr, c, speed);
|
|
|
+ }
|
|
|
|
|
|
- // return "";
|
|
|
+ if(tool_other::is_vehicle(card_ptr->m_type))//统计车卡
|
|
|
+ {
|
|
|
+ c->m_area->m_vehicle_count++;
|
|
|
+ //车卡考勤
|
|
|
+ module_attendance_vehicle::instance()->on_enter(card_ptr, c, speed);
|
|
|
+
|
|
|
+ // //区域车卡超速
|
|
|
+ // module_area_over_speed::instance()->on_enter(card_ptr, c, speed);
|
|
|
}
|
|
|
-private:
|
|
|
- /**
|
|
|
- * @brief 线程函数
|
|
|
- */
|
|
|
- void run()
|
|
|
+
|
|
|
+ log_debug("module_area::on_enter 车卡数=%d, 人卡数=%d",
|
|
|
+ c->m_area->m_vehicle_count.load(), c->m_area->m_person_count.load());
|
|
|
+}
|
|
|
+
|
|
|
+void module_area::on_hover(uint64_t card_id,std::shared_ptr<area_hover>&c,double speed,uint64_t type)
|
|
|
+{
|
|
|
+ auto card_ptr=card_list::instance()->get(tool_other::to_uint64_cardid(type, card_id));
|
|
|
+ if(!card_ptr)
|
|
|
{
|
|
|
- // std::vector<std::shared_ptr<ya_event>> arr;
|
|
|
- // get_all_events(arr);
|
|
|
+ log_error("卡不存在card_id=%d", card_id);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // if(!arr.empty())//发送给web端
|
|
|
- // {
|
|
|
- // swsClientMgr.send(JSON_CMD_VALUE_PUSH, tool_json::evs_to_json(arr));
|
|
|
- // }
|
|
|
+ if(tool_other::is_person(card_ptr->m_type))//统计人卡
|
|
|
+ {
|
|
|
+ // //区域人卡超时
|
|
|
+ // module_area_timeout::instance()->on_hover(card_ptr, c, speed, _map);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @brief 获取所有的告警事件
|
|
|
- * @param out_data
|
|
|
- */
|
|
|
- void get_all_events(std::vector<std::shared_ptr<ya_event>>& arr)
|
|
|
+ if(tool_other::is_vehicle(card_ptr->m_type))//统计车卡
|
|
|
{
|
|
|
- {
|
|
|
- std::lock_guard<std::mutex> lock(_mutex);
|
|
|
-
|
|
|
- auto it_map = _map.begin();
|
|
|
- for(;it_map!=_map.end();++it_map)
|
|
|
- {
|
|
|
- arr.push_back(it_map->second);
|
|
|
- if(ES_DEAL_HELP== it_map->second->m_status)//删除掉已经处理的
|
|
|
- {
|
|
|
- _map.erase(it_map--);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // //区域车卡超速
|
|
|
+ // module_area_over_speed::instance()->on_hover(card_ptr, c, speed, _map);
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- std::map<uint64_t, std::shared_ptr<ya_event>> _map;
|
|
|
-};
|
|
|
+void module_area::on_leave(uint64_t card_id,std::shared_ptr<area_hover>&c,double speed,uint64_t type)
|
|
|
+{
|
|
|
+ auto card_ptr=card_list::instance()->get(tool_other::to_uint64_cardid(type, card_id));
|
|
|
+ if(!card_ptr)
|
|
|
+ {
|
|
|
+ log_error("卡不存在card_id=%d", card_id);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
-#endif // MODULE_AREA_H
|
|
|
+ if(tool_other::is_person(card_ptr->m_type))//统计人卡
|
|
|
+ {
|
|
|
+ c->m_area->m_person_count--;
|
|
|
+
|
|
|
+ // //区域人卡超员
|
|
|
+ // module_area_overman::instance()->on_leave(card_ptr, c, speed);
|
|
|
+ // //区域人卡超时
|
|
|
+ // module_area_timeout::instance()->on_leave(card_ptr, c, speed);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(tool_other::is_vehicle(card_ptr->m_type))//统计车卡
|
|
|
+ {
|
|
|
+ c->m_area->m_vehicle_count--;
|
|
|
+
|
|
|
+ // //区域车卡超速
|
|
|
+ // module_area_over_speed::instance()->on_leave(card_ptr, c, speed);
|
|
|
+ }
|
|
|
+}
|