package com.hzya.frame.plugin.lets.util;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.hzya.frame.plugin.lets.resultvo.CalculateDateVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：liuyang
 * @Package：com.hzya.frame.plugin.lets.util
 * @Project：kangarooDataCenterV3
 * @name：DateStrUtil
 * @Date：2024/7/30 14:05
 * @Filename：DateStrUtil
 */
public class DateStrUtil {
    /**
     * 计算全天时间段
     *
     * @author liuyang
     */
    public static CalculateDateVo calculateCalculateEntireDayPeriod(String dateStr) {
        List<String> startAndEnd = new ArrayList<>();

        String targetDate = null;
        if (dateStr != null) {
            targetDate = dateStr;
        } else {
            targetDate = calculateYesterdayDate();//拉取'昨天'的日期
        }

        CalculateDateVo calculateDateVo = new CalculateDateVo();
        calculateDateVo.setStart_time(targetDate + " 00:00:00");
        calculateDateVo.setEnd_time(targetDate + " 23:59:59");
        return calculateDateVo;
    }

    /**
     * 计算昨天的单据日期
     *
     * @author liuyang
     */
    public static String calculateYesterdayDate() {
        DateTime yesterdayDate = DateUtil.yesterday();
        return DateUtil.format(yesterdayDate, "yyyy-MM-dd");
    }
}
