From bce3fcf05020405e33199706c3d91e9b9a71bd39 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 01 十二月 2023 12:42:05 +0800
Subject: [PATCH] 关键属性查重特殊字符转义添加

---
 Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/log/service/impl/LogLocalServiceImpl.java |   87 ++++++++++++++++++++++++++-----------------
 1 files changed, 52 insertions(+), 35 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 021d373..0a2e420 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
@@ -82,7 +82,7 @@
 	 * @param logParentPath
 	 * @return
 	 */
-	//@Override
+	@Override
 	public List<LocalLogVO> getSystemLogList(String logParentPath) {
 		List<LocalLogVO> localLogsVO = new ArrayList<>();
 		// 涓嶄负绌鸿鏄庢槸鍔犺浇褰撳墠杩欎釜鏈嶅姟璺緞涓嬬殑鏃ュ織鏂囦欢
@@ -90,44 +90,48 @@
 			File file = new File(logParentPath);
 			if (file.isDirectory()) {
 				File[] files = file.listFiles();
-				Arrays.stream(files).forEach(item->{
-					// 缁勫缓鏃ュ織鏂囦欢瀵硅薄
-					LocalLogVO localLog = new LocalLogVO();
-					localLog.setLogName(item.getName());
-					localLog.setLogType(getLogType(item.getName()));
-					localLog.setCreateTime(getLastModifiedOrCreatTime(false,logParentPath));
-					localLog.setLastModifier(getLastModifiedOrCreatTime(true,logParentPath));
-					localLog.setLogPath(logParentPath);
-					String serviceId = getServiceId(logParentPath);
-					localLog.setServiceId(serviceId);
-					localLog.setServiceName(getServiceName(serviceId));
-					localLog.setHasChildren(false);
-					localLogsVO.add(localLog);
-				});
+				if(Func.isNotEmpty(files) && files.length>0){
+					Arrays.stream(files).forEach(item->{
+						// 缁勫缓鏃ュ織鏂囦欢瀵硅薄
+						LocalLogVO localLog = new LocalLogVO();
+						localLog.setLogName(item.getName());
+						localLog.setLogType(getLogType(item.getName()));
+						localLog.setCreateTime(getLastModifiedOrCreatTime(false,logParentPath));
+						localLog.setLastModifier(getLastModifiedOrCreatTime(true,logParentPath));
+						localLog.setLogPath(logParentPath);
+						String serviceId = getServiceId(logParentPath);
+						localLog.setServiceId(serviceId);
+						localLog.setServiceName(getServiceName(serviceId));
+						localLog.setHasChildren(false);
+						localLogsVO.add(localLog);
+					});
+				}
 			}
 		}else {
 			File fileDir = new File(PARENTPATH);
 			File[] childDir = fileDir.listFiles();
-			Arrays.stream(childDir).forEach(dir->{
-				if(dir.getName().contains("ubcs_")){
-					String fullPath = dir.getPath() + LOGPATH;
-					File file = new File(fullPath);
-					if(file.exists()){
-						LocalLogVO localLogVO = new LocalLogVO();
-						localLogVO.setLastModifier(getLastModifiedOrCreatTime(true,fullPath));
-						localLogVO.setCreateTime(getLastModifiedOrCreatTime(false,fullPath));
-						localLogVO.setLogPath(fullPath);
-						String serviceId = getServiceId(file.getPath());
-						localLogVO.setServiceId(serviceId);
-						String serviceName = getServiceName(serviceId);
-						localLogVO.setServiceName(serviceName);
-						localLogVO.setLogType(serviceName+"鏃ュ織鐖剁洰褰�");
-						localLogVO.setLogName(serviceName+"鏃ュ織鐖剁洰褰�");
-						localLogVO.setHasChildren(true);
-						localLogsVO.add(localLogVO);
+			if(Func.isNotEmpty(childDir) && childDir.length > 0){
+				Arrays.stream(childDir).forEach(dir->{
+					if(dir.getName().contains("ubcs_")){
+						String fullPath = dir.getPath() + LOGPATH;
+						File file = new File(fullPath);
+						if(file.exists()){
+							LocalLogVO localLogVO = new LocalLogVO();
+							localLogVO.setLastModifier(getLastModifiedOrCreatTime(true,fullPath));
+							localLogVO.setCreateTime(getLastModifiedOrCreatTime(false,fullPath));
+							localLogVO.setLogPath(fullPath);
+							String serviceId = getServiceId(file.getPath());
+							localLogVO.setServiceId(serviceId);
+							String serviceName = getServiceName(serviceId);
+							localLogVO.setServiceName(serviceName);
+							localLogVO.setLogType(serviceName+"鏃ュ織鐖剁洰褰�");
+							localLogVO.setLogName(serviceName+"鏃ュ織鐖剁洰褰�");
+							localLogVO.setHasChildren(true);
+							localLogsVO.add(localLogVO);
+						}
 					}
-				}
-			});
+				});
+			}
 		}
 		return localLogsVO;
 	}
@@ -225,7 +229,7 @@
 			throw new ServerException("鏈幏鍙栧埌璇ユ棩蹇楄矾寰勶紒");
 		}
 		FileObjectBO fileObjectBO = new FileObjectBO();
-		String logFullPaths = localLogVO.getLogFullPaths();
+		String logFullPaths = this.convertWindows2Linux(localLogVO.getLogFullPaths());
 		// 鍒ゆ柇鏄惁鏄埗鐩綍
 		if(!localLogVO.getHasChildren()){
 			//鍙笅杞戒竴涓棩蹇楁枃浠�
@@ -283,6 +287,19 @@
 	}
 
 	/**
+	 * 涓嬭浇涔嬪墠灏唚indows鐨勮矾寰勬牸寮忚浆鎹负linux
+	 * @param fullPath
+	 * @return
+	 */
+	private String convertWindows2Linux(String fullPath){
+		String os = System.getProperty("os.name").toLowerCase();
+		if (!os.contains("win")) {
+			fullPath = fullPath.replace("\\", "/");
+		}
+		return fullPath;
+	}
+
+	/**
 	 * 鍒犻櫎鏃ュ織鏂囦欢
 	 * @param localLogVO 鏂囦欢鍏ㄨ矾寰勯泦鍚�
 	 * @throws ServerException

--
Gitblit v1.9.3