Browse Source

新增mongodb插入查询功能,iotdb新增对driverLocation数据类型支持,新增通过csv文件导入driverLocation数据至数据库功能

kuanglingwei 2 years ago
parent
commit
c8e75f5a7e

+ 33 - 0
conf/mongodb/log.properties

@@ -0,0 +1,33 @@
+handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+#SEVERE(最高值)
+#WARNING
+#INFO
+#CONFIG
+#FINE
+#FINER
+#FINEST(最低值)
+#OFF
+
+.level = ALL
+
+# default file output is in user's home directory.
+java.util.logging.FileHandler.pattern = log/mongodb/log.log
+java.util.logging.FileHandler.count = 100
+java.util.logging.FileHandler.level = INFO
+#java.util.logging.FileHandler.level = WARNING
+java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+
+# Limit the message that are printed on the console to INFO and above.
+java.util.logging.ConsoleHandler.level = INFO
+#java.util.logging.ConsoleHandler.level = WARNING
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+
+############################################################
+# Facility specific properties.
+############################################################
+java.level = WARNING
+javax.level = WARNING
+sun.level = WARNING

+ 9 - 1
iotdb/pom.xml

@@ -20,23 +20,31 @@
             <artifactId>iotdb-session</artifactId>
             <version>0.13.3</version>
         </dependency>
+
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
             <version>1.18.12</version>
         </dependency>
+
         <dependency>
             <groupId>commons-cli</groupId>
             <artifactId>commons-cli</artifactId>
             <version>1.3.1</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-csv</artifactId>
+            <version>1.7</version>
+        </dependency>
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.13.1</version>
             <scope>test</scope>
         </dependency>
-
     </dependencies>
     <build>
         <plugins>

+ 33 - 8
iotdb/src/main/java/db/DBApiEntry.java

@@ -9,10 +9,7 @@ import org.apache.iotdb.tsfile.write.record.Tablet;
 import util.SpentTimeCalculator;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.SortedMap;
+import java.util.*;
 import java.util.logging.Logger;
 
 public class DBApiEntry {
@@ -30,13 +27,14 @@ public class DBApiEntry {
      * @return
      * @dateTime 2022/11/29 19:15
      */
-    public DBApiEntry(String host, int port) throws IOException {
+    public DBApiEntry(String host, int port) {
         this.host = host;
         this.port = port;
         this.session = new Session.Builder()
                 .host(this.host)
                 .port(this.port)
                 .build();
+        logger.info(String.format("create DBApiEntry host:%s port:%s", this.host, this.port));
     }
 
     /**
@@ -155,7 +153,7 @@ public class DBApiEntry {
      * @dateTime 2022/11/29 20:43
      */
     public boolean insertTablet(Tablet tablet) {
-        if(tablet.rowSize == 0 || tablet == null) {
+        if(tablet == null || tablet.rowSize == 0) {
             return false;
         }
 
@@ -175,6 +173,34 @@ public class DBApiEntry {
         }
     }
 
+    /**
+     * @description 插入多个tablet
+     * @param tablets
+     * @return boolean
+     * @dateTime 2023/1/11 21:51
+     */
+    public boolean insertTablets(Map<String, Tablet> tablets) {
+        if(tablets == null || tablets.isEmpty()) {
+            logger.info(String.format("tablets is null or empty!"));
+            return false;
+        }
+
+        try {
+            SpentTimeCalculator stc = SpentTimeCalculator.create().begin();
+            this.open();
+            this.session.insertTablets(tablets);
+            this.close();
+            stc.end();
+            logger.info(String.format("InsertTablet insertTabletSeriesSize:[%d] spendTime:%d(ms)",
+                    tablets.size(), stc.getSpendTime()));
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.severe(String.format("InsertTablets exception:%s", e));
+            return false;
+        }
+    }
+
     /**
      * @description 插入一条record,即一个设备一个时间戳下多个测点的数据。
      * @param record
@@ -210,7 +236,7 @@ public class DBApiEntry {
      * @dateTime 2022/11/30 9:09
      */
     public boolean insertMultiRecord(List<Record> records) {
-        if(records.size() == 0) {
+        if(records.isEmpty()) {
             return false;
         }
 
@@ -253,7 +279,6 @@ public class DBApiEntry {
      * @dateTime 2022/11/30 17:10
      */
     public Hashtable<String, DBVal> queryLast(List<String> paths) {
-
         if(paths.isEmpty()) {
             return null;
         }

+ 19 - 0
iotdb/src/main/java/db/DriverLocationFieldName.java

@@ -0,0 +1,19 @@
+package db;
+
+public enum DriverLocationFieldName {
+    _CLASS("_class"), CREATETIME("createTime"), DRIVERID("driverId"),
+    DIRECTION("direction"), ELEVATION("elevation"),
+    LAT("lat"), LNG("lng"), SPEED("speed");
+
+    private String value;
+
+    DriverLocationFieldName(String value) { this.value = value; }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

+ 100 - 0
iotdb/src/main/java/db/DriverLocationVal.java

@@ -0,0 +1,100 @@
+package db;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.text.ParseException;
+
+
+@NoArgsConstructor
+@Data
+public class DriverLocationVal {
+    private static final long serialVersionUID = 1L;
+
+    private String driverId;    // 数值型点名 - pointName
+    private String _class = "";
+    private long utcTime;       // 数值型实时UTC时间,精确到ms
+    private double direction;   // 方向
+    private int elevation;      // 海拔
+    private double lat;         // 经度
+    private double lng;         // 纬度
+    private double speed;       // 速度
+
+    private ValueStatus valueStatus = ValueStatus.VALID;       // 数值型实时状态
+
+    public DriverLocationVal(String driverId, long utcTime, double direction, int elevation,
+                             double lat, double lng, double speed) {
+        this.driverId = driverId;
+        this.utcTime = utcTime;
+        this.direction = direction;
+        this.elevation = elevation;
+        this.lat = lat;
+        this.lng = lng;
+        this.speed = speed;
+    }
+
+    public DriverLocationVal(String _class, String driverId, long utcTime, double direction,
+                             int elevation, double lat, double lng, double speed) {
+        this._class = _class;
+        this.driverId = driverId;
+        this.utcTime = utcTime;
+        this.direction = direction;
+        this.elevation = elevation;
+        this.lat = lat;
+        this.lng = lng;
+        this.speed = speed;
+    }
+
+    /*
+     * 返回时间戳,单位为秒
+     */
+    public long getUtcTime() {
+        return utcTime/1000;
+    }
+
+    /*
+     * 返回时间戳,单位为毫秒
+     */
+    public long getUtcTimeMilliSeconds() {
+        return utcTime;
+    }
+
+    /*
+     * 返回时间戳,单位为毫秒
+     */
+    public void setUtcTimeMilliSeconds(long utcTime) {
+        this.utcTime = utcTime;
+    }
+
+    /*
+     * utcTime 单位为秒
+     */
+    public void setUtcTime(long utcTime) {
+        this.utcTime = utcTime*1000;
+    }
+
+    @Override
+    public String toString() {
+        try {
+            return String.format("driverId:%s createTime:%s direction:%.2f elevation:%d " +
+                            "lat:%.2f lng:%.2f speed:%.2f _class:%s _class:%s",
+                    this.driverId, Util.uTCSecondsToDateString(this.utcTime), this.direction,
+                    this.elevation, this.lat, this.lng, this.speed, this._class, this._class);
+        }
+        catch (ParseException e) {
+            return String.format("Parse uTCSecondsToDateString Exception, " +
+                    "driverId:%s createTime:%s direction:%.2f elevation:%d " +
+                    "lat:%.2f lng:%.2f speed:%.2f _class:%s _class:%s",
+                    this.driverId, this.utcTime, this.direction, this.elevation,
+                    this.lat, this.lng, this.speed, this._class, this._class);
+        }
+    }
+
+    public void setValueStatusInvalid() {
+        this.valueStatus = ValueStatus.INVALID;
+    }
+
+    public boolean isValueValid() {
+        return ValueStatus.VALID==this.valueStatus;
+    }
+}

+ 1 - 0
iotdb/src/main/java/demo/Globals.java

@@ -4,4 +4,5 @@ public class Globals {
     // public final static String HOST = "192.168.116.128";
     public final static String HOST = "127.0.0.1";
     public final static int PORT = 6667;
+    public final static String STORAGEGROUP = "root.driver_location.testCollection";
 }

+ 28 - 0
iotdb/src/main/java/demo/insert/ImportHistoricalData.java

@@ -0,0 +1,28 @@
+package demo.insert;
+
+import db.DBApiEntry;
+import db.DriverLocationVal;
+import demo.Globals;
+import org.apache.iotdb.tsfile.write.record.Tablet;
+import util.DataReader;
+
+import java.util.*;
+
+public class ImportHistoricalData {
+    public final static String CSVFILEPATH = "F:\\T3_Data\\iotdbTest209000.csv";
+
+    public static void main(String[] args) {
+        // 读取csv文件,生成DriverLocation对象
+        Hashtable<String, List<DriverLocationVal>> driverLocationValHashtable =
+                DataReader.GetDriverLocationValFromCSV(CSVFILEPATH);
+        // 将DriverLocation对象转为Tablet格式
+        Map<String, Tablet> tablets =
+                DataReader.driverLocationValToTablet(driverLocationValHashtable);
+        // 执行插入数据函数
+        DBApiEntry dbApiEntry = new DBApiEntry("39.104.80.229", Globals.PORT);
+        dbApiEntry.insertTablets(tablets);
+        // for(Tablet tablet : tablets.values()) {
+        //     dbApiEntry.insertTablet(tablet);
+        // }
+    }
+}

+ 174 - 0
iotdb/src/main/java/util/DataReader.java

@@ -0,0 +1,174 @@
+package util;
+
+import db.DBApiEntry;
+import db.DriverLocationFieldName;
+import db.DriverLocationVal;
+import db.Util;
+import demo.Globals;
+import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVRecord;
+import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.write.record.Tablet;
+import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.ParseException;
+import java.util.*;
+import java.util.logging.Logger;
+
+public class DataReader {
+    public static final Logger logger = Logger.getLogger(DBApiEntry.class.getName());
+
+    /**
+     * @description 将一系列DriverLocationVal数据转换为多个tables形式,其中result.key为缓冲函数提供作用
+     * @param driverLocationValHashtable
+     * @return java.util.Map<java.lang.String,org.apache.iotdb.tsfile.write.record.Tablet>
+     * @dateTime 2023/1/11 21:56
+     */
+    public static Map<String, Tablet> driverLocationValToTablet(
+            Hashtable<String, List<DriverLocationVal>> driverLocationValHashtable) {
+        if(driverLocationValHashtable == null || driverLocationValHashtable.isEmpty()) {
+            logger.info(String.format("driverLocationValHashtable is null or empty!"));
+            return null;
+        }
+
+        Map<String, Tablet> tablets = new HashMap<>();
+        long totalTabletSize = 0L;
+        // 遍历每一台driverId,为其声明tablet,相当于以汽车id命名的表
+        for(String driverId : driverLocationValHashtable.keySet()) {
+            List<DriverLocationVal> driverLocationValList = driverLocationValHashtable.get(driverId);
+
+            if(driverLocationValList == null || driverLocationValList.isEmpty()) {
+                continue;
+            }
+
+            // 根据driverId命名设备id,并充当度量名
+            String deviceId = String.format(Globals.STORAGEGROUP + "." + driverId);
+            List<MeasurementSchema> schema = new ArrayList<>();
+            // measurementId可乱序,相当于set集合,表明某个度量值具体的value属性
+            MeasurementSchema measurementschema0 = new MeasurementSchema(
+                    DriverLocationFieldName._CLASS.getValue(),
+                    TSDataType.TEXT, TSEncoding.PLAIN, CompressionType.SNAPPY);
+            MeasurementSchema measurementschema1 = new MeasurementSchema(
+                    DriverLocationFieldName.DIRECTION.getValue(),
+                    TSDataType.DOUBLE, TSEncoding.GORILLA, CompressionType.SNAPPY);
+            MeasurementSchema measurementschema2 = new MeasurementSchema(
+                    DriverLocationFieldName.ELEVATION.getValue(),
+                    TSDataType.INT32, TSEncoding.RLE, CompressionType.SNAPPY);
+            MeasurementSchema measurementschema3 = new MeasurementSchema(
+                    DriverLocationFieldName.LAT.getValue(),
+                    TSDataType.DOUBLE, TSEncoding.GORILLA, CompressionType.SNAPPY);
+            MeasurementSchema measurementschema4 = new MeasurementSchema(
+                    DriverLocationFieldName.LNG.getValue(),
+                    TSDataType.DOUBLE, TSEncoding.GORILLA, CompressionType.SNAPPY);
+            MeasurementSchema measurementschema5 = new MeasurementSchema(
+                    DriverLocationFieldName.SPEED.getValue(),
+                    TSDataType.DOUBLE, TSEncoding.GORILLA, CompressionType.SNAPPY);
+            // 添加策略集
+            schema.add(measurementschema0);
+            schema.add(measurementschema1);
+            schema.add(measurementschema2);
+            schema.add(measurementschema3);
+            schema.add(measurementschema4);
+            schema.add(measurementschema5);
+            // 声明tablet:指定单个tablet最大行数为10000,默认1024
+            Tablet tablet = new Tablet(deviceId, schema, 10000);
+            if(tablet == null) {
+                logger.info(String.format("declaration tablet is null"));
+                return null;
+            }
+
+            // 针对单独tablet添加value值
+            // 可同时为多个度量插入若干各dataPoint(支持留空白,会自添空值),添加value指明度量名即可
+            int index = 0;
+            for(DriverLocationVal driverLocationVal : driverLocationValList) {
+                tablet.addTimestamp(index, driverLocationVal.getUtcTimeMilliSeconds());
+
+                tablet.addValue(DriverLocationFieldName._CLASS.getValue(),
+                        index, driverLocationVal.get_class());
+                tablet.addValue(DriverLocationFieldName.DIRECTION.getValue(),
+                        index, driverLocationVal.getDirection());
+                tablet.addValue(DriverLocationFieldName.ELEVATION.getValue(),
+                        index, driverLocationVal.getElevation());
+                tablet.addValue(DriverLocationFieldName.LAT.getValue(),
+                        index, driverLocationVal.getLat());
+                tablet.addValue(DriverLocationFieldName.LNG.getValue(),
+                        index, driverLocationVal.getLng());
+                tablet.addValue(DriverLocationFieldName.SPEED.getValue(),
+                        index, driverLocationVal.getSpeed());
+
+                index++;
+            }
+            // Bitmap
+            tablet.initBitMaps();
+            tablet.rowSize += driverLocationValList.size();
+            totalTabletSize += driverLocationValList.size();
+
+            // 将tablet添加进Map
+            tablets.put(deviceId, tablet);
+        }
+        logger.info(String.format("all tablet size is:[%d]", totalTabletSize));
+        return tablets;
+    }
+
+    /**
+     * @description 从指定csv文件内读取数据,转换为DriverLocationVal格式
+     * @param filePath
+     * @return java.util.Hashtable<java.lang.String,db.DriverLocationVal>
+     * @dateTime 2023/1/11 21:17
+     */
+    public static Hashtable<String, List<DriverLocationVal>> GetDriverLocationValFromCSV(
+            String filePath) {
+        if(filePath.isEmpty()) {
+            logger.info(String.format("csv file path is null!"));
+            return null;
+        }
+
+        Hashtable<String, List<DriverLocationVal>> result = new Hashtable<>();
+
+        try (Reader reader = Files.newBufferedReader(Paths.get(filePath))) {
+            Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(reader);
+            records.iterator().next();
+            for (CSVRecord record : records) {
+                try {
+                    // 从record获取数据,具体索引为列号
+                    DriverLocationVal driverLocationVal = new DriverLocationVal();
+                    driverLocationVal.setUtcTime(Util.dateStringToUTCMilliSeconds(record.get(0)));
+                    driverLocationVal.setElevation(Integer.parseInt(record.get(1)));
+                    driverLocationVal.setDriverId(record.get(2));
+                    driverLocationVal.setLng(Double.parseDouble(record.get(3)));
+                    driverLocationVal.set_class(record.get(4));
+                    driverLocationVal.setLat(Double.parseDouble(record.get(5)));
+                    driverLocationVal.setSpeed(Double.parseDouble(record.get(6)));
+                    driverLocationVal.setDirection(Double.parseDouble(record.get(7)));
+
+                    // 判断result内是否具备driverId,具备则采取List添加即可
+                    if(result.containsKey(driverLocationVal.getDriverId())) {
+                        result.get(driverLocationVal.getDriverId()).add(driverLocationVal);
+                    }
+                    // 不具备添加HashTable映射
+                    else {
+                        List<DriverLocationVal> driverLocationValList = new ArrayList<>();
+                        driverLocationValList.add(driverLocationVal);
+                        result.put(driverLocationVal.getDriverId(), driverLocationValList);
+                    }
+                }
+                catch (ParseException e) {
+                    logger.severe(String.format("Parse Time error, driverId:[%s] createTime:[%s]",
+                            record.get(2), record.get(0)));
+                    return null;
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            logger.severe(String.format("read csv file exception:%s", e));
+            return null;
+        }
+        return result;
+    }
+}

BIN
lib/iotdb.jar


+ 88 - 0
mongodb/pom.xml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>tsdb-benchmark</artifactId>
+        <groupId>giannischen.nuaa.edu.cn</groupId>
+        <version>0.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>  <!-- 若无该相对路径,导入Maven项目时,可能该模块pom依赖无法加载 -->
+    </parent>
+
+    <artifactId>mongodb</artifactId>
+    <name>mongodb</name>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <!-- https://mvnrepository.com/artifact/org.mongodb/bson -->
+        <dependency>
+            <groupId>org.mongodb</groupId>
+            <artifactId>bson</artifactId>
+            <version>4.8.1</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-core -->
+        <dependency>
+            <groupId>org.mongodb</groupId>
+            <artifactId>mongodb-driver-core</artifactId>
+            <version>4.8.1</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-sync -->
+        <dependency>
+            <groupId>org.mongodb</groupId>
+            <artifactId>mongodb-driver-sync</artifactId>
+            <version>4.8.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.12</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>3.4.2</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <!--这里指定要运行的main类-->
+                            <mainClass>demo.allInsert.InsertHistoricalRandomData</mainClass>
+                        </manifest>
+                    </archive>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 213 - 0
mongodb/src/main/java/db/DBApiEntry.java

@@ -0,0 +1,213 @@
+package db;
+
+import com.mongodb.MongoBulkWriteException;
+import com.mongodb.client.MongoClient;
+import com.mongodb.client.MongoClients;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import static com.mongodb.client.model.Sorts.ascending;
+import static com.mongodb.client.model.Sorts.orderBy;
+
+import com.mongodb.client.result.InsertManyResult;
+import com.mongodb.client.result.InsertOneResult;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.bson.Document;
+import org.bson.conversions.Bson;
+import util.ParseDataFormat;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+@NoArgsConstructor
+@Data
+public class DBApiEntry {
+    public static final Logger logger = Logger.getLogger(DBApiEntry.class.getName());
+    private String url = "mongodb://47.92.125.208:27017/?maxPoolSize=20&w=majority";;
+    private String database = "admin";
+    private String collectionName = "testCollection";
+
+    private long lookback = 365l*24*60*60*1000;     //定义“最近时间”
+    private int slowQueryTimeThrehold = 20000;      //单位毫秒,低时间告警阈值
+
+    //TODO 连接参数设置
+
+    public DBApiEntry(String url, String database) {
+        this.url = url;
+        this.database = database;
+    }
+
+    public DBApiEntry(String url, String database, String collectionName) {
+        this.url = url;
+        this.database = database;
+        this.collectionName = collectionName;
+        logger.info(String.format("create DBApiEntry url:%s database:%s collectionName:%s"
+                , this.url, this.database, this.collectionName));
+    }
+
+    /**
+     * @description
+     * @param method
+     * @param query
+     * @param spendTime
+     * @return void
+     * @dateTime 2023/1/10 20:01
+     */
+    private void logSlowQuery(String method, String query, long spendTime) {
+        if(spendTime > this.slowQueryTimeThrehold) {
+            logger.severe(String.format("slowQuery spendTime:%d(ms) method:%s query:%s",
+                    spendTime, method, query));
+        }
+    }
+
+    /**
+     * @description 将单个dbval插入数据库
+     * @param dbval
+     * @return boolean
+     * @dateTime 2023/1/10 20:21
+     */
+    public boolean insertRecord(DBVal dbval) {
+        if(dbval == null) {
+            return false;
+        }
+
+        try (MongoClient mongoClient = MongoClients.create(this.url)) {
+            MongoDatabase mongoDatabase = mongoClient.getDatabase(this.database);
+            //TODO Collection属性设置
+            MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName);
+
+            Document doc = ParseDataFormat.dbvalToDocument(dbval);
+            InsertOneResult result = collection.insertOne(doc);
+
+            logger.info(String.format("Inserted a document with the following id:%s"
+                    , result.getInsertedId().asObjectId().getValue().toHexString()));
+        } catch (ParseException e) {
+            e.printStackTrace();
+            logger.severe(String.format("Parse dbval to document exception:%s", e));
+            return false;
+        }
+        return true;        // 需运行完try退出,以便释放mongoClient
+    }
+
+    /**
+     * @description 将一系列dbval插入数据库
+     * @param dbvalList
+     * @return boolean
+     * @dateTime 2023/1/10 20:21
+     */
+    public boolean insertRecords(List<DBVal> dbvalList) {
+        if(dbvalList.isEmpty()) {
+            return false;
+        }
+
+        try (MongoClient mongoClient = MongoClients.create(this.url)) {
+            MongoDatabase mongoDatabase = mongoClient.getDatabase(this.database);
+            //TODO Collection属性设置
+            MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName);
+
+            try {
+                List<Document> documents = ParseDataFormat.dbvalsToDocuments(dbvalList);
+                InsertManyResult result = collection.insertMany(documents);
+
+                List<String> insertedIds = new ArrayList<>();
+                result.getInsertedIds().values()
+                        .forEach(doc -> insertedIds.add(doc.asObjectId().getValue().toHexString()));
+                logger.info(String.format("Inserted documents with the following ids:%s"
+                        , insertedIds.toString()));
+            }
+            catch (ParseException e) {
+                e.printStackTrace();
+                logger.severe(String.format("Parse dbvals to documents exception:%s", e));
+                return false;
+            }
+            catch (MongoBulkWriteException e) {
+                List<String> insertedIds = new ArrayList<>();
+                e.getWriteResult().getInserts()
+                        .forEach(doc -> insertedIds.add(doc.getId().asObjectId()
+                                .getValue().toHexString()));
+                logger.info(String.format("A MongoBulkWriteException occurred, but there " +
+                        "are successfully processed documents with the following ids:%s"
+                        , insertedIds.toString()));
+
+                e.printStackTrace();
+                logger.severe(String.format("InsertRecords exception:%s", e));
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * @description 通过driverId查询DBVal对象
+     * @param driverId
+     * @return java.util.List<db.DBVal>
+     * @dateTime 2023/1/11 11:24
+     */
+    public List<DBVal> queryBySingleDriverId(String driverId) {
+        if(driverId.isEmpty()) {
+            return null;
+        }
+
+        List<DBVal> dbValList;
+        try (MongoClient mongoClient = MongoClients.create(this.url)) {
+            MongoDatabase mongoDatabase = mongoClient.getDatabase(this.database);
+            //TODO Collection属性设置
+            MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName);
+
+            Bson filter = Filters.eq(FieldName.DRIVERID.getValue(), driverId);
+            try {
+                List<Document> documentList = new ArrayList<>();
+                collection.find(filter).sort(ascending(FieldName.CREATETIME.getValue()))
+                        .into(documentList);
+
+                dbValList = ParseDataFormat.documentsToDBVals(documentList);
+                logger.info(String.format("result size:%d", dbValList.size()));
+            }
+            catch (ParseException e) {
+                e.printStackTrace();
+                logger.severe(String.format("Parse documents to dbvals exception:%s", e));
+                return null;
+            }
+        }
+        return dbValList;
+    }
+
+    /**
+     * @description 通过若干driverId查询对应DBVal值
+     * @param driverIdList
+     * @return java.util.List<db.DBVal>
+     * @dateTime 2023/1/11 15:29
+     */
+    public List<DBVal> queryByMultiDriverId(List<String> driverIdList) {
+        if(driverIdList.isEmpty()) {
+            return null;
+        }
+
+        List<DBVal> dbValList;
+        try (MongoClient mongoClient = MongoClients.create(this.url)) {
+            MongoDatabase mongoDatabase = mongoClient.getDatabase(this.database);
+            //TODO Collection属性设置
+            MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName);
+
+            Bson filter = Filters.in(FieldName.DRIVERID.getValue(), driverIdList);
+            try {
+                List<Document> documentList = new ArrayList<>();
+                Bson orderBySort = orderBy(ascending((FieldName.DRIVERID.getValue())),
+                        ascending(FieldName.CREATETIME.getValue()));
+                collection.find(filter).sort(orderBySort).into(documentList);
+
+                dbValList = ParseDataFormat.documentsToDBVals(documentList);
+                logger.info(String.format("result size:%d", dbValList.size()));
+            }
+            catch (ParseException e) {
+                e.printStackTrace();
+                logger.severe(String.format("Parse documents to dbvals exception:%s", e));
+                return null;
+            }
+        }
+        return dbValList;
+    }
+}

+ 101 - 0
mongodb/src/main/java/db/DBVal.java

@@ -0,0 +1,101 @@
+package db;
+
+import lombok.NoArgsConstructor;
+import lombok.Data;
+
+import java.text.ParseException;
+
+
+@NoArgsConstructor
+@Data
+public class DBVal {
+    private static final long serialVersionUID = 1L;
+
+    private String driverId;    // 数值型点名 - pointName
+    private String _id = "";    // document Id
+    private String _class = "";
+    private long utcTime;       // 数值型实时UTC时间,精确到ms
+    private double direction;   // 方向
+    private int elevation;      // 海拔
+    private double lat;         // 经度
+    private double lng;         // 纬度
+    private double speed;       // 速度
+
+    private ValueStatus valueStatus = ValueStatus.VALID;       // 数值型实时状态
+
+    public DBVal(String driverId, long utcTime, double direction, int elevation,
+                 double lat, double lng, double speed) {
+        this.driverId = driverId;
+        this.utcTime = utcTime;
+        this.direction = direction;
+        this.elevation = elevation;
+        this.lat = lat;
+        this.lng = lng;
+        this.speed = speed;
+    }
+
+    public DBVal(String _id, String driverId, long utcTime, double direction,
+                 int elevation, double lat, double lng, double speed) {
+        this._id = _id;
+        this.driverId = driverId;
+        this.utcTime = utcTime;
+        this.direction = direction;
+        this.elevation = elevation;
+        this.lat = lat;
+        this.lng = lng;
+        this.speed = speed;
+    }
+
+    /*
+     * 返回时间戳,单位为秒
+     */
+    public long getUtcTime() {
+        return utcTime/1000;
+    }
+
+    /*
+     * 返回时间戳,单位为毫秒
+     */
+    public long getUtcTimeMilliSeconds() {
+        return utcTime;
+    }
+
+    /*
+     * 返回时间戳,单位为毫秒
+     */
+    public void setUtcTimeMilliSeconds(long utcTime) {
+        this.utcTime = utcTime;
+    }
+
+    /*
+     * utcTime 单位为秒
+     */
+    public void setUtcTime(long utcTime) {
+        this.utcTime = utcTime*1000;
+    }
+
+    @Override
+    public String toString() {
+        try {
+            return String.format("driverId:%s createTime:%s direction:%.2f elevation:%d " +
+                            "lat:%.2f lng:%.2f speed:%.2f _id:%s _class:%s",
+                    this.driverId, Util.uTCSecondsToDateString(this.utcTime), this.direction,
+                    this.elevation, this.lat, this.lng, this.speed, this._id, this._class);
+        }
+        catch (ParseException e) {
+            return String.format("Parse uTCSecondsToDateString Exception, " +
+                    "driverId:%s createTime:%s direction:%.2f elevation:%d " +
+                    "lat:%.2f lng:%.2f speed:%.2f _id:%s _class:%s",
+                    this.driverId, this.utcTime, this.direction, this.elevation,
+                    this.lat, this.lng, this.speed, this._id, this._class);
+        }
+    }
+
+    public void setValueStatusInvalid() {
+        this.valueStatus = ValueStatus.INVALID;
+    }
+
+    public boolean isValueValid() {
+        return ValueStatus.VALID==this.valueStatus;
+    }
+}

+ 19 - 0
mongodb/src/main/java/db/FieldName.java

@@ -0,0 +1,19 @@
+package db;
+
+public enum FieldName {
+    _ID("_id"), _CLASS("_class"), CREATETIME("createTime"),
+    DRIVERID("driverId"), DIRECTION("direction"), ELEVATION("elevation"),
+    LAT("lat"), LNG("lng"), SPEED("speed");
+
+    private String value;
+
+    FieldName(String value) { this.value = value; }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

+ 199 - 0
mongodb/src/main/java/db/Util.java

@@ -0,0 +1,199 @@
+package db;
+
+import org.bson.Document;
+import org.bson.types.ObjectId;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class Util {
+    /**
+     * 将标准时间转为Unix秒
+     * @param date String格式时间
+     * @return long
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static long dateStringToUTCSeconds(String date) throws ParseException {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return (long) (format.parse(date).getTime() / 1000);
+    }
+
+    /**
+     * 将标准时间转为Unix毫秒
+     * @param date String格式时间
+     * @return long
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static long dateStringToUTCMilliSeconds(String date) throws ParseException {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return format.parse(date).getTime();
+    }
+
+
+    /**
+     * 将Unix秒转为标准时间
+     * @param utcSeconds long格式当前unix时间秒数
+     * @return String
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static String uTCSecondsToDateString(long utcSeconds) throws ParseException {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return format.format(new Date(utcSeconds * 1000));
+    }
+
+   /**
+     * 将Unix秒转为标准时间
+     * @param utcMilliSeconds long格式当前unix时间毫秒数
+     * @return String
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static String uTCMilliSecondsToDateString(long utcMilliSeconds) {
+        try {
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            return format.format(new Date(utcMilliSeconds));
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
+   /**
+     * 将Unix秒转为标准时间
+     * @param utcMilliSeconds long格式当前unix时间毫秒数
+     * @return String
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static String uTCMilliSecondsToDateStringWithMs(long utcMilliSeconds) {
+        try {
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
+            return format.format(new Date(utcMilliSeconds));
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
+    public static String uTCMSToDateString(String utcSeconds) throws ParseException {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long second= Long.parseLong(utcSeconds.substring(0,10));
+        return (format.format(new Date(second*1000)))+":"+utcSeconds.substring(10);
+    }
+
+    /**
+     * 将Unix秒转为标准时间
+     * @param utcSeconds long格式当前unix时间秒数
+     * @return String
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static String uTCSecondsToDateStringYear(long utcSeconds) throws ParseException {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy");
+        return format.format(new Date(utcSeconds * 1000));
+    }
+
+    /**
+     * 将Unix秒转为标准时间
+     * @param utcSeconds long格式当前unix时间秒数
+     * @return String
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static String uTCSecondsToDateStringMonth(long utcSeconds) throws ParseException {
+        SimpleDateFormat format = new SimpleDateFormat("MM");
+        return format.format(new Date(utcSeconds * 1000));
+    }
+
+    /**
+     * 返回当前时间的Unix值,单位为毫秒
+     * @return long
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static long currentUTCSeconds() {
+        return System.currentTimeMillis() / 1000;
+    }
+
+    /**
+     * 返回当前时间的Unix值,单位为毫秒
+     * @return long
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static long currentUTCMilliSeconds() {
+        return System.currentTimeMillis();
+    }
+
+    public static OffsetDateTime toOffsetDateTime(long timeMilli) {
+        return OffsetDateTime.ofInstant(Instant.ofEpochMilli(timeMilli), ZoneId.systemDefault());
+    }
+    /**
+     * 返回human-readable的数据尺寸大小
+     * @param size
+     * @return String
+     * @author none
+     * @date 2020-11-05 00:00
+     */
+    public static String getNetFileSizeDescription(long size) {
+        StringBuffer bytes = new StringBuffer();
+        DecimalFormat format = new DecimalFormat("###.0");
+        if (size >= 1024 * 1024 * 1024) {
+            double i = (size / (1024.0 * 1024.0 * 1024.0));
+            bytes.append(format.format(i)).append("GB");
+        } else if (size >= 1024 * 1024) {
+            double i = (size / (1024.0 * 1024.0));
+            bytes.append(format.format(i)).append("MB");
+        } else if (size >= 1024) {
+            double i = (size / (1024.0));
+            bytes.append(format.format(i)).append("KB");
+        } else if (size < 1024) {
+            if (size <= 0) {
+                bytes.append("0B");
+            } else {
+                bytes.append((int) size).append("B");
+            }
+        }
+        return bytes.toString();
+    }
+
+    /*
+    判断对象是否为空,进一步判断对象中的属性是否都为空
+     */
+    public  boolean objCheckIsNull(Object object){
+        Class clazz = (Class)object.getClass(); // 得到类对象
+        Field fields[] = clazz.getDeclaredFields(); // 得到所有属性
+        boolean flag = true; //定义返回结果,默认为true
+        for(Field field : fields){
+            field.setAccessible(true);
+            Object fieldValue = null;
+            try {
+                fieldValue = field.get(object); //得到属性值
+                Type fieldType =field.getGenericType();//得到属性类型
+                String fieldName = field.getName(); // 得到属性名
+                System.out.println("属性类型:"+fieldType+",属性名:"+fieldName+",属性值:"+fieldValue);
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+            if(fieldValue != null){  //只要有一个属性值不为null 就返回false 表示对象不为null
+                flag = false;
+                break;
+            }
+        }
+        return flag;
+    }
+}

+ 5 - 0
mongodb/src/main/java/db/ValueStatus.java

@@ -0,0 +1,5 @@
+package db;
+
+public enum ValueStatus {
+    VALID, INVALID
+}

+ 7 - 0
mongodb/src/main/java/demo/Globals.java

@@ -0,0 +1,7 @@
+package demo;
+
+public class Globals {
+    public final static String URL = "mongodb://39.104.80.229:27017/?maxPoolSize=20&w=majority";;
+    public final static String DATABASE = "driver_location";
+    public final static String COLLECTIONNAME = "testCollection";       // 相当于表名
+}

+ 21 - 0
mongodb/src/main/java/demo/InsertMultiRecords.java

@@ -0,0 +1,21 @@
+package demo;
+
+import db.DBApiEntry;
+import db.DBVal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InsertMultiRecords {
+    public static void main(String[] args) {
+        DBVal dbval = new DBVal("id19", 1673405036, (double)11.0, 11, (double)12.0,
+                (double)13.0, (double)14.0);
+        DBVal dbval2 = new DBVal("id20", 1673405036, (double)11.0, 11, (double)12.0,
+                (double)13.0, (double)14.0);
+        List<DBVal> dbValList = new ArrayList<>();
+        dbValList.add(dbval);
+        dbValList.add(dbval2);
+        DBApiEntry dbApiEntry = new DBApiEntry(Globals.URL, Globals.DATABASE, Globals.COLLECTIONNAME);
+        dbApiEntry.insertRecords(dbValList);
+    }
+}

+ 13 - 0
mongodb/src/main/java/demo/InsertSingleRecord.java

@@ -0,0 +1,13 @@
+package demo;
+
+import db.DBApiEntry;
+import db.DBVal;
+
+public class InsertSingleRecord {
+    public static void main(String[] args) {
+        DBVal dbval = new DBVal("id", 1673305030, (double)11.0, 11, (double)12.0,
+                (double)13.0, (double)14.0);
+        DBApiEntry dbApiEntry = new DBApiEntry(Globals.URL, Globals.DATABASE, Globals.COLLECTIONNAME);
+        dbApiEntry.insertRecord(dbval);
+    }
+}

+ 21 - 0
mongodb/src/main/java/demo/QueryByMultiDriverId.java

@@ -0,0 +1,21 @@
+package demo;
+
+import db.DBApiEntry;
+import db.DBVal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class QueryByMultiDriverId {
+    public static void main(String[] args) {
+        List<String> driverIdList = new ArrayList<>();
+        driverIdList.add("id19");
+        driverIdList.add("id20");
+
+        DBApiEntry dbApiEntry = new DBApiEntry(Globals.URL, Globals.DATABASE, Globals.COLLECTIONNAME);
+        List<DBVal> dbValList1 = dbApiEntry.queryByMultiDriverId(driverIdList);
+        for(DBVal dbval1 : dbValList1) {
+            System.out.println(dbval1.toString());
+        }
+    }
+}

+ 16 - 0
mongodb/src/main/java/demo/QueryBySingleDriverId.java

@@ -0,0 +1,16 @@
+package demo;
+
+import db.DBApiEntry;
+import db.DBVal;
+
+import java.util.List;
+
+public class QueryBySingleDriverId {
+    public static void main(String[] args) {
+        DBApiEntry dbApiEntry = new DBApiEntry(Globals.URL, Globals.DATABASE, Globals.COLLECTIONNAME);
+        List<DBVal> dbValList1 = dbApiEntry.queryBySingleDriverId("id19");
+        for(DBVal dbval1 : dbValList1) {
+            System.out.println(dbval1.toString());
+        }
+    }
+}

+ 18 - 0
mongodb/src/main/java/log/LogConfig.java

@@ -0,0 +1,18 @@
+package log;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.logging.LogManager;
+
+public class LogConfig {
+    public static void init() {
+        try {
+            InputStream in = new FileInputStream(new File("./conf/mongodb/log.properties"));
+            LogManager.getLogManager().readConfiguration(in);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+}

+ 83 - 0
mongodb/src/main/java/util/ParseDataFormat.java

@@ -0,0 +1,83 @@
+package util;
+
+import db.DBVal;
+import db.FieldName;
+import db.Util;
+import org.bson.Document;
+import org.bson.types.ObjectId;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ParseDataFormat {
+    /**
+     * @description DBVal对象转为Document对象
+     * @param dbval
+     * @return Document
+     * @dateTime 2023/1/10 20:29
+     */
+    public static Document dbvalToDocument(DBVal dbval) throws ParseException {
+        Document document = new Document("_id", new ObjectId())
+                .append(FieldName._CLASS.getValue(), dbval.get_class())
+                .append(FieldName.CREATETIME.getValue(),
+                        Util.uTCSecondsToDateString(dbval.getUtcTime()))
+                .append(FieldName.DIRECTION.getValue(), dbval.getDirection())
+                .append(FieldName.DRIVERID.getValue(), dbval.getDriverId())
+                .append(FieldName.ELEVATION.getValue(), dbval.getElevation())
+                .append(FieldName.LAT.getValue(), dbval.getLat())
+                .append(FieldName.LNG.getValue(), dbval.getLng())
+                .append(FieldName.SPEED.getValue(), dbval.getSpeed());
+        return document;
+    }
+
+    /**
+     * @description 多个DBVal对象转为Document对象
+     * @param dbvalList
+     * @return List<Document>
+     * @dateTime 2023/1/10 20:29
+     */
+    public static List<Document> dbvalsToDocuments(List<DBVal> dbvalList) throws ParseException {
+        List<Document> documentList = new ArrayList<>();
+        for(DBVal dbval : dbvalList) {
+            Document document = new Document("_id", new ObjectId())
+                    .append(FieldName._CLASS.getValue(), dbval.get_class())
+                    .append(FieldName.CREATETIME.getValue(),
+                            Util.uTCSecondsToDateString(dbval.getUtcTime()))
+                    .append(FieldName.DIRECTION.getValue(), dbval.getDirection())
+                    .append(FieldName.DRIVERID.getValue(), dbval.getDriverId())
+                    .append(FieldName.ELEVATION.getValue(), dbval.getElevation())
+                    .append(FieldName.LAT.getValue(), dbval.getLat())
+                    .append(FieldName.LNG.getValue(), dbval.getLng())
+                    .append(FieldName.SPEED.getValue(), dbval.getSpeed());
+            documentList.add(document);
+        }
+        return documentList;
+    }
+
+    /**
+     * @description 将一系列Document对象转换为DBVal对象
+     * @param documentList
+     * @return java.util.List<db.DBVal>
+     * @dateTime 2023/1/11 11:20
+     */
+    public static List<DBVal> documentsToDBVals(List<Document> documentList) throws ParseException {
+        List<DBVal> dbValList = new ArrayList<>();
+        for(Document document : documentList) {
+            String _id = document.getObjectId("_id").toHexString();
+            String driverId = document.getString(FieldName.DRIVERID.getValue());
+            long utcTime = Util.dateStringToUTCSeconds(
+                    document.getString(FieldName.CREATETIME.getValue()));
+            double direction = document.getDouble(FieldName.DIRECTION.getValue());
+            int elevation = document.getInteger(FieldName.ELEVATION.getValue());
+            double lat = document.getDouble(FieldName.LAT.getValue());
+            double lng = document.getDouble(FieldName.LNG.getValue());
+            double speed = document.getDouble(FieldName.SPEED.getValue());
+
+            DBVal dbVal = new DBVal(_id, driverId, utcTime, direction, elevation,
+                    lat, lng, speed);
+            dbValList.add(dbVal);
+        }
+        return dbValList;
+    }
+}

+ 20 - 0
mongodb/src/test/java/giannischen/nuaa/edu/cn/AppTest.java

@@ -0,0 +1,20 @@
+package giannischen.nuaa.edu.cn;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+{
+    /**
+     * Rigorous Test :-)
+     */
+    @Test
+    public void shouldAnswerWithTrue()
+    {
+        assertTrue( true );
+    }
+}

+ 8 - 0
pom.xml

@@ -15,16 +15,19 @@
       <module>tsdb</module>
       <module>influxdb</module>
       <module>iotdb</module>
+      <module>mongodb</module>
   </modules>
 
   <properties>
     <maven.compiler.source>8</maven.compiler.source>
     <maven.compiler.target>8</maven.compiler.target>
     <java.version>1.8</java.version>
+
     <influxdb.version>0.0.1-SNAPSHOT</influxdb.version>
     <tsdb.version>0.0.1-SNAPSHOT</tsdb.version>
     <common.version>0.0.1-SNAPSHOT</common.version>
     <iotdb.version>0.0.1-SNAPSHOT</iotdb.version>
+    <mongodb.version>0.0.1-SNAPSHOT</mongodb.version>
 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
@@ -46,6 +49,11 @@
         <artifactId>iotdb</artifactId>
         <version>${iotdb.version}</version>
       </dependency>
+      <dependency>
+        <groupId>giannischen.nuaa.edu.cn</groupId>
+        <artifactId>mongodb</artifactId>
+        <version>${mongodb.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 

+ 3 - 3
shell/iotdb/lastData/querySinglePointLastData.sh

@@ -1,14 +1,14 @@
 #!/usr/bin/env bash
 # 该功能目前没用
 
-ROOT=$(cd `dirname $0`/../../; pwd)
+ROOT=$(cd `dirname $0`/../../../; pwd)
 cd $ROOT
 
 source $ROOT/shell/tsdb/common.sh
-
+host=39.104.80.229
 pointIndex=1
 storagePath="root.test1.wf01.wt01";
 echo "----test query point last data pointIndex:${pointIndex}"
 java -cp ./lib/iotdb.jar demo.query.last.QuerySinglePointLastData \
 --host $host --storagePath ${storagePath} --pointNamePrefix pointName1_ --pointIndex ${pointIndex} \
---showQueryResult 1 2>&1 | tee -a ./log/iotdb/out.log
+--showQueryResult 3 2>&1 | tee -a ./log/iotdb/out.log

+ 1 - 1
tsdb-benchmark.iml

@@ -6,7 +6,7 @@
     <content url="file://$MODULE_DIR$">
       <excludeFolder url="file://$MODULE_DIR$/target" />
     </content>
-    <orderEntry type="inheritedJdk" />
+    <orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
 </module>