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

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

import com.jpsoft.shinestar.modules.base.entity.WorkPersonScheduling;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.jpsoft.shinestar.modules.business.entity.WorkScheduleAttendance;
import java.util.Map;
import com.jpsoft.shinestar.modules.common.dto.Sort;

@Repository
public interface WorkScheduleAttendanceDAO {
	int insert(WorkScheduleAttendance entity);
	int update(WorkScheduleAttendance entity);
	int exist(String id);
	WorkScheduleAttendance get(String id);
	int delete(String id);
	List<WorkScheduleAttendance> list();
	List<WorkScheduleAttendance> search(Map<String,Object> searchParams,List<Sort> sortList);

	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);


    WorkScheduleAttendance findByPersonIdShiftIdAttendanceDateClassifyResult(long personId, String workShiftId, String date, String classify,String result);
    WorkScheduleAttendance findByPersonIdRecordTimeResult(long personId, String recordTime, String result);
    List<Long> findPersonIdListRecordTimeResult(String attendanceDate, String result);
	List<WorkScheduleAttendance> findByPersonScheduleIdAndClassify(String personScheduleId, String workShiftId, String classify);
	WorkScheduleAttendance findLastByPersonScheduleIdAndClassify(String personScheduleId, String workShiftId, String classify);
    List<WorkScheduleAttendance> findByPersonIdAndDate(Long personId, Date beginDate, Date endDate,String result ,String workStatus);
    int deleteByPersonIdAndAttendanceDate(Long personId, String attendanceDate);
    int deleteByPersonIdAndAttendanceDateAndExcludeShiftId(Long personId, String attendanceDate, String shiftIds);
    int deleteByPersonIdAndAttendanceDateAndExcludeSchedule(Long personId, String attendanceDate, WorkPersonScheduling workPersonScheduling);

	List<WorkScheduleAttendance> findGroupByPersonIdAndMonthsAndResult(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);
	List<WorkScheduleAttendance> findNotGroupByPersonIdAndMonthsAndResult(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);
	List<WorkScheduleAttendance> findAbsenteeismGroupByPersonIdAndMonthsAndResult(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);
	double findSumLMinuteByParams(Long personId, Date startDate, Date endDate, Map<String, Object> searchParams);
	int findCountByParams(Long personId, Date startDate, Date endDate,Map<String, Object> searchParams);

	List<WorkScheduleAttendance> numListSearch(Map<String, Object> searchParams, List<Sort> sortList);
	List<Integer> findHqWorkTimeByPersonIdAndSEDate(Long personId, Date startDate,Date endDate);
	List<Integer> findHqCloseTimeByPersonIdAndSEDate(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(@Param("limit") int limit);

    int updateWorkMinute(WorkScheduleAttendance wsa);

	double 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);

    void updateScheduleByPersonIdAndAttendanceDate(Long personId, String dateStr, String personScheduleId, String shiftId);

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