Browse Source

文件比较漏了Integer

menglu 3 years ago
parent
commit
44b2f22768

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

@@ -8,7 +8,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableScheduling
 public class Application_ibms_data_sdk {
 
-	public static void main(String[] args) {
+	public static void main(String[] args) throws Exception {
 		SpringApplication.run(Application_ibms_data_sdk.class, args);
 	}
 

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

@@ -1,5 +1,7 @@
 package com.persagy.ibms.data.sdk.util;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.Iterator;
 
 import com.alibaba.fastjson.JSONArray;
@@ -133,10 +135,18 @@ public class FastJsonCompareUtil {
 
 		boolean result = false;
 		if (value1.getClass() == value2.getClass()) {
-			if (value1 instanceof Long && value2 instanceof Long) {
+			if (value1 instanceof Integer && value2 instanceof Integer) {
+				result = ((Integer) value1).intValue() == ((Integer) value2).intValue();
+			} else if (value1 instanceof Long && value2 instanceof Long) {
 				result = ((Long) value1).longValue() == ((Long) value2).longValue();
+			} else if (value1 instanceof BigInteger && value2 instanceof BigInteger) {
+				result = ((BigInteger) value1).longValue() == ((BigInteger) value2).longValue();
+			} else if (value1 instanceof Float && value2 instanceof Float) {
+				result = Math.abs(((Float) value1).floatValue() - ((Float) value2).floatValue()) < 0.00000001;
 			} else if (value1 instanceof Double && value2 instanceof Double) {
 				result = Math.abs(((Double) value1).doubleValue() - ((Double) value2).doubleValue()) < 0.00000001;
+			} else if (value1 instanceof BigDecimal && value2 instanceof BigDecimal) {
+				result = Math.abs(((BigDecimal) value1).doubleValue() - ((BigDecimal) value2).doubleValue()) < 0.00000001;
 			} else if (value1 instanceof Boolean && value2 instanceof Boolean) {
 				result = ((Boolean) value1).booleanValue() == ((Boolean) value2).booleanValue();
 			} else if (value1 instanceof String && value2 instanceof String) {

+ 3 - 2
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/FileUtil.java

@@ -70,10 +70,11 @@ public class FileUtil {
 
 			return true;
 		} else if (file1.isFile() && file2.isFile()) {
-			log.info(LogUtil.refreshLoggerName + "\t" + "Compare " + file1.getPath() + " " + file2.getPath());
 			Object json1 = FastJsonReaderUtil.Instance().Read(file1);
 			Object json2 = FastJsonReaderUtil.Instance().Read(file2);
-			return FastJsonCompareUtil.Instance().CompareObject(json1, json2);
+			boolean file_compare = FastJsonCompareUtil.Instance().CompareObject(json1, json2);
+			log.info(LogUtil.refreshLoggerName + "\t" + "Compare " + file1.getPath() + " " + file2.getPath() + "\t" + file_compare);
+			return file_compare;
 		} else {
 			return false;
 		}

+ 2 - 2
ibms-data-sdk/src/main/java/com/sagacloud/ExpressionUtil.java

@@ -2,7 +2,6 @@ package com.sagacloud;
 
 import java.io.ByteArrayInputStream;
 
-import lombok.extern.slf4j.Slf4j;
 import org.antlr.runtime.ANTLRInputStream;
 import org.antlr.runtime.CommonTokenStream;
 import org.antlr.runtime.tree.CommonTree;
@@ -10,13 +9,14 @@ import org.antlr.runtime.tree.CommonTreeNodeStream;
 
 import com.alibaba.fastjson.JSONObject;
 import com.persagy.ibms.data.sdk.data.SceneProperty;
-import com.persagy.ibms.data.sdk.util.LogUtil;
 import com.persagy.ibms.data.sdk.util.Repository;
 import com.sagacloud.advanced.expression.AdvancedExpressionLexer;
 import com.sagacloud.advanced.expression.AdvancedExpressionParser;
 import com.sagacloud.advanced.expression.AdvancedExpressionScanner;
 import com.sagacloud.advanced.expression.AdvancedExpressionWalker;
 
+import lombok.extern.slf4j.Slf4j;
+
 @Slf4j
 public class ExpressionUtil {