更改定时任务的位置
This commit is contained in:
parent
959ffe6b2e
commit
31580190e2
@ -14,7 +14,6 @@ import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/export")
|
||||
@ConditionalOnProperty(name = "switch.auto-export-and-upload", havingValue = "true", matchIfMissing = true)
|
||||
public class ExportController {
|
||||
|
||||
@Resource
|
||||
|
||||
50
dsp/src/main/java/com/jsc/dsp/task/AutoUpload.java
Normal file
50
dsp/src/main/java/com/jsc/dsp/task/AutoUpload.java
Normal file
@ -0,0 +1,50 @@
|
||||
package com.jsc.dsp.task;
|
||||
|
||||
import com.jsc.dsp.service.ConfigService;
|
||||
import com.jsc.dsp.utils.AutoExportAndUpload;
|
||||
import com.jsc.dsp.utils.DatabaseConnector;
|
||||
import com.jsc.dsp.utils.FTPConnector;
|
||||
import com.jsc.dsp.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(name = "switch.auto-export-and-upload", havingValue = "true", matchIfMissing = true)
|
||||
public class AutoUpload {
|
||||
|
||||
@Resource
|
||||
AutoExportAndUpload autoExportAndUploadComponent;
|
||||
|
||||
@Value("${custom.ftpUploadPath}")
|
||||
String ftpUploadPath;
|
||||
|
||||
@Scheduled(cron = "${custom.exportTaskSchedule}")
|
||||
public void exportNewsDataAndUpload() {
|
||||
autoExportAndUploadComponent.exportDataAndUpload();
|
||||
}
|
||||
|
||||
}
|
||||
@ -29,7 +29,6 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(name = "switch.auto-export-and-upload", havingValue = "true", matchIfMissing = true)
|
||||
public class AutoExportAndUpload {
|
||||
|
||||
@Resource
|
||||
@ -62,7 +61,6 @@ public class AutoExportAndUpload {
|
||||
/**
|
||||
* 每周一、三、五的早上8点,执行导出数据的任务
|
||||
*/
|
||||
@Scheduled(cron = "${custom.exportTaskSchedule}")
|
||||
public void exportDataAndUpload() {
|
||||
logger.info("开始导出excel和pdf数据...");
|
||||
String lastLoadTime = configService.getConfigValueByName("last_loadtime");
|
||||
@ -77,12 +75,8 @@ public class AutoExportAndUpload {
|
||||
zipAndUploadDirectory(excelOutputPath, zipFileFullName, remoteZipPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每周一、三、五的早上8点,执行导出数据的任务
|
||||
*/
|
||||
@Scheduled(cron = "${custom.exportTaskSchedule}")
|
||||
public void exportTwitterDataAndUpload() {
|
||||
logger.info("开始导出twitter excel和pdf数据...");
|
||||
logger.info("开始导出twitter excel数据...");
|
||||
String twitterLastLoadTime = configService.getConfigValueByName("twitter_last_loadtime");
|
||||
String currentLoadTime = StringUtils.DateToString(new Date());
|
||||
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user