|
@@ -292,9 +292,29 @@ class tool_other
|
|
|
{
|
|
|
public:
|
|
|
|
|
|
- static uint64_t to_uint64_cardid(uint32_t type, uint32_t id)
|
|
|
+ static bool is_person(int32_t type)
|
|
|
{
|
|
|
- return (static_cast<uint64_t>(type)<<32)|id; ////// (类型<<32)|卡号
|
|
|
+ return CT_PERSON == type;
|
|
|
+ }
|
|
|
+
|
|
|
+ static bool is_vehicle(int32_t type)
|
|
|
+ {
|
|
|
+ return CT_VEHICLE == type;
|
|
|
+ }
|
|
|
+
|
|
|
+ static bool is_up_site(int32_t reader_type_id)
|
|
|
+ {
|
|
|
+ return READER_TYPE_ID_UP == reader_type_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ static bool is_attendance(int32_t stat_attendance)
|
|
|
+ {
|
|
|
+ return AS_ATTENDANCE == stat_attendance;
|
|
|
+ }
|
|
|
+
|
|
|
+ static uint64_t to_uint64_cardid(uint64_t type, uint64_t id)
|
|
|
+ {
|
|
|
+ return (type<<32)|id; ////// (类型<<32)|卡号
|
|
|
}
|
|
|
|
|
|
static uint64_t to_event_list_id(int obj_id, EVENT_TYPE ev_type)
|
|
@@ -325,14 +345,14 @@ public:
|
|
|
ev_ptr->x = card_ptr->x;
|
|
|
ev_ptr->y = card_ptr->y;
|
|
|
|
|
|
- if(nullptr!=card_ptr->m_area_hover)
|
|
|
- {
|
|
|
- ev_ptr->m_area_id = card_ptr->m_area_hover->m_area->id();
|
|
|
- }
|
|
|
+// if(nullptr!=card_ptr->m_area_hover)
|
|
|
+// {
|
|
|
+// ev_ptr->m_area_id = card_ptr->m_area_hover->m_area->id();
|
|
|
+// }
|
|
|
|
|
|
- ev_ptr->m_landmarkid = card_ptr->m_landmarkid;
|
|
|
- ev_ptr->m_landmarkdist = card_ptr->m_landmarkdist;
|
|
|
- ev_ptr->m_landmarkdirect = card_ptr->m_landmarkdirect;
|
|
|
+// ev_ptr->m_landmarkid = card_ptr->m_landmarkid;
|
|
|
+// ev_ptr->m_landmarkdist = card_ptr->m_landmarkdist;
|
|
|
+// ev_ptr->m_landmarkdirect = card_ptr->m_landmarkdirect;
|
|
|
}
|
|
|
|
|
|
static event_ptr find_event(int obj_id, EVENT_TYPE ev_type, const event_map& ev_map)
|
|
@@ -384,45 +404,59 @@ public:
|
|
|
PushAsync(sql);
|
|
|
}
|
|
|
|
|
|
- static void save_attendance(const std::shared_ptr<card_location_base> card_ptr)
|
|
|
+ static void save_attendance(const std::shared_ptr<card_location_base> card_ptr,
|
|
|
+ const std::shared_ptr<area_hover> area_hover_ptr)
|
|
|
{
|
|
|
char sql[LENGTH_SQL] = {0};
|
|
|
|
|
|
std::string call("add_att_staff");
|
|
|
- if(CT_VEHICLE==card_ptr->m_type)//车卡
|
|
|
+ if(tool_other::is_vehicle(card_ptr->m_type))//车卡
|
|
|
{
|
|
|
call="add_att_vehicle";
|
|
|
}
|
|
|
|
|
|
- auto tt = card_ptr->m_attendance_start_time;
|
|
|
- if(AS_ATTENDANCE != card_ptr->m_stat_attendance)//考勤结束时间
|
|
|
+ auto start = card_ptr->m_attendance_start_time;
|
|
|
+ auto end = card_ptr->m_attendance_start_time;
|
|
|
+ if(!tool_other::is_attendance(card_ptr->m_stat_attendance))//考勤结束时间
|
|
|
{
|
|
|
- tt = std::chrono::system_clock::now();
|
|
|
+ std::time_t end_t= card_ptr->m_time/1000;
|
|
|
+ end = std::chrono::system_clock::from_time_t(end_t);
|
|
|
}
|
|
|
|
|
|
- std::string _time = tool_time::to_str(tt);
|
|
|
+ std::string start_str = tool_time::to_str(start);
|
|
|
+ std::string end_str = tool_time::to_str(end);
|
|
|
+
|
|
|
+ int landmarkid = 0;
|
|
|
+ int landmarkdirect=0;
|
|
|
+ double landmarkdist=0;
|
|
|
+ if(area_hover_ptr)
|
|
|
+ {
|
|
|
+ landmarkid = area_hover_ptr->landmark_id;
|
|
|
+ landmarkdirect = area_hover_ptr->landmark_dir;
|
|
|
+ landmarkdist = area_hover_ptr->landmark_dis;
|
|
|
+ }
|
|
|
|
|
|
- sprintf(sql, "CALL %s(%ld, %d, '%s', '%s', %d, %d, %.3f);", call.c_str(),
|
|
|
- card_ptr->m_id, card_ptr->m_type, _time.c_str(), _time.c_str(),
|
|
|
- card_ptr->m_landmarkid, card_ptr->m_landmarkdirect, card_ptr->m_landmarkdist);
|
|
|
+ sprintf(sql, "CALL %s(%d, %d, '%s', '%s', %d, %d, %.3f);", call.c_str(),
|
|
|
+ card_ptr->m_id, card_ptr->m_type, start_str.c_str(), end_str.c_str(),
|
|
|
+ landmarkid, landmarkdirect, landmarkdist);
|
|
|
|
|
|
PushAsync(sql);
|
|
|
}
|
|
|
|
|
|
static void save_his_raw_data(const std::shared_ptr<card> card_ptr)
|
|
|
{
|
|
|
- char sql[LENGTH_SQL] = {0};
|
|
|
- std::string _time = tool_time::to_str(card_ptr->m_deal_time);
|
|
|
-
|
|
|
- sprintf(sql,
|
|
|
- "INSERT IGNORE INTO his_raw_data(card_id, reader_id, antenna_id, reader_stamp, card_stamp, \
|
|
|
- fly_time, distance, ranging_type, power_state, accelerate, his_time, rec_time ) \
|
|
|
- VALUES(%d, %d, %d, %d, %d, %ld, %4.f, %d, %d, %d, '%s', '%s');",
|
|
|
- card_ptr->m_id, card_ptr->m_site_id, card_ptr->m_antenna_id,
|
|
|
- card_ptr->m_reader_tickcount, card_ptr->m_time_stamp,
|
|
|
- card_ptr->m_flying_time, card_ptr->m_distance, card_ptr->m_ranging_type, card_ptr->m_power_state,
|
|
|
- card_ptr->m_accelerate_state,
|
|
|
- card_ptr->m_str_his_time.c_str(), card_ptr->m_str_rec_time.c_str());
|
|
|
+// char sql[LENGTH_SQL] = {0};
|
|
|
+// std::string _time = tool_time::to_str(card_ptr->m_deal_time);
|
|
|
+
|
|
|
+// sprintf(sql,
|
|
|
+// "INSERT IGNORE INTO his_raw_data(card_id, reader_id, antenna_id, reader_stamp, card_stamp, \
|
|
|
+// fly_time, distance, ranging_type, power_state, accelerate, his_time, rec_time ) \
|
|
|
+// VALUES(%d, %d, %d, %d, %d, %ld, %4.f, %d, %d, %d, '%s', '%s');",
|
|
|
+// card_ptr->m_id, card_ptr->m_site_id, card_ptr->m_antenna_id,
|
|
|
+// card_ptr->m_reader_tickcount, card_ptr->m_time_stamp,
|
|
|
+// card_ptr->m_flying_time, card_ptr->m_distance, card_ptr->m_ranging_type, card_ptr->m_power_state,
|
|
|
+// card_ptr->m_accelerate_state,
|
|
|
+// card_ptr->m_str_his_time.c_str(), card_ptr->m_str_rec_time.c_str());
|
|
|
}
|
|
|
|
|
|
|