package com.mortals.xhx.module.attendance.service.impl;
import cn.hutool.core.date.DateUtil;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.module.attendance.model.AttendanceRecordDetailQuery;
import com.mortals.xhx.module.attendance.model.AttendanceRecordQuery;
import com.mortals.xhx.module.attendance.service.AttendanceRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.attendance.dao.AttendanceRecordDetailDao;
import com.mortals.xhx.module.attendance.model.AttendanceRecordDetailEntity;
import com.mortals.xhx.module.attendance.service.AttendanceRecordDetailService;

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

/**
* AttendanceRecordDetailService
* 考勤打卡记录详细信息 service实现
*
* @author zxfei
* @date 2023-04-07
*/
@Service("attendanceRecordDetailService")
public class AttendanceRecordDetailServiceImpl extends AbstractCRUDServiceImpl<AttendanceRecordDetailDao, AttendanceRecordDetailEntity, Long> implements AttendanceRecordDetailService {

    @Autowired
    private AttendanceRecordService attendanceRecordService;

  /*  @Override
    public void loadCache() {
        //仅读取当日数据
        log.info("removeAllCache..." + this.getCacheName());
        cacheService.del(this.getCacheName());
        log.info("loadCache..." + this.getCacheName());
        AttendanceRecordQuery attendanceRecordQuery = new AttendanceRecordQuery();
        attendanceRecordQuery.setAttendanceDateStart(DateUtil.today());
        attendanceRecordQuery.setAttendanceDateEnd(DateUtil.today());
        attendanceRecordService.find(attendanceRecordQuery).parallelStream().forEach(item->{
            AttendanceRecordDetailQuery detailQuery = new AttendanceRecordDetailQuery();
            detailQuery.setRecordId(item.getId());
            this.getDao().getList(detailQuery).parallelStream().forEach(entity->{
                this.putCache(entity.getId().toString(), entity);
            });
        });
    }*/

    @Override
    public List<AttendanceRecordDetailEntity> getListByWhere(AttendanceRecordQuery query) {
        return dao.getListByWhere(query);
    }
}