menglu 3 years ago
parent
commit
191ef1ab52

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


+ 14 - 8
ibms-data-sdk/pom.xml

@@ -2,7 +2,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.persagy</groupId>
 	<artifactId>ibms-data-sdk</artifactId>
-	<version>0.1.5</version>
+	<version>0.1.6</version>
 
 	<repositories>
 		<repository>
@@ -212,9 +212,15 @@
 		</dependency>
 
 		<dependency>
+			<groupId>org.ansj</groupId>
+			<artifactId>ansj_seg</artifactId>
+			<version>5.1.6</version>
+		</dependency>
+
+		<dependency>
 			<groupId>com.persagy</groupId>
 			<artifactId>sailfish</artifactId>
-			<version>0.0.42</version>
+			<version>0.0.43</version>
 		</dependency>
 	</dependencies>
 
@@ -237,12 +243,12 @@
 				<artifactId>maven-jar-plugin</artifactId>
 				<version>2.4</version>
 				<configuration>
-<!--					<excludes>-->
-<!--						<exclude>*.properties</exclude>-->
-<!--						<exclude>*.xml</exclude>-->
-<!--						<exclude>*.json</exclude>-->
-<!--						<exclude>*.xlsx</exclude>-->
-<!--					</excludes>-->
+					<!-- <excludes> -->
+					<!-- <exclude>*.properties</exclude> -->
+					<!-- <exclude>*.xml</exclude> -->
+					<!-- <exclude>*.json</exclude> -->
+					<!-- <exclude>*.xlsx</exclude> -->
+					<!-- </excludes> -->
 					<archive>
 						<manifest>
 							<addClasspath>true</addClasspath>

+ 125 - 10
ibms-data-sdk/src/main/java/a/A.java

@@ -1,8 +1,12 @@
 package a;
 
 import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileReader;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
@@ -10,6 +14,10 @@ import java.util.Random;
 
 import javax.imageio.ImageIO;
 
+import org.ansj.domain.Result;
+import org.ansj.domain.Term;
+import org.ansj.splitWord.analysis.ToAnalysis;
+
 import com.persagy.ibms.data.sdk.util.Constant;
 import com.persagy.ibms.data.sdk.util.ImageUtil;
 
@@ -47,7 +55,7 @@ public class A {
 			InputStream is = new FileInputStream(choose);
 			BufferedImage bi = ImageIO.read(is);
 			is.close();
-			List<String> strList = ImageUtil.toStringList(bi, true);
+			List<String> strList = ImageUtil.toStringList(bi, false);
 			for (String str : strList) {
 				System.out.println(str);
 				// log.error(str);
@@ -60,24 +68,131 @@ public class A {
 	}
 
 	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);
 		}
+		log.warn("compute result: " + status);
 	}
 
-	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++) {
+	// static String[] fuhao1 = { ",", ".", "?", ":", ";", "'", "\"", "(", ")", "!", "、" };
+	// static String[] fuhao2 = { ",", "。", "?", ":", ";", "‘", "’", "“", "”", "(", ")", "!" };
+	static String[] fuhao1 = { ",", ".", ":", ";", "'", "\"", "(", ")", "、" };
+	static String[] fuhao2 = { ",", "。", ":", ";", "‘", "’", "“", "”", "(", ")" };
+
+	public static void chinese_split(String title, List<String> lineList) {
+		Result result = ToAnalysis.parse(title);
+		List<Term> termList = result.getTerms();
+		List<String> tmpList = new ArrayList<String>();
+		for (Term Term : termList) {
+			String name = Term.getName();
+			boolean isfuhao = false;
+			if (!isfuhao) {
+				for (String fuhao : fuhao1) {
+					if (fuhao.equals(name)) {
+						isfuhao = true;
+						break;
+					}
+				}
+			}
+			if (!isfuhao) {
+				for (String fuhao : fuhao2) {
+					if (fuhao.equals(name)) {
+						isfuhao = true;
+						break;
+					}
+				}
+			}
+			if (!isfuhao) {
+				int index = 0;
+				while (index < name.length()) {
+					int next_index;
+					if (name.length() == index + 3) {
+						next_index = index + 3;
+					} else {
+						next_index = index + 2 < name.length() ? index + 2 : name.length();
+					}
+					tmpList.add(name.substring(index, next_index));
+					index = next_index;
+				}
+			}
+		}
+		for (int i = 0; i < tmpList.size(); i++) {
+			String curr = tmpList.get(i);
+			if (i < tmpList.size() - 1) {
+				String next = tmpList.get(i + 1);
+				if (curr.length() + next.length() <= 2) {
+					lineList.add(curr + next);
+					i++;
+					continue;
+				}
+			}
+			lineList.add(curr);
+		}
+	}
+
+	public static void print_text(String status, String filename, boolean all, boolean sleep) {
+		File file = new File("img" + Constant.getSeperator() + filename);
+		if (file.exists() && file.isFile()) {
+			List<String> lineList = new ArrayList<String>();
+			try {
+				BufferedReader reader = new BufferedReader(new FileReader(file));
+				String temp;
+				while ((temp = reader.readLine()) != null) {
+					if (temp.length() > 0) {
+						lineList.add(temp);
+					}
+				}
+				reader.close();
+			} catch (Exception e) {
+				log.error(e.getMessage(), e);
+			}
+
+			List<String> wordList = new ArrayList<String>();
+			if (all) {
+				for (String line : lineList) {
+					chinese_split(line, wordList);
+				}
+			} else {
+				Random rand = new Random();
+				int index = rand.nextInt(lineList.size());
+				chinese_split(lineList.get(index), wordList);
+			}
+			boolean isTextBlack = true;
+			for (String word : wordList) {
+				if (sleep) {
+					try {
+						Thread.sleep(1000L);
+					} catch (InterruptedException e) {
+					}
+				}
+				int fontSize = word.length() == 1 ? 108 : (word.length() == 2 ? 64 : 48);
 				try {
-					Thread.sleep(1000L);
-				} catch (InterruptedException e) {
+					ByteArrayOutputStream os = new ByteArrayOutputStream();
+					ImageUtil.drawChinese(word, false, fontSize, isTextBlack, os);
+					os.close();
+					InputStream is = new ByteArrayInputStream(os.toByteArray());
+					BufferedImage bi = ImageIO.read(is);
+					is.close();
+					List<String> strList = ImageUtil.toStringList(bi);
+					for (String str : strList) {
+						System.out.println(str);
+					}
+				} catch (Exception e) {
+					log.error(e.getMessage(), e);
 				}
-				log.warn("compute result: " + status);
-				printOne(file, false, i);
+				log.warn(status);
 			}
 		}
 	}
+
+	public static void main(String[] args) throws Exception {
+		A.print_text("good", "joke.txt", false, false);
+		A.print_text("good", "joke.txt", false, false);
+		List<String> wordList = new ArrayList<String>();
+		A.chinese_split("我叫李太白,我是一个诗人,我生活在唐朝", wordList);
+		for (String word : wordList) {
+			System.out.println(word);
+		}
+	}
 }

+ 5 - 3
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DaemonThread.java

@@ -51,6 +51,8 @@ public class DaemonThread extends Thread {
 	public static List<RepositoryComputeThread> threadList = new CopyOnWriteArrayList<RepositoryComputeThread>();
 
 	public void run() {
+		A.print_text("welcome", "welcome.txt", false, false);
+
 		KeywordUtil.keyWordMap = Constant.keyWordMap;
 		KeywordUtil.prefixMap = Constant.prefixMap;
 		KeywordUtil.suffixMap = Constant.suffixMap;
@@ -220,9 +222,9 @@ public class DaemonThread extends Thread {
 
 				// 循环打印字符画
 				if (LogOfRun.errorList.size() == 0) {
-					A.print_joke("perfect");
+					A.print_text("compute result: perfect", "joke.txt", false, true);
 				} else {
-					A.print_joke("good");
+					A.print_text("compute result: good", "joke.txt", false, true);
 				}
 
 				break;
@@ -231,7 +233,7 @@ public class DaemonThread extends Thread {
 				A.print("bad");
 
 				// 循环打印字符画
-				A.print_joke("bad");
+				A.print_text("compute result: bad", "joke.txt", false, true);
 			}
 		}
 

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

@@ -63,7 +63,7 @@ public class DownloadThread_config extends Thread {
 			}
 
 			Date currTime = new Date();
-			String tmpPath = Constant.ibms_physical_world;
+			String tmpPath = Constant.config;
 			String LatestPath = Constant.getLatestPath(tmpPath, false, false);
 			boolean changed = false;
 			if (LatestPath == null || ConfigRefresh.last_refresh == null

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

@@ -132,10 +132,10 @@ public class RefreshThread extends Thread {
 
 					if (LogOfRun.errorList.size() == 0) {
 						A.print("perfect");
-						A.print_joke("perfect");
+						A.print_text("compute result: perfect", "joke.txt", false, true);
 					} else {
 						A.print("good");
-						A.print_joke("good");
+						A.print_text("compute result: good", "joke.txt", false, true);
 					}
 				} catch (Exception e) {
 					String message = LogUtil.GetExceptionStackTrace(e);
@@ -144,7 +144,7 @@ public class RefreshThread extends Thread {
 					LogOfRun.status = "failure";
 
 					A.print("bad");
-					A.print_joke("bad");
+					A.print_text("compute result: bad", "joke.txt", false, true);
 				}
 				for (String resource : LogOfRun.resourceTime_new.keySet()) {
 					RepositoryContainer.RepositoryProject.resourceMap_try.put(resource, LogOfRun.resourceTime_new.get(resource));

+ 2 - 2
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/WebSocketCheckThread.java

@@ -35,7 +35,7 @@ public class WebSocketCheckThread extends Thread {
 			try {
 				WebSocketClient outCallWebSocketClientHolder = IOTWebSocketClient.client;
 				if (null == outCallWebSocketClientHolder) {
-					log.info("IOT当前连接还未建立");
+					log.debug("IOT当前连接还未建立");
 					return;
 				}
 				if (!outCallWebSocketClientHolder.isOpen()) {
@@ -71,7 +71,7 @@ public class WebSocketCheckThread extends Thread {
 			try {
 				WebSocketClient outCallWebSocketClientHolder = AlarmWebSocketClient.client;
 				if (null == outCallWebSocketClientHolder) {
-					log.info("Alarm当前连接还未建立");
+					log.debug("Alarm当前连接还未建立");
 					return;
 				}
 				if (!outCallWebSocketClientHolder.isOpen()) {

+ 5 - 5
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -63,7 +63,7 @@ public class RWDLoadUtil {
 			for (File file : files) {
 				int index_ = file.getName().indexOf('.');
 				String code = file.getName().substring(0, index_);
-				log.info(infoPath + Constant.getSeperator() + "" + file.getName());
+				log.debug(infoPath + Constant.getSeperator() + "" + file.getName());
 				try {
 					JSONArray array = FastJsonReaderUtil.Instance().ReadJSONArray(new File(infoPath + Constant.getSeperator() + "" + file.getName()));
 					SceneDataSet SceneDataSet = new SceneDataSet(false, "rwd/info/" + code);
@@ -127,7 +127,7 @@ public class RWDLoadUtil {
 					continue;
 				}
 				String className = Repository.classCode2NameMap.get(code);
-				log.info(objectPath + Constant.getSeperator() + "" + file.getName());
+				log.debug(objectPath + Constant.getSeperator() + "" + file.getName());
 				JSONArray array = FastJsonReaderUtil.Instance().ReadJSONArray(new File(objectPath + Constant.getSeperator() + "" + file.getName()));
 				// info_replace
 				if (Repository.code2objTypeMap.containsKey(code)) {
@@ -237,7 +237,7 @@ public class RWDLoadUtil {
 				for (File file : files) {
 					int index_ = file.getName().indexOf('.');
 					String code = file.getName().substring(0, index_);
-					log.info(relationPath + Constant.getSeperator() + "" + dir.getName() + Constant.getSeperator() + file.getName());
+					log.debug(relationPath + Constant.getSeperator() + "" + dir.getName() + Constant.getSeperator() + file.getName());
 					JSONArray array = FastJsonReaderUtil.Instance().ReadJSONArray(
 							new File(relationPath + Constant.getSeperator() + "" + dir.getName() + Constant.getSeperator() + file.getName()));
 					SceneDataSet SceneDataSet = new SceneDataSet(false, "rwd/relation/" + dir.getName() + "/" + code);
@@ -658,7 +658,7 @@ public class RWDLoadUtil {
 					objectArrayDicZKT.put(ibmsSceneCode, new ConcurrentHashMap<String, SceneDataValue>());
 				}
 				Map<String, SceneDataValue> mapInner = objectArrayDicZKT.get(ibmsSceneCode);
-				log.info(objectPath + Constant.getSeperator() + ibmsSceneCode + " " + ibmsClassCode);
+				log.debug(objectPath + Constant.getSeperator() + ibmsSceneCode + " " + ibmsClassCode);
 				JSONArray array = FastJsonReaderUtil.Instance().ReadJSONArray(
 						new File(objectPath + Constant.getSeperator() + ibmsSceneCode + Constant.getSeperator() + ibmsClassCode + ".json"));
 				SceneDataSet SceneDataSet = new SceneDataSet(false, "zkt-object" + "/" + ibmsSceneCode + "/" + ibmsClassCode);
@@ -779,7 +779,7 @@ public class RWDLoadUtil {
 				int index_ = file.getName().indexOf('.');
 				String code = file.getName().substring(0, index_);
 				String infoPath = validPath + Constant.getSeperator() + product;
-				log.info(infoPath + Constant.getSeperator() + file.getName());
+				log.debug(infoPath + Constant.getSeperator() + file.getName());
 				try {
 					JSONArray array = FastJsonReaderUtil.Instance().ReadJSONArray(new File(infoPath + Constant.getSeperator() + file.getName()));
 					SceneDataSet SceneDataSet = new SceneDataSet(false, "ibms-group-object" + "/" + product + "/" + code);