package com.mortals.xhx.module.attendance.service.impl;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.module.attendance.dao.AttendanceRecordDetailDao;
import com.mortals.xhx.module.attendance.model.AttendanceRecordDetailEntity;
import com.mortals.xhx.module.attendance.model.AttendanceRecordQuery;
import com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery;
import org.apache.commons.collections4.CollectionUtils;
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.AttendanceStaffStatDao;
import com.mortals.xhx.module.attendance.model.AttendanceStaffStatEntity;
import com.mortals.xhx.module.attendance.service.AttendanceStaffStatService;

import java.util.List;

/**
* AttendanceStaffStatService
* 考勤人员汇总信息 service实现
*
* @author zxfei
* @date 2023-04-08
*/
@Service("attendanceStaffStatService")
public class AttendanceStaffStatServiceImpl extends AbstractCRUDServiceImpl<AttendanceStaffStatDao, AttendanceStaffStatEntity, Long> implements AttendanceStaffStatService {

    @Autowired
    private AttendanceRecordDetailDao attendanceRecordDetailDao;

    @Override
    public List<AttendanceStaffStatEntity> getListExt(AttendanceSummaryQuery params) throws AppException {
        if(params==null){
            throw new AppException("查询条件对象不能为空");
        }
        if(params.getStaffId()==null){
            throw new AppException("人员信息id不能为空");
        }
        if(StringUtils.isEmpty(params.getSummaryTimeStart())||StringUtils.isEmpty(params.getSummaryTimeEnd())){
            throw new AppException("查询日期范围不能为空");
        }

        List<AttendanceStaffStatEntity> list = dao.getListExt(params);
//        if(CollectionUtils.isNotEmpty(list)){
//            for(AttendanceStaffStatEntity entity:list){
//                AttendanceRecordQuery query = new AttendanceRecordQuery();
//                query.setStaffId(entity.getStaffId());
//                String dayStr = entity.getYear()+"-"+entity.getMonth()+"-"+entity.getDay();
//                query.setAttendanceDateStart(dayStr);
//                query.setAttendanceDateEnd(dayStr);
//                List<AttendanceRecordDetailEntity> entityList = attendanceRecordDetailDao.getListByWhere(query);
//                entity.setAttendanceRecordDetail(entityList);
//            }
//        }
        return list;
    }
}