diff --git a/core/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java b/core/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java index 556aa7fab4..e242b1bc14 100644 --- a/core/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java +++ b/core/backend/src/main/java/io/dataease/commons/constants/ParamConstants.java @@ -112,6 +112,7 @@ public interface ParamConstants { MSG_TIME_OUT("basic.msgTimeOut"), LOG_TIME_OUT("basic.logTimeOut"), + DS_SYNC_LOG_TIME_OUT("basic.dsSyncLogTimeOut"), DS_CHECK_INTERVAL("basic.dsCheckInterval"), DS_CHECK_INTERVAL_TYPE("basic.dsCheckIntervalType"), DEFAULT_LOGIN_TYPE("basic.loginType"), diff --git a/core/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java b/core/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java index ba7f003500..c4340ab033 100644 --- a/core/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java +++ b/core/backend/src/main/java/io/dataease/controller/sys/response/BasicInfo.java @@ -15,6 +15,8 @@ public class BasicInfo extends LoginLimitInfo implements Serializable { private String msgTimeOut; @ApiModelProperty("日志保留时间") private String logTimeOut; + @ApiModelProperty("数据同步日志保留时间") + private String dsSyncLogTimeOut; @ApiModelProperty("显示首页") private String openHomePage; @ApiModelProperty("默认登录方式") diff --git a/core/backend/src/main/java/io/dataease/service/CleaningRebotService.java b/core/backend/src/main/java/io/dataease/service/CleaningRebotService.java index 7b3f501c47..2288ee25de 100644 --- a/core/backend/src/main/java/io/dataease/service/CleaningRebotService.java +++ b/core/backend/src/main/java/io/dataease/service/CleaningRebotService.java @@ -1,6 +1,7 @@ package io.dataease.service; import io.dataease.ext.CleaningRebotMapper; +import io.dataease.service.dataset.DataSetTableTaskLogService; import io.dataease.service.message.SysMsgService; import io.dataease.service.sys.log.LogService; import org.springframework.beans.factory.annotation.Value; @@ -23,6 +24,8 @@ public class CleaningRebotService { @Resource private SysMsgService sysMsgService; + @Resource + private DataSetTableTaskLogService dataSetTableTaskLogService; public void execute() { int floatDept = 0; @@ -43,5 +46,6 @@ public class CleaningRebotService { } logService.cleanDisusedLog(); sysMsgService.cleanDisusedMsg(); + dataSetTableTaskLogService.cleanLog(); } } diff --git a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskLogService.java b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskLogService.java index 969461a17f..320ea16705 100644 --- a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskLogService.java +++ b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskLogService.java @@ -1,6 +1,7 @@ package io.dataease.service.dataset; import cn.hutool.core.date.DateUtil; +import io.dataease.commons.constants.ParamConstants; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.ServletUtils; import io.dataease.controller.dataset.request.DataSetTaskInstanceGridRequest; @@ -13,6 +14,7 @@ import io.dataease.plugins.common.base.domain.DatasetTableTaskLog; import io.dataease.plugins.common.base.domain.DatasetTableTaskLogExample; import io.dataease.plugins.common.base.mapper.DatasetTableTaskLogMapper; import io.dataease.plugins.common.base.mapper.DatasetTableTaskMapper; +import io.dataease.service.system.SystemParameterService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCell; @@ -29,6 +31,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.OutputStream; import java.net.URLEncoder; +import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.UUID; @@ -46,6 +49,8 @@ public class DataSetTableTaskLogService { private ExtDataSetTaskMapper extDataSetTaskMapper; @Resource private DatasetTableTaskMapper datasetTableTaskMapper; + @Resource + private SystemParameterService systemParameterService; public DatasetTableTaskLog save(DatasetTableTaskLog datasetTableTaskLog, Boolean hasTask) { if (hasTask && datasetTableTaskMapper.selectByPrimaryKey(datasetTableTaskLog.getTaskId()) == null) { @@ -210,5 +215,23 @@ public class DataSetTableTaskLogService { return example; } + private static final String LOG_RETENTION = "30"; + + public void cleanLog() { + String value = systemParameterService.getValue(ParamConstants.BASIC.DS_SYNC_LOG_TIME_OUT.getValue()); + value = StringUtils.isBlank(value) ? LOG_RETENTION : value; + int logRetention = Integer.parseInt(value); + Calendar instance = Calendar.getInstance(); + Calendar startInstance = (Calendar) instance.clone(); + startInstance.add(Calendar.DATE, -logRetention); + startInstance.set(Calendar.HOUR_OF_DAY, 0); + startInstance.set(Calendar.MINUTE, 0); + startInstance.set(Calendar.SECOND, 0); + startInstance.set(Calendar.MILLISECOND, -1); + long timeInMillis = startInstance.getTimeInMillis(); + DatasetTableTaskLogExample example = new DatasetTableTaskLogExample(); + example.createCriteria().andCreateTimeLessThan(timeInMillis); + datasetTableTaskLogMapper.deleteByExample(example); + } } diff --git a/core/backend/src/main/java/io/dataease/service/system/SystemParameterService.java b/core/backend/src/main/java/io/dataease/service/system/SystemParameterService.java index f4c5bc0207..2168abbcdc 100644 --- a/core/backend/src/main/java/io/dataease/service/system/SystemParameterService.java +++ b/core/backend/src/main/java/io/dataease/service/system/SystemParameterService.java @@ -82,6 +82,9 @@ public class SystemParameterService { if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.LOG_TIME_OUT.getValue())) { result.setLogTimeOut(param.getParamValue()); } + if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.DS_SYNC_LOG_TIME_OUT.getValue())) { + result.setDsSyncLogTimeOut(param.getParamValue()); + } if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.DEFAULT_LOGIN_TYPE.getValue())) { String paramValue = param.getParamValue(); result.setLoginType(StringUtils.isNotBlank(paramValue) ? Integer.parseInt(paramValue) : 0); diff --git a/core/frontend/src/lang/en.js b/core/frontend/src/lang/en.js index 617806473a..19d7844838 100644 --- a/core/frontend/src/lang/en.js +++ b/core/frontend/src/lang/en.js @@ -890,6 +890,7 @@ export default { request_timeout: 'Request timeout', message_retention_time: 'Message retention time', log_retention_time: 'Log retention time', + ds_sync_log_retention_time: 'Data sync log retention time', ds_check_time: 'Data source detection interval', test_mail_recipient: 'Used only as a test mail recipient', to_enable_tsl: 'If the SMTP port is 587, you usually need to enable TSL', diff --git a/core/frontend/src/lang/tw.js b/core/frontend/src/lang/tw.js index d5deca71ac..af5aa0f52d 100644 --- a/core/frontend/src/lang/tw.js +++ b/core/frontend/src/lang/tw.js @@ -889,6 +889,7 @@ export default { request_timeout: '請求超時時間', message_retention_time: '消息保留時間', log_retention_time: '日誌保留時間', + ds_sync_log_retention_time: '数据同步日誌保留時間', ds_check_time: '數據源檢測時間間隔', test_mail_recipient: '僅用來作為測試郵件收件人', to_enable_tsl: '如果SMTP埠是587,通常需要啟用TSL', diff --git a/core/frontend/src/lang/zh.js b/core/frontend/src/lang/zh.js index b4db1cadf6..dc0ca4b1fd 100644 --- a/core/frontend/src/lang/zh.js +++ b/core/frontend/src/lang/zh.js @@ -888,6 +888,7 @@ export default { request_timeout: '请求超时时间', message_retention_time: '消息保留时间', log_retention_time: '日志保留时间', + ds_sync_log_retention_time: '数据同步日志保留时间', ds_check_time: '数据源检测时间间隔', test_mail_recipient: '仅用来作为测试邮件收件人', to_enable_tsl: '如果SMTP端口是587,通常需要启用TSL', diff --git a/core/frontend/src/views/system/sysParam/BasicSetting.vue b/core/frontend/src/views/system/sysParam/BasicSetting.vue index 6af1c4f9bc..475b66afbe 100644 --- a/core/frontend/src/views/system/sysParam/BasicSetting.vue +++ b/core/frontend/src/views/system/sysParam/BasicSetting.vue @@ -84,6 +84,18 @@ >{{ $t('components.day') }} + + + +