Browse Source

准备搞下载记录

menglu 3 years ago
parent
commit
a275ef0f21

+ 1 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DaemonThread.java

@@ -187,6 +187,7 @@ public class DaemonThread extends Thread {
 					Thread.sleep(1000L);
 				}
 				LogOfRun.status = "success";
+				RepositoryContainer.RepositoryProject.AddSuccessLogOfRun(LogOfRun);
 			} catch (Exception e) {
 				String message = LogUtil.GetExceptionStackTrace(e);
 				log.error(e.getMessage(), e);

+ 1 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/RefreshThread.java

@@ -156,6 +156,7 @@ public class RefreshThread extends Thread {
 					DaemonThread.path_zkt_physical_world = this.path_zkt_physical_world;
 					DaemonThread.path_ibms_physical_world = this.path_ibms_physical_world;
 					LogOfRun.status = "success";
+					RepositoryContainer.RepositoryProject.AddSuccessLogOfRun(LogOfRun);
 				} catch (Exception e) {
 					String message = LogUtil.GetExceptionStackTrace(e);
 					log.error(e.getMessage(), e);

+ 44 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/LogOfDownload.java

@@ -1,5 +1,49 @@
 package com.persagy.ibms.data.sdk.util;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
 public class LogOfDownload {
+	private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+
+	public Date startTime;
+	public Date endTime;
+	public List<JSONObject> downloadList = new CopyOnWriteArrayList<JSONObject>();
+	public String pathOld;
+	public long fileSizeOld;
+	public String pathNew;
+	public long fileSizeNew;
+	public List<JSONObject> changeList = new CopyOnWriteArrayList<JSONObject>();
+	public List<JSONObject> errorList = new CopyOnWriteArrayList<JSONObject>();
+	public String status;// running,success,failure
+
+	public LogOfDownload() {
+		this.startTime = new Date();
+	}
 
+	public synchronized JSONObject toJSON() {
+		JSONObject result = new JSONObject();
+		if (startTime != null) {
+			result.put("startTime", sdf.format(startTime));
+		}
+		{
+			JSONArray errorArray = new JSONArray();
+			for (JSONObject error : errorList) {
+				errorArray.add(error);
+			}
+			result.put("errorArray", errorArray);
+		}
+		if (endTime != null) {
+			result.put("endTime", sdf.format(endTime));
+		}
+		if (status != null) {
+			result.put("status", status);
+		}
+		return result;
+	}
 }

+ 1 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/LogOfRun.java

@@ -15,7 +15,7 @@ import lombok.extern.slf4j.Slf4j;
 
 @Slf4j
 public class LogOfRun {
-	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 
 	public Date startTime;
 	public Date endTime;

+ 6 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RepositoryImpl.java

@@ -1,5 +1,7 @@
 package com.persagy.ibms.data.sdk.util;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -357,16 +359,20 @@ public class RepositoryImpl extends RepositoryBase {
 
 	@Override
 	public void log_step_begin(int step, int property_count, int value_count) {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 		JSONObject stepJSON = new JSONObject();
 		stepJSON.put("property_count", property_count);
 		stepJSON.put("value_count", value_count);
+		stepJSON.put("beginTime", sdf.format(new Date()));
 		this.RepositoryProject.logOfRun.stepList.add(stepJSON);
 	}
 
 	@Override
 	public void log_step_end(int step, int finish_count) {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 		JSONObject stepJSON = this.RepositoryProject.logOfRun.stepList.get(this.RepositoryProject.logOfRun.stepList.size() - 1);
 		stepJSON.put("finish_count", finish_count);
+		stepJSON.put("endTime", sdf.format(new Date()));
 	}
 
 	@Override

+ 9 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RepositoryProject.java

@@ -35,17 +35,25 @@ public class RepositoryProject {
 
 	public LogOfRun logOfRun;
 	public List<LogOfRun> logOfRunList = new CopyOnWriteArrayList<LogOfRun>();
+	public List<LogOfRun> successLogOfRunList = new CopyOnWriteArrayList<LogOfRun>();
 
 	public List<JSONObject> logOfAlarmList = new CopyOnWriteArrayList<JSONObject>();
 
 	public void AddLogOfRun(LogOfRun LogOfRun) {
 		this.logOfRun = LogOfRun;
 		this.logOfRunList.add(0, LogOfRun);
-		for (int i = this.logOfRunList.size() - 1; i > 1024; i--) {
+		for (int i = this.logOfRunList.size() - 1; i > 32; i--) {
 			this.logOfRunList.remove(i);
 		}
 	}
 
+	public void AddSuccessLogOfRun(LogOfRun LogOfRun) {
+		this.successLogOfRunList.add(0, LogOfRun);
+		for (int i = this.successLogOfRunList.size() - 1; i > 4; i--) {
+			this.successLogOfRunList.remove(i);
+		}
+	}
+
 	public void AddLogOfAlarm(JSONObject LogOfRun) {
 		this.logOfAlarmList.add(0, LogOfRun);
 		for (int i = this.logOfAlarmList.size() - 1; i > 1024; i--) {