|
@@ -4,12 +4,23 @@ package test;
|
|
|
import test.entity.Point;
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
//暂时先自己写connection从数据库中获取
|
|
|
|
|
|
public class GetPoints {
|
|
|
|
|
|
+ String userName = "nps_tc01";
|
|
|
+ String password = "nps_tc01";
|
|
|
+ String driver = "oracle.jdbc.driver.OracleDriver";
|
|
|
+ String url = "jdbc:oracle:thin:@172.16.2.114:1521:orcl1";
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<Point> realShapePoints = new ArrayList<>();
|
|
|
+ ArrayList<Point> allPoints = new ArrayList<>();
|
|
|
+
|
|
|
public ArrayList<Point> returnPoints(){
|
|
|
|
|
|
ArrayList<Point> pointList = new ArrayList<>();
|
|
@@ -18,17 +29,61 @@ public class GetPoints {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void getPoints(){
|
|
|
+ public void getPoints() throws SQLException {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String realShapeBeginTime = "2020-06-24 11:12:31.000000";
|
|
|
+ String realShapeEndTime = "2020-06-24 11:13:09.000000";
|
|
|
+
|
|
|
+ String allPointsBeginTime = "2020-06-24 11:12:31.000000";
|
|
|
+ String allPointsEndTime = "2020-06-24 11:13:09.000000";
|
|
|
+
|
|
|
+ String sql1 = "select GPS_LAT,GPS_LON from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + realShapeBeginTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + realShapeEndTime + "', 'yyyy-mm-dd hh24:mi:ss.ff')";
|
|
|
+ String sql2 = "select GPS_LAT,GPS_LON from T_LOC_APP_CLIENT_STATUS@DBLINKLOC WHERE CLIENT_RECORD_TIME between to_timestamp('" + allPointsBeginTime + "', 'yyyy-mm-dd hh24:mi:ss.ff') and to_timestamp('" + allPointsEndTime + "', 'yyyy-mm-dd hh24:mi:ss.ff')";
|
|
|
+
|
|
|
+ realShapePoints = buildPoints(sql1);
|
|
|
+ allPoints = buildPoints(sql2);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// Connection
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public ArrayList<Point> buildPoints(String sql) throws SQLException {
|
|
|
+
|
|
|
|
|
|
- String userName = "nps_tc01";
|
|
|
- String password = "nps_tc01";
|
|
|
- String driver = "oracle.jdbc.driver.OracleDriver";
|
|
|
- String url = "jdbc:oracle:thin:@jsdinghehui.com:10521:ORCL";
|
|
|
+ ArrayList<Point> pointArrayList = new ArrayList<>();
|
|
|
|
|
|
ConnectToSourceDB connectToSourceDB = new ConnectToSourceDB();
|
|
|
connectToSourceDB.setConnPara(userName,password,driver,url);
|
|
|
-// Connection
|
|
|
+ Connection connection = connectToSourceDB.getConnection();
|
|
|
+
|
|
|
+
|
|
|
+ DbOperate dbOperate = new DbOperate();
|
|
|
+
|
|
|
+ ResultSet resultSet = dbOperate.runQuerySql(connection,sql);
|
|
|
+
|
|
|
+ GpsExchange gpsExchange = new GpsExchange();
|
|
|
+
|
|
|
+ while (resultSet.next()){
|
|
|
+
|
|
|
+ Double lat = resultSet.getDouble(1);
|
|
|
+ Double lon = resultSet.getDouble(2);
|
|
|
+ Point point = gpsExchange.gpsToPoints(lat,lon);
|
|
|
+ pointArrayList.add(point);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return pointArrayList;
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|