package jnpf.attendance.service;

import jnpf.base.UserInfo;
import jnpf.base.service.SuperService;
import jnpf.entity.attendance.AttendanceClockInResult;
import jnpf.entity.attendance.AttendanceMachineManage;
import jnpf.entity.attendance.FtbAttendanceDailyRule;
import jnpf.exception.QueryException;

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

/**
 * 打卡服务2.0
 *
 * @author yanwenfu
 * @create 2025-09-23
 */
public interface ClockInResultService extends SuperService<AttendanceClockInResult> {

    /**
     * 查询今天可以打卡的出勤规则
     * @param today 日期
     * @param userInfo 用户信息
     * @return java.util.List<jnpf.entity.attendance.FtbAttendanceDailyRule>
     */
    List<FtbAttendanceDailyRule> getTodayRuleList(Date today, UserInfo userInfo);

    /**
     * 查询所有用户今天可以打卡的出勤规则
     * @param today 日期
     * @param userId 用户id(有则查单人, 无则查全部)
     * @return java.util.List<jnpf.entity.attendance.FtbAttendanceDailyRule>
     */
    Map<String, List<FtbAttendanceDailyRule>> getTodayRuleListByUser(Date today, String userId);

    /**
     * 查询指定用户的出勤规则[批量]
     * @param groupedMap k:userId_targetDate v:当日+前一日的出勤规则
     * @param userGroupMap 用户考勤组map
     * @return java.util.Map<java.lang.String,java.util.List<jnpf.entity.attendance.FtbAttendanceDailyRule>>
     */
    Map<String, List<FtbAttendanceDailyRule>> getRuleListByUserDay(Map<String, List<FtbAttendanceDailyRule>> groupedMap, Map<String, List<String>> userGroupMap);

    /**
     * 清除异常的出勤规则
     * @param ruleList 出勤规则列表
     * @param userId 用户id
     * @return java.util.List<jnpf.entity.attendance.FtbAttendanceDailyRule>
     */
    List<FtbAttendanceDailyRule> clearErrorRule(List<FtbAttendanceDailyRule> ruleList, String userId, Date date, List<String> effectGroupIds);

    /**
     * 获取用户绑定的考勤机
     * @param userId 用户id
     * @return java.util.List<jnpf.entity.attendance.AttendanceMachineManage>
     */
    List<AttendanceMachineManage> getMachineList(String userId, String tenantId);
}
