浏览代码

多数据源切换,tomcat安全版本升级配置

shilin 4 年之前
父节点
当前提交
31b9c41c28
共有 44 个文件被更改,包括 2630 次插入46 次删除
  1. 23 0
      pom.xml
  2. 25 0
      src/main/java/com/gyee/frame/common/conf/GoldenConfig.java
  3. 11 0
      src/main/java/com/gyee/frame/common/conf/V2Config.java
  4. 14 24
      src/main/java/com/gyee/frame/service/app/index/IndexService.java
  5. 3 3
      src/main/java/com/gyee/frame/service/app/targetdetail/TargetdetailService.java
  6. 4 5
      src/main/java/com/gyee/frame/service/app/windpowerstationdetail/WindpowerstationdetailService.java
  7. 3 3
      src/main/java/com/gyee/frame/service/app/windpowerstationdetail/Windspeedpowermodule.java
  8. 210 0
      src/main/java/com/gyee/frame/util/IRealTimeDataBaseUtil.java
  9. 23 0
      src/main/java/com/gyee/frame/util/RealTimeDataBaseFactory.java
  10. 48 0
      src/main/java/com/gyee/frame/util/golden/ApiGolden.java
  11. 1262 0
      src/main/java/com/gyee/frame/util/golden/EdosUtil.java
  12. 33 0
      src/main/java/com/gyee/frame/util/golden/StringUtil.java
  13. 28 0
      src/main/java/com/gyee/frame/util/golden/timeseries/BaseTsQuery.java
  14. 38 0
      src/main/java/com/gyee/frame/util/golden/timeseries/BasicTsData.java
  15. 29 0
      src/main/java/com/gyee/frame/util/golden/timeseries/BasicTsPoint.java
  16. 24 0
      src/main/java/com/gyee/frame/util/golden/timeseries/BlobTsData.java
  17. 22 0
      src/main/java/com/gyee/frame/util/golden/timeseries/BlobWriteTsData.java
  18. 24 0
      src/main/java/com/gyee/frame/util/golden/timeseries/BooleanTsData.java
  19. 19 0
      src/main/java/com/gyee/frame/util/golden/timeseries/BooleanWriteTsData.java
  20. 18 0
      src/main/java/com/gyee/frame/util/golden/timeseries/Coordinate.java
  21. 26 0
      src/main/java/com/gyee/frame/util/golden/timeseries/CoordinateTsData.java
  22. 21 0
      src/main/java/com/gyee/frame/util/golden/timeseries/CoordinateWriteTsData.java
  23. 30 0
      src/main/java/com/gyee/frame/util/golden/timeseries/DoubleStatData.java
  24. 25 0
      src/main/java/com/gyee/frame/util/golden/timeseries/DoubleTsData.java
  25. 19 0
      src/main/java/com/gyee/frame/util/golden/timeseries/DoubleWriteTsData.java
  26. 38 0
      src/main/java/com/gyee/frame/util/golden/timeseries/ErrorRequest.java
  27. 27 0
      src/main/java/com/gyee/frame/util/golden/timeseries/GeneralTsData.java
  28. 8 0
      src/main/java/com/gyee/frame/util/golden/timeseries/Interpolation.java
  29. 230 0
      src/main/java/com/gyee/frame/util/golden/timeseries/JsonObjectHelper.java
  30. 24 0
      src/main/java/com/gyee/frame/util/golden/timeseries/LongTsData.java
  31. 20 0
      src/main/java/com/gyee/frame/util/golden/timeseries/LongWriteTsData.java
  32. 24 0
      src/main/java/com/gyee/frame/util/golden/timeseries/StringTsData.java
  33. 33 0
      src/main/java/com/gyee/frame/util/golden/timeseries/StringUtil.java
  34. 20 0
      src/main/java/com/gyee/frame/util/golden/timeseries/StringWriteTsData.java
  35. 15 0
      src/main/java/com/gyee/frame/util/golden/timeseries/TsData.java
  36. 15 0
      src/main/java/com/gyee/frame/util/golden/timeseries/TsDataType.java
  37. 12 0
      src/main/java/com/gyee/frame/util/golden/timeseries/TsPoint.java
  38. 36 0
      src/main/java/com/gyee/frame/util/golden/timeseries/TsPointData.java
  39. 23 0
      src/main/java/com/gyee/frame/util/golden/timeseries/TsPointDataList.java
  40. 17 0
      src/main/java/com/gyee/frame/util/golden/timeseries/TsQuery.java
  41. 71 4
      src/main/java/com/gyee/frame/util/mongodb/JedisPoolUtil.java
  42. 28 1
      src/main/java/com/gyee/frame/util/mongodb/MongodbUtilImpl.java
  43. 2 0
      src/main/resources/application.yml
  44. 5 6
      src/test/java/test/MongoDBTest.java

+ 23 - 0
pom.xml

@@ -23,6 +23,7 @@
 		<java.version>1.8</java.version>
 		<commons.fileupload.version>1.3.3</commons.fileupload.version>
 		<commons.io.version>2.5</commons.io.version>
+		<tomcat.version>9.0.35</tomcat.version>
 	</properties>
 	
 	<!-- https://mvnrepository.com/ 查找jar网站 -->
@@ -269,6 +270,28 @@
 			<artifactId>jedis</artifactId>
 			<version>2.9.0</version>
 		</dependency>
+
+
+		<dependency>
+			<groupId>org.apache.tomcat</groupId>
+			<artifactId>tomcat-juli</artifactId>
+			<version>${tomcat.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.tomcat.embed</groupId>
+			<artifactId>tomcat-embed-core</artifactId>
+			<version>${tomcat.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.tomcat.embed</groupId>
+			<artifactId>tomcat-embed-el</artifactId>
+			<version>${tomcat.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.tomcat.embed</groupId>
+			<artifactId>tomcat-embed-websocket</artifactId>
+			<version>${tomcat.version}</version>
+		</dependency>
 	</dependencies>
 
 

+ 25 - 0
src/main/java/com/gyee/frame/common/conf/GoldenConfig.java

@@ -0,0 +1,25 @@
+package com.gyee.frame.common.conf;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 读取项目相关配置
+ * 
+ * @author gyee
+ */
+
+@Configuration
+@ConfigurationProperties(prefix = "golden")
+public class GoldenConfig
+{
+    public static String baseurl;
+
+    public static String getBaseurl() {
+        return baseurl;
+    }
+
+    public static void setBaseurl(String baseurl) {
+        GoldenConfig.baseurl = baseurl;
+    }
+}

+ 11 - 0
src/main/java/com/gyee/frame/common/conf/V2Config.java

@@ -36,6 +36,17 @@ public class V2Config
     private static String demoEnabled;
     /** 滚动验证码 **/
     private static Boolean rollVerification;
+    /** 实时数据库 **/
+    private  static String realtimedataBase;
+
+    public static String getRealtimedataBase() {
+        return realtimedataBase;
+    }
+
+    public static void setRealtimedataBase(String realtimedataBase) {
+        V2Config.realtimedataBase = realtimedataBase;
+    }
+
     public String getName()
     {
         return name;

+ 14 - 24
src/main/java/com/gyee/frame/service/app/index/IndexService.java

@@ -1,33 +1,23 @@
 package com.gyee.frame.service.app.index;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.SpringApplication;
-import org.springframework.stereotype.Service;
-
-import com.gyee.SpringbootStart;
 import com.gyee.frame.common.spring.Constant;
 import com.gyee.frame.common.spring.InitialRunner;
-import com.gyee.frame.model.auto.Weatherfd;
-import com.gyee.frame.model.auto.WeatherfdExample;
 import com.gyee.frame.model.auto.WindPowerstationTestingPoint;
 import com.gyee.frame.model.auto.Windpowerstation;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.enumeration.Messagetype;
 import com.gyee.frame.netty.websocket.util.SocketToolService;
-import com.gyee.frame.util.DateUtils;
-import com.gyee.frame.util.mongodb.IMongodbUtil;
-import com.gyee.frame.util.mongodb.MongodbUtilImpl;
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
+import com.gyee.frame.util.RealTimeDataBaseFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Service
 public class IndexService extends SocketToolService{
@@ -45,7 +35,7 @@ public class IndexService extends SocketToolService{
 	        windpowerstationAll.setId("0");
 	        wpls.add(windpowerstationAll);
 	        Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
-	        IMongodbUtil mongodb = new MongodbUtilImpl();
+	        IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
 
 	        for(Windpowerstation windpowerstation:wpls){
 	            Map<String,Double> pointDataMap = new HashMap();
@@ -130,7 +120,7 @@ public class IndexService extends SocketToolService{
         windpowerstationAll.setId("0");
         wpls.add(windpowerstationAll);
         Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
+        IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
 
         for(Windpowerstation windpowerstation:wpls){
             Map<String,Double> pointDataMap = new HashMap();
@@ -366,7 +356,7 @@ public class IndexService extends SocketToolService{
 	        windpowerstationAll.setId("0");
 	        wpls.add(windpowerstationAll);
 	        Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
-	        IMongodbUtil mongodb = new MongodbUtilImpl();
+	        IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
 
 	        for(Windpowerstation windpowerstation:wpls){
 	            Map<String,Double> pointDataMap = new HashMap();

+ 3 - 3
src/main/java/com/gyee/frame/service/app/targetdetail/TargetdetailService.java

@@ -4,8 +4,8 @@ import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.enumeration.Messagetype;
 import com.gyee.frame.netty.websocket.util.SocketToolService;
 import com.gyee.frame.util.DateUtils;
-import com.gyee.frame.util.mongodb.IMongodbUtil;
-import com.gyee.frame.util.mongodb.MongodbUtilImpl;
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
+import com.gyee.frame.util.RealTimeDataBaseFactory;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -25,7 +25,7 @@ public class TargetdetailService extends SocketToolService {
     public static Map<String,String> targetdetail_target_pointMap = new HashMap<>();
     public static Map<String,String> targetdetail_curve_pointMap = new HashMap<>();
     public static Map<String,String> targetdetail_histogram_pointMap = new HashMap<>();
-    IMongodbUtil mongodb = new MongodbUtilImpl();
+    IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
     private double decimal(int num,double value){
         return new BigDecimal(value).setScale(num, RoundingMode.HALF_EVEN).doubleValue();
     }

+ 4 - 5
src/main/java/com/gyee/frame/service/app/windpowerstationdetail/WindpowerstationdetailService.java

@@ -2,7 +2,6 @@ package com.gyee.frame.service.app.windpowerstationdetail;
 
 import com.gyee.frame.common.spring.Constant;
 import com.gyee.frame.common.spring.InitialRunner;
-import com.gyee.frame.common.spring.SpringUtils;
 import com.gyee.frame.model.auto.WindPowerstationTestingPoint;
 import com.gyee.frame.model.auto.Windpowerinfoday;
 import com.gyee.frame.model.auto.Windpowerstation;
@@ -10,9 +9,9 @@ import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.enumeration.Messagetype;
 import com.gyee.frame.netty.websocket.util.SocketToolService;
 import com.gyee.frame.service.WindpowerinfodayService;
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
+import com.gyee.frame.util.RealTimeDataBaseFactory;
 import com.gyee.frame.util.StringUtils;
-import com.gyee.frame.util.mongodb.IMongodbUtil;
-import com.gyee.frame.util.mongodb.MongodbUtilImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -47,7 +46,7 @@ public class WindpowerstationdetailService extends SocketToolService {
         windpowerstationAll.setId("0");
         wpls.add(windpowerstationAll);
         Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
+        IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
 
         for(Windpowerstation windpowerstation:wpls){
             Map<String,Double> pointDataMap = new HashMap();
@@ -132,7 +131,7 @@ public class WindpowerstationdetailService extends SocketToolService {
         windpowerstationAll.setId("0");
         wpls.add(windpowerstationAll);
         Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
+        IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
 
         for(Windpowerstation windpowerstation:wpls){
             Map<String,Double> pointDataMap = new HashMap();

+ 3 - 3
src/main/java/com/gyee/frame/service/app/windpowerstationdetail/Windspeedpowermodule.java

@@ -7,8 +7,8 @@ import com.gyee.frame.model.auto.Windpowerstation;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.model.enumeration.Messagetype;
 import com.gyee.frame.netty.websocket.util.SocketToolService;
-import com.gyee.frame.util.mongodb.IMongodbUtil;
-import com.gyee.frame.util.mongodb.MongodbUtilImpl;
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
+import com.gyee.frame.util.RealTimeDataBaseFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -35,7 +35,7 @@ public class Windspeedpowermodule extends SocketToolService {
         windpowerstationAll.setId("0");
         wpls.add(windpowerstationAll);
         Map<String,Map<String,Double>> windpowerstationpointDataMap = new HashMap();
-        IMongodbUtil mongodb = new MongodbUtilImpl();
+        IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
 
         for(Windpowerstation windpowerstation:wpls){
             Map<String,Double> pointDataMap = new HashMap();

+ 210 - 0
src/main/java/com/gyee/frame/util/IRealTimeDataBaseUtil.java

@@ -0,0 +1,210 @@
+package com.gyee.frame.util;
+
+
+import com.gyee.frame.model.auto.WindPowerstationTestingPoint;
+import com.gyee.frame.model.auto.WindTurbineTestingPointAi;
+import com.gyee.frame.model.custom.DNAStatVal;
+import com.gyee.frame.model.custom.DNAVal;
+import com.gyee.frame.model.custom.PointData;
+
+import java.util.List;
+import java.util.Map;
+
+
+public interface IRealTimeDataBaseUtil {
+    /**
+     * 通过风场测点获得测点实时数据
+     * @param point 只是用了code字段,作为唯一标识
+     * @returns
+     * @throws Exception
+     */
+    public PointData getRealData(WindPowerstationTestingPoint point) throws Exception;
+
+    /**
+     * 通过风场测点获得测点历史快照数据
+     * @param point 只是用了code字段,作为唯一标识
+     * @param beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @param count  点数
+     * @param pried  时间间隔
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistoryDatasSnap(WindPowerstationTestingPoint point, Long beginDate, Long endDate, Long count, Long pried) throws Exception;
+
+    /**
+     * 通过风场测点获得测点历史存储数据,存多少取多少
+     * @param point 只是用了code字段,作为唯一标识
+     * @param beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistoryDatasRaw(WindPowerstationTestingPoint point, Long beginDate, Long endDate) throws Exception;
+
+    /**
+     * 通过风机测点获得测点实时数据
+     * @param point 只是用了id字段,作为唯一标识
+     * @return
+     * @throws Exception
+     */
+    public PointData getRealData(WindTurbineTestingPointAi point) throws Exception;
+
+    /**
+     * 通过风机测点获得历史快照
+     * @param point  只是用了id字段,作为唯一标识
+     * @param  beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @param count  点数
+     * @param pried  时间间隔
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistoryDatasSnap(WindTurbineTestingPointAi point, Long beginDate, Long endDate, Long count, Long pried) throws Exception;
+
+    /**
+     * 通过风机测点获得测点历史存储数据,存多少取多少
+     * @param point 只是用了id字段,作为唯一标识
+     * @param  beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistoryDatasRaw(WindTurbineTestingPointAi point, Long beginDate, Long endDate) throws Exception;
+
+
+    /**
+     * 通过风机测点获得测点实时数据
+     * @param pointid 测点编号
+     * @return
+     * @throws Exception
+     */
+    public PointData getRealData(String pointid) throws Exception;
+
+    /**
+     * 通过全局点名获得测点实时数据 读取多个点
+     * @param pointids 测点的数组
+     * @return 列表集合
+     * @throws Exception
+     */
+    public List<PointData> getRealData(String... pointids) throws Exception;
+    /**
+     * 通过全局点名获得测点实时数据 读取多个点
+     * @param pointids 测点的列表
+     * @return 列表集合
+     * @throws Exception
+     */
+    public List<PointData> getRealData(List<String> pointids) throws Exception;
+    /**
+     * 通过全局点名获得测点实时数据 读取多个点
+     * @param pointids 测点的数组
+     * @return Map集合
+     * @throws Exception
+     */
+    public Map<String,Double> getRealDataMap(String... pointids) throws Exception;
+
+    /**
+     * 通过全局点名获得历史数据快照
+     * @param pointid  全局点名
+     * @param beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @param count  点数
+     * @param pried  时间间隔
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistoryDatasSnap(String pointid, Long beginDate, Long endDate, Long count, Long pried) throws Exception;
+
+    /**
+     * 通过风机测点获得测点历史存储数据,存多少取多少
+     * @param pointid 全局点名
+     * @param  beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistoryDatasRaw(String pointid, Long beginDate, Long endDate) throws Exception;
+
+
+    /**
+     * 通过风机测点获得测点指定时间周期的统计数据
+     * @param point 只是用了id字段,作为唯一标识
+     * @param  beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @param count  点数
+     * @param pried  时间间隔
+     * @type 0、最大值。1、最小值。、平均值
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistStat(WindTurbineTestingPointAi point, Long beginDate, Long endDate, Long count, Long pried, int type) throws Exception;
+
+    /**
+     * 通过风场测点获得测点指定时间周期的统计数据
+     * @param point 只是用了code字段,作为唯一标识
+     * @param  beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @param count  点数
+     * @param pried  时间间隔
+     * @type 0、最大值。1、最小值。、平均值
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistStat(WindPowerstationTestingPoint point, Long beginDate, Long endDate, Long count, Long pried, int type) throws Exception;
+
+    /**
+     * 通过全局点名获得测点指定时间周期的统计数据
+     * @param pointid 全局点名
+     * @param  beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @param count  点数
+     * @param pried  时间间隔
+     * @type 0、最大值。1、最小值。、平均值
+     * @return
+     * @throws Exception
+     */
+    public List<PointData> getHistStat(String pointid, Long beginDate, Long endDate, Long count, Long pried, int type) throws Exception;
+
+    /**
+     * 通过全局点名获得测点指定时间周期的统计数据 同时返回max、min、avg数据
+     * @param point 全局点名
+     * @param  beginDate 开始时间(秒级)
+     * @param endDate 结束时间(秒级)
+     * @param pried  时间间隔
+     * @return
+     * @throws Exception
+     */
+    public DNAStatVal[] getHistStat(String point, Long beginDate, Long endDate, Integer pried) throws Exception;
+    /**
+     * 补录单点历史数据
+     * @param point 测点对象
+     * @return
+     * @throws Exception
+     */
+    public void updatePoint(PointData point) throws Exception;
+
+    /**
+     * 批量查询实时数据
+     * @param tagNames 测点字符串数组
+     * @return
+     * @throws Exception
+     */
+
+    public DNAVal[] getRealtimeTagValues(String... tagNames) throws Exception;
+
+    /**
+     * 批量插入历史数据
+     * @param pointls 测点对象集合
+     * @throws Exception
+     */
+    public void updatePoint(List<PointData> pointls) throws Exception;
+
+    /**
+     *
+     * @param nameList 测点名称列表集合
+     * @param tTime  时间点(秒级)
+     * @return
+     * @throws Exception
+     */
+    public DNAVal[] getHistMatrix(String[] nameList, int tTime) throws Exception;
+}

+ 23 - 0
src/main/java/com/gyee/frame/util/RealTimeDataBaseFactory.java

@@ -0,0 +1,23 @@
+package com.gyee.frame.util;
+
+
+import com.gyee.frame.common.conf.V2Config;
+import com.gyee.frame.util.golden.EdosUtil;
+import com.gyee.frame.util.mongodb.MongodbUtilImpl;
+
+public class RealTimeDataBaseFactory {
+
+
+    public static IRealTimeDataBaseUtil createRealTimeDataBase() {
+
+
+        switch (V2Config.getRealtimedataBase()) {
+            case "mongodb":
+                return new MongodbUtilImpl();
+            case "golden":
+                return new EdosUtil();
+            default:
+                return new MongodbUtilImpl();
+        }
+    }
+}

+ 48 - 0
src/main/java/com/gyee/frame/util/golden/ApiGolden.java

@@ -0,0 +1,48 @@
+/** 
+ * Project Name:nxfd2 
+ * File Name:ApiEdos.java 
+ * Package Name:com.gyee.frame.util
+ * Date:2016-7-25下午12:26:14 
+ * Copyright (c) 2016, chenzhou1025@126.com All Rights Reserved. 
+ * 
+ */
+
+package com.gyee.frame.util.golden;
+
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * ClassName:ApiEdos <br/>
+ * Function: TODO ADD FUNCTION. <br/>
+ * Reason: TODO ADD REASON. <br/>
+ * Date: 2016-7-25 下午12:26:14 <br/>
+ * 
+ * @author 石林
+ * @version
+ * @since JDK 1.6
+ * @see
+ */
+public class ApiGolden {
+
+    private static RestTemplate restTemplate = null;
+
+  
+    private ApiGolden() {
+
+    }
+
+    public static RestTemplate getInstance() {
+    	
+    	
+
+        if (restTemplate == null) {
+        	
+        	restTemplate = new RestTemplate();
+
+        }
+
+        return restTemplate;
+
+    }
+
+}

文件差异内容过多而无法显示
+ 1262 - 0
src/main/java/com/gyee/frame/util/golden/EdosUtil.java


+ 33 - 0
src/main/java/com/gyee/frame/util/golden/StringUtil.java

@@ -0,0 +1,33 @@
+package com.gyee.frame.util.golden;
+
+import org.apache.commons.lang3.StringUtils;
+/**
+ * String辅助类
+ * 
+ */
+public class StringUtil extends StringUtils {
+	
+	/**
+	 * 非空判断
+	 * 
+	 * @param obj
+	 * @return
+	 */
+	public static boolean isNotBlank(Object obj) {
+		return !isBlank(obj);
+	}
+
+	/**
+	 * 为空判断
+	 * 
+	 * @param obj
+	 * @return
+	 */
+	public static boolean isBlank(Object obj) {
+		if (obj == null || StringUtils.isBlank(obj.toString())) {
+			return true;
+		}
+		return false;
+	}
+
+}

+ 28 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/BaseTsQuery.java

@@ -0,0 +1,28 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import lombok.Data;
+
+@Data
+public class BaseTsQuery implements TsQuery {
+
+    private final TsPoint tsPoint;
+    private final long startTs;
+    private final long endTs;
+    private final int interval;
+    private final int limit;
+    private final Interpolation interpolation;
+
+    public BaseTsQuery(TsPoint tsPoint, long startTs, long endTs, int interval, int limit, Interpolation interpolation) {
+        this.tsPoint = tsPoint;
+        this.startTs = startTs;
+        this.endTs = endTs;
+        this.interval = interval;
+        this.limit = limit;
+        this.interpolation = interpolation;
+    }
+
+    public BaseTsQuery(TsPoint tsPoint, long startTs, long endTs) {
+        this(tsPoint, startTs, endTs, 1, 1, Interpolation.RAW);
+    }
+
+}

+ 38 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/BasicTsData.java

@@ -0,0 +1,38 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public abstract class BasicTsData implements TsData, Comparable<BasicTsData>{
+
+    private final long ts;
+
+    private final short status;
+
+    public BasicTsData(long ts, short status) {
+        this.ts = ts;
+        this.status = status;
+    }
+
+    public long getTs() {
+        return ts;
+    }
+
+    public short getStatus() {
+        return status;
+    }
+
+    @Override
+    public int compareTo(BasicTsData o) {
+        return Long.compare(ts, o.ts);
+    }
+
+    @Override
+    public String toString() {
+        return "BasicTsData{ts='" + ts +
+                "', status='" + this.getStatus() +
+                "'}";
+    }
+
+}
+

+ 29 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/BasicTsPoint.java

@@ -0,0 +1,29 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class BasicTsPoint implements TsPoint{
+
+    private final String id;
+
+    private final TsDataType tsDataType;
+
+    public BasicTsPoint(String id,  TsDataType tsDataType) {
+        this.id = id;
+        this.tsDataType = tsDataType;
+    }
+
+    public String getId() { return id; }
+
+    public TsDataType getTsDataType() {return tsDataType; }
+
+    @Override
+    public String toString() {
+        return "BasicTsPoint{id='" + id +
+                "', dataType='" + this.getTsDataType() +
+                "'}";
+    }
+
+}
+

+ 24 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/BlobTsData.java

@@ -0,0 +1,24 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import java.util.Base64;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class BlobTsData extends BasicTsData {
+
+    private final byte[] blob;
+
+    public BlobTsData(long ts, short status, byte[] blob) {
+        super(ts, status);
+        this.blob = blob;
+    }
+
+    //public byte[] getBlob() { return  blob ;}
+
+    public String getBlobValue() {
+        return Base64.getEncoder().encodeToString(blob);
+    }
+
+}
+

+ 22 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/BlobWriteTsData.java

@@ -0,0 +1,22 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import java.util.Base64;
+
+import lombok.Data;
+
+/**
+ * @descrition:
+ * @author:Wanghs
+ * @date:2018-05-04
+ */
+@Data
+public class BlobWriteTsData {
+    private String tagName;
+    private long ts;
+    private  byte[]blob;
+
+    public String getValue() {
+        return Base64.getEncoder().encodeToString(blob);
+    }
+
+}

+ 24 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/BooleanTsData.java

@@ -0,0 +1,24 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class BooleanTsData extends BasicTsData {
+
+    private final boolean actualValue;
+
+    public BooleanTsData(long ts, short status, boolean actualValue) {
+        super(ts, status);
+        this.actualValue = actualValue;
+    }
+
+//    public boolean getActualValue() {
+//        return actualValue;
+//    }
+
+    public String getBooleanValue() {
+        return Boolean.toString(actualValue);
+    }
+
+}
+

+ 19 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/BooleanWriteTsData.java

@@ -0,0 +1,19 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import lombok.Data;
+
+/**
+ * @descrition:
+ * @author:Wanghs
+ * @date:2018-05-04
+ */
+@Data
+public class BooleanWriteTsData  {
+    private String tagName;
+    private long ts;
+    private boolean actualValue;
+
+    public boolean getValue() {
+        return this.actualValue;
+    }
+}

+ 18 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/Coordinate.java

@@ -0,0 +1,18 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+@Data
+@AllArgsConstructor
+public class Coordinate {
+
+    private double latitude;
+
+    private double longitude;
+
+}
+

+ 26 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/CoordinateTsData.java

@@ -0,0 +1,26 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class CoordinateTsData extends BasicTsData {
+
+    private final Coordinate coordinate;
+
+    public CoordinateTsData(long ts, short status, double latitude, double longitude) {
+        super(ts, status);
+        this.coordinate = new Coordinate(latitude, longitude);
+    }
+
+    public CoordinateTsData(long ts, short status, Coordinate coordinate) {
+        super(ts, status);
+        this.coordinate = coordinate;
+    }
+
+    public Coordinate getCoordinateValue() {
+        return coordinate;
+        //return String.format("{\"longitude\":%f,\"latitude\":\"%f\"}", longitude, latitude);
+    }
+
+}
+

+ 21 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/CoordinateWriteTsData.java

@@ -0,0 +1,21 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import lombok.Data;
+
+/**
+ * @descrition:
+ * @author:Wanghs
+ * @date:2018-05-04
+ */
+@Data
+public class CoordinateWriteTsData  {
+
+    private String tagName;
+    private long ts;
+    private  double latitude;
+    private  double longitude;
+
+    public double getLatitude() { return  latitude ;}
+    public double getLongitude() {return  longitude; }
+
+}

+ 30 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/DoubleStatData.java

@@ -0,0 +1,30 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class DoubleStatData {
+
+    private DoubleTsData avg;
+    private DoubleTsData max;
+    private DoubleTsData min;
+
+    public DoubleStatData(DoubleTsData avg, DoubleTsData max, DoubleTsData min) {
+        this.avg = avg;
+        this.max = max;
+        this.min = min;
+    }
+
+    public DoubleTsData getAvg() {
+        return avg;
+    }
+
+    public DoubleTsData getMax() {
+        return max;
+    }
+
+    public DoubleTsData getMin() {
+        return min;
+    }
+}
+

+ 25 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/DoubleTsData.java

@@ -0,0 +1,25 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class DoubleTsData extends BasicTsData {
+
+    private final double actualValue;
+
+    public DoubleTsData(long ts, short status, double actualValue) {
+        super(ts, status);
+        this.actualValue = actualValue;
+    }
+
+
+    public double getDoubleValue() {
+        return actualValue;
+    }
+
+//    public String getValue() {
+//        return Double.toString(actualValue);
+//    }
+
+}
+

+ 19 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/DoubleWriteTsData.java

@@ -0,0 +1,19 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import lombok.Data;
+
+/**
+ * @descrition:
+ * @author:Wanghs
+ * @date:2018-05-04
+ */
+@Data
+public class DoubleWriteTsData  {
+    private String tagName;
+    private long ts;
+    private double actualValue;
+
+    public double getValue() {
+        return this.actualValue;
+    }
+}

+ 38 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/ErrorRequest.java

@@ -0,0 +1,38 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import com.gyee.frame.model.custom.PointData;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @descrition:接口请求失败返回操作类
+ * @author:Wanghs
+ * @date:2018-05-21
+ */
+public class ErrorRequest {
+
+    public static List<PointData> RequestListError(String pointId) {
+        List<PointData> dataList = new ArrayList<>();
+        return dataList;
+    }
+
+    public static List<PointData> RequestListError(String... pointId) {
+        List<PointData> dataList = new ArrayList<>();
+        return dataList;
+    }
+
+    public static PointData RequestError(String pointId) {
+        PointData data = new PointData();
+        data.setPointValueInDouble(0);
+        data.setPointName("0");
+        return data;
+    }
+
+    public static Map<String, Double> RequestMapError() {
+        Map<String, Double> resultMap = new HashMap();
+        return resultMap;
+    }
+}

+ 27 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/GeneralTsData.java

@@ -0,0 +1,27 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import java.util.Optional;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class GeneralTsData implements TsData {
+
+    private long ts;
+    private short status;
+    private Optional<Double> doubleValue;
+    private Optional<Long> longValue;
+    private Optional<Boolean> booleanValue;
+    private Optional<String> stringValue;
+    private Optional<String> blobValue;
+    private Optional<Coordinate> coordinateValue;
+
+}
+

+ 8 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/Interpolation.java

@@ -0,0 +1,8 @@
+
+package com.gyee.frame.util.golden.timeseries;
+
+public enum Interpolation {
+    SNAP,   // 历史快照数据
+    INTERPOLATION, //插值
+    RAW    //原始数据
+}

+ 230 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/JsonObjectHelper.java

@@ -0,0 +1,230 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.gyee.frame.model.custom.DNAStatVal;
+import com.gyee.frame.model.custom.DNAVal;
+import com.gyee.frame.model.custom.PointData;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * @descrition:JSONObject转实体辅助类
+ * @author:Wanghs
+ * @date:2018-05-10
+ */
+public class JsonObjectHelper {
+    public static List<PointData> phrasePointData(JSONArray jsonArray, String tagName) {
+        List<PointData> result = new ArrayList<>();
+
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject tsData = jsonArray.getJSONObject(i);
+
+            Long ts = tsData.getLong("ts");
+            String pointValue = null;
+            if (tsData.containsKey("doubleValue")) {
+                pointValue = tsData.getString("doubleValue");
+            } else if (tsData.containsKey("booleanValue")) {
+                pointValue = tsData.getString("booleanValue");
+            } else if (tsData.containsKey("longValue")) {
+                pointValue = tsData.getString("longValue");
+            } else if (tsData.containsKey("stringValue")) {
+                pointValue = tsData.getString("stringValue");
+            }
+            PointData pointData = new PointData();
+            pointData.setEdnaId(tagName);
+            pointData.setPointName("1");
+            pointData.setPointTime(ts / 1000);
+            pointData.setPointValue(pointValue);
+            pointData.setPointValueInDouble(Double.parseDouble(pointValue));
+            //System.out.println("key= " + tagName + ", ts = " + ts + ", value = " + pointValue);
+            result.add(pointData);
+        }
+        return result;
+    }
+//
+//    public static List<PointData> phrasePointData(JSONArray jsonArray,String...tagName) {
+//        List<PointData> result = new ArrayList<>();
+//
+//        for (int i = 0; i < jsonArray.size(); i++) {
+//            JSONObject jsonData = jsonArray.getJSONObject(i);
+//            JSONObject tsData = jsonData.getJSONObject("tsData");
+//            Long ts = tsData.getLong("ts");
+//            String pointValue = null;
+//            if (tsData.containsKey("doubleValue")) {
+//                pointValue = tsData.getString("doubleValue");
+//            } else if (tsData.containsKey("booleanValue")) {
+//                pointValue = tsData.getString("booleanValue");
+//            } else if (tsData.containsKey("longValue")) {
+//                pointValue = tsData.getString("longValue");
+//            } else if (jsonData.containsKey("stringValue")) {
+//                pointValue = tsData.getString("stringValue");
+//            }
+//            PointData pointData = new PointData();
+//            pointData.setPointName("1");
+//            pointData.setEdnaId(tagName[i]);
+//            pointData.setPointTime(ts / 1000);
+//            pointData.setPointValue(pointValue);
+//            pointData.setPointValueInDouble(Double.parseDouble(pointValue));
+//         //   System.out.println("key= " + tagName + ", ts = " + ts + ", value = " + pointValue);
+//            result.add(pointData);
+//        }
+//        return result;
+//    }
+
+    public static List<PointData> phrasePointData(JSONObject jsonObject) {
+        List<PointData> result = new ArrayList<>();
+        Iterator<String> sIterator = jsonObject.keySet().iterator();
+        while (sIterator.hasNext()) {
+            // 获得key
+            String key = sIterator.next();
+            // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
+            JSONObject jsonData = jsonObject.getJSONObject(key);
+            Long ts = jsonData.getLong("ts");
+            String pointValue = null;
+            if (jsonData.containsKey("doubleValue")) {
+                pointValue = jsonData.getString("doubleValue");
+            } else if (jsonData.containsKey("booleanValue")) {
+                pointValue = jsonData.getString("booleanValue");
+            } else if (jsonData.containsKey("longValue")) {
+                pointValue = jsonData.getString("longValue");
+            } else if (jsonData.containsKey("stringValue")) {
+                pointValue = jsonData.getString("stringValue");
+            }
+
+            PointData pointData = new PointData();
+            pointData.setEdnaId(key);
+            pointData.setPointName("1");
+            pointData.setPointValue(pointValue);
+            pointData.setPointTime(ts/1000);
+            if(pointValue.equals("false")  )
+            {
+            	pointData.setPointValueInDouble(0.0);
+            }else  if(pointValue.equals("true") )
+            {
+            	pointData.setPointValueInDouble(1.0);
+            }else
+            {
+                pointData.setPointValueInDouble(Double.parseDouble(pointValue));
+            }
+
+         //  System.out.println("key= " + key + ", ts = " + ts + ", value = " + pointValue);
+            result.add(pointData);
+        }
+        return result;
+    }
+    /**
+     * @param arry    DoubleStatData集合
+     * @param tagName 标签点名
+     * @param type    0、最大值。1、最小值。2、平均值
+     */
+    public static List<PointData> GeneralTsDataToPointDataByStat(JSONArray arry, String tagName, int type) {
+        List<PointData> result = new ArrayList<>();
+        for (int i = 0; i < arry.size(); i++) {
+            JSONObject jsonData = arry.getJSONObject(i);
+            PointData data = new PointData();
+            data.setEdnaId(tagName);
+            data.setPointName("1");
+            JSONObject avgData = null;
+            JSONObject maxData = null;
+            JSONObject minData = null;
+            if (jsonData.containsKey("avg")) {
+                avgData = jsonData.getJSONObject("avg");
+            }
+            if (jsonData.containsKey("max")) {
+                maxData = jsonData.getJSONObject("max");
+            }
+            if (jsonData.containsKey("min")) {
+                minData = jsonData.getJSONObject("min");
+            }
+            switch (type) {
+                case 0:
+                    data.setPointValue(String.valueOf(maxData.getString("doubleValue")));
+                    data.setPointValueInDouble(Double.valueOf(maxData.getString("doubleValue")));
+                    data.setPointTime(Long.valueOf(maxData.getString("ts")) / 1000);
+                    break;
+                case 1:
+                    data.setPointValue(String.valueOf(minData.getString("doubleValue")));
+                    data.setPointValueInDouble(Double.valueOf(minData.getString("doubleValue")));
+                    data.setPointTime(Long.valueOf(minData.getString("ts")) / 1000);
+                    break;
+                case 2:
+                    data.setPointValue(String.valueOf(avgData.getString("doubleValue")));
+                    data.setPointValueInDouble(Double.valueOf(avgData.getString("doubleValue")));
+                    data.setPointTime(Long.valueOf(avgData.getString("ts")) / 1000);
+                    break;
+                default:
+                    break;
+            }
+            result.add(data);
+        }
+        return result;
+    }
+
+    public static DNAVal[] phraseDNAVal(JSONObject jsonObject, String[] tagName) {
+        DNAVal[] arr = new DNAVal[jsonObject.size()];
+        List<DNAVal> list = new ArrayList<>();
+        Iterator<String> sIterator = jsonObject.keySet().iterator();
+
+        for (int i = 0; i < tagName.length; i++) {
+            // 获得key
+            String key = tagName[i];
+            // 根据key获得value, value也可以是JSONObject,JSONArray,使用对应的参数接收即可
+            JSONObject jsonData = jsonObject.getJSONObject(key);
+            DNAVal data = new DNAVal();
+            data.Time = Integer.parseInt(String.valueOf(Long.valueOf(jsonData.getString("ts")) / 1000));
+            data.Status = (short) jsonData.getShortValue("status");
+            data.DValue = (Double.valueOf(jsonData.getDoubleValue("doubleValue")));
+            list.add(data);
+        }
+
+        return list.toArray(arr);
+    }
+
+    public static DNAStatVal[] phraseDNAVal(JSONArray jsonArray) {
+
+        DNAStatVal[] arr = new DNAStatVal[jsonArray.size()];
+        List<DNAStatVal> list = new ArrayList<>();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject jsonData = jsonArray.getJSONObject(i);
+            JSONObject avgData = null;
+            JSONObject maxData = null;
+            JSONObject minData = null;
+            if (jsonData.containsKey("avg")) {
+                avgData = jsonData.getJSONObject("avg");
+            }
+            if (jsonData.containsKey("max")) {
+                maxData = jsonData.getJSONObject("max");
+            }
+            if (jsonData.containsKey("min")) {
+                minData = jsonData.getJSONObject("min");
+            }
+            DNAStatVal statVal = new DNAStatVal();
+
+            DNAVal avgVal = new DNAVal();
+            DNAVal maxVal = new DNAVal();
+            DNAVal minVal = new DNAVal();
+
+            avgVal.Time = Integer.valueOf(String.valueOf(Long.valueOf(avgData.getString("ts")) / 1000));
+            avgVal.DValue = Double.valueOf(avgData.getString("doubleValue"));
+
+            maxVal.Time =  Integer.valueOf(String.valueOf(Long.valueOf(maxData.getString("ts")) / 1000));
+            maxVal.DValue = Double.valueOf(maxData.getString("doubleValue"));
+
+            minVal.Time =  Integer.valueOf(String.valueOf(Long.valueOf(minData.getString("ts")) / 1000));
+            minVal.DValue = Double.valueOf(minData.getString("doubleValue"));
+
+            statVal.max = maxVal;
+            statVal.min = minVal;
+            statVal.avg = avgVal;
+
+            list.add(statVal);
+        }
+
+        return list.toArray(arr);
+    }
+
+}

+ 24 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/LongTsData.java

@@ -0,0 +1,24 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class LongTsData extends BasicTsData {
+
+    private final long actualValue;
+
+    public LongTsData(long ts, short status, long actualValue) {
+        super(ts, status);
+        this.actualValue = actualValue;
+    }
+
+    public long getLongValue() {
+        return actualValue;
+    }
+
+//    public String getValue() {
+//        return Long.toString(actualValue);
+//    }
+
+}
+

+ 20 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/LongWriteTsData.java

@@ -0,0 +1,20 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import lombok.Data;
+
+/**
+ * @descrition:
+ * @author:Wanghs
+ * @date:2018-05-04
+ */
+@Data
+public class LongWriteTsData  {
+
+    private String tagName;
+    private long ts;
+    private long actualValue;
+
+    public long getValue() {
+        return this.actualValue;
+    }
+}

+ 24 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/StringTsData.java

@@ -0,0 +1,24 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public class StringTsData extends BasicTsData {
+
+    private final String actualValue;
+
+    public StringTsData(long ts, short status, String actualValue) {
+        super(ts, status);
+        this.actualValue = actualValue;
+    }
+
+//    public String getActualValue() {
+//        return actualValue;
+//    }
+
+    public String getStringValue() {
+        return actualValue;
+    }
+
+}
+

+ 33 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/StringUtil.java

@@ -0,0 +1,33 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import org.apache.commons.lang3.StringUtils;
+/**
+ * String辅助类
+ * 
+ */
+public class StringUtil extends StringUtils {
+	
+	/**
+	 * 非空判断
+	 * 
+	 * @param obj
+	 * @return
+	 */
+	public static boolean isNotBlank(Object obj) {
+		return !isBlank(obj);
+	}
+
+	/**
+	 * 为空判断
+	 * 
+	 * @param obj
+	 * @return
+	 */
+	public static boolean isBlank(Object obj) {
+		if (obj == null || StringUtils.isBlank(obj.toString())) {
+			return true;
+		}
+		return false;
+	}
+
+}

+ 20 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/StringWriteTsData.java

@@ -0,0 +1,20 @@
+package com.gyee.frame.util.golden.timeseries;
+
+import lombok.Data;
+
+/**
+ * @descrition:String类型写入实体类
+ * @author:Wanghs
+ * @date:2018-05-04
+ */
+@Data
+public class StringWriteTsData  {
+    private String tagName;
+    private long ts;
+    private String actualValue;
+
+    public String getValue() {
+        return this.actualValue;
+    }
+
+}

+ 15 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/TsData.java

@@ -0,0 +1,15 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public interface TsData {
+
+    long getTs();
+
+    short getStatus();
+
+    //double getValue();
+
+}
+

+ 15 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/TsDataType.java

@@ -0,0 +1,15 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public enum TsDataType {
+    LONG,
+    DOUBLE,
+    BOOLEAN,
+    STRING,
+    BLOB,
+    COORDINATE
+
+}
+

+ 12 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/TsPoint.java

@@ -0,0 +1,12 @@
+package com.gyee.frame.util.golden.timeseries;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+public interface TsPoint {
+
+    String getId();
+
+    TsDataType getTsDataType();
+}
+

+ 36 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/TsPointData.java

@@ -0,0 +1,36 @@
+package com.gyee.frame.util.golden.timeseries;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TsPointData {
+
+    private String tagName;
+    private GeneralTsData tsData;
+
+    public TsDataType findDataType() {
+        if (tsData.getDoubleValue().isPresent())
+            return TsDataType.DOUBLE;
+        else if (tsData.getBooleanValue().isPresent())
+            return TsDataType.BOOLEAN;
+        else if (tsData.getLongValue().isPresent())
+            return TsDataType.LONG;
+        else if (tsData.getStringValue().isPresent())
+            return TsDataType.STRING;
+        else if (tsData.getBlobValue().isPresent())
+            return TsDataType.BLOB;
+        else if (tsData.getCoordinateValue().isPresent())
+            return TsDataType.COORDINATE;
+
+        return TsDataType.DOUBLE;
+    }
+}
+

+ 23 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/TsPointDataList.java

@@ -0,0 +1,23 @@
+package com.gyee.frame.util.golden.timeseries;
+
+
+import java.util.List;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author songwb<songwb@aliyun.com>
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TsPointDataList {
+
+    private String tagName;
+
+    private List<GeneralTsData> tsDataList;
+
+}
+

+ 17 - 0
src/main/java/com/gyee/frame/util/golden/timeseries/TsQuery.java

@@ -0,0 +1,17 @@
+package com.gyee.frame.util.golden.timeseries;
+
+public interface TsQuery {
+
+    TsPoint getTsPoint();
+
+    long getStartTs();
+
+    long getEndTs();
+
+    int getInterval();
+
+    int getLimit();
+
+    Interpolation getInterpolation();
+
+}

+ 71 - 4
src/main/java/com/gyee/frame/util/mongodb/JedisPoolUtil.java

@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.frame.common.spring.InitialRunner;
 import com.gyee.frame.model.auto.RMConfig;
+import com.gyee.frame.model.custom.DNAVal;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.util.StringUtils;
+import org.apache.commons.collections.map.LinkedMap;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 import redis.clients.jedis.Jedis;
@@ -52,7 +54,7 @@ public class JedisPoolUtil {
 
 
 
-        Map<String, Response<String>> resmap = new HashMap<String, Response<String>>();
+        Map<String, Response<String>> resmap = new LinkedMap();
 
         Jedis jedis = jedisPool.getResource();
 
@@ -228,7 +230,7 @@ public class JedisPoolUtil {
     @SuppressWarnings("unchecked")
     public Map<String, Double> getRealDataMap(String... key) throws IOException {
 
-        Map<String, Double> map = new HashMap<String, Double>();
+        Map<String, Double> map = new LinkedMap();
 
         if (StringUtils.isNotNull(key) && key.length > 0) {
 
@@ -285,11 +287,11 @@ public class JedisPoolUtil {
     @SuppressWarnings("unchecked")
     public Map<String, Double> getRealDataMap(List<String> key) throws IOException {
 
-        Map<String, Double> map = new HashMap<String, Double>();
+        Map<String, Double> map = new LinkedMap();
 
         if (StringUtils.isNotNull(key) && !key.isEmpty()) {
 
-            Map<String, Response<String>> resmap = new HashMap<String, Response<String>>();
+            Map<String, Response<String>> resmap = new LinkedMap();
             Jedis jedis = jedisPool.getResource();
 
             Pipeline pipelined = jedis.pipelined();
@@ -360,4 +362,69 @@ public class JedisPoolUtil {
     public JedisPool getJedisPool() {
         return jedisPool;
     }
+
+    public DNAVal[] getRealtimeTagValues(String... tagNames) throws Exception {
+
+      
+        if (StringUtils.isNotNull(tagNames) && tagNames.length>0) {
+
+            DNAVal[] dNAVal=  new DNAVal[tagNames.length];
+
+            Map<String, Response<String>> resmap = new LinkedMap();
+            Jedis jedis = jedisPool.getResource();
+
+            Pipeline pipelined = jedis.pipelined();
+            for (String code : tagNames) {
+
+                if (InitialRunner.rmcmap.containsKey(code)) {
+
+                    RMConfig rmc = InitialRunner.rmcmap.get(code);
+
+                    pipelined.select(rmc.getRedisindex());
+
+                    resmap.put(code, pipelined.get(code));
+
+                }else
+                {
+
+                    pipelined.select(ARR_NUM);
+
+                    resmap.put(code, pipelined.get(code));
+
+                }
+
+            }
+            pipelined.sync();
+            pipelined.close();
+
+            int i=0;
+            for (String code : resmap.keySet()) {
+                String result = resmap.get(code).get();
+                if (result != null && result.length() > 0) {
+                    Map<Object, Object> json = (Map<Object, Object>) JSONObject.parse(result);
+
+                    Double value = 0.0;
+                    for (Object jsonmap : json.entrySet()) {
+
+                        Map.Entry<Object, Object> tempmap = (Map.Entry<Object, Object>) jsonmap;
+
+
+                        Integer time = Integer.valueOf(String.valueOf(tempmap.getKey()));
+
+                        value = Double.valueOf(String.valueOf(tempmap.getValue()));
+
+                        dNAVal[i].Time=time;
+                        dNAVal[i].DValue=value;
+
+
+                    }
+
+                    i++;
+                }
+            }
+
+            returnResource(jedis);
+        }
+        return new DNAVal[0];
+    }
 }

+ 28 - 1
src/main/java/com/gyee/frame/util/mongodb/MongodbUtilImpl.java

@@ -5,7 +5,9 @@ import com.gyee.frame.common.spring.SpringUtils;
 import com.gyee.frame.model.auto.WindPowerstationTestingPoint;
 import com.gyee.frame.model.auto.WindTurbineTestingPointAi;
 import com.gyee.frame.model.custom.DNAStatVal;
+import com.gyee.frame.model.custom.DNAVal;
 import com.gyee.frame.model.custom.PointData;
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
 import com.gyee.frame.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -18,7 +20,7 @@ import java.util.Map;
 /**
  *
  */
-public class MongodbUtilImpl implements IMongodbUtil {
+public class MongodbUtilImpl implements IRealTimeDataBaseUtil {
 
 
     private JedisPoolUtil jedisPoolUtil= SpringUtils.getBean(JedisPoolUtil.class);
@@ -310,5 +312,30 @@ public class MongodbUtilImpl implements IMongodbUtil {
         mdb.updatePoint(point, jedisPoolUtil.getJedisPool());
     }
 
+    @Override
+    public DNAVal[] getRealtimeTagValues(String... tagNames) throws Exception {
+        return jedisPoolUtil.getRealtimeTagValues(tagNames);
+    }
+
+    @Override
+    public void updatePoint(List<PointData> pointls) throws Exception {
+
+        if(!pointls.isEmpty())
+        {
+            for(PointData point:pointls)
+            {
+                mdb.updatePoint(point, jedisPoolUtil.getJedisPool());
+            }
+        }
+    }
 
+
+
+    @Override
+    public DNAVal[] getHistMatrix(String[] nameList, int tTime) throws Exception {
+
+//        List<PointData> ls = mdb.getHistoryDatasSnap(pointid, beginDate, endDate, count, pried);
+
+        return new DNAVal[0];
+    }
 }

+ 2 - 0
src/main/resources/application.yml

@@ -25,6 +25,8 @@ gyee:
   demoEnabled: false
   #漂亮得拖动验证码 默认false普通验证码、true滚动验证码
   rollVerification: true
+  #实时数据库
+  realtimedataBase: mongodb
 #tomcat websocket
 server :
   port : 8082

+ 5 - 6
src/test/java/test/MongoDBTest.java

@@ -1,12 +1,10 @@
 package test;
 
 import com.gyee.SpringbootStart;
-import com.gyee.frame.common.conf.redis.CacheConfig;
-import com.gyee.frame.common.conf.redis.Constant;
 import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.util.DateUtils;
-import com.gyee.frame.util.mongodb.IMongodbUtil;
-import com.gyee.frame.util.mongodb.MongodbUtilImpl;
+import com.gyee.frame.util.IRealTimeDataBaseUtil;
+import com.gyee.frame.util.RealTimeDataBaseFactory;
 import lombok.SneakyThrows;
 import org.springframework.boot.SpringApplication;
 
@@ -21,9 +19,10 @@ public class MongoDBTest {
     public static void main(String[] args) {
 
         SpringApplication.run(SpringbootStart.class, args);
-        IMongodbUtil mongodb = new MongodbUtilImpl();
+        IRealTimeDataBaseUtil mongodb= RealTimeDataBaseFactory.createRealTimeDataBase();
+
         Calendar c = Calendar.getInstance();
-        c.set(Calendar.MONTH, 3);
+       c.set(Calendar.MONTH, 3);
         c.set(Calendar.DAY_OF_MONTH, 25);
         c.set(Calendar.HOUR_OF_DAY, 0);
         c.set(Calendar.MINUTE, 0);