推特推文信息打包逻辑优化
This commit is contained in:
parent
31580190e2
commit
49d20396b2
@ -43,10 +43,11 @@ public class ExportController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/triggerTwitterTask")
|
||||
public ReturnT<String> triggerTwitterTask() {
|
||||
@PostMapping("/exportTwitterExcel")
|
||||
public ReturnT<String> triggerTwitterTask(@RequestBody JSONObject object) {
|
||||
try {
|
||||
new Thread(() -> autoExportAndUpload.exportTwitterDataAndUpload()).start();
|
||||
String startTime = object.getString("startTime");
|
||||
new Thread(() -> autoExportAndUpload.exportTwitterDataAndUpload(startTime)).start();
|
||||
return new ReturnT<>(200, "", "");
|
||||
} catch (Exception e) {
|
||||
return new ReturnT<>(500, e.getMessage(), "");
|
||||
|
||||
@ -75,13 +75,13 @@ public class AutoExportAndUpload {
|
||||
zipAndUploadDirectory(excelOutputPath, zipFileFullName, remoteZipPath);
|
||||
}
|
||||
|
||||
public void exportTwitterDataAndUpload() {
|
||||
public void exportTwitterDataAndUpload(String startTime) {
|
||||
logger.info("开始导出twitter excel数据...");
|
||||
String twitterLastLoadTime = configService.getConfigValueByName("twitter_last_loadtime");
|
||||
// String twitterLastLoadTime = configService.getConfigValueByName("twitter_last_loadtime");
|
||||
String currentLoadTime = StringUtils.DateToString(new Date());
|
||||
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
databaseConnector.twitterToXlsx(twitterLastLoadTime);
|
||||
copyPagesFiles(twitterLastLoadTime, currentLoadTime);
|
||||
databaseConnector.twitterToXlsx(startTime);
|
||||
copyPagesFiles(startTime, currentLoadTime);
|
||||
configService.setConfigValueByName("twitter_last_loadtime", currentLoadTime);
|
||||
String zipFileName = "data_twitter-" + timestamp + "-001.zip";
|
||||
String zipFileFullName = backupFilePath + File.separator + zipFileName;
|
||||
@ -124,16 +124,16 @@ public class AutoExportAndUpload {
|
||||
}
|
||||
|
||||
// 上传 ZIP 文件
|
||||
try (InputStream zipInputStream = Files.newInputStream(localZipFile)) {
|
||||
boolean uploaded = ftpConnector.uploadFile(zipInputStream, remoteZipPath);
|
||||
if (uploaded) {
|
||||
logger.info("ZIP 文件上传成功 - 本地: {}, FTP: {}", localZipPath, remoteZipPath);
|
||||
} else {
|
||||
logger.error("ZIP 文件上传失败 - FTP: {}", remoteZipPath);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error("读取本地 ZIP 文件失败: {}", localZipPath, e);
|
||||
}
|
||||
// try (InputStream zipInputStream = Files.newInputStream(localZipFile)) {
|
||||
// boolean uploaded = ftpConnector.uploadFile(zipInputStream, remoteZipPath);
|
||||
// if (uploaded) {
|
||||
// logger.info("ZIP 文件上传成功 - 本地: {}, FTP: {}", localZipPath, remoteZipPath);
|
||||
// } else {
|
||||
// logger.error("ZIP 文件上传失败 - FTP: {}", remoteZipPath);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// logger.error("读取本地 ZIP 文件失败: {}", localZipPath, e);
|
||||
// }
|
||||
|
||||
// 注意:此处不再删除 localZipFile,由调用方决定是否保留或清理
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user