
package com.lideeyunji.core.framework.config.job;

import cn.hutool.core.date.DateUtil;
import com.lideeyunji.core.framework.service.ILideeYunJiService;
import com.lideeyunji.tool.framework.yunji.component.properties.lideeYunjiProperties;
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
import com.lideeyunji.tool.framework.tenant.core.aop.TenantIgnore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 删除excel临时表数据
 */
@Component
@Slf4j
public class ClearExcelDataJob implements JobHandler {

    @Autowired
    private ILideeYunJiService lideeYunJiService;

    @Override
    @TenantIgnore
    public String execute(String param) {
        log.info("*********** 开始清理Excel Data日志 ************");
        Date now = DateUtil.date();
        Integer day = lideeYunjiProperties.getExcelDay();

        //x天之前
        Date clearDate = DateUtil.offsetDay(now, -day);

        Integer clearCou = lideeYunJiService.clearExcelData(clearDate);

        String resultStr="*********** Excel Data日志清理完成，共清理了"+clearCou+"条 ************";
        log.info(resultStr);
        return resultStr;
    }

}
