#include "module_site.h"

#include<card.h>
#include"module_attendance_person.h"
#include"common_tool.h"
#include"ant.h"
#include"log.h"


void module_site::enter_site(uint32_t card_id,int enter_site,int32_t type)
{
    auto card_ptr=card_list::instance()->get(tool_other::type_id_to_u64(type, card_id));
    if(!card_ptr)
    {
        log_error("卡不存在card_id=%ld, type=%ld", card_id, type);
        return;
    }

    auto site_ptr=sit_list::instance()->get(enter_site);
    if(!site_ptr)
    {
        log_error("[enter site]%d,%d在分站列表中找不到分站，分站id=%d",card_id, type,enter_site);
        return;
    }

    if(card_ptr->is_person())
    {
        module_attendance_person::instance()->enter_site(card_ptr, site_ptr);
    }

    if(card_ptr->is_vehicle())
    {

    }
}

/**
 * @brief 离开现有分站处理，记录现有分站的进出时间和地点
 * @param card_id
 * @param enter_site
 */
void module_site::leave_site(uint32_t card_id,int enter_site, int32_t type)
{
    auto card_ptr=card_list::instance()->get(tool_other::type_id_to_u64(type, card_id));
    if(!card_ptr)
    {
        log_error("卡不存在card_id=%ld, type=%ld", card_id, type);
        return;
    }

    auto site_ptr=sit_list::instance()->get(enter_site);
    if(!site_ptr)
    {
        log_error("[leave site]%d,%d在分站列表中找不到分站，分站id=%d",card_id,type, enter_site);
        return;
    }

    if(card_ptr->is_person())
    {

    }

    if(card_ptr->is_vehicle())
    {

    }
}
