package com.qy.worksheetsystem.service.impl;

import com.qy.worksheetsystem.model.mapper.THRATSWorkCalendarItemMapper;
import com.qy.worksheetsystem.service.THRATSWorkCalendarItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class THRATSWorkCalendarItemServiceImpl implements THRATSWorkCalendarItemService {
    @Resource
    private THRATSWorkCalendarItemMapper thratsWorkCalendarItemMapper;

    @Override
    public List<Map<String, String>> selectWorkCalendar(Map map) {
        //0:工作日
        //1：休息日
        //2：法定假日
        List<Map<String, String>> selectWorkCalendar=thratsWorkCalendarItemMapper.selectWorkCalendar(map);
        List<Map<String, String>> mapList = new ArrayList<>();
        log.info(map.toString());
        for (int i = 0; i < selectWorkCalendar.size(); i++) {
            Map<String, String> maps = new HashMap<>();
            Map<String, String> stringStringMap = selectWorkCalendar.get(i);

            String strDate = stringStringMap.get("FDate");
            String date = strDate.substring(0, 10);
            maps.put("date", date);
            maps.put("dateType", stringStringMap.get("dateType"));
            mapList.add(maps);
        }
        return mapList;
    }
}
