package com.yida.data.attendance.service;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yida.data.attendance.dto.AttendanceCountPageDTO;
import com.yida.data.attendance.dto.AttendanceDayReportDTO;
import com.yida.data.attendance.dto.AttendanceResultByDayDTO;
import com.yida.data.attendance.dto.AttendanceResultByStartAndEndTimeDTO;
import com.yida.data.attendance.dto.AttendanceStatusByMonthDTO;
import com.yida.data.attendance.dto.ManageListUserDTO;
import com.yida.data.attendance.vo.AttdanceResultDetailVO;
import com.yida.data.attendance.vo.AttdanceResultTotalVO;
import com.yida.data.attendance.vo.AttdanceResultVO;
import com.yida.data.attendance.vo.AttendanceRuleVO;
import com.yida.data.attendance.vo.AttendanceStatusByMonthVO;
import com.yida.data.attendance.vo.DateStatusVO;
import com.yida.data.attendance.vo.DownLoadAttendanceResultVO;
import com.yida.data.attendance.vo.ManageListUserAttendanceDetailTotalVO;
import com.yida.data.attendance.vo.ManageListUserAttendanceDetailVO;
import com.yida.data.attendance.vo.ManageListUserVO;
import com.yida.data.attendance.vo.StaRecordCountVO;
import com.yida.data.attendance.vo.StaffIdentityVO;
import com.yida.data.attendance.vo.UserAttendanceResultByDayVO;
import com.yida.data.attendance.vo.UserAttendanceResultByTimeSlotVO;
import com.yida.data.common.core.entity.attendance.attendance.AttendanceRecord;
import com.yida.data.common.core.entity.attendance.attendance.AttendanceResult;
import com.yida.data.common.core.entity.attendance.attendance.AttendanceRule;
import com.yida.data.user.vo.DownLoadPicVO;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 考勤-考勤结果 Service接口
 *
 * @date 2023-08-09 11:37:25
 */
public interface AttendanceResultService extends IService<AttendanceResult> {

    /**
     * 计算保存考勤结果
     *
     * @param record
     */
    @Async
    void addResult(AttendanceRecord record);

    /**
     * 学生考勤-概况统计
     *
     * @param dto
     * @return
     */
    IPage<AttdanceResultVO> listResultPage(AttendanceCountPageDTO dto);

    AttdanceResultTotalVO total(AttendanceCountPageDTO dto);


    void downLocalAttendanceResult(AttendanceCountPageDTO dto, String uuid);


    /**
     * 下载考勤日报
     *
     * @param dto
     * @param uuid
     */
    void downLocalAttendanceDayReport(AttendanceDayReportDTO dto, String uuid);


    /**
     * 学生考勤-明细
     *
     * @param dto
     * @return
     */
    IPage<AttdanceResultDetailVO> listResultDetailPage(AttendanceCountPageDTO dto);

    /**
     * 获取当前月份用户考勤状态汇总--个人
     *
     * @param dto
     * @return
     */
    List<DateStatusVO> getUserAttendanceStatusByMonth(AttendanceStatusByMonthDTO dto);

    /**
     * 获取某日用户考勤结果
     *
     * @param attendanceResultByDayDTO
     * @return
     */
    List<UserAttendanceResultByDayVO> getUserAttendanceResultByDay(AttendanceResultByDayDTO attendanceResultByDayDTO);

    /**
     * 获取某时间段内用户考勤结果统计
     *
     * @param dto
     * @return
     */
    UserAttendanceResultByTimeSlotVO getUserAttendanceResultByTimeSlot(AttendanceResultByStartAndEndTimeDTO dto);


    /**
     * 查询管理员日历展示状态
     *
     * @param dto
     * @return
     */
    List<DateStatusVO> findTotalUserStatus(ManageListUserDTO dto);


    /**
     * 查询管理员管理考勤统计
     *
     * @param dto
     * @return
     */
    List<ManageListUserVO> findManageListUserVO(ManageListUserDTO dto);

    /**
     * 职工查看管理考勤明细
     *
     * @param dto
     * @return
     */
    JSONObject findManageListUserDetailVO(ManageListUserDTO dto);


    /**
     * 职工查看管理考勤明细-汇总
     *
     * @param dto
     * @return
     */
    ManageListUserAttendanceDetailTotalVO findManageListUserDetailTotalVO(ManageListUserDTO dto);

    /**
     * 职工管理员获取部门树
     *
     * @param userId
     * @param searchUserType
     * @return
     */
    List findManageUserDeptTree(Long userId, Integer searchUserType);


    /**
     * 查询职工身份信息
     *
     * @param staffId
     * @return
     */
    StaffIdentityVO findStaffIdentity(Long staffId);


    /**
     * 每日凌晨先初始化考勤结果
     */
    @Async
    void initUserAttendance();


    /**
     * 每日/每周/每月考勤数据  以便于下载
     */
    @Async
    void initAttendanceReport(Long schoolId, LocalDate currentDate);


    /**
     * 发送迟到提醒
     *
     * @param mode       0=推动至教职工，1=推送至学生家长
     * @param userType   0=职工，1=学生
     * @param ruleId
     * @param ruleTimeId
     * @param staffIds   推送职工ID集合
     * @param isManager  是否推送管理员1=是，0=否
     */
    void lateReport(Integer mode, Integer userType, Long ruleId, Long ruleTimeId, List<Long> staffIds, Integer isManager);


    /**
     * @param mode     0=推动至教职工，1=推送至学生家长
     * @param userType 0=职工，1=学生
     * @param ruleId
     */
    void dayReport(Integer mode, Integer userType, Long ruleId);


    /**
     * 系统首页考勤概况统计
     *
     * @param startDate
     * @param endDate
     * @param schoolIds
     * @return
     */
    StaRecordCountVO staRecordCount(LocalDate startDate, LocalDate endDate, List<Long> schoolIds);

}
