#include "area_business_forbid.h"

#include"vector"
#include"event.h"
#include"common_tool.h"
#include"area.h"
#include "card.h"
#include "module_call.h"

struct forbid_data:business_data
{
    forbid_data()
    {
    }
};

area_business_forbid::area_business_forbid()
{
}

void area_business_forbid::on_load_his(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_forbid::on_enter(const std::shared_ptr<area_hover>&a,
                                    const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data>&ptr)
{
    EVENT_TYPE ev_type = ET_CARD_AREA_FORBIDDEN_PERSON;
    if(card_ptr->is_vehicle())
    {
        ev_type = ET_CARD_AREA_FORBIDDEN_VEHICLE;
    }

    uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
    event_tool::instance()->handle_event(OT_CARD, ev_type, id, 0, 0, true);

    //呼叫
    module_call::instance()->system_call_apoint(card_ptr->m_id,card_ptr->m_type);
}

void area_business_forbid::on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr)
{

}

//记录退出时间等信息
void area_business_forbid::on_leave(const std::shared_ptr<area_hover>&a,
                                    const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
{
    EVENT_TYPE ev_type = ET_CARD_AREA_FORBIDDEN_PERSON;
    if(card_ptr->is_vehicle())
    {
        ev_type = ET_CARD_AREA_FORBIDDEN_VEHICLE;
    }

    uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
    event_tool::instance()->handle_event(OT_CARD, ev_type, id, 0, 0, false);

    //取消呼叫
    module_call::instance()->system_cancel_call_apoint(card_ptr->m_id,card_ptr->m_type);
}


