package com.mortals.xhx.module.attendance.service.impl;

import com.mortals.xhx.module.attendance.model.AttendanceStaffStatEntity;
import com.mortals.xhx.module.attendance.model.AttendanceStaffStatQuery;
import com.mortals.xhx.module.attendance.service.AttendanceStaffStatService;
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.AttendanceStatDao;
import com.mortals.xhx.module.attendance.model.AttendanceStatEntity;
import com.mortals.xhx.module.attendance.service.AttendanceStatService;

import java.util.List;

/**
 * AttendanceStatService
 * 考勤汇总信息 service实现
 *
 * @author zxfei
 * @date 2023-04-08
 */
@Service("attendanceStatService")
public class AttendanceStatServiceImpl extends AbstractCRUDServiceImpl<AttendanceStatDao, AttendanceStatEntity, Long> implements AttendanceStatService {
    @Autowired
    private AttendanceStaffStatService attendanceStaffStatService;

    @Override
    protected void findAfter(AttendanceStatEntity entity, Context context, List<AttendanceStatEntity> list) throws AppException {

        list.forEach(item -> {
            AttendanceStaffStatQuery staffStatQuery = new AttendanceStaffStatQuery();
            staffStatQuery.setStaffId(entity.getStaffId());
            //比较 year  month day todo
//            staffStatQuery.setYear(year);//相等
//            staffStatQuery.setYearStart();
//            staffStatQuery.setYearEnd();
            //month and day  同上
            List<AttendanceStaffStatEntity> attendanceStaffStatEntities = attendanceStaffStatService.find(staffStatQuery);
           item.setAttendanceStaffStatEntities(attendanceStaffStatEntities);

        });


        super.findAfter(entity, context, list);
    }
}