package com.sw.mes.yb.scheduled;

import com.sw.mes.core.utils.DateUtil;
import com.sw.mes.core.utils.WbServiceUtils;
import com.sw.mes.third.service.SapGiService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class GiScheduling {
    @Autowired
    private SapGiService sapGiService;

    @XxlJob("sapGiScheduling")
    public void SapGiScheduling() {
        Date nowTime = new Date();
        String sapDate = WbServiceUtils.getSapDate(nowTime);
        //当前时间字符串
        String nowStr = DateUtil.formatDate(nowTime, DateUtil.longFormat);
        String yesterdayStr = DateUtil.formatDate(DateUtil.addDay(nowTime, -1), DateUtil.longFormat);
        sapGiService.sendGi(nowStr, yesterdayStr, sapDate, false);
    }

    @XxlJob("sapMaterialGiScheduling")
    public void SapMaterialGiScheduling() {
        Date nowTime = new Date();
        String sapDate = WbServiceUtils.getSapDate(nowTime);
        //当前时间字符串
        String nowStr = DateUtil.formatDate(nowTime, DateUtil.longFormat);
        String yesterdayStr = DateUtil.formatDate(DateUtil.addDay(nowTime, -1), DateUtil.longFormat);
        sapGiService.sendMaterialGi(nowStr, yesterdayStr, sapDate, false);
    }

    @XxlJob("sapGiSchedulingTest")
    public void sapGiSchedulingTest() {
        Date nowTime = new Date();
        String sapDate = WbServiceUtils.getSapDate(nowTime);
        //当前时间字符串
        String nowStr = DateUtil.formatDate(nowTime, DateUtil.longFormat);
        String yesterdayStr = DateUtil.formatDate(DateUtil.addDay(nowTime, -1), DateUtil.longFormat);
        sapGiService.sendGi(nowStr, yesterdayStr, sapDate, true);
    }

    @XxlJob("sapMaterialGiSchedulingTest")
    public void sapMaterialGiSchedulingTest() {
        Date nowTime = new Date();
        String sapDate = WbServiceUtils.getSapDate(nowTime);
        //当前时间字符串
        String nowStr = DateUtil.formatDate(nowTime, DateUtil.longFormat);
        String yesterdayStr = DateUtil.formatDate(DateUtil.addDay(nowTime, -1), DateUtil.longFormat);
        sapGiService.sendMaterialGi(nowStr, yesterdayStr, sapDate, true);
    }
}
