Jelajahi Sumber

增加点获取

16s01 4 tahun lalu
induk
melakukan
a54d7d4d46
4 mengubah file dengan 154 tambahan dan 12 penghapusan
  1. 61 6
      src/test/GetPoints.java
  2. 26 0
      src/test/GpsExchange.java
  3. 44 6
      src/test/cal.java
  4. 23 0
      src/test/entity/GpsCor.java

+ 61 - 6
src/test/GetPoints.java

@@ -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;
+
 
     }
 
+
+
 }

+ 26 - 0
src/test/GpsExchange.java

@@ -0,0 +1,26 @@
+package test;
+
+//import test.entity.GpsCor;
+import test.entity.Point;
+
+public class GpsExchange {
+
+    public Point gpsToPoints(Double lat,Double lon){
+
+        Point point = new Point();
+
+        return point;
+
+
+    }
+
+
+//    public GpsCor pointsToGps(){
+//
+//        GpsCor gpsCor = new GpsCor();
+//
+//        return gpsCor;
+//
+//    }
+
+}

+ 44 - 6
src/test/cal.java

@@ -5,18 +5,21 @@ import test.entity.Point;
 import test.entity.WholeIndexOccupy;
 
 import java.lang.reflect.Array;
+import java.sql.SQLException;
 import java.util.ArrayList;
 
 public class cal {
 
-    ArrayList<OccupyPerX> occupyPerXArrayList = new ArrayList<>();
+    ArrayList<OccupyPerX> occupyPerXArrayList = new ArrayList<>();//占用情况
 
-    public void countNumber(){
+    public ArrayList<Point> countNumber() throws SQLException {
 
-        GetPoints getPointsRealShape = new GetPoints();
-        ArrayList<Point> realShapePoints = getPointsRealShape.returnPoints();//实际形状的平面坐标
-        GetPoints getPoints = new GetPoints();//所有待计算点
-        ArrayList<Point> allPoints = getPoints.returnPoints();//所有待计算点,铲车作业平面坐标
+        GetPoints getPoints = new GetPoints();
+        getPoints.getPoints();
+
+        ArrayList<Point> realShapePoints = getPoints.realShapePoints;//实际形状的平面坐标
+//        GetPoints getPoints = new GetPoints();//所有待计算点
+        ArrayList<Point> allPoints = getPoints.allPoints;//所有待计算点,铲车作业平面坐标
         Split split = new Split();
         split.cal(realShapePoints);
 
@@ -103,6 +106,41 @@ public class cal {
         }
 
 
+        ArrayList<Point> shape = new ArrayList<>();
+        for (int i = 0 ; i < occupyPerXArrayList.size();i++){
+
+            OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
+            Double xCor = minX + i * xGap + 0.5 * xGap;
+            Integer yIndex = occupyPerX.maxYIndex;
+            Double yCor = minY + i * yGap + 0.5 * yGap;
+            Point point = new Point();
+            point.setColX(xCor);
+            point.setColY(yCor);
+
+            shape.add(point);
+        }
+
+        for (int i = 0 ; i < occupyPerXArrayList.size();i++){
+
+            OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
+            Double xCor = minX + i * xGap + 0.5 * xGap;
+            Integer yIndex = occupyPerX.minYIndex;
+            Double yCor = minY + i * yGap + 0.5 * yGap;
+            Point point = new Point();
+            point.setColX(xCor);
+            point.setColY(yCor);
+
+            shape.add(point);
+        }
+
+        return shape;
+
+
+
+
+
+
+
 
 
 

+ 23 - 0
src/test/entity/GpsCor.java

@@ -0,0 +1,23 @@
+package test.entity;
+
+public class GpsCor {
+
+    public Double lat;
+    public Double lon;
+
+    public Double getLat() {
+        return lat;
+    }
+
+    public void setLat(Double lat) {
+        this.lat = lat;
+    }
+
+    public Double getLon() {
+        return lon;
+    }
+
+    public void setLon(Double lon) {
+        this.lon = lon;
+    }
+}