diff --git a/core/core-backend/src/main/java/io/dataease/exportCenter/dao/auto/entity/CoreExportDownloadTask.java b/core/core-backend/src/main/java/io/dataease/exportCenter/dao/auto/entity/CoreExportDownloadTask.java
new file mode 100644
index 0000000000..c2b11aa364
--- /dev/null
+++ b/core/core-backend/src/main/java/io/dataease/exportCenter/dao/auto/entity/CoreExportDownloadTask.java
@@ -0,0 +1,57 @@
+package io.dataease.exportCenter.dao.auto.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+
+/**
+ *
+ * 下载任务列表
+ *
+ *
+ * @author fit2cloud
+ * @since 2025-06-16
+ */
+@TableName("core_export_download_task")
+public class CoreExportDownloadTask implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String id;
+
+ private Long createTime;
+
+ private Long validTime;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Long getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Long createTime) {
+ this.createTime = createTime;
+ }
+
+ public Long getValidTime() {
+ return validTime;
+ }
+
+ public void setValidTime(Long validTime) {
+ this.validTime = validTime;
+ }
+
+ @Override
+ public String toString() {
+ return "CoreExportDownloadTask{" +
+ "id = " + id +
+ ", createTime = " + createTime +
+ ", validTime = " + validTime +
+ "}";
+ }
+}
diff --git a/core/core-backend/src/main/java/io/dataease/exportCenter/dao/auto/mapper/CoreExportDownloadTaskMapper.java b/core/core-backend/src/main/java/io/dataease/exportCenter/dao/auto/mapper/CoreExportDownloadTaskMapper.java
new file mode 100644
index 0000000000..304b623d54
--- /dev/null
+++ b/core/core-backend/src/main/java/io/dataease/exportCenter/dao/auto/mapper/CoreExportDownloadTaskMapper.java
@@ -0,0 +1,18 @@
+package io.dataease.exportCenter.dao.auto.mapper;
+
+import io.dataease.exportCenter.dao.auto.entity.CoreExportDownloadTask;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ *
+ * 下载任务列表 Mapper 接口
+ *
+ *
+ * @author fit2cloud
+ * @since 2025-06-16
+ */
+@Mapper
+public interface CoreExportDownloadTaskMapper extends BaseMapper {
+
+}
diff --git a/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java b/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java
index 24a73ea7ec..9d2513cea2 100644
--- a/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java
+++ b/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java
@@ -180,7 +180,7 @@ public class ExportCenterManage implements BaseExportApi {
public void download(String id, HttpServletResponse response) throws Exception {
- if (!downLoadInfos.stream().anyMatch(downLoadInfo -> downLoadInfo.getId().equals(id))) {
+ if (coreExportDownloadTaskMapper.selectById(id) == null) {
DEException.throwException("任务不存在");
}
CoreExportTask exportTask = coreExportTaskRepository.findById(id).orElse(null);
@@ -367,7 +367,7 @@ public class ExportCenterManage implements BaseExportApi {
exportTask.setExportTime(System.currentTimeMillis());
exportTask.setParams(JsonUtil.toJSONString(request).toString());
exportTask.setExportMachineName(hostName());
- coreExportTaskRepository.saveAndFlush(exportTask);
+ exportTaskMapper.insert(exportTask);
if(busiFlag.equalsIgnoreCase("dashboard")){
exportCenterDownLoadManage.startPanelViewTask(exportTask, request);
}else {
@@ -829,20 +829,27 @@ public class ExportCenterManage implements BaseExportApi {
@DeLog(id = "#p0", ot = LogOT.DOWNLOAD, st = LogST.DATA)
public void generateDownloadUri(String id) {
- if (!downLoadInfos.stream().anyMatch(downLoadInfo -> downLoadInfo.getId().equals(id))) {
- DownLoadInfo downLoadInfo = new DownLoadInfo();
- downLoadInfo.setId(id);
- downLoadInfo.setCreateTime(System.currentTimeMillis());
- downLoadInfo.setValidTime(5L);
- downLoadInfos.add(downLoadInfo);
+ CoreExportDownloadTask coreExportDownloadTask = coreExportDownloadTaskMapper.selectById(id);
+ if (coreExportDownloadTask != null) {
+ coreExportDownloadTask.setCreateTime(System.currentTimeMillis());
+ coreExportDownloadTaskMapper.updateById(coreExportDownloadTask);
+ } else {
+ coreExportDownloadTask = new CoreExportDownloadTask();
+ coreExportDownloadTask.setId(id);
+ coreExportDownloadTask.setCreateTime(System.currentTimeMillis());
+ coreExportDownloadTask.setValidTime(5L);
+ coreExportDownloadTaskMapper.insert(coreExportDownloadTask);
}
}
- private List downLoadInfos = new ArrayList<>();
- @Scheduled(fixedRate = 10 * 1000)
+ @Scheduled(fixedRate = 60 * 60 * 1000)
public void checkDownLoadInfos() {
- downLoadInfos.removeIf(downLoadInfo -> System.currentTimeMillis() - downLoadInfo.createTime > downLoadInfo.validTime * 60 * 1000);
+ coreExportDownloadTaskMapper.selectList(null).forEach(downLoadInfo -> {
+ if (System.currentTimeMillis() - downLoadInfo.getCreateTime() > downLoadInfo.getValidTime() * 60 * 1000) {
+ coreExportDownloadTaskMapper.deleteById(downLoadInfo.getId());
+ }
+ });
}
@Data
diff --git a/core/core-backend/src/main/resources/db/desktop/V2.10.11__ddl.sql b/core/core-backend/src/main/resources/db/desktop/V2.10.11__ddl.sql
new file mode 100644
index 0000000000..04053fbd77
--- /dev/null
+++ b/core/core-backend/src/main/resources/db/desktop/V2.10.11__ddl.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `core_export_download_task`;
+CREATE TABLE `core_export_download_task`
+(
+ `id` varchar(255) NOT NULL,
+ `create_time` bigint(20) DEFAULT NULL,
+ `valid_time` bigint(20) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) COMMENT='下载任务列表';
diff --git a/core/core-backend/src/main/resources/db/migration/V2.10.11__ddl.sql b/core/core-backend/src/main/resources/db/migration/V2.10.11__ddl.sql
new file mode 100644
index 0000000000..04053fbd77
--- /dev/null
+++ b/core/core-backend/src/main/resources/db/migration/V2.10.11__ddl.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `core_export_download_task`;
+CREATE TABLE `core_export_download_task`
+(
+ `id` varchar(255) NOT NULL,
+ `create_time` bigint(20) DEFAULT NULL,
+ `valid_time` bigint(20) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) COMMENT='下载任务列表';