package jnpf.attendance.service.impl;

import cn.hutool.core.collection.CollUtil;
import jnpf.attendance.mapper.EnableBalanceMapper;
import jnpf.attendance.service.EnableBalanceService;
import jnpf.base.service.SuperServiceImpl;
import jnpf.entity.attendance.AttendanceEnableBalance;
import jnpf.model.attendance.vo.attendance.OvertimeSalaryHoursJsonVo;
import jnpf.model.attendance.vo.attendance.OvertimeSalaryHoursVo;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 加班余额记录[不存休,仅记录]服务实现
 *
 * @author yanwenfu
 * @create 2025-10-03
 */
@Service
public class EnableBalanceServiceImpl extends SuperServiceImpl<EnableBalanceMapper, AttendanceEnableBalance> implements EnableBalanceService {
    @Override
    public Map<String, OvertimeSalaryHoursVo> getOvertimeSalary(String startDate, String endDate, List<String> userIds) {
        List<OvertimeSalaryHoursVo> list = this.baseMapper.getOvertimeSalary(startDate, endDate, userIds);
        return CollUtil.isNotEmpty(list) ? list.stream().collect(Collectors.toMap(OvertimeSalaryHoursVo::getUserId, v -> v)) : new HashMap<>();
    }

    @Override
    public List<OvertimeSalaryHoursJsonVo> getOvertimeSalaryJson(String startDate, String endDate, List<String> userIds) {
        return this.baseMapper.getOvertimeSalaryJson(startDate, endDate, userIds);
    }
}
