package com.jpsoft.shinestar.modules.base.dao;

import com.jpsoft.shinestar.modules.base.entity.CompanyInfo;
import com.jpsoft.shinestar.modules.base.entity.PersonDeviceLog;
import com.jpsoft.shinestar.modules.base.entity.PersonDeviceRelation;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 墨鱼_mo
 * @date 2020-3-15 14:22
 */
@Repository
public interface PersonDeviceLogDAO {
    int insert(PersonDeviceLog personDeviceLog);

    List<PersonDeviceLog> search(Map<String, Object> searchParams, List<Sort> sortList);

    List<PersonDeviceLog> simpleSearch(Map<String, Object> searchParams, List<Sort> sortList);

    List<PersonDeviceLog> findByPersonAndDate(@Param("personId") Long personId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    PersonDeviceLog  get(String id);

    List<Long> queryUnAttendanceList(String companyCode, Date startTime, Date endTime, List<String> excludeCompanyList);
    List<Long> queryAttendanceList(String companyCode, Date startTime, Date endTime, List<String> excludeCompanyList);

    PersonDeviceLog findLastPersonLog(Long personId, float temperatureMax);

    Integer getDayCheckedVistorNumByDeviceNoList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<String> list);


    List<PersonDeviceLog> findAllPersonLogByDeviceNo(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                                                 @Param("deviceNoList") String deviceNoList);

    List<PersonDeviceLog> findAllPersonLogByCompanyIdAndDeviceNo(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                                                 @Param("companyList") List<CompanyInfo> companyList,
                                                                 @Param("deviceNoList") List<String> deviceNoList);

    List<PersonDeviceLog> findLastPersonLogByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("companyList") List<CompanyInfo> list);

    List<PersonDeviceLog> findVisitorLogByDeviceNoList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<String> list, @Param("filter") String filter, @Param("max") BigDecimal max);

    List<PersonDeviceLog> findLastTeacherLogByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list);

    List<PersonDeviceLog> findLastStudentLogByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list);

    Integer getDayCheckedPersonNumByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list, @Param("popedom") String popedom);

    int delete(String id);

    List<PersonDeviceLog> findExpiredVisitorRecord(@Param("limit") int limit);

    long countByAttendance(String companyCode, Date beginDate, Date endDate);

    Integer getDayAbnormalNumByDeviceNoList(Date startTime, Date endTime, List<String> list, BigDecimal temperatureMax);

    PersonDeviceLog findByPersonAndRecordTime(Long personId, Date recordTime);

    List<Long> queryAttendanceListByCompanyId(String companyId, Date startTime, Date endTime);

    List<Long> queryUnAttendanceListByCompanyId(String companyId, Date startTime, Date endTime);

    List<PersonDeviceLog> findByPersonAndDateAndScene(Long personId, Date beginTime, Date endTime, String scene);


    List<PersonDeviceLog> importData();

    int update(PersonDeviceLog personDeviceLog);
}
