package org.dromara.payment.timer;

import cn.hutool.core.date.DateUtil;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.dromara.payment.taxRecords.service.ISwMonitorService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author sunzexing
 * @version 1.0
 * @title CreateSwMonitorJob
 * @description  生成完税证明记录
 * @create 2024-07-26 21:46
 */
@Component
public class CreateSwMonitorJob {


    @Resource
    private ISwMonitorService swMonitorService;


    @XxlJob("createSwMonitorJob")
    public void create(){

        Date currentDate = new Date();
        currentDate = DateUtil.offsetDay(currentDate,-5).toJdkDate();

        String month = DateUtil.format(currentDate,"yyyy-MM");
        XxlJobHelper.log("开始生成"+month+"完税证明记录");
        try{
            this.swMonitorService.createSwRecords(currentDate);
            XxlJobHelper.log("结束生成"+month+"完税证明记录");
        }catch (Exception e){
            e.printStackTrace();
            XxlJobHelper.log("生成"+month+"完税证明记录失败"+ e.getMessage());
        }



    }



}
