Merge pull request #9445 from dataease/pr@dev@fixExportData

fix: 基础参数中增加后台导出文件保留时间配置项
This commit is contained in:
taojinlong 2024-04-29 15:41:18 +08:00 committed by GitHub
commit 3f625a4ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 68 additions and 5 deletions

View File

@ -113,6 +113,7 @@ public interface ParamConstants {
LOG_TIME_OUT("basic.logTimeOut"),
DS_SYNC_LOG_TIME_OUT("basic.dsSyncLogTimeOut"),
EXPORT_FILE_TIME_OUT("basic.exportFileTimeOut"),
DS_CHECK_INTERVAL("basic.dsCheckInterval"),
DS_CHECK_INTERVAL_TYPE("basic.dsCheckIntervalType"),
DEFAULT_LOGIN_TYPE("basic.loginType"),

View File

@ -17,6 +17,8 @@ public class BasicInfo extends LoginLimitInfo implements Serializable {
private String logTimeOut;
@ApiModelProperty("数据同步日志保留时间")
private String dsSyncLogTimeOut;
@ApiModelProperty("后台导出文件保留时间")
private String exportFileTimeOut;
@ApiModelProperty("显示首页")
private String openHomePage;
@ApiModelProperty("默认登录方式")

View File

@ -2,6 +2,7 @@ package io.dataease.service;
import io.dataease.ext.CleaningRebotMapper;
import io.dataease.service.dataset.DataSetTableTaskLogService;
import io.dataease.service.exportCenter.ExportCenterService;
import io.dataease.service.message.SysMsgService;
import io.dataease.service.sys.log.LogService;
import org.springframework.beans.factory.annotation.Value;
@ -27,6 +28,8 @@ public class CleaningRebotService {
@Resource
private DataSetTableTaskLogService dataSetTableTaskLogService;
@Resource
private ExportCenterService exportCenterService;
public void execute() {
int floatDept = 0;
do {
@ -47,5 +50,6 @@ public class CleaningRebotService {
logService.cleanDisusedLog();
sysMsgService.cleanDisusedMsg();
dataSetTableTaskLogService.cleanLog();
exportCenterService.cleanLog();
}
}

View File

@ -1136,10 +1136,10 @@ public class ChartDataBuild {
} else {
switch (columnPermissionItem.getDesensitizationRule().getCustomBuiltInRule()) {
case RetainBeforeMAndAfterN:
if (StringUtils.isEmpty(originStr) || originStr.length() <= columnPermissionItem.getDesensitizationRule().getM() + columnPermissionItem.getDesensitizationRule().getN() + 1) {
if (StringUtils.isEmpty(originStr) || originStr.length() < columnPermissionItem.getDesensitizationRule().getM() + columnPermissionItem.getDesensitizationRule().getN()) {
desensitizationStr = String.join("", Collections.nCopies(columnPermissionItem.getDesensitizationRule().getM(), "X")) + "***" + String.join("", Collections.nCopies(columnPermissionItem.getDesensitizationRule().getN(), "X"));
} else {
desensitizationStr = StringUtils.substring(originStr, 0, columnPermissionItem.getDesensitizationRule().getM()) + "***" + StringUtils.substring(originStr, originStr.length() - columnPermissionItem.getDesensitizationRule().getN() - 1, originStr.length());
desensitizationStr = StringUtils.substring(originStr, 0, columnPermissionItem.getDesensitizationRule().getM()) + "***" + StringUtils.substring(originStr, originStr.length() - columnPermissionItem.getDesensitizationRule().getN(), originStr.length());
}
break;
case RetainMToN:

View File

@ -1,8 +1,8 @@
package io.dataease.service.exportCenter;
import com.alibaba.excel.EasyExcel;
import com.google.gson.Gson;
import io.dataease.auth.api.dto.CurrentUserDto;
import io.dataease.commons.constants.ParamConstants;
import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.utils.*;
import io.dataease.controller.request.chart.ChartExtRequest;
@ -39,6 +39,7 @@ import io.dataease.service.dataset.*;
import io.dataease.service.datasource.DatasourceService;
import io.dataease.service.engine.EngineService;
import io.dataease.service.panel.PanelGroupService;
import io.dataease.service.system.SystemParameterService;
import io.dataease.websocket.entity.WsMessage;
import io.dataease.websocket.service.WsService;
import org.apache.commons.collections4.CollectionUtils;
@ -50,6 +51,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
@ -72,6 +74,8 @@ import java.util.stream.Collectors;
@Service
public class ExportCenterService {
@Resource
private SystemParameterService systemParameterService;
@Resource
private ChartViewMapper chartViewMapper;
@Resource
@ -360,7 +364,8 @@ public class ExportCenterService {
public void addTask(String exportFrom, String exportFromType, PanelViewDetailsRequest request) {
ExportTask exportTask = new ExportTask();
exportTask.setId(UUID.randomUUID().toString());
exportTask.setUserId(AuthUtils.getUser().getUserId());
CurrentUserDto u = (CurrentUserDto) SecurityUtils.getSubject().getPrincipal();
exportTask.setUserId(u.getUserId());
exportTask.setExportFrom(exportFrom);
exportTask.setExportFromType(exportFromType);
exportTask.setExportStatus("PENDING");
@ -1329,7 +1334,27 @@ public class ExportCenterService {
map.put("data", jsonArray);
return map;
}
private static final String LOG_RETENTION = "30";
public void cleanLog() {
String value = systemParameterService.getValue(ParamConstants.BASIC.EXPORT_FILE_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();
ExportTaskExample exportTaskExample = new ExportTaskExample();
ExportTaskExample.Criteria criteria = exportTaskExample.createCriteria();
criteria.andExportTimeLessThan(timeInMillis);
exportTaskMapper.selectByExample(exportTaskExample).forEach(exportTask -> {
delete(exportTask.getId());
});
}
}

View File

@ -87,6 +87,9 @@ public class SystemParameterService {
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.DS_SYNC_LOG_TIME_OUT.getValue())) {
result.setDsSyncLogTimeOut(param.getParamValue());
}
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.EXPORT_FILE_TIME_OUT.getValue())) {
result.setExportFileTimeOut(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);

View File

@ -1082,6 +1082,7 @@ export default {
message_retention_time: 'Message retention time',
log_retention_time: 'Log retention time',
ds_sync_log_retention_time: 'Data sync log retention time',
export_file_retention_time: 'Export file 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',

View File

@ -1082,6 +1082,7 @@ export default {
message_retention_time: '消息保留時間',
log_retention_time: '日誌保留時間',
ds_sync_log_retention_time: '數據同步日誌保留時間',
export_file_retention_time: '导出文件保留時間',
ds_check_time: '數據源檢測時間間隔',
test_mail_recipient: '僅用來作為測試郵件收件人',
to_enable_tsl: '如果SMTP埠是587通常需要啟用TSL',

View File

@ -1077,6 +1077,7 @@ export default {
message_retention_time: '消息保留时间',
log_retention_time: '日志保留时间',
ds_sync_log_retention_time: '数据同步日志保留时间',
export_file_retention_time: '后台导出文件保留时间',
ds_check_time: '数据源检测时间间隔',
test_mail_recipient: '仅用来作为测试邮件收件人',
to_enable_tsl: '如果SMTP端口是587通常需要启用TSL',

View File

@ -96,6 +96,18 @@
>{{ $t('components.day') }}</template></el-input>
</el-form-item>
<el-form-item
:label="$t('system_parameter_setting.export_file_retention_time')"
prop="exportFileTimeOut"
>
<el-input
v-model="formInline.exportFileTimeOut"
:placeholder="$t('system_parameter_setting.empty_msg')"
><template
slot="append"
>{{ $t('components.day') }}</template></el-input>
</el-form-item>
<el-form-item :label="$t('system_parameter_setting.ds_check_time')">
<el-form
:inline="true"
@ -303,6 +315,13 @@ export default {
trigger: 'blur'
}
],
exportFileTimeOut: [
{
pattern: '^([1-9]|[1-9][0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-5])$',
message: this.$t('system_parameter_setting.msg_error'),
trigger: 'blur'
}
],
limitTimes: [
{ validator: this.validateNumber, trigger: 'blur' }
@ -430,6 +449,12 @@ export default {
type: 'text',
sort: 2
},
{
paramKey: 'basic.exportFileTimeOut',
paramValue: this.formInline.exportFileTimeOut,
type: 'text',
sort: 2
},
{
paramKey: 'basic.loginType',
paramValue: this.formInline.loginType,