|
|
@ -343,7 +343,8 @@ public class LogService { |
|
|
|
// return getFileContent(fileList, null, null, null, null);
|
|
|
|
// return getFileContent(fileList, null, null, null, null);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
public File exportLog(ActionRequest request, ActionResponse response) throws IOException { |
|
|
|
public File exportLog(ActionRequest request, ActionResponse response, String userAuth) |
|
|
|
|
|
|
|
throws IOException { |
|
|
|
String password = request.getContext().get("password").toString(); |
|
|
|
String password = request.getContext().get("password").toString(); |
|
|
|
String confirmPassword = request.getContext().get("confirmPassword").toString(); |
|
|
|
String confirmPassword = request.getContext().get("confirmPassword").toString(); |
|
|
|
String startTime = request.getContext().get("exportStartTime").toString(); |
|
|
|
String startTime = request.getContext().get("exportStartTime").toString(); |
|
|
@ -366,39 +367,44 @@ public class LogService { |
|
|
|
List<LogEntity> selectResult = new ArrayList<>(); |
|
|
|
List<LogEntity> selectResult = new ArrayList<>(); |
|
|
|
List<LogEntity> logEntitiesList = logEntityRepository.all().fetch(); |
|
|
|
List<LogEntity> logEntitiesList = logEntityRepository.all().fetch(); |
|
|
|
if (startTime != null && endTime != null) { |
|
|
|
if (startTime != null && endTime != null) { |
|
|
|
// 如果输入的开始时间与结束时间都不为空,则输出时间范围内的所有记录
|
|
|
|
// 如果输入的开始时间与结束时间都不为空,则输出时间范围内符合用户角色的所有记录
|
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
if ((getSqlLongTime(logEntity.getTime()) > getSqlLongTime(startTime)) |
|
|
|
if ((getSqlLongTime(logEntity.getTime()) > getSqlLongTime(startTime)) |
|
|
|
&& (getSqlLongTime(logEntity.getTime()) < getSqlLongTime(endTime))) { |
|
|
|
&& (getSqlLongTime(logEntity.getTime()) < getSqlLongTime(endTime)) |
|
|
|
|
|
|
|
&& userAuth.equals(logEntity.getUserAuth().getValue())) { |
|
|
|
selectResult.add(logEntity); |
|
|
|
selectResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (startTime == null && endTime != null) { |
|
|
|
if (startTime == null && endTime != null) { |
|
|
|
// 如果输入的开始时间为空,则输出结束时间之前的所有记录
|
|
|
|
// 如果输入的开始时间为空,则输出结束时间之前的符合用户角色的所有记录
|
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
if ((getSqlLongTime(logEntity.getTime()) < getSqlLongTime(endTime))) { |
|
|
|
if ((getSqlLongTime(logEntity.getTime()) < getSqlLongTime(endTime)) |
|
|
|
|
|
|
|
&& userAuth.equals(logEntity.getUserAuth().getValue())) { |
|
|
|
selectResult.add(logEntity); |
|
|
|
selectResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (startTime != null && endTime == null) { |
|
|
|
if (startTime != null && endTime == null) { |
|
|
|
// 如果输入的结束时间为空,则输出开始时间之后的所有记录
|
|
|
|
// 如果输入的结束时间为空,则输出开始时间之后的符合用户角色的所有记录
|
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
if ((getSqlLongTime(logEntity.getTime()) > getSqlLongTime(startTime))) { |
|
|
|
if ((getSqlLongTime(logEntity.getTime()) > getSqlLongTime(startTime)) |
|
|
|
|
|
|
|
&& userAuth.equals(logEntity.getUserAuth().getValue())) { |
|
|
|
selectResult.add(logEntity); |
|
|
|
selectResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (startTime == null && endTime == null) { |
|
|
|
if (startTime == null && endTime == null) { |
|
|
|
// 如果输入的时间都为空,则输出所有记录
|
|
|
|
// 如果输入的时间都为空,则输出符合用户角色的所有记录
|
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
for (LogEntity logEntity : logEntitiesList) { |
|
|
|
|
|
|
|
if (userAuth.equals(logEntity.getUserAuth().getValue())) { |
|
|
|
selectResult.add(logEntity); |
|
|
|
selectResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
// Object jsonObject = JSONObject.toJSON(selectResult);
|
|
|
|
// Object jsonObject = JSONObject.toJSON(selectResult);
|
|
|
|
return exportLogExcelZip(selectResult, password); |
|
|
|
return exportLogExcelZip(selectResult, password); |
|
|
|
} |
|
|
|
} |
|
|
@ -664,10 +670,10 @@ public class LogService { |
|
|
|
logConfig.setBackupTime(backupTime); |
|
|
|
logConfig.setBackupTime(backupTime); |
|
|
|
// 计算文件大小,单位以M表示,精确小数点后两位
|
|
|
|
// 计算文件大小,单位以M表示,精确小数点后两位
|
|
|
|
Map<String, String> fileSizeMap = getSize(filePath); |
|
|
|
Map<String, String> fileSizeMap = getSize(filePath); |
|
|
|
logConfig.setThresholdSystemManageUserSize(fileSizeMap.get("16")); |
|
|
|
logConfig.setThresholdSystemManageUserSize(fileSizeMap.get("1")); |
|
|
|
logConfig.setThresholdSecurityUserSize("1"); |
|
|
|
logConfig.setThresholdSecurityUserSize("2"); |
|
|
|
logConfig.setThresholdSecurityAuditUserSize("2"); |
|
|
|
logConfig.setThresholdSecurityAuditUserSize("3"); |
|
|
|
logConfig.setThresholdServiceUserSize("3"); |
|
|
|
logConfig.setThresholdServiceUserSize("4"); |
|
|
|
logConfig.setFilePath(filePath); |
|
|
|
logConfig.setFilePath(filePath); |
|
|
|
if (logConfig.getRecordType().equals("Current")) { |
|
|
|
if (logConfig.getRecordType().equals("Current")) { |
|
|
|
logConfig.setRecordType("History"); |
|
|
|
logConfig.setRecordType("History"); |
|
|
@ -696,19 +702,19 @@ public class LogService { |
|
|
|
if (getSqlLongTime(logEntity.getTime()) > getLongTime(logConfig.getLogStartTime()) |
|
|
|
if (getSqlLongTime(logEntity.getTime()) > getLongTime(logConfig.getLogStartTime()) |
|
|
|
&& getSqlLongTime(logEntity.getTime()) < getLongTime(logConfig.getLogEndTime())) { |
|
|
|
&& getSqlLongTime(logEntity.getTime()) < getLongTime(logConfig.getLogEndTime())) { |
|
|
|
// 如果当条记录时间大于开始时间小于结束时间,则判断角色
|
|
|
|
// 如果当条记录时间大于开始时间小于结束时间,则判断角色
|
|
|
|
if (logEntity.getUserAuth().getValue().equals("16")) { |
|
|
|
if (logEntity.getUserAuth().getValue().equals("1")) { |
|
|
|
// 系统管理员
|
|
|
|
// 系统管理员
|
|
|
|
systemManageUserResult.add(logEntity); |
|
|
|
systemManageUserResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
if (logEntity.getUserAuth().getValue().equals("1")) { |
|
|
|
if (logEntity.getUserAuth().getValue().equals("2")) { |
|
|
|
// 安全保密员
|
|
|
|
// 安全保密员
|
|
|
|
securityUserSelectResult.add(logEntity); |
|
|
|
securityUserSelectResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
if (logEntity.getUserAuth().getValue().equals("2")) { |
|
|
|
if (logEntity.getUserAuth().getValue().equals("3")) { |
|
|
|
// 安全审计员
|
|
|
|
// 安全审计员
|
|
|
|
securityAuditUserSelectResult.add(logEntity); |
|
|
|
securityAuditUserSelectResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
if (logEntity.getUserAuth().getValue().equals("3")) { |
|
|
|
if (logEntity.getUserAuth().getValue().equals("4")) { |
|
|
|
// 业务用户
|
|
|
|
// 业务用户
|
|
|
|
serviceUserSelectResult.add(logEntity); |
|
|
|
serviceUserSelectResult.add(logEntity); |
|
|
|
} |
|
|
|
} |
|
|
@ -836,10 +842,10 @@ public class LogService { |
|
|
|
|
|
|
|
|
|
|
|
public Map<String, String> getSize(String filePath) { |
|
|
|
public Map<String, String> getSize(String filePath) { |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
map.put("16", getFileSize(filePath + "systemManageUser.zip")); |
|
|
|
map.put("1", getFileSize(filePath + "systemManageUser.zip")); |
|
|
|
map.put("1", getFileSize(filePath + "securityUser.zip")); |
|
|
|
map.put("2", getFileSize(filePath + "securityUser.zip")); |
|
|
|
map.put("2", getFileSize(filePath + "securityAuditUser.zip")); |
|
|
|
map.put("3", getFileSize(filePath + "securityAuditUser.zip")); |
|
|
|
map.put("3", getFileSize(filePath + "serviceUser.zip")); |
|
|
|
map.put("4", getFileSize(filePath + "serviceUser.zip")); |
|
|
|
return map; |
|
|
|
return map; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|