소스 검색

完善聚合数据类型转换

menglu 3 년 전
부모
커밋
761ab5c516

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

@@ -335,7 +335,7 @@ public class ComputeUtil {
 						sb.append(ss.propertyName);
 					}
 					log.info("computeOnce:" + sb.toString());
-					// if (sb.toString().equals("基础对象-设备-清单")) {
+					// if (sb.toString().equals("基础对象-品质-公共照明-照明空间-清单-照明状态")) {
 					// System.out.println();
 					// }
 				}
@@ -459,6 +459,37 @@ public class ComputeUtil {
 						}
 					}
 				}
+				if (sceneProperty.propertyValueSchema.equals("int")) {
+					if (sv.value_prim.value != null) {
+						Object jt = sv.value_prim.value;
+						int jtValue;
+						if (jt instanceof Integer) {
+							jtValue = ((Integer) jt).intValue();
+						} else if (jt instanceof Long) {
+							jtValue = ((Long) jt).intValue();
+						} else if (jt instanceof Float) {
+							jtValue = ((Float) jt).intValue();
+						} else {
+							jtValue = ((Double) jt).intValue();
+						}
+						sv.value_prim.value = jtValue;
+					}
+				} else if (sceneProperty.propertyValueSchema.equals("double")) {
+					if (sv.value_prim.value != null) {
+						Object jt = sv.value_prim.value;
+						double jtValue;
+						if (jt instanceof Integer) {
+							jtValue = ((Integer) jt).doubleValue();
+						} else if (jt instanceof Long) {
+							jtValue = ((Long) jt).doubleValue();
+						} else if (jt instanceof Float) {
+							jtValue = ((Float) jt).doubleValue();
+						} else {
+							jtValue = ((Double) jt).doubleValue();
+						}
+						sv.value_prim.value = jtValue;
+					}
+				}
 			}
 			sv.finish = true;
 		} else if (sceneProperty.propertyValueType.equals("custom")) {

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

@@ -1154,7 +1154,17 @@ public class QueryUtil {
 				int count_valid = 0;
 				for (Object jt : agg_items_one) {
 					if (jt != null) {
-						sum += (double) (jt);
+						double jtValue;
+						if (jt instanceof Integer) {
+							jtValue = ((Integer) jt).doubleValue();
+						} else if (jt instanceof Long) {
+							jtValue = ((Long) jt).doubleValue();
+						} else if (jt instanceof Float) {
+							jtValue = ((Float) jt).doubleValue();
+						} else {
+							jtValue = ((Double) jt).doubleValue();
+						}
+						sum += jtValue;
 						count_valid++;
 					}
 				}