package com.bonus.system.index.service;

import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.system.index.dao.HomePageDao;
import com.bonus.system.index.entity.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * 首页-业务层
 * @author zys
 */
@Service("homePageService")
public class HomePageServiceImpl implements HomePageService{

    @Resource(name = "homePageDao")
    private HomePageDao homePageDao;

    @Override
    public IndexDataBean getHomePageData(String date) {
        String month = DateUtils.getMonth();
        date = StringUtils.isEmpty(date) ? DateUtils.getDate() : date;
        //今日出勤状态查询
        IndexTodayAttBean todayAttBean = homePageDao.getTodayAttData(date);
        //今日异常统计
        IndexAbnormalBean todayAbnormalBean = homePageDao.getTodayAbnormalData(date);
        //当月轮休、临时外出异常情况
        IndexMonthAbnormalBean monthAbnormalBean = homePageDao.getMonthAbnormalData(month);
        //组织人员
        List<IndexOrgNumBean> orgNumBean = homePageDao.getOrgNumData();
        //当月异常统计
        IndexAbnormalBean monthAbnormalTypeTotalBean = homePageDao.getMonthAbnormalTypeData(month);
        return new IndexDataBean(todayAttBean, todayAbnormalBean, monthAbnormalBean,
                orgNumBean, monthAbnormalTypeTotalBean);
    }

    @Override
    public List<MapBean> getMapData() {
        return homePageDao.getMapData();
    }
}
