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

import com.jpsoft.shinestar.modules.base.entity.*;
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-20 9:20
 */
@Repository
public interface PersonDeviceFilterLogDAO {

    void insert(PersonDeviceFilterLog personDeviceFilterLog);


    PersonDeviceFilterLog findByPersonIdAndDeviceNoAndTimeZones(@Param("personId") Integer personId, @Param("deviceNo") String deviceNo, @Param("timeZones") String timeZones);

    int update(PersonDeviceFilterLog personDeviceFilterLog);

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

    List<PersonDeviceFilterLog> findByPersonAndDate(@Param("personId") Long personId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    PersonDeviceFilterLog findByPersonOrderTemperature(@Param("personId") Long personId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    List<PersonDeviceFilterLog> temperatureNormalStatistics(String companyCode, BigDecimal temperature, Date startDate, Date endDate);

    List<PersonDeviceFilterLog> temperatureUnusualStatistics(String companyCode, BigDecimal temperature, Date startDate, Date endDate);

    List<PersonDeviceFilterLog> list();

    List<Map<String, Object>> unusualStatistics(String companyCode, Long personId, BigDecimal temperature, Date startDate, Date endDate);

    PersonDeviceFilterLog lastPersonLog(Long personId);

    PersonDeviceFilterLog getByPersonIdAndDate(@Param("personId") Long personId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    PersonDeviceFilterLog get(Long id);

    long countByTimeRangeAndCompanyCode(String companyCode, Long personId, int status, BigDecimal temperatureMax, Date startDate, Date endDate);

    Integer getDayAbnormalNum(@Param("startTime") Date startTime, @Param("endTime") Date endTime, BigDecimal temperatureMax);

    Integer getDayAbnormalNumByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list, BigDecimal temperatureMax);

    Integer getDayNormalNumByCompanyId(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("companyId") String companyId, BigDecimal temperatureMax);

    Integer countDayByPersonIdAndDate(Long personId, Date startDate, Date endDate);

    Integer countDetectedByCompanyId(String companyId, Date startDate, Date endDate);

    long countUndetectedByCompanyCode(String companyCode, List<PersonCompany> personCompanyList, Date startTime, Date endTime);

    List<PersonInfo> findUndetectedByCompanyCode(@Param("searchParams") Map<String, Object> searchParams);

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

    int deleteExpiredVisitorRecord(@Param("limit") int limit);

    List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("companyInfo") CompanyInfo companyInfo);

    long countDetectedByCompanyIds(List<String> companyIds, Date startTime, Date endTime);

    List<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams);

    List<PersonDeviceFilterLog> findByPersonAndDeviceNoAndTime(Long personId, String deviceNo, String startTime, String endTime);

    long countDetectedByCompanyCode(String companyCode, Date startTime, Date endTime);

    List<PersonDeviceFilterLog> findByTimeAndPersonId(String queryTime, Long personId);
}
