From 49d20396b29a7f6844f8f95717d9cb3b3701ed35 Mon Sep 17 00:00:00 2001 From: DELL Date: Tue, 27 Jan 2026 10:40:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E7=89=B9=E6=8E=A8=E6=96=87=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=89=93=E5=8C=85=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsc/dsp/controller/ExportController.java | 7 +++-- .../jsc/dsp/utils/AutoExportAndUpload.java | 28 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/dsp/src/main/java/com/jsc/dsp/controller/ExportController.java b/dsp/src/main/java/com/jsc/dsp/controller/ExportController.java index dc7fa2b..11f8514 100644 --- a/dsp/src/main/java/com/jsc/dsp/controller/ExportController.java +++ b/dsp/src/main/java/com/jsc/dsp/controller/ExportController.java @@ -43,10 +43,11 @@ public class ExportController { } } - @PostMapping("/triggerTwitterTask") - public ReturnT triggerTwitterTask() { + @PostMapping("/exportTwitterExcel") + public ReturnT 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(), ""); diff --git a/dsp/src/main/java/com/jsc/dsp/utils/AutoExportAndUpload.java b/dsp/src/main/java/com/jsc/dsp/utils/AutoExportAndUpload.java index 905daa2..763513f 100644 --- a/dsp/src/main/java/com/jsc/dsp/utils/AutoExportAndUpload.java +++ b/dsp/src/main/java/com/jsc/dsp/utils/AutoExportAndUpload.java @@ -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,由调用方决定是否保留或清理 }