package com.bonus.canteen.core.common.export.task;

import com.bonus.canteen.core.common.export.service.ExportRecordService;
import com.bonus.canteen.core.data.dataset.Executors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
public class ExportCancelRunner implements ApplicationRunner {
   private static final Logger log = LoggerFactory.getLogger(ExportCancelRunner.class);
   @Autowired
   @Lazy
   private ExportRecordService exportRecordService;

   @Override
   public void run(ApplicationArguments args) {
      try {
         Executors.doInAllTenant((s) -> {
            this.exportRecordService.cancelAllWaitingAndCreating();
         });
      } catch (Exception var3) {
         log.error("[异步导出]取消所有任务失败", var3);
      }

   }
}
