瀏覽代碼

曲线数据限制位数

menglu 3 年之前
父節點
當前提交
6fdad95acc
共有 2 個文件被更改,包括 35 次插入1 次删除
  1. 1 1
      ibms-data-sdk/pom.xml
  2. 34 0
      ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/DeamonUtil.java

+ 1 - 1
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.3</version>
+	<version>0.1.4</version>
 
 	<repositories>
 		<repository>

+ 34 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/DeamonUtil.java

@@ -1,5 +1,6 @@
 package com.persagy.ibms.data.sdk.util;
 
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -22,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
 public class DeamonUtil {
 
 	public static void Process_deamon(RepositoryBase Repository) throws Exception {
+		DecimalFormat df = new DecimalFormat("#.#");
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
 		Map<String, Boolean> pointMap = new ConcurrentHashMap<String, Boolean>();
 		for (SceneDataValue sdv : Repository.deamon_sdv2pointList.keySet()) {
@@ -100,6 +102,38 @@ public class DeamonUtil {
 				}
 				sdv.value_prim.change = true;
 			} else if (QueryType.equals("curve")) {
+				for (SceneDataObject SceneDataObject : dataList) {
+					SceneDataValue valueSDV = SceneDataObject.get("data_value");
+					double valueOld = DataUtil.primitive2double(valueSDV.value_prim.value);
+					String value = df.format(valueOld);
+					if (value.endsWith(".0")) {
+						value = value.substring(0, value.length() - ".0".length());
+					}
+					Object valueNew;
+					try {
+						valueNew = Long.parseLong(value);
+					} catch (Exception e1) {
+						try {
+							double doubleValue = Double.parseDouble(value);
+							if (Constant.iot_round_d_to_enable) {
+								double tmpDouble = doubleValue;
+								for (int index_d = 0; index_d < Constant.iot_round_d_to_length; index_d++) {
+									tmpDouble *= 10;
+								}
+								long tmpLong = (long) tmpDouble;
+								tmpDouble = tmpLong;
+								for (int index_d = 0; index_d < Constant.iot_round_d_to_length; index_d++) {
+									tmpDouble /= 10;
+								}
+								doubleValue = tmpDouble;
+							}
+							valueNew = doubleValue;
+						} catch (Exception e) {
+							valueNew = value;
+						}
+					}
+					valueSDV.value_prim.value = valueNew;
+				}
 				sdv.value_array.set = dataList;
 				sdv.value_array.setRowChange(true);
 			}