#ifndef AREA_BUSINESS_CAR_ATTENDANCE_H
#define AREA_BUSINESS_CAR_ATTENDANCE_H


#include"area_business.h"
#include"unordered_map"


class area_business_car_attendance:public area_business
{
public:
    area_business_car_attendance();

    virtual int area_business_type()
    {
        return 6;
    }

    void on_load_his(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr);

    //记录进入时间等信息,结束考勤,根据离开的时间和距离，判断是否记录一条新的考勤记录
    void on_enter(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr);
    void on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);
    //记录离开考勤区域信息,开始考勤
    void on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);

    //static void save_attendance(const std::shared_ptr<card_location_base>& card_ptr, const std::shared_ptr<area_hover> area_hover_ptr){}
    static void init_attendance_area_from_db();

private:
    static bool is_attendance_area(int area_id, int vehicle_type_id)
    {
        return  m_map.end() != m_map.find(to_list_id(area_id, vehicle_type_id));
    }

    static uint64_t to_list_id(int area_id, int vehicle_type_id)
    {
        return (static_cast<uint64_t>(area_id)<<32) | static_cast<uint64_t>(vehicle_type_id);
    }

    ///area_id<<32| vehicle_type_id; att_rule_id
    static std::unordered_map<uint64_t, int> m_map;
};
#endif // AREA_BUSINESS_CAR_ATTENDANCE_H
