Quellcode durchsuchen

统计读取和写入

xushili vor 7 Monaten
Ursprung
Commit
a709f2a81e

+ 19 - 0
common/data/src/main/java/com/gyee/gaia/common/data/point/PointData.java

@@ -1,5 +1,7 @@
 package com.gyee.gaia.common.data.point;
 
+import com.gyee.gaia.common.data.timeseries.TsDataType;
+
 /**
  * 测点数据
  */
@@ -8,6 +10,8 @@ public class PointData {
      * 时间戳
      */
     private long ts;
+
+    private String tagName;
     /**
      * 数据
      */
@@ -23,6 +27,13 @@ public class PointData {
      */
     private int status;
 
+    public TsDataType getType(){
+        if (tagName.contains("di")||tagName.contains("DI"))
+            return TsDataType.BOOLEAN;
+        else
+            return TsDataType.DOUBLE;
+    }
+
     public boolean isBooleanValue() {
         return booleanValue;
     }
@@ -51,6 +62,14 @@ public class PointData {
         this.status = status;
     }
 
+    public String getTagName() {
+        return tagName;
+    }
+
+    public void setTagName(String tagName) {
+        this.tagName = tagName;
+    }
+
     public double getValue() {
         if (booleanValue) {
             return 1;

+ 2 - 0
timeseries/dao-interface/src/main/java/com/gyee/gaia/dao/timeseries/IHistoryDao.java

@@ -1,5 +1,6 @@
 package com.gyee.gaia.dao.timeseries;
 
+import com.gyee.gaia.common.data.point.PointData;
 import com.gyee.gaia.common.data.timeseries.*;
 
 import java.util.List;
@@ -21,5 +22,6 @@ public interface IHistoryDao {
      * @throws Exception
      */
     Map<String, TsData> getHistorySection(List<TsPoint> tsPoints, Long ts) throws Exception;
+    List<PointData> getHistorySection2(List<TsPoint> tsPoints, Long ts) throws Exception;
 
 }

+ 3 - 0
timeseries/dao-interface/src/main/java/com/gyee/gaia/dao/timeseries/ILatestDao.java

@@ -1,5 +1,6 @@
 package com.gyee.gaia.dao.timeseries;
 
+import com.gyee.gaia.common.data.point.PointData;
 import com.gyee.gaia.common.data.timeseries.TsData;
 import com.gyee.gaia.common.data.timeseries.TsPoint;
 import com.gyee.gaia.common.data.timeseries.TsPointData;
@@ -11,6 +12,7 @@ public interface ILatestDao {
 
 
     Map<String, TsData> getTsDataLatest(List<TsPoint> tsPoints) throws Exception;
+    List<PointData> getTsDataLatest2(List<TsPoint> tsPoints) throws Exception;
 
     int writeDoubleLatest(List<TsPointData> list) throws Exception;
 
@@ -25,5 +27,6 @@ public interface ILatestDao {
     int writeCoordinateLatest(List<TsPointData> list) throws Exception;
 
     boolean writeLatest(List<TsPointData> dataList) throws Exception;
+    boolean writeLatest2(List<PointData> dataList) throws Exception;
 
 }

+ 34 - 0
timeseries/dao-taoscz/src/main/java/com/gyee/gaia/dao/taoscz/TaosHistoryDao.java

@@ -1,5 +1,6 @@
 package com.gyee.gaia.dao.taoscz;
 
+import com.gyee.gaia.common.data.point.PointData;
 import com.gyee.gaia.common.data.timeseries.*;
 import com.gyee.gaia.common.exception.WisdomException;
 import com.gyee.gaia.dao.timeseries.IHistoryDao;
@@ -147,6 +148,39 @@ public class TaosHistoryDao implements IHistoryDao {
         return result;
     }
 
+    @Override
+    public List<PointData> getHistorySection2(List<TsPoint> tsPoints, Long ts) throws Exception {
+        List<PointData> result = new ArrayList<>();
+        //存储线程的返回值
+        List<Future<List<PointData>>> results = new LinkedList<>();
+
+        Map<TsDataType, List<TsPoint>> pointGroup = tsPoints.stream().collect(Collectors.groupingBy(TsPoint::getTsDataType));
+        for (Map.Entry<TsDataType, List<TsPoint>> entry : pointGroup.entrySet()) {
+            String[] tagNames = entry.getValue().stream().map(TsPoint::getId).toArray(String[]::new);
+            tagNames = Arrays.stream(tagNames).map(tp -> tp.replaceFirst("\\.", "__")).toArray(String[]::new);
+            if (entry.getKey() == TsDataType.DOUBLE)
+                for (String tag : tagNames) {
+                    TaskCallable2 task = new TaskCallable2(taosConfig, ts, tag, TsDataType.DOUBLE);
+                    Future<List<PointData>> submit = taskConfig.getInstance().submit(task);
+                    results.add(submit);
+                }
+            if (entry.getKey() == TsDataType.BOOLEAN) {
+                for (String tag : tagNames) {
+                    TaskCallable2 task = new TaskCallable2(taosConfig, ts, tag, TsDataType.BOOLEAN);
+                    Future<List<PointData>> submit = taskConfig.getInstance().submit(task);
+                    results.add(submit);
+                }
+            }
+        }
+        //返回结果
+        for (int i = 0; i < results.size(); i++) {
+            List<PointData> map = results.get(i).get();
+            List<PointData> collect = map.stream().peek(pd -> pd.setTagName(pd.getTagName().replaceFirst("__", "."))).collect(Collectors.toList());
+            result.addAll(collect);
+        }
+
+        return result;
+    }
     public List<TsData> getDoubleTsDataHistory(TsQuery tsQuery) throws Exception {
         List<TsData> tsDataList = new ArrayList<>();
 

+ 128 - 4
timeseries/dao-taoscz/src/main/java/com/gyee/gaia/dao/taoscz/TaosLatestDao.java

@@ -1,5 +1,6 @@
 package com.gyee.gaia.dao.taoscz;
 
+import com.gyee.gaia.common.data.point.PointData;
 import com.gyee.gaia.common.data.timeseries.*;
 import com.gyee.gaia.common.exception.WisdomException;
 import com.gyee.gaia.dao.timeseries.ILatestDao;
@@ -12,10 +13,7 @@ import org.springframework.stereotype.Component;
 
 import java.sql.ResultSet;
 import java.sql.Statement;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -51,6 +49,25 @@ public class TaosLatestDao implements ILatestDao {
         }
         return result2;
     }
+    @Override
+    public List<PointData> getTsDataLatest2(List<TsPoint> tsPoints) throws Exception {
+        List<PointData> result = new ArrayList<>();
+        Map<TsDataType, List<TsPoint>> pointGroup = tsPoints.stream().collect(Collectors.groupingBy(TsPoint::getTsDataType));
+        for (Map.Entry<TsDataType, List<TsPoint>> entry : pointGroup.entrySet()) {
+            String[] tagNames = entry.getValue().stream().map(tp -> tp.getId().replaceFirst("\\.", "__")).toArray(String[]::new);
+            if (entry.getKey() == TsDataType.DOUBLE) {
+                result.addAll(getDoubleTsDataSnapshots2(tagNames));
+            } else if (entry.getKey() == TsDataType.BOOLEAN) {
+                result.addAll(getBooleanTsDataSnapshots2(tagNames));
+            } else if (entry.getKey() == TsDataType.LONG) {
+                result.addAll(getLongTsDataSnapshots2(tagNames));
+            } else {
+                throw new WisdomException("Taos不支持数据类型:" + entry.getKey());
+            }
+        }
+        List<PointData> collect = result.stream().peek(pd -> pd.setTagName(pd.getTagName().replaceFirst("__", "."))).collect(Collectors.toList());
+        return collect;
+    }
 
 
     @Override
@@ -74,6 +91,25 @@ public class TaosLatestDao implements ILatestDao {
         return i == list.size() ? list.size() : 0;
     }
 
+    public int writeDoubleLatest2(List<PointData> list) throws Exception {
+        Statement st = config.getInstance().createStatement();
+        StringBuilder sb = new StringBuilder();
+        sb.append("INSERT INTO ");
+        for (PointData obj : list) {
+            long time = obj.getTs();
+            String point = config.getTableName(obj.getTagName());
+            double value = obj.getDoubleValue();
+            sb.append(point).append(" USING ").append(config.getDbName())
+                    .append(".").append(config.getAIStableName())
+                    .append(" TAGS ('','','','','') VALUES (");
+            sb.append(time).append(",").append(value).append(") ");
+        }
+        sb.append(";");
+        val i = st.executeUpdate(sb.toString());
+
+        return i == list.size() ? list.size() : 0;
+    }
+
     @Override
     public int writeStringLatest(List<TsPointData> list) throws Exception {
         Statement st = config.getInstance().createStatement();
@@ -110,6 +146,23 @@ public class TaosLatestDao implements ILatestDao {
 
         return i;
     }
+    @Override
+    public int writeBooleanLatest2(List<PointData> list) throws Exception {
+        Statement st = config.getInstance().createStatement();
+        StringBuilder sb = new StringBuilder();
+        sb.append("insert into ");
+        for (PointData obj : list) {
+            long time = obj.getTs();
+            String point = obj.getTagName();
+            boolean value = obj.getBooleanValue();
+            sb.append(point).append(" values (");
+            sb.append(time).append(",").append(value).append(") ");
+        }
+        sb.append(";");
+        int i = st.executeUpdate(sb.toString());
+
+        return i;
+    }
 
     @Override
     public int writeLongLatest(List<TsPointData> list) throws Exception {
@@ -175,6 +228,23 @@ public class TaosLatestDao implements ILatestDao {
         }
         return writeCount > 0 ? true : false;
     }
+    @Override
+    public boolean writeLatest2(List<PointData> dataList) throws Exception {
+        int writeCount = 0;
+        dataList = dataList.stream().peek(tpd -> tpd.setTagName(tpd.getTagName().replaceFirst("\\.", "__"))).collect(Collectors.toList());
+        Map<TsDataType, List<PointData>> pointGroup = dataList.stream().collect(Collectors.groupingBy(PointData::getType));
+        for (Map.Entry<TsDataType, List<PointData>> entry : pointGroup.entrySet()) {
+            List<PointData> pointDataList = entry.getValue();
+            if (entry.getKey() == TsDataType.DOUBLE) {
+                int count = writeDoubleLatest2(pointDataList);
+                writeCount = writeCount + count;
+            } else if (entry.getKey() == TsDataType.BOOLEAN) {
+                int count = writeBooleanLatest2(pointDataList);
+                writeCount = writeCount + count;
+            }
+        }
+        return writeCount > 0 ? true : false;
+    }
 
     public Map<String, TsData> getDoubleTsDataSnapshots(String... tagNames) throws Exception {
         Map<String, TsData> tsDataMap = new HashMap<>();
@@ -191,6 +261,25 @@ public class TaosLatestDao implements ILatestDao {
         return tsDataMap;
     }
 
+    public List<PointData> getDoubleTsDataSnapshots2(String... tagNames) throws Exception {
+        List<PointData> tsDataMap = new ArrayList<>();
+        Statement st = config.getInstance().createStatement();
+
+        String inString = Arrays.stream(tagNames).map(s -> "'" + s.toLowerCase() + "'").collect(Collectors.joining(","));
+        inString = "select last_row(*),tbname from " + config.getDbName() + "." + config.getAIStableName()
+                + " where tbname in (" + inString + ") group by tbname;";
+        ResultSet rs = st.executeQuery(inString);
+
+        while (rs.next()) {
+            PointData pointData = new PointData();
+            pointData.setTagName(rs.getString(3).toUpperCase());
+            pointData.setTs(rs.getTimestamp(1).getTime());
+            pointData.setDoubleValue(rs.getDouble(2));
+            tsDataMap.add(pointData);
+        }
+        return tsDataMap;
+    }
+
     public Map<String, TsData> getLongTsDataSnapshots(String... tagNames) throws Exception {
         Map<String, TsData> tsDataMap = new HashMap<>();
         Statement st = config.getInstance().createStatement();
@@ -204,6 +293,23 @@ public class TaosLatestDao implements ILatestDao {
         return tsDataMap;
     }
 
+    public List<PointData> getLongTsDataSnapshots2(String... tagNames) throws Exception {
+        List<PointData> tsDataMap = new ArrayList<>();
+        Statement st = config.getInstance().createStatement();
+        for (String tag : tagNames) {
+            String tableName = config.getTableName(tag);
+            ResultSet rs = st.executeQuery("select last_row(*) from " + tableName);
+            while (rs.next()) {
+                PointData pointData = new PointData();
+                pointData.setTagName(tag);
+                pointData.setTs(rs.getTimestamp(1).getTime());
+                pointData.setLongValue(rs.getLong(2));
+                tsDataMap.add(pointData);
+            }
+        }
+        return tsDataMap;
+    }
+
     public Map<String, TsData> getBooleanTsDataSnapshots(String... tagNames) throws Exception {
         Map<String, TsData> tsDataMap = new HashMap<>();
         Statement st = config.getInstance().createStatement();
@@ -218,5 +324,23 @@ public class TaosLatestDao implements ILatestDao {
         }
         return tsDataMap;
     }
+    public List<PointData> getBooleanTsDataSnapshots2(String... tagNames) throws Exception {
+        List<PointData> tsDataMap = new ArrayList<>();
+        Statement st = config.getInstance().createStatement();
+
+        String inString = Arrays.stream(tagNames).map(s -> "'" + s.toLowerCase() + "'").collect(Collectors.joining(","));
+        inString = "select last_row(*),tbname from " + config.getDbName() + "." + config.getDIStableName() +
+                " where tbname in (" + inString + ") group by tbname;";
+        ResultSet rs = st.executeQuery(inString);
+
+        while (rs.next()) {
+            PointData pointData = new PointData();
+            pointData.setTagName(rs.getString(3).toUpperCase());
+            pointData.setTs(rs.getTimestamp(1).getTime());
+            pointData.setBooleanValue(rs.getBoolean(2));
+            tsDataMap.add(pointData);
+        }
+        return tsDataMap;
+    }
 
 }

+ 76 - 0
timeseries/dao-taoscz/src/main/java/com/gyee/gaia/dao/taoscz/TaskCallable2.java

@@ -0,0 +1,76 @@
+package com.gyee.gaia.dao.taoscz;
+
+import com.gyee.gaia.common.data.point.PointData;
+import com.gyee.gaia.common.data.timeseries.BooleanTsData;
+import com.gyee.gaia.common.data.timeseries.DoubleTsData;
+import com.gyee.gaia.common.data.timeseries.TsData;
+import com.gyee.gaia.common.data.timeseries.TsDataType;
+import com.gyee.gaia.common.utils.StringUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+@Slf4j
+public class TaskCallable2 implements Callable<List<PointData>> {
+
+    private TaosConfig taosConfig;
+    private long time;
+    private String tagName;
+    private TsDataType type;
+
+    private long day_time = 86400000L;
+    private long year_time = 8640000000L;
+
+    public TaskCallable2(TaosConfig taosConfig, long time, String tagName, TsDataType type) {
+        this.taosConfig = taosConfig;
+        this.time = time;
+        this.tagName = tagName;
+        this.type = type;
+    }
+
+
+    @Override
+    public List<PointData> call() {
+        TsData tsData = null;
+        Statement st = null;
+        ResultSet rs = null;
+        List<PointData> result = new ArrayList<>();
+
+        if (StringUtil.isBlank(tagName))
+            return result;
+
+        try {
+            st = taosConfig.getInstance().createStatement();
+            //            String point = TaosCovertUtil.coverStationPrefix(this.tagName) + "." + this.tagName.replace(".", "_");
+            //            String tableName = dbName+ "." + this.tagName;
+            StringBuilder sb = new StringBuilder();
+            sb.append("select last_row(*) from ").append(taosConfig.getDbName()).append(".")
+                    .append(tagName).append(" where ts<=").append(time);
+            rs = st.executeQuery(sb.toString());
+            if (rs.next()) {
+                PointData pd = new PointData();
+                pd.setTagName(tagName);
+                pd.setTs(this.time);
+                if (this.type == TsDataType.DOUBLE)
+                    //tsData = new DoubleTsData(this.time, (short) 0, rs.getDouble(2));
+                    pd.setDoubleValue(rs.getDouble(2));
+                else if (this.type == TsDataType.BOOLEAN)
+                    //tsData = new BooleanTsData(this.time, (short) 0, rs.getBoolean(2));
+                    pd.setBooleanValue(rs.getBoolean(2));
+
+                result.add(pd);
+            }
+            //result.put(this.tagName, tsData);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+}

+ 56 - 2
timeseries/data-adapter/src/main/java/com/gyee/gaia/dataadapter/controller/timeseries/TsDataController.java

@@ -1,5 +1,6 @@
 package com.gyee.gaia.dataadapter.controller.timeseries;
 
+import com.gyee.gaia.common.data.point.PointData;
 import com.gyee.gaia.common.data.timeseries.DoubleStatData;
 import com.gyee.gaia.common.data.timeseries.TsData;
 import com.gyee.gaia.common.data.timeseries.TsPointData;
@@ -50,6 +51,18 @@ public class TsDataController {
         }
     }
 
+    @GetMapping("/latest2")
+    public List<PointData> getLatest2(
+            @RequestParam(value = "keys", required = false) Optional<String> keyStr) {
+        if (keyStr.isPresent()) {
+            String[] tagNames = keyStr.get().split(",");
+            List<PointData> data = tsDataService.getLatest2(tagNames);
+            if (data != null) return data;
+        }
+        List<PointData> nullData = new ArrayList<>();
+        return nullData;
+    }
+
     @GetMapping("/history/raw")
     public List<TsData> getHistoryRaw(@RequestParam(value = "tagName", required = false) Optional<String> tagName,
                                       @RequestParam(value = "thingType", required = false) Optional<String> thingType,
@@ -123,9 +136,20 @@ public class TsDataController {
                 list = new ArrayList<>();
             return list;
         } else {
-            List<DoubleStatData> list = new ArrayList<>();
-            return list;
+            return new ArrayList<>();
+        }
+    }
+
+
+    @GetMapping("/history/stat2")
+    public DoubleStatData getHistoryStat(@RequestParam(value = "tagName", required = false) Optional<String> tagName,
+                                               @RequestParam(value = "startTs", required = false) Optional<Long> startTs,
+                                               @RequestParam(value = "endTs", required = false) Optional<Long> endTs) {
+        DoubleStatData statData = null;
+        if (tagName.isPresent() && startTs.isPresent() && endTs.isPresent()) {
+            statData = tsDataService.getHistoryStat2(tagName.get(), startTs.get(), endTs.get());
         }
+        return statData;
     }
 
     @GetMapping("/history/section")
@@ -159,6 +183,22 @@ public class TsDataController {
 
     }
 
+    @GetMapping("/history/section2")
+    public List<PointData> getHistorySection2(@RequestParam(value = "tagNames", required = false) Optional<String> tagNames,
+                                              @RequestParam(value = "ts", required = false) Optional<Long> ts) {
+        try {
+            if (tagNames.isPresent() && ts.isPresent()) {
+                String[] tagNameArr = tagNames.get().split(",");
+                List<PointData> map = tsDataService.getHistorySection2(ts.get(), tagNameArr);
+                if (map != null)
+                    return map;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return new ArrayList<>();
+    }
+
     @PostMapping("/history/batch")
     //@ResponseBody
     public boolean writeHistoryBatch(@RequestBody List<TsPointData> tsDataList) {
@@ -220,6 +260,20 @@ public class TsDataController {
         return tsDataService.writeLatest(tsDataList);
     }
 
+
+    @PostMapping("/latest2/batch")
+    //@ResponseBody
+    public boolean writeLatestBatch2(@RequestBody List<PointData> tsDataList) throws Exception {
+        return tsDataService.writeLatest2(tsDataList);
+    }
+
+    @PostMapping("/latest2")
+    //@ResponseBody
+    public boolean writeLatest(@RequestBody PointData tsData) throws Exception {
+        List<PointData> tsDataList = new ArrayList<>();
+        tsDataList.add(tsData);
+        return tsDataService.writeLatest2(tsDataList);
+    }
 }
 
 

+ 52 - 0
timeseries/data-adapter/src/main/java/com/gyee/gaia/dataadapter/domain/timeseries/TsDataService.java

@@ -1,5 +1,6 @@
 package com.gyee.gaia.dataadapter.domain.timeseries;
 
+import com.gyee.gaia.common.data.point.PointData;
 import com.gyee.gaia.common.data.timeseries.*;
 import com.gyee.gaia.common.exception.WisdomException;
 import com.gyee.gaia.dao.timeseries.IHistoryDao;
@@ -42,6 +43,22 @@ public class TsDataService {
         return null;
     }
 
+    public List<PointData> getLatest2(String... tagNames) {
+        try {
+            List<TsPoint> tsPoints = tsPointService.getTsPoint(tagNames);
+            List<PointData> result = latestDao.getTsDataLatest2(tsPoints);
+            return result;
+        } catch (WisdomException e) {
+            log.error("异常点:" + tagNames.toString());
+            log.error(e.getMessage());
+        } catch (Exception e) {
+            log.error("异常点:" + tagNames.toString());
+            log.error(e.getMessage());
+            e.printStackTrace();
+        }
+        return null;
+    }
+
     /**
      * @param thingType
      * @param thingId
@@ -161,6 +178,21 @@ public class TsDataService {
         return null;
     }
 
+    public DoubleStatData getHistoryStat2(String tagName, long startTs, long endTs) {
+        try {
+            TsPoint tsPoint = tsPointService.getTsPoint(tagName);
+            TsQuery tsQuery = new BaseTsQuery(tsPoint, startTs, endTs, 60, 0, Interpolation.SNAP);
+            List<DoubleStatData> history = historyDao.getDoubleStatDataHistory(tsQuery);
+            if(history.isEmpty()) return null;
+            return history.get(0);
+        } catch (Exception e) {
+            log.error("异常点:" + tagName);
+            log.error(e.getMessage());
+        }
+
+        return null;
+    }
+
     public List<DoubleStatData> getHistoryStat(String thingType, String thingId, String uniformCode, long startTs, long endTs, int interval) {
         try {
             TsPoint tsPoint = tsPointService.getTsPoint(thingType, thingId, uniformCode);
@@ -186,6 +218,10 @@ public class TsDataService {
         return latestDao.writeLatest(dataList);
     }
 
+    public boolean writeLatest2(List<PointData> dataList) throws Exception {
+        return latestDao.writeLatest2(dataList);
+    }
+
     public Map<String, TsData> getHistorySection(long ts, String... tagNames) {
         try {
             List<TsPoint> tsPoints = tsPointService.getTsPoint(tagNames);
@@ -202,6 +238,22 @@ public class TsDataService {
         return null;
     }
 
+    public List<PointData> getHistorySection2(long ts, String... tagNames) {
+        try {
+            List<TsPoint> tsPoints = tsPointService.getTsPoint(tagNames);
+            List<PointData> result = historyDao.getHistorySection2(tsPoints, ts);
+            return result;
+        } catch (WisdomException e) {
+            log.error("异常点:" + tagNames.toString());
+            log.error(e.getMessage());
+        } catch (Exception e) {
+            log.error("异常点:" + tagNames.toString());
+            log.error(e.getMessage());
+            e.printStackTrace();
+        }
+        return null;
+    }
+
     public Map<String, TsData> getHistorySection(long ts, String thingId, String thingType, String... uniformCode) throws Exception {
         try {
             List<TsPoint> pointList = tsPointService.getTsPoint(thingType, thingId, uniformCode);

+ 12 - 2
timeseries/data-adapter/src/main/java/com/gyee/gaia/dataadapter/domain/timeseries/TsPointService.java

@@ -29,7 +29,13 @@ public class TsPointService {
        /* Map<String, TsPoint> tMap = tagMap.entrySet().stream()
                 .filter(s -> tagNameList.contains(s.getKey()))
                 .collect(Collectors.toMap(e -> (String) e.getKey(), e -> e.getValue()));*/
-
+        /*for (String tagName : tagNames) {
+            if(tagName.contains("DI")){
+                selectList.add(new BasicTsPoint(tagName, TsDataType.BOOLEAN));
+            }else {
+                selectList.add(new BasicTsPoint(tagName, TsDataType.DOUBLE));
+            }
+        }*/
         for (int i = 0; i < tagNames.length; i++) {
             if (tagMap.containsKey(tagNames[i])) {
 
@@ -73,7 +79,11 @@ public class TsPointService {
     }
 
     public TsPoint getTsPoint(String tagName) {
-
+        /*if(tagName.contains("DI")){
+            return new BasicTsPoint(tagName, TsDataType.BOOLEAN);
+        }else {
+            return new BasicTsPoint(tagName, TsDataType.DOUBLE);
+        }*/
         TsPoint tsPoint = null;
         if (this.tagMap.containsKey(tagName)) {
             tsPoint = tagMap.get(tagName);

+ 2 - 0
资源文件/sql/taossql.sql

@@ -42,3 +42,5 @@ TAGS (station_id BINARY(50),equipment_id BINARY(50),state_type NCHAR(50))
 CREATE DATABASE IF NOT EXISTS jsfw_db UPDATE 2;
 create stable if not exists pointci (ts timestamp,val double)
 tags (description nchar(100),station binary(20),category binary(20),facility binary(20),uniformcode binary(20));
+
+create stable if not exists jsfw_db.state_point (ts timestamp,val tinyint,status tinyint,time int) tags (description nchar(100));

BIN
资源文件/日电量计算说明.xlsx