package com.xiang.xservice.common.utils;


import com.xiang.xmc.service.cache.service.IRedisService;
import com.xiang.xservice.common.entity.DayResult;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author: xiang
 * @Date: 2025-10-04 10:34
 */
@Slf4j
@RequiredArgsConstructor
@AllArgsConstructor
public class DateUtils {

    private IRedisService redisService;
    public Boolean validHoliday(DayResult result) {
        if (validHolidayTime(result.getDate(), result.getStatusDesc(), result.getWeek(), result.getStatus()))
            return Boolean.TRUE;
        return Boolean.FALSE;
    }

    private Boolean validHolidayTime(String date, String statusDesc, String week, String status) {
        if (StringUtils.equals(status, "1")) {
            return Boolean.TRUE;
        }
        if (StringUtils.equals(status, "2")) {
            log.info("当前日期:{}, {}, 是工作日", date, week);
            return Boolean.FALSE;
        }
        if (StringUtils.isEmpty(status)) {
            if (StringUtils.equals(week, "周六") || StringUtils.equals(week, "周日")) {
                log.info("当前日期:{}, {}, 是周末", date, week);
                return Boolean.TRUE;
            }
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }
}
