|
@@ -7,25 +7,17 @@
|
|
|
#include"log.h"
|
|
|
|
|
|
|
|
|
-struct enter_or_leave_data:business_data
|
|
|
-{
|
|
|
- enter_or_leave_data()
|
|
|
- {
|
|
|
- m_enter_time_ms = tool_time::now_to_ms();
|
|
|
- }
|
|
|
-
|
|
|
- uint64_t m_enter_time_ms;
|
|
|
-};
|
|
|
-
|
|
|
//进入区域则入库操作
|
|
|
-void area_business_card_enter_or_leave::on_enter(const std::shared_ptr<area_hover>&area_hover_ptr,
|
|
|
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data>&ptr)
|
|
|
+void area_business_card_enter_or_leave::on_enter(const std::shared_ptr<area_hover>&a,
|
|
|
+ const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr)
|
|
|
{
|
|
|
- auto ptr_temp = std::make_shared<enter_or_leave_data>();
|
|
|
- ptr_temp->m_enter_time_ms = area_hover_ptr->m_enter_time;
|
|
|
- ptr = ptr_temp;
|
|
|
- area_hover_ptr->m_data[area_business_type()] = ptr_temp;
|
|
|
- save_his_area_location_enter(area_hover_ptr, card_ptr, ptr_temp->m_enter_time_ms);
|
|
|
+ char sql[LENGTH_SQL]{0};
|
|
|
+ std::string start_time = tool_time::to_str_ex(a->m_enter_time);
|
|
|
+ std::string card_id = tool_other::type_id_to_str(c->m_type,c->m_id);
|
|
|
+ const auto &p=a->m_enter_point;
|
|
|
+ snprintf(sql,LENGTH_SQL,"INSERT INTO his_location_area (card_id,area_id,map_id,enter_time,start_point)VALUES ('%s',%d,%d,'%s','%.2f,%.2f');",
|
|
|
+ card_id.c_str(),a->id(),a->mapid(),start_time.c_str(),p.x,p.y);
|
|
|
+ db_tool::PushAsync(sql);
|
|
|
}
|
|
|
|
|
|
void area_business_card_enter_or_leave::on_hover(const std::shared_ptr<area_hover>&a,
|
|
@@ -34,57 +26,15 @@ void area_business_card_enter_or_leave::on_hover(const std::shared_ptr<area_hove
|
|
|
|
|
|
}
|
|
|
//出区域则入库
|
|
|
-void area_business_card_enter_or_leave::on_leave(const std::shared_ptr<area_hover>&area_hover_ptr,
|
|
|
- const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
|
|
|
-{
|
|
|
- if(nullptr == ptr)
|
|
|
- {
|
|
|
- log_error("出区域失败:nullptr == ptr");
|
|
|
- return;
|
|
|
- }
|
|
|
- auto ptr_temp = dynamic_cast<enter_or_leave_data*>(ptr.get());
|
|
|
- if (nullptr == ptr_temp)
|
|
|
- {
|
|
|
- return ;
|
|
|
- }
|
|
|
- save_his_area_location_leave(area_hover_ptr, card_ptr, ptr_temp->m_enter_time_ms);
|
|
|
-}
|
|
|
-
|
|
|
-///入库
|
|
|
-void area_business_card_enter_or_leave::save_his_area_location_enter(const std::shared_ptr<area_hover>&area_hover_ptr,
|
|
|
- const std::shared_ptr<card_location_base>&card_ptr,
|
|
|
- uint64_t start_time_ms)
|
|
|
-{
|
|
|
- char sql[LENGTH_SQL] = {0};
|
|
|
-
|
|
|
- std::string call(card_ptr->is_vehicle()?"add_area_vehicle":"add_area_staff");
|
|
|
-
|
|
|
- std::string start_str = tool_time::to_str_ex(start_time_ms);
|
|
|
-
|
|
|
- sprintf(sql, "CALL %s(%s, %d, %d, %d, '%s','%s');", call.c_str(),
|
|
|
- tool_other::type_id_to_str(card_ptr->m_type, card_ptr->m_id).c_str(),
|
|
|
- card_ptr->m_id, area_hover_ptr->id(), area_hover_ptr->mapid(), start_str.c_str(), start_str.c_str());
|
|
|
-
|
|
|
- db_tool::PushAsync(sql);
|
|
|
-}
|
|
|
-
|
|
|
-///入库
|
|
|
-void area_business_card_enter_or_leave::save_his_area_location_leave(const std::shared_ptr<area_hover>&area_hover_ptr,
|
|
|
- const std::shared_ptr<card_location_base>&card_ptr,
|
|
|
- uint64_t start_time_ms)
|
|
|
+void area_business_card_enter_or_leave::on_leave(const std::shared_ptr<area_hover>&a,
|
|
|
+ const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr)
|
|
|
{
|
|
|
- char sql[LENGTH_SQL] = {0};
|
|
|
-
|
|
|
- std::string call(card_ptr->is_vehicle()?"add_area_vehicle":"add_area_staff");
|
|
|
-
|
|
|
- std::string start_str = tool_time::to_str_ex(start_time_ms);
|
|
|
- std::string end_str = tool_time::to_str_ex(tool_time::now_to_ms());
|
|
|
-
|
|
|
- sprintf(sql, "CALL %s(%s, %d, %d, %d, '%s','%s');", call.c_str(),
|
|
|
- tool_other::type_id_to_str(card_ptr->m_type, card_ptr->m_id).c_str(),
|
|
|
- card_ptr->m_id, area_hover_ptr->id(), area_hover_ptr->mapid(), start_str.c_str(), end_str.c_str());
|
|
|
-
|
|
|
+ char sql[LENGTH_SQL]{0};
|
|
|
+ std::string start_time = tool_time::to_str_ex(a->m_enter_time);
|
|
|
+ std::string end_time = tool_time::to_str_ex(a->m_last_time);
|
|
|
+ std::string card_id = tool_other::type_id_to_str(c->m_type,c->m_id);
|
|
|
+ const auto &ep=a->m_last_point;
|
|
|
+ snprintf(sql,LENGTH_SQL,"UPDATE his_location_area SET leave_time='%s',end_point='%.2f,%.2f' WHERE card_id = '%s' AND area_id=%d AND enter_time='%s';",
|
|
|
+ end_time.c_str(),ep.x,ep.y,card_id.c_str(),a->id(),start_time.c_str());
|
|
|
db_tool::PushAsync(sql);
|
|
|
}
|
|
|
-
|
|
|
-
|