package com.zcloud.personnel.positioning.persistence.mapper;

import com.zcloud.personnel.positioning.persistence.dataobject.PersonnelLocalPersonDO;
import com.zcloud.personnel.positioning.persistence.dataobject.PersonnelMappingSnapshotDO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalBindingSnapshotDO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalLocationSnapshotDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface PersonnelMatchMapper {
    long countActive(@Param("sourceConfigCode") String sourceConfigCode);

    long countAll();

    long countMatched();

    LocalDateTime maxLastSyncTime(@Param("sourceConfigCode") String sourceConfigCode);

    int upsert(@Param("params") Map<String, Object> params);

    int disableMissing(@Param("sourceConfigCode") String sourceConfigCode,
                       @Param("syncTime") LocalDateTime syncTime);

    int updateOnline(@Param("sourceConfigCode") String sourceConfigCode,
                     @Param("terminalNo") String terminalNo,
                     @Param("deviceStatus") String deviceStatus,
                     @Param("syncTime") LocalDateTime syncTime);

    int markStaleOffline(@Param("sourceConfigCode") String sourceConfigCode,
                         @Param("syncTime") LocalDateTime syncTime);

    List<PersonnelMappingSnapshotDO> listMatched(@Param("params") Map<String, Object> params);

    List<PersonnelLocalPersonDO> listPeopleByPhones(@Param("values") List<String> values);

    List<PersonnelLocalPersonDO> listPeopleByTerminalNos(@Param("values") List<String> values);

    List<TerminalBindingSnapshotDO> listTerminalBindingsByIdCardNos(@Param("values") List<String> values);

    List<TerminalLocationSnapshotDO> listTerminals(@Param("values") List<String> values);
}
