package jnpf.attendance.bean;

import jnpf.enums.attendance.ClockInStatusEnum;
import jnpf.util.ConstantUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

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

/**
 * 变更配置
 *
 * @author yanwenfu
 * @create 2024-11-11
 */
@Configuration
@Getter
@Setter
public class ChangeConfig {

    private Map<Integer, Map<ClockInStatusEnum, List<ClockInStatusEnum>>> changeMap = new HashMap<>();

    public ChangeConfig() {
        changeMap.put(ConstantUtil.ON_WORK, getOnWorkMap());
        changeMap.put(ConstantUtil.OFF_WORK, getOffWorkMap());
    }

    private Map<ClockInStatusEnum, List<ClockInStatusEnum>> getOnWorkMap() {

        Map<ClockInStatusEnum, List<ClockInStatusEnum>> map = new HashMap<>();
        map.put(ClockInStatusEnum.NORMAL, List.of(ClockInStatusEnum.WORK_LATE, ClockInStatusEnum.NO_CLOCK));
        map.put(ClockInStatusEnum.WORK_LATE, List.of(ClockInStatusEnum.NORMAL, ClockInStatusEnum.WORK_LATE, ClockInStatusEnum.NO_CLOCK));
        map.put(ClockInStatusEnum.NO_CLOCK, List.of(ClockInStatusEnum.NORMAL, ClockInStatusEnum.WORK_LATE));
        map.put(ClockInStatusEnum.ABSENCE, List.of(ClockInStatusEnum.NORMAL, ClockInStatusEnum.WORK_LATE));
        return map;
    }

    private Map<ClockInStatusEnum, List<ClockInStatusEnum>> getOffWorkMap() {

        Map<ClockInStatusEnum, List<ClockInStatusEnum>> map = new HashMap<>();
        map.put(ClockInStatusEnum.NORMAL, List.of(ClockInStatusEnum.HOME_EARLY, ClockInStatusEnum.NO_CLOCK));
        map.put(ClockInStatusEnum.HOME_EARLY, List.of(ClockInStatusEnum.NORMAL, ClockInStatusEnum.HOME_EARLY, ClockInStatusEnum.NO_CLOCK));
        map.put(ClockInStatusEnum.NO_CLOCK, List.of(ClockInStatusEnum.NORMAL, ClockInStatusEnum.HOME_EARLY));
        map.put(ClockInStatusEnum.ABSENCE, List.of(ClockInStatusEnum.NORMAL, ClockInStatusEnum.HOME_EARLY));
        return map;
    }
}
