Bladeren bron

增加持续打印功能

menglu 3 jaren geleden
bovenliggende
commit
8e9b7eda63

BIN
ibms-data-sdk/img/bad/joke/Cry1.bmp


BIN
ibms-data-sdk/img/bad/joke/Cry2.bmp


BIN
ibms-data-sdk/img/good/joke/Laugh1.bmp


BIN
ibms-data-sdk/img/good/joke/Laugh2.bmp


BIN
ibms-data-sdk/img/perfect/joke/Cow1.bmp


BIN
ibms-data-sdk/img/perfect/joke/Cow2.bmp


+ 28 - 15
ibms-data-sdk/src/main/java/a/A.java

@@ -17,9 +17,8 @@ import lombok.extern.slf4j.Slf4j;
 
 @Slf4j
 public class A {
-	private static boolean print(String dir) {
+	private static boolean printOne(File file, boolean index_rand, int index) {
 		try {
-			File file = new File("img" + Constant.getSeperator() + dir);
 			if (!file.exists()) {
 				return false;
 			}
@@ -36,8 +35,15 @@ public class A {
 			if (validList.size() == 0) {
 				return false;
 			}
-			Random rand = new Random();
-			File choose = validList.get(rand.nextInt(validList.size()));
+
+			int file_index;
+			if (index_rand) {
+				Random rand = new Random();
+				file_index = rand.nextInt(validList.size());
+			} else {
+				file_index = index % validList.size();
+			}
+			File choose = validList.get(file_index);
 			InputStream is = new FileInputStream(choose);
 			BufferedImage bi = ImageIO.read(is);
 			is.close();
@@ -53,18 +59,25 @@ public class A {
 		}
 	}
 
-	public static boolean bad() {
-		boolean result = print("bad");
-		return result;
-	}
-
-	public static boolean good() {
-		boolean result = print("good");
-		return result;
+	public static void print(String status) {
+		log.warn("compute result: " + status);
+		File file = new File("img" + Constant.getSeperator() + status);
+		if (file.exists() && file.isDirectory()) {
+			printOne(file, true, -1);
+		}
 	}
 
-	public static boolean perfect() {
-		boolean result = print("perfect");
-		return result;
+	public static void print_joke(String status) {
+		File file = new File("img" + Constant.getSeperator() + status + Constant.getSeperator() + "joke");
+		if (file.exists() && file.isDirectory()) {
+			for (int i = 0; i < 60; i++) {
+				try {
+					Thread.sleep(1000L);
+				} catch (InterruptedException e) {
+				}
+				log.warn("compute result: " + status);
+				printOne(file, false, i);
+			}
+		}
 	}
 }

+ 21 - 9
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DaemonThread.java

@@ -167,26 +167,25 @@ public class DaemonThread extends Thread {
 
 				LogOfRun.status = "success";
 				RepositoryContainer.RepositoryProject.AddSuccessLogOfRun(LogOfRun);
-
-				if (LogOfRun.errorList.size() == 0) {
-					A.perfect();
-				} else {
-					A.good();
-				}
 			} catch (Exception e) {
 				String message = LogUtil.GetExceptionStackTrace(e);
 				log.error(e.getMessage(), e);
 				LogOfRun.error(null, message);
 				LogOfRun.status = "failure";
-
-				A.bad();
 			}
 			for (String resource : LogOfRun.resourceTime_new.keySet()) {
 				RepositoryContainer.RepositoryProject.resourceMap_try.put(resource, LogOfRun.resourceTime_new.get(resource));
 			}
 			LogOfRun.endTime = new Date();
 
-			if (RepositoryContainer.RepositoryProject.compute_finish) {
+			if (LogOfRun.status.equals("success")) {
+				// 打印字符画
+				if (LogOfRun.errorList.size() == 0) {
+					A.print("perfect");
+				} else {
+					A.print("good");
+				}
+
 				try {
 					if (Constant.iot_websocket_url != null) {
 						log.warn("iot-websocket");
@@ -219,7 +218,20 @@ public class DaemonThread extends Thread {
 					LogOfRun.status = "failure";
 				}
 
+				// 循环打印字符画
+				if (LogOfRun.errorList.size() == 0) {
+					A.print_joke("perfect");
+				} else {
+					A.print_joke("good");
+				}
+
 				break;
+			} else {
+				// 打印字符画
+				A.print("bad");
+
+				// 循环打印字符画
+				A.print_joke("bad");
 			}
 		}
 

+ 24 - 21
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DownloadThread_config.java

@@ -58,33 +58,36 @@ public class DownloadThread_config extends Thread {
 			} catch (InterruptedException e) {
 				log.error(e.getMessage(), e);
 			}
+			if (!ConfigRefresh.enable) {
+				continue;
+			}
 
 			Date currTime = new Date();
+			String tmpPath = Constant.ibms_physical_world;
+			String LatestPath = Constant.getLatestPath(tmpPath, false, false);
 			boolean changed = false;
-			if (ConfigRefresh.last_refresh == null
+			if (LatestPath == null || ConfigRefresh.last_refresh == null
 					|| currTime.getTime() - ConfigRefresh.last_refresh.getTime() > 1000L * ConfigRefresh.interval_second) {
-				if (ConfigRefresh.enable) {
-					LogOfDownload LogOfDownload = new LogOfDownload();
-					RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
-					try {
-						log.warn(name + " check begin");
-						changed = Process_config(LogOfDownload);
-						if (changed) {
-							String validPath = Constant.getLatestPath(Constant.config, false, false);
-							log.warn(name + " check end " + validPath);
-						} else {
-							log.warn(name + " check end");
-						}
-						LogOfDownload.status = "success";
-						RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
-					} catch (Exception e) {
-						String message = LogUtil.GetExceptionStackTrace(e);
-						log.error(e.getMessage(), e);
-						LogOfDownload.error(null, message);
-						LogOfDownload.status = "failure";
+				LogOfDownload LogOfDownload = new LogOfDownload();
+				RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
+				try {
+					log.warn(name + " check begin");
+					changed = Process_config(LogOfDownload);
+					if (changed) {
+						String validPath = Constant.getLatestPath(tmpPath, false, false);
+						log.warn(name + " check end " + validPath);
+					} else {
+						log.warn(name + " check end");
 					}
-					LogOfDownload.endTime = new Date();
+					LogOfDownload.status = "success";
+					RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
+				} catch (Exception e) {
+					String message = LogUtil.GetExceptionStackTrace(e);
+					log.error(e.getMessage(), e);
+					LogOfDownload.error(null, message);
+					LogOfDownload.status = "failure";
 				}
+				LogOfDownload.endTime = new Date();
 				ConfigRefresh.last_refresh = currTime;
 			}
 		}

+ 27 - 21
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DownloadThread_ibms.java

@@ -55,33 +55,39 @@ public class DownloadThread_ibms extends Thread {
 			} catch (InterruptedException e) {
 				log.error(e.getMessage(), e);
 			}
+			if (!Constant.ibms_physical_world_enable) {
+				continue;
+			}
+			if (!ConfigRefresh.enable) {
+				continue;
+			}
 
 			Date currTime = new Date();
+			String tmpPath = Constant.ibms_physical_world;
+			String LatestPath = Constant.getLatestPath(tmpPath, true, false);
 			boolean changed = false;
-			if (ConfigRefresh.last_refresh == null
+			if (LatestPath == null || ConfigRefresh.last_refresh == null
 					|| currTime.getTime() - ConfigRefresh.last_refresh.getTime() > 1000L * ConfigRefresh.interval_second) {
-				if (Constant.ibms_physical_world_enable && ConfigRefresh.enable) {
-					LogOfDownload LogOfDownload = new LogOfDownload();
-					RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
-					try {
-						log.warn(name + " check begin");
-						changed = RWDDownloadUtil.Process_ibms_physical_world(LogOfDownload);
-						if (changed) {
-							String validPath = Constant.getLatestPath(Constant.ibms_physical_world, true, false);
-							log.warn(name + " check end " + validPath);
-						} else {
-							log.warn(name + " check end");
-						}
-						LogOfDownload.status = "success";
-						RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
-					} catch (Exception e) {
-						String message = LogUtil.GetExceptionStackTrace(e);
-						log.error(e.getMessage(), e);
-						LogOfDownload.error(null, message);
-						LogOfDownload.status = "failure";
+				LogOfDownload LogOfDownload = new LogOfDownload();
+				RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
+				try {
+					log.warn(name + " check begin");
+					changed = RWDDownloadUtil.Process_ibms_physical_world(LogOfDownload);
+					if (changed) {
+						String validPath = Constant.getLatestPath(tmpPath, true, false);
+						log.warn(name + " check end " + validPath);
+					} else {
+						log.warn(name + " check end");
 					}
-					LogOfDownload.endTime = new Date();
+					LogOfDownload.status = "success";
+					RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
+				} catch (Exception e) {
+					String message = LogUtil.GetExceptionStackTrace(e);
+					log.error(e.getMessage(), e);
+					LogOfDownload.error(null, message);
+					LogOfDownload.status = "failure";
 				}
+				LogOfDownload.endTime = new Date();
 				ConfigRefresh.last_refresh = currTime;
 			}
 		}

+ 27 - 21
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DownloadThread_info_point.java

@@ -58,33 +58,39 @@ public class DownloadThread_info_point extends Thread {
 			} catch (InterruptedException e) {
 				log.error(e.getMessage(), e);
 			}
+			if (!Constant.info_point_version.equals("new")) {
+				continue;
+			}
+			if (!ConfigRefresh.enable) {
+				continue;
+			}
 
 			Date currTime = new Date();
+			String tmpPath = Constant.info_point;
+			String LatestPath = Constant.getLatestPath(tmpPath, true, false);
 			boolean changed = false;
-			if (ConfigRefresh.last_refresh == null
+			if (LatestPath == null || ConfigRefresh.last_refresh == null
 					|| currTime.getTime() - ConfigRefresh.last_refresh.getTime() > 1000L * ConfigRefresh.interval_second) {
-				if (ConfigRefresh.enable && Constant.info_point_version.equals("new")) {
-					LogOfDownload LogOfDownload = new LogOfDownload();
-					RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
-					try {
-						log.warn(name + " check begin");
-						changed = Process(LogOfDownload);
-						if (changed) {
-							String validPath = Constant.getLatestPath(Constant.info_point, false, false);
-							log.warn(name + " check end " + validPath);
-						} else {
-							log.warn(name + " check end");
-						}
-						LogOfDownload.status = "success";
-						RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
-					} catch (Exception e) {
-						String message = LogUtil.GetExceptionStackTrace(e);
-						log.error(e.getMessage(), e);
-						LogOfDownload.error(null, message);
-						LogOfDownload.status = "failure";
+				LogOfDownload LogOfDownload = new LogOfDownload();
+				RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
+				try {
+					log.warn(name + " check begin");
+					changed = Process(LogOfDownload);
+					if (changed) {
+						String validPath = Constant.getLatestPath(tmpPath, false, false);
+						log.warn(name + " check end " + validPath);
+					} else {
+						log.warn(name + " check end");
 					}
-					LogOfDownload.endTime = new Date();
+					LogOfDownload.status = "success";
+					RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
+				} catch (Exception e) {
+					String message = LogUtil.GetExceptionStackTrace(e);
+					log.error(e.getMessage(), e);
+					LogOfDownload.error(null, message);
+					LogOfDownload.status = "failure";
 				}
+				LogOfDownload.endTime = new Date();
 				ConfigRefresh.last_refresh = currTime;
 			}
 		}

+ 24 - 21
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DownloadThread_rwd.java

@@ -55,33 +55,36 @@ public class DownloadThread_rwd extends Thread {
 			} catch (InterruptedException e) {
 				log.error(e.getMessage(), e);
 			}
+			if (!ConfigRefresh.enable) {
+				continue;
+			}
 
 			Date currTime = new Date();
+			String tmpPath = Constant.physical_world;
+			String LatestPath = Constant.getLatestPath(tmpPath, true, false);
 			boolean changed = false;
-			if (ConfigRefresh.last_refresh == null
+			if (LatestPath == null || ConfigRefresh.last_refresh == null
 					|| currTime.getTime() - ConfigRefresh.last_refresh.getTime() > 1000L * ConfigRefresh.interval_second) {
-				if (ConfigRefresh.enable) {
-					LogOfDownload LogOfDownload = new LogOfDownload();
-					RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
-					try {
-						log.warn(name + " check begin");
-						changed = RWDDownloadUtil.Process_physical_world(LogOfDownload);
-						if (changed) {
-							String validPath = Constant.getLatestPath(Constant.physical_world, true, false);
-							log.warn(name + " check end " + validPath);
-						} else {
-							log.warn(name + " check end");
-						}
-						LogOfDownload.status = "success";
-						RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
-					} catch (Exception e) {
-						String message = LogUtil.GetExceptionStackTrace(e);
-						log.error(e.getMessage(), e);
-						LogOfDownload.error(null, message);
-						LogOfDownload.status = "failure";
+				LogOfDownload LogOfDownload = new LogOfDownload();
+				RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
+				try {
+					log.warn(name + " check begin");
+					changed = RWDDownloadUtil.Process_physical_world(LogOfDownload);
+					if (changed) {
+						String validPath = Constant.getLatestPath(tmpPath, true, false);
+						log.warn(name + " check end " + validPath);
+					} else {
+						log.warn(name + " check end");
 					}
-					LogOfDownload.endTime = new Date();
+					LogOfDownload.status = "success";
+					RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
+				} catch (Exception e) {
+					String message = LogUtil.GetExceptionStackTrace(e);
+					log.error(e.getMessage(), e);
+					LogOfDownload.error(null, message);
+					LogOfDownload.status = "failure";
 				}
+				LogOfDownload.endTime = new Date();
 				ConfigRefresh.last_refresh = currTime;
 			}
 		}

+ 27 - 21
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DownloadThread_zkt.java

@@ -55,33 +55,39 @@ public class DownloadThread_zkt extends Thread {
 			} catch (InterruptedException e) {
 				log.error(e.getMessage(), e);
 			}
+			if (!Constant.zkt_physical_world_enable) {
+				continue;
+			}
+			if (!ConfigRefresh.enable) {
+				continue;
+			}
 
 			Date currTime = new Date();
+			String tmpPath = Constant.zkt_physical_world;
+			String LatestPath = Constant.getLatestPath(tmpPath, true, false);
 			boolean changed = false;
-			if (ConfigRefresh.last_refresh == null
+			if (LatestPath == null || ConfigRefresh.last_refresh == null
 					|| currTime.getTime() - ConfigRefresh.last_refresh.getTime() > 1000L * ConfigRefresh.interval_second) {
-				if (Constant.zkt_physical_world_enable && ConfigRefresh.enable) {
-					LogOfDownload LogOfDownload = new LogOfDownload();
-					RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
-					try {
-						log.warn(name + " check begin");
-						changed = RWDDownloadUtil.Process_zkt_physical_world(LogOfDownload);
-						if (changed) {
-							String validPath = Constant.getLatestPath(Constant.zkt_physical_world, true, false);
-							log.warn(name + " check end " + validPath);
-						} else {
-							log.warn(name + " check end");
-						}
-						LogOfDownload.status = "success";
-						RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
-					} catch (Exception e) {
-						String message = LogUtil.GetExceptionStackTrace(e);
-						log.error(e.getMessage(), e);
-						LogOfDownload.error(null, message);
-						LogOfDownload.status = "failure";
+				LogOfDownload LogOfDownload = new LogOfDownload();
+				RepositoryContainer.RepositoryProject.AddLogOfDownload(name, LogOfDownload);
+				try {
+					log.warn(name + " check begin");
+					changed = RWDDownloadUtil.Process_zkt_physical_world(LogOfDownload);
+					if (changed) {
+						String validPath = Constant.getLatestPath(tmpPath, true, false);
+						log.warn(name + " check end " + validPath);
+					} else {
+						log.warn(name + " check end");
 					}
-					LogOfDownload.endTime = new Date();
+					LogOfDownload.status = "success";
+					RepositoryContainer.RepositoryProject.AddSuccessLogOfDownload(name, LogOfDownload);
+				} catch (Exception e) {
+					String message = LogUtil.GetExceptionStackTrace(e);
+					log.error(e.getMessage(), e);
+					LogOfDownload.error(null, message);
+					LogOfDownload.status = "failure";
 				}
+				LogOfDownload.endTime = new Date();
 				ConfigRefresh.last_refresh = currTime;
 			}
 		}

+ 6 - 3
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/RefreshThread.java

@@ -131,9 +131,11 @@ public class RefreshThread extends Thread {
 					RepositoryContainer.RepositoryProject.AddSuccessLogOfRun(LogOfRun);
 
 					if (LogOfRun.errorList.size() == 0) {
-						A.perfect();
+						A.print("perfect");
+						A.print_joke("perfect");
 					} else {
-						A.good();
+						A.print("good");
+						A.print_joke("good");
 					}
 				} catch (Exception e) {
 					String message = LogUtil.GetExceptionStackTrace(e);
@@ -141,7 +143,8 @@ public class RefreshThread extends Thread {
 					LogOfRun.error(null, message);
 					LogOfRun.status = "failure";
 
-					A.bad();
+					A.print("bad");
+					A.print_joke("bad");
 				}
 				for (String resource : LogOfRun.resourceTime_new.keySet()) {
 					RepositoryContainer.RepositoryProject.resourceMap_try.put(resource, LogOfRun.resourceTime_new.get(resource));

+ 18 - 9
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDDownloadUtil.java

@@ -199,8 +199,8 @@ public class RWDDownloadUtil {
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 		String validPath = Constant.getLatestPath(Constant.physical_world, true);
 		// 存储临时文件
-		File dir1;
-		{
+		File dir1 = null;
+		if (validPath != null) {
 			String tmpPath = Constant.physical_world + Constant.getSeperator() + "tmp1";
 			dir1 = new File(tmpPath);
 			RWDDownloadUtil.Load_physical_world(tmpPath, LogOfDownload);
@@ -212,7 +212,10 @@ public class RWDDownloadUtil {
 			RWDDownloadUtil.Load_physical_world(tmpPath, LogOfDownload);
 		}
 		// 检查一致性
-		boolean compare = FileUtil.compareRecursive(dir1, dir2, null);
+		boolean compare = true;
+		if (validPath != null) {
+			compare = FileUtil.compareRecursive(dir1, dir2, null);
+		}
 		log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
 		boolean result;
 		if (compare) {
@@ -387,8 +390,8 @@ public class RWDDownloadUtil {
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 		String validPath = Constant.getLatestPath(Constant.zkt_physical_world, true);
 		// 存储临时文件
-		File dir1;
-		{
+		File dir1 = null;
+		if (validPath != null) {
 			String tmpPath = Constant.zkt_physical_world + Constant.getSeperator() + "tmp1";
 			dir1 = new File(tmpPath);
 			RWDDownloadUtil.Load_zkt_physical_world(tmpPath, LogOfDownload);
@@ -400,7 +403,10 @@ public class RWDDownloadUtil {
 			RWDDownloadUtil.Load_zkt_physical_world(tmpPath, LogOfDownload);
 		}
 		// 检查一致性
-		boolean compare = FileUtil.compareRecursive(dir1, dir2, null);
+		boolean compare = true;
+		if (validPath != null) {
+			compare = FileUtil.compareRecursive(dir1, dir2, null);
+		}
 		log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
 		boolean result;
 		if (compare) {
@@ -627,8 +633,8 @@ public class RWDDownloadUtil {
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 		String validPath = Constant.getLatestPath(Constant.ibms_physical_world, true);
 		// 存储临时文件
-		File dir1;
-		{
+		File dir1 = null;
+		if (validPath != null) {
 			String tmpPath = Constant.ibms_physical_world + Constant.getSeperator() + "tmp1";
 			dir1 = new File(tmpPath);
 			RWDDownloadUtil.Load_ibms_physical_world(tmpPath, LogOfDownload);
@@ -640,7 +646,10 @@ public class RWDDownloadUtil {
 			RWDDownloadUtil.Load_ibms_physical_world(tmpPath, LogOfDownload);
 		}
 		// 检查一致性
-		boolean compare = FileUtil.compareRecursive(dir1, dir2, null);
+		boolean compare = true;
+		if (validPath != null) {
+			compare = FileUtil.compareRecursive(dir1, dir2, null);
+		}
 		log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
 		boolean result;
 		if (compare) {

BIN
ibms-data-sdk/src/main/resources/interval_range.xlsx