From 2cedb574c22cf2f77418929e79f23ace0a7e7ac6 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期一, 29 四月 2024 10:05:12 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/log/service/impl/LogLocalServiceImpl.java | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/log/service/impl/LogLocalServiceImpl.java b/Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/log/service/impl/LogLocalServiceImpl.java index 0a2e420..8e91b71 100644 --- a/Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/log/service/impl/LogLocalServiceImpl.java +++ b/Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/log/service/impl/LogLocalServiceImpl.java @@ -26,6 +26,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.FileTime; import java.rmi.ServerException; import java.text.SimpleDateFormat; import java.util.*; @@ -84,7 +85,7 @@ */ @Override public List<LocalLogVO> getSystemLogList(String logParentPath) { - List<LocalLogVO> localLogsVO = new ArrayList<>(); + List<LocalLogVO> localLogsVOS = new ArrayList<>(); // 涓嶄负绌鸿鏄庢槸鍔犺浇褰撳墠杩欎釜鏈嶅姟璺緞涓嬬殑鏃ュ織鏂囦欢 if(Func.isNotEmpty(logParentPath)){ File file = new File(logParentPath); @@ -96,14 +97,14 @@ LocalLogVO localLog = new LocalLogVO(); localLog.setLogName(item.getName()); localLog.setLogType(getLogType(item.getName())); - localLog.setCreateTime(getLastModifiedOrCreatTime(false,logParentPath)); - localLog.setLastModifier(getLastModifiedOrCreatTime(true,logParentPath)); + localLog.setCreateTime(getLastModifiedOrCreatTime(false,item.getPath())); + localLog.setLastModifier(getLastModifiedOrCreatTime(true,item.getPath())); localLog.setLogPath(logParentPath); String serviceId = getServiceId(logParentPath); localLog.setServiceId(serviceId); localLog.setServiceName(getServiceName(serviceId)); localLog.setHasChildren(false); - localLogsVO.add(localLog); + localLogsVOS.add(localLog); }); } } @@ -117,8 +118,8 @@ File file = new File(fullPath); if(file.exists()){ LocalLogVO localLogVO = new LocalLogVO(); - localLogVO.setLastModifier(getLastModifiedOrCreatTime(true,fullPath)); - localLogVO.setCreateTime(getLastModifiedOrCreatTime(false,fullPath)); + localLogVO.setLastModifier(getLastModifiedOrCreatTime(true,file.getPath())); + localLogVO.setCreateTime(getLastModifiedOrCreatTime(false,file.getPath())); localLogVO.setLogPath(fullPath); String serviceId = getServiceId(file.getPath()); localLogVO.setServiceId(serviceId); @@ -127,13 +128,15 @@ localLogVO.setLogType(serviceName+"鏃ュ織鐖剁洰褰�"); localLogVO.setLogName(serviceName+"鏃ュ織鐖剁洰褰�"); localLogVO.setHasChildren(true); - localLogsVO.add(localLogVO); + localLogsVOS.add(localLogVO); } } }); } } - return localLogsVO; + // 瀵规棩蹇楄繘琛岄檷搴忔帓搴� + List<LocalLogVO> resLocalLogVOS = localLogsVOS.stream().sorted(Comparator.comparing(LocalLogVO::getLastModifier).reversed()).collect(Collectors.toList()); + return resLocalLogVOS; } /** @@ -265,7 +268,6 @@ if(!logFile.exists() || !logFile.isFile()){ throw new VciBaseException("鏈湴鏃ュ織鏂囦欢璺緞"+item.getPath()+"涓湭鎵惧埌鏃ュ織"); } - try(OutputStream os = new FileOutputStream(file); InputStream ins = new FileInputStream(logFile); ){ @@ -277,10 +279,13 @@ String zipName = new File(tempFolder).getPath() + File.separator + getLogFileName(logFullPaths) + "绛�"+file1.length + "涓枃浠�.zip"; zipUtil.folderToZipFile(tempFolder,zipName); fileObjectBO.setFileLocalPath(zipName); + fileObjectBO.setName(zipName); fileObjectBO.setFileExtension(".log"); if(log.isDebugEnabled()){ log.debug("涓嬭浇鏂囦欢鐨勪俊鎭�,",zipName); } + }else{ + throw new ServerException("璇ョ洰褰曚笅涓嶅瓨鍦ㄦ棩蹇楁枃浠讹紒"); } } return fileObjectBO; -- Gitblit v1.9.3