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

import cn.hutool.json.JSONObject;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.base.entity.*;
import com.jpsoft.shinestar.modules.common.dto.Sort;

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

/**
 * @author 墨鱼_mo
 * @date 2020-3-20 9:13
 */
public interface PersonDeviceFilterLogService {

    /**
     * 设备自动上传的时间段过人记录
     * @param deviceNo
     * @param temperature
     * @param faceImageJson
     * @param libMatInfoListJson
     * @param matchPersonInfo
     */
    void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date, Integer maskFlag, String faceImageUrl, String address, PersonHealthLedger personHealthLedger);

    Page<PersonDeviceFilterLog> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList);

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

    PersonDeviceFilterLog findByPersonOrderTemperature(Long personId, String startDate, String endDate);

    List<PersonDeviceFilterLog> list();

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

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

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

    PersonDeviceFilterLog lastPersonLog(Long personId);

    PersonDeviceFilterLog getByPersonIdAndDate(Long personId, String startDate, String endDate);

    PersonDeviceFilterLog get(Long id);

    /**
     *
     * @param companyCode
     * @param personId
     * @param status 1-正常，-1-不正常，0-不考虑温度
     * @param temperatureMax
     * @param startTime
     * @param endTime
     * @return
     */
    long countByTimeRangeAndCompanyCode(String companyCode, Long personId, int status, BigDecimal temperatureMax, Date startTime, Date endTime);
    long countUndetectedByCompanyCode(String companyCode, List<PersonCompany> personCompanyList, Date startTime, Date endTime);

    Integer getDayAbnormalNum(Date startTime, Date endTime);

    Integer getDayAbnormalNumByCompanyList(Date startTime, Date endTime, List<CompanyInfo> list);

    Integer getDayNormalNumByCompanyId(Date startTime, Date endTime, String companyId);

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

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

    Page<PersonInfo> findUndetectedPersonList(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count);

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

    int deleteExpiredVisitorRecord(int limit);

    List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(Date beginTime, Date endTime, CompanyInfo companyInfo);

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


    Page<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams, int pageIndex, int pageSize, boolean b);

    void insertFilterLog(String deviceNo, PersonInfo personInfo, BigDecimal temperature, String faceImageUrl, Date recordDate,
                         int matchStatus, String matchMsg, int matchFaceId, String address, PersonHealthLedger personHealthLedger);

    long countDetectedByCompanyCode(String companyCode, Date startDate, Date endDate);

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