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

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

import cn.hutool.core.date.DateTime;
import com.jpsoft.shinestar.modules.business.entity.WorkScheduleAttendance;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;

public interface WorkScheduleAttendanceService {
	WorkScheduleAttendance get(String id);
	boolean exist(String id);
	int insert(WorkScheduleAttendance model);
	int update(WorkScheduleAttendance model);
	int delete(String id);
	List<WorkScheduleAttendance> list();
	Page<WorkScheduleAttendance> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
    boolean punchIn(String deviceNo, Long personId, BigDecimal temperature, Date recordTime);

	List<Date> findAttendanceDateByPersonAndMonths(Long personId, List<String> months);
	List<String> findShiftByPersonAndAttendanceDate(Long personId, String attendanceDate);

	List<WorkScheduleAttendance> findByPersonIdAndShiftIdAndAttendanceDate(Long personId,String shiftId,String attendanceDate);
	int findFullAttendanceCount(Long personId, List<String> months);


	/**
	 * 批量更新考勤记录
	 * @param companyId 所属单位
	 * @param personId 指定人员编号（可以为空）
	 * @param startDate 起始时间
	 * @param endDate	结束时间
	 * @param append    添加打卡记录（手动批量更新设为true，定时批量更新时设为false）
	 * @return
	 */
    int batchUpdate(String companyId,String workShiftId,Long personId,String personName, Date startDate, Date endDate,boolean append);

    WorkScheduleAttendance findByPersonIdShiftIdAttendanceDateClassifyResult(long personId, String workShiftId, String date, String classify,String result);

    WorkScheduleAttendance findByPersonIdRecordTimeResult(long personId, String recordTime, String result);

    List<WorkScheduleAttendance> listSearch(Map<String, Object> searchParams,List<Sort> sortList);

	List<Long> findPersonIdListRecordTimeResult(String attendanceDate, String result);

	WorkScheduleAttendance findLastByPersonScheduleIdAndClassify(String personScheduleId, String workShiftId, String classify);
	List<WorkScheduleAttendance> findByPersonIdAndDate(Long personId, Date beginDate, Date endDate,String result ,String workStatus);

	/**
	 * 查询旷工和全勤
	 * 根据日期和班次去重
	 * 根据result 查询数据大于1的
	 * 每日
	 * @param personId
	 * @return
	 */
	List<WorkScheduleAttendance> findGroupByPersonIdAndMonthsAndResult(Long personId, Date startDate, Date endDate,String result);
	BigDecimal findAbsenteeism(Long personId, Date startDate, Date endDate,String result);
	BigDecimal findTotalAttendance(Long personId, Date startDate, Date endDate,String result);
	Double findSumLMinuteByParams(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);
	int findCountByParams(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);
	BigDecimal findBusinessTripNum(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);
	BigDecimal findLeaveNum(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);

	List<WorkScheduleAttendance> numListSearch(Map<String, Object> searchParams1, List<Sort> sortList1);

    void updatePersonAttendance(Long personId, Date startTime, Date endTime);


	int findHqOvertimeByPersonIdAndSEDate(Long personId, Date startDate,Date endDate);

    WorkScheduleAttendance findOneBySupplementWorkPersonId(String supplementWorkPersonId);

    WorkScheduleAttendance findOneByWorkOverPersonId(String workOverPersonId);

    List<Map> statScheduleAttendanceByDate(Long personId, Date startDate, Date endDate);

    List<WorkScheduleAttendance> findEmptyWorkMinuteList(int limit);

	List<WorkScheduleAttendance> findByPersonScheduleIdAndClassify(String personScheduleId, String workShiftId, String classify);

	int updateWorkMinute(WorkScheduleAttendance wsa);

    BigDecimal findSumWorkMinuteByParams(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);

	List<Map> queryDuplicateRecord(Date startDate, int limit);

	WorkScheduleAttendance findByScheduleAttendanceId(String personScheduleId, String workShiftId, String classify);

    List<WorkScheduleAttendance> findByPersonIdAttendanceDateResult(Long personId, String attendanceDate, String result);
}