更新定时删除任务
parent
77957dc94a
commit
609b9e6bb6
@ -0,0 +1,95 @@
|
|||||||
|
package com.glxp.api.admin.thread;
|
||||||
|
|
||||||
|
import com.glxp.api.admin.dao.schedule.ScheduledDao;
|
||||||
|
import com.glxp.api.admin.entity.info.ScheduledEntity;
|
||||||
|
import com.glxp.api.admin.req.info.ScheduledRequest;
|
||||||
|
import com.glxp.api.admin.service.basic.BasicDownloadService;
|
||||||
|
import com.glxp.api.admin.service.basic.BasicExportService;
|
||||||
|
import com.glxp.api.admin.service.thrsys.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||||
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
import org.springframework.scheduling.support.CronTrigger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@EnableScheduling
|
||||||
|
public class CleanDataTask implements SchedulingConfigurer {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ScheduledDao scheduledDao;
|
||||||
|
@Resource
|
||||||
|
private BasicExportService basicExportService;
|
||||||
|
@Resource
|
||||||
|
private BasicDownloadService basicDownloadService;
|
||||||
|
@Resource
|
||||||
|
private ThrCorpExportLogService thrCorpExportLogService;
|
||||||
|
@Resource
|
||||||
|
private ThrCorpImportDetailService thrCorpImportDetailService;
|
||||||
|
@Resource
|
||||||
|
private ThrCorpImportLogService thrCorpImportLogService;
|
||||||
|
@Resource
|
||||||
|
private ThrImportLogService thrImportLogService;
|
||||||
|
@Resource
|
||||||
|
private ThrOrderDetailService thrOrderDetailService;
|
||||||
|
@Resource
|
||||||
|
private ThrOrderExportLogService thrOrderExportLogService;
|
||||||
|
@Resource
|
||||||
|
private ThrOrderImportDetailService thrOrderImportDetailService;
|
||||||
|
@Resource
|
||||||
|
private ThrOrderImportLogService thrOrderImportLogService;
|
||||||
|
@Resource
|
||||||
|
private ThrProductsImportLogService thrProductsImportLogService;
|
||||||
|
@Resource
|
||||||
|
private ThrProductsExportLogService thrProductsExportLogService;
|
||||||
|
@Resource
|
||||||
|
private ThrProductsImportDetailService thrProductsImportDetailService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||||
|
taskRegistrar.addTriggerTask(() -> process(),
|
||||||
|
triggerContext -> {
|
||||||
|
ScheduledRequest scheduledRequest = new ScheduledRequest();
|
||||||
|
scheduledRequest.setCronName("ScheduledDeletion");
|
||||||
|
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
|
||||||
|
String cron = scheduledEntity.getCron();
|
||||||
|
if (cron.isEmpty()) {
|
||||||
|
log.error("cron is null");
|
||||||
|
}
|
||||||
|
return new CronTrigger(cron).nextExecutionTime(triggerContext);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void process() {
|
||||||
|
log.info("开始清理 30 天前的历史数据");
|
||||||
|
//删除同步任务
|
||||||
|
log.info("开始删除同步任务历史记录");
|
||||||
|
basicExportService.deleteByTime();
|
||||||
|
//删除下载记录
|
||||||
|
log.info("开始删除下载记录");
|
||||||
|
basicDownloadService.deleteByTime();
|
||||||
|
//删除第三方数据
|
||||||
|
log.info("开始删除第三方数据");
|
||||||
|
thrCorpExportLogService.deleteByTime();
|
||||||
|
thrCorpImportDetailService.deleteByTime();
|
||||||
|
thrCorpImportLogService.deleteByTime();
|
||||||
|
thrImportLogService.deleteByTime();
|
||||||
|
thrOrderDetailService.deleteByTime();
|
||||||
|
thrOrderExportLogService.deleteByTime();
|
||||||
|
thrOrderImportDetailService.deleteByTime();
|
||||||
|
thrOrderImportLogService.deleteByTime();
|
||||||
|
thrProductsImportLogService.deleteByTime();
|
||||||
|
thrProductsExportLogService.deleteByTime();
|
||||||
|
thrProductsImportDetailService.deleteByTime();
|
||||||
|
log.info("历史数据清理完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue