forked from github/dataease
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
6cfec39d80
@ -32,12 +32,13 @@ public class SysLogController {
|
|||||||
@ApiOperation("查询日志")
|
@ApiOperation("查询日志")
|
||||||
@PostMapping("/logGrid/{goPage}/{pageSize}")
|
@PostMapping("/logGrid/{goPage}/{pageSize}")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(paramType = "path", name = "goPage", value = "页码", required = true, dataType = "Integer"),
|
@ApiImplicitParam(paramType = "path", name = "goPage", value = "页码", required = true, dataType = "Integer"),
|
||||||
@ApiImplicitParam(paramType = "path", name = "pageSize", value = "页容量", required = true, dataType = "Integer"),
|
@ApiImplicitParam(paramType = "path", name = "pageSize", value = "页容量", required = true, dataType = "Integer"),
|
||||||
@ApiImplicitParam(name = "request", value = "查询条件", required = true)
|
@ApiImplicitParam(name = "request", value = "查询条件", required = true)
|
||||||
})
|
})
|
||||||
public Pager<List<SysLogGridDTO>> logGrid(@PathVariable int goPage, @PathVariable int pageSize,
|
public Pager<List<SysLogGridDTO>> logGrid(@PathVariable int goPage, @PathVariable int pageSize,
|
||||||
@RequestBody KeyGridRequest request) {
|
@RequestBody KeyGridRequest request) {
|
||||||
|
request = logService.logRetentionProxy(request);
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
return PageUtils.setPageInfo(page, logService.query(request));
|
return PageUtils.setPageInfo(page, logService.query(request));
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ public class SysLogController {
|
|||||||
@ApiOperation("导出操作日志")
|
@ApiOperation("导出操作日志")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ApiImplicitParam(name = "request", value = "查询条件", required = true)
|
@ApiImplicitParam(name = "request", value = "查询条件", required = true)
|
||||||
public void export(@RequestBody KeyGridRequest request) throws Exception{
|
public void export(@RequestBody KeyGridRequest request) throws Exception {
|
||||||
logService.exportExcel(request);
|
logService.exportExcel(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package io.dataease.service;
|
package io.dataease.service;
|
||||||
|
|
||||||
import io.dataease.ext.CleaningRebotMapper;
|
import io.dataease.ext.CleaningRebotMapper;
|
||||||
|
import io.dataease.service.sys.log.LogService;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -16,6 +17,9 @@ public class CleaningRebotService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CleaningRebotMapper cleaningRebotMapper;
|
private CleaningRebotMapper cleaningRebotMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LogService logService;
|
||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
int floatDept = 0;
|
int floatDept = 0;
|
||||||
do {
|
do {
|
||||||
@ -33,5 +37,6 @@ public class CleaningRebotService {
|
|||||||
cleaningRebotMapper.delFloatingCreatorLink();
|
cleaningRebotMapper.delFloatingCreatorLink();
|
||||||
cleaningRebotMapper.delFloatingCreatorLinkMapping();
|
cleaningRebotMapper.delFloatingCreatorLinkMapping();
|
||||||
}
|
}
|
||||||
|
logService.cleanDisusedLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||||
|
import io.dataease.commons.constants.ParamConstants;
|
||||||
import io.dataease.commons.constants.SysLogConstants;
|
import io.dataease.commons.constants.SysLogConstants;
|
||||||
import io.dataease.commons.utils.AuthUtils;
|
import io.dataease.commons.utils.AuthUtils;
|
||||||
import io.dataease.commons.utils.BeanUtils;
|
import io.dataease.commons.utils.BeanUtils;
|
||||||
@ -18,8 +19,10 @@ import io.dataease.exception.DataEaseException;
|
|||||||
import io.dataease.ext.ExtSysLogMapper;
|
import io.dataease.ext.ExtSysLogMapper;
|
||||||
import io.dataease.ext.query.GridExample;
|
import io.dataease.ext.query.GridExample;
|
||||||
import io.dataease.i18n.Translator;
|
import io.dataease.i18n.Translator;
|
||||||
|
import io.dataease.plugins.common.base.domain.SysLogExample;
|
||||||
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
|
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.mapper.SysLogMapper;
|
import io.dataease.plugins.common.base.mapper.SysLogMapper;
|
||||||
|
import io.dataease.service.system.SystemParameterService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -31,14 +34,13 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LogService {
|
public class LogService {
|
||||||
|
|
||||||
|
private static final String LOG_RETENTION = "30";
|
||||||
private Gson gson = new Gson();
|
private Gson gson = new Gson();
|
||||||
|
|
||||||
// 仪表板的额外操作 分享以及公共链接
|
// 仪表板的额外操作 分享以及公共链接
|
||||||
@ -68,6 +70,69 @@ public class LogService {
|
|||||||
@Resource
|
@Resource
|
||||||
private LogManager logManager;
|
private LogManager logManager;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SystemParameterService systemParameterService;
|
||||||
|
|
||||||
|
public void cleanDisusedLog() {
|
||||||
|
String value = systemParameterService.getValue(ParamConstants.BASIC.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();
|
||||||
|
SysLogExample example = new SysLogExample();
|
||||||
|
example.createCriteria().andTimeLessThan(timeInMillis);
|
||||||
|
sysLogMapper.deleteByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public KeyGridRequest logRetentionProxy(KeyGridRequest request) {
|
||||||
|
String value = systemParameterService.getValue(ParamConstants.BASIC.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);
|
||||||
|
long startTime = startInstance.getTimeInMillis();
|
||||||
|
|
||||||
|
Calendar endInstance = (Calendar) instance.clone();
|
||||||
|
endInstance.add(Calendar.DATE, 1);
|
||||||
|
endInstance.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
endInstance.set(Calendar.MINUTE, 0);
|
||||||
|
endInstance.set(Calendar.SECOND, 0);
|
||||||
|
long endTime = endInstance.getTimeInMillis();
|
||||||
|
|
||||||
|
|
||||||
|
List<ConditionEntity> conditions = request.getConditions();
|
||||||
|
if (CollectionUtils.isNotEmpty(conditions) && conditions.stream().anyMatch(condition -> StringUtils.equals("time", condition.getField()))) {
|
||||||
|
conditions.forEach(condition -> {
|
||||||
|
if (StringUtils.equals("time", condition.getField()) && startTime > ((List<Long>) condition.getValue()).get(0)) {
|
||||||
|
((List<Long>) condition.getValue()).set(0, startTime);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ConditionEntity conditionEntity = new ConditionEntity();
|
||||||
|
conditionEntity.setField("time");
|
||||||
|
conditionEntity.setOperator("between");
|
||||||
|
List<Long> times = new ArrayList<>();
|
||||||
|
times.add(startTime);
|
||||||
|
times.add(endTime);
|
||||||
|
conditionEntity.setValue(times);
|
||||||
|
conditions.add(conditionEntity);
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<SysLogGridDTO> query(KeyGridRequest request) {
|
public List<SysLogGridDTO> query(KeyGridRequest request) {
|
||||||
|
|
||||||
@ -223,7 +288,8 @@ public class LogService {
|
|||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
private List<FolderItem> viewPanelTypes () {
|
|
||||||
|
private List<FolderItem> viewPanelTypes() {
|
||||||
Integer[] opTypes = new Integer[]{13, 14};
|
Integer[] opTypes = new Integer[]{13, 14};
|
||||||
Integer[] sourceTypes = new Integer[]{3};
|
Integer[] sourceTypes = new Integer[]{3};
|
||||||
return typesByArr(opTypes, sourceTypes);
|
return typesByArr(opTypes, sourceTypes);
|
||||||
@ -340,7 +406,7 @@ public class LogService {
|
|||||||
//文件名称
|
//文件名称
|
||||||
String fileName = "DataEase操作日志";
|
String fileName = "DataEase操作日志";
|
||||||
String encodeFileName = URLEncoder.encode(fileName, "UTF-8");
|
String encodeFileName = URLEncoder.encode(fileName, "UTF-8");
|
||||||
response.setHeader("Content-disposition", "attachment;filename="+encodeFileName+".xls");
|
response.setHeader("Content-disposition", "attachment;filename=" + encodeFileName + ".xls");
|
||||||
wb.write(outputStream);
|
wb.write(outputStream);
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user