Browse Source

sdk日志先加到这

menglu 3 years ago
parent
commit
d20f0b5cc1

+ 2 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/BaseUtil.java

@@ -30,6 +30,7 @@ public class BaseUtil {
 			for (String name : Constant.ConfigRefreshMap.keySet()) {
 				ConfigRefresh ConfigRefresh = Constant.ConfigRefreshMap.get(name);
 				JSONObject ContentItem = new JSONObject();
+				ContentItem.put("name", name);
 				ContentItem.put("enable", ConfigRefresh.enable);
 				ContentItem.put("interval_second", ConfigRefresh.interval_second);
 				ContentItem.put("last_refresh", ConfigRefresh.last_refresh == null ? null : sdf.format(ConfigRefresh.last_refresh));
@@ -44,7 +45,7 @@ public class BaseUtil {
 			} else if (command.equals("stop")) {
 				ConfigRefresh.enable = false;
 			} else if (command.equals("reset_time")) {
-				ConfigRefresh.last_refresh = new Date((new Date()).getTime() - ConfigRefresh.interval_second);
+				ConfigRefresh.last_refresh = new Date((new Date()).getTime() - 1000L * ConfigRefresh.interval_second);
 			} else if (command.equals("interval_second")) {
 				long interval_second = paramJSON.getLong("interval_second");
 				interval_second = interval_second < 0L ? 0L : interval_second;

+ 18 - 10
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/FileUtil.java

@@ -79,33 +79,41 @@ public class FileUtil {
 					if (!compareKey(fileMap1, fileMap2)) {
 						for (String key : fileMap1.keySet()) {
 							if (!fileMap2.containsKey(key)) {
-								file_old.add(fileMap1.get(key).getAbsolutePath());
+								file_old.add(fileMap1.get(key).getPath());
 							}
 						}
 						for (String key : fileMap2.keySet()) {
 							if (!fileMap1.containsKey(key)) {
-								file_new.add(fileMap2.get(key).getAbsolutePath());
+								file_new.add(fileMap2.get(key).getPath());
 							}
 						}
 					}
 					if (!compareKey(dirMap1, dirMap2)) {
 						for (String key : dirMap1.keySet()) {
 							if (!dirMap2.containsKey(key)) {
-								dir_old.add(dirMap1.get(key).getAbsolutePath());
+								dir_old.add(dirMap1.get(key).getPath());
 							}
 						}
 						for (String key : dirMap2.keySet()) {
 							if (!dirMap1.containsKey(key)) {
-								dir_new.add(dirMap2.get(key).getAbsolutePath());
+								dir_new.add(dirMap2.get(key).getPath());
 							}
 						}
 					}
 					JSONObject file_change = new JSONObject();
-					file_change.put("dir_name", file1.getAbsolutePath());
-					file_change.put("file_old", file_old);
-					file_change.put("file_new", file_new);
-					file_change.put("dir_old", dir_old);
-					file_change.put("dir_new", dir_new);
+					file_change.put("dir_name", file1.getPath());
+					if (file_old.size() > 0) {
+						file_change.put("file_old", file_old);
+					}
+					if (file_new.size() > 0) {
+						file_change.put("file_new", file_new);
+					}
+					if (dir_old.size() > 0) {
+						file_change.put("dir_old", dir_old);
+					}
+					if (dir_new.size() > 0) {
+						file_change.put("dir_new", dir_new);
+					}
 					LogOfDownload.changeList.add(file_change);
 				}
 			}
@@ -139,7 +147,7 @@ public class FileUtil {
 			if (!file_compare) {
 				if (LogOfDownload != null) {
 					JSONObject file_change = new JSONObject();
-					file_change.put("file_name", file1.getAbsolutePath());
+					file_change.put("file_name", file1.getPath());
 					file_change.put("length_old", file1.length());
 					file_change.put("length_new", file2.length());
 					LogOfDownload.changeList.add(file_change);

+ 18 - 3
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/LogOfDownload.java

@@ -42,10 +42,25 @@ public class LogOfDownload {
 		if (startTime != null) {
 			result.put("startTime", sdf.format(startTime));
 		}
+		// {
+		// JSONArray downloadArray = new JSONArray();
+		// downloadArray.addAll(downloadList);
+		// result.put("downloadArray", downloadArray);
+		// }
+		if (downloadList.size() > 0) {
+			int downloadCount = 0;
+			long donwloadSize = 0L;
+			for (JSONObject item : downloadList) {
+				downloadCount++;
+				donwloadSize += item.getLong("filesize");
+			}
+			result.put("downloadCount", downloadCount);
+			result.put("donwloadSize", donwloadSize);
+		}
 		{
-			JSONArray downloadArray = new JSONArray();
-			downloadArray.addAll(downloadList);
-			result.put("downloadArray", downloadArray);
+			JSONArray changeArray = new JSONArray();
+			changeArray.addAll(changeList);
+			result.put("changeArray", changeArray);
 		}
 		{
 			JSONArray errorArray = new JSONArray();