瀏覽代碼

小地图上传oss

wuweihao 4 年之前
父節點
當前提交
46d8e922c8
共有 29 個文件被更改,包括 781 次插入204 次删除
  1. 5 0
      README.md
  2. 5 1
      laser/pom.xml
  3. 0 20
      laser/src/main/java/com/fdkankan/indoor/base/config/TransactionConfig.java
  4. 13 0
      laser/src/main/java/com/fdkankan/indoor/base/constant/TypeConstant.java
  5. 192 0
      laser/src/main/java/com/fdkankan/indoor/base/convert/FixRouteMap.java
  6. 1 76
      laser/src/main/java/com/fdkankan/indoor/base/convert/GetRoute.java
  7. 50 17
      laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateUtil.java
  8. 8 0
      laser/src/main/java/com/fdkankan/indoor/base/util/CmdUtils.java
  9. 6 6
      laser/src/main/java/com/fdkankan/indoor/core/controller/MapController.java
  10. 1 0
      laser/src/main/java/com/fdkankan/indoor/core/controller/MapSmallController.java
  11. 14 0
      laser/src/main/java/com/fdkankan/indoor/core/controller/TestController.java
  12. 44 0
      laser/src/main/java/com/fdkankan/indoor/core/controller/TiledMapController.java
  13. 21 0
      laser/src/main/java/com/fdkankan/indoor/core/entity/TiledMapEntity.java
  14. 4 2
      laser/src/main/java/com/fdkankan/indoor/core/entity/dto/SceneAgePageDto.java
  15. 20 0
      laser/src/main/java/com/fdkankan/indoor/core/entity/dto/TiledEditDto.java
  16. 56 0
      laser/src/main/java/com/fdkankan/indoor/core/entity/dto/TiledMapDto.java
  17. 14 0
      laser/src/main/java/com/fdkankan/indoor/core/mapper/TiledMapMapper.java
  18. 2 0
      laser/src/main/java/com/fdkankan/indoor/core/service/RouteService.java
  19. 25 0
      laser/src/main/java/com/fdkankan/indoor/core/service/TiledMapService.java
  20. 73 1
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/DataSetServiceImpl.java
  21. 14 0
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/IBaseServiceImpl.java
  22. 17 38
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java
  23. 19 15
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/MapSmallServiceImpl.java
  24. 2 1
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/RouteServiceImpl.java
  25. 26 23
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/SceneServiceImpl.java
  26. 11 4
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/SiteServiceImpl.java
  27. 102 0
      laser/src/main/java/com/fdkankan/indoor/core/service/impl/TiledMapServiceImpl.java
  28. 19 0
      laser/src/main/resources/application-dev.properties
  29. 17 0
      laser/src/main/resources/application-sit.properties

+ 5 - 0
README.md

@@ -114,4 +114,9 @@ t-p307mDm
 
 # doc
  sit: http://test.4dkankan.com:9294/doc.html#/home
+
+
+# 登录体系
+   共用四维看看登录体系
+ 
              

+ 5 - 1
laser/pom.xml

@@ -194,7 +194,11 @@
 			<!--<version>${pagehelper.version}</version>-->
 		<!--</dependency>-->
 
-
+		<!--springboot中的redis依赖-->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-redis</artifactId>
+		</dependency>
 
 	</dependencies>
 

+ 0 - 20
laser/src/main/java/com/fdkankan/indoor/base/config/TransactionConfig.java

@@ -1,20 +0,0 @@
-//package com.fdkankan.indoor.base.config;
-//
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.data.mongodb.MongoDbFactory;
-//import org.springframework.data.mongodb.MongoTransactionManager;
-//
-///**
-// * Created by owen on 2021/7/29 0029 17:26
-// * mongodb 事务配置类
-// */
-//@Configuration
-//public class TransactionConfig {
-//
-//    @Bean
-//    MongoTransactionManager transactionManager(MongoDbFactory factory){
-//        return new MongoTransactionManager(factory);
-//    }
-//
-//}

+ 13 - 0
laser/src/main/java/com/fdkankan/indoor/base/constant/TypeConstant.java

@@ -20,6 +20,19 @@ public class TypeConstant {
     /**特殊点-第一点*/
     public final static String POI_FIRST_VIEW = "firstView";
 
+    /**四维看看token前缀*/
+    public final static String REDIS_PREFIX = "token#";
+
+    public final static String REDIS_INIT_PATH = "initPath_";
+
+    /**最优路径文件名*/
+    public final static String ROUTE_CSV = "final_freespace.csv";
+
+
+
+
+
+
 
 
 

+ 192 - 0
laser/src/main/java/com/fdkankan/indoor/base/convert/FixRouteMap.java

@@ -0,0 +1,192 @@
+package com.fdkankan.indoor.base.convert;
+
+import com.fdkankan.indoor.base.constant.MsgCode;
+import com.fdkankan.indoor.base.exception.BaseRuntimeException;
+import com.fdkankan.indoor.core.entity.ControlPointEntity;
+import lombok.extern.slf4j.Slf4j;
+import net.sf.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by owen on 2021/8/19 0019 15:26
+ * 修改数据包含:final_freespace.csv
+ */
+@Slf4j
+public class FixRouteMap {
+
+    private static double[] getTransfromMatrix(double orientation, JSONObject location)
+    {
+        double a1 = Math.cos(orientation);
+        double a2 = Math.sin(orientation);
+
+        double[] mat = new double[16];
+        mat[0] = a1;
+        mat[1] = a2;
+        mat[4] = -1*a2;
+        mat[5] = a1;
+        mat[10] = 1;
+        mat[12] = location.getDouble("x");
+        mat[13] = location.getDouble("y");
+        mat[14] = location.getDouble("z");
+        mat[15] = 1;
+        return mat;
+    }
+
+    private static double[] applyMatrix4(double[] position, double[] e ) {
+
+        double x = position[0];
+        double y = position[1];
+        double z = position[2];
+        double w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
+
+        position[0] = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
+        position[1] = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
+        position[2] = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
+
+        return position;
+
+    }
+
+    /**
+     * 更新route数据
+     * @param orientation dataSet.orientation
+     * @param gpsLocation dataSet.location
+     * @param controlPoint 对应场景码控制点
+     * @param path final_freespace.csv 文件目录路径
+     * @return
+     * @throws Exception
+     */
+    public static List<String> updateRouteMap(double orientation, double[] gpsLocation, ControlPointEntity controlPoint, String path) throws Exception {
+
+        // dataSet.location的gps坐标转本地坐标
+        double[] ageLocation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
+
+        // 新的本地坐标, 转出来应该是原点, 很接近0
+        JSONObject newLocation = new JSONObject();
+        newLocation.put("x", ageLocation[0]);
+        newLocation.put("y", ageLocation[1]);
+        newLocation.put("z", gpsLocation[2]);
+        log.info("newLocation: {}", newLocation );
+
+
+        double[] newMatrix = getTransfromMatrix(orientation, newLocation);
+
+
+        // 读取棋盘的坐标,读文件final_freespace.csv,不要读数据库,最初的坐标
+        String routePath = path + "/final_freespace.csv";
+        log.info("routePath: {}", routePath);
+        if (!cn.hutool.core.io.FileUtil.isFile(routePath)){
+            log.info("输入路径有误, path: {}", routePath);
+            throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
+        }
+        List<String> list = FileUtil.readFileByLines2(routePath);
+        log.info("数据读取成功");
+
+        // 修改棋盘每个顶点坐标,然后再入库
+        List<String> newRoute = new ArrayList<>();
+        for (String line : list) {
+            // 将每一行的坐标值获取处理进行修改
+            String[] split = line.split(" ");
+
+            double[] oldPoint = {Double.valueOf(split[0]), Double.valueOf(split[1]), Double.valueOf(split[2])};
+            double[] newPoint =  applyMatrix4(oldPoint,newMatrix);
+
+            // 重新组装每一行数据
+            String newLine = Arrays.asList(newPoint[0], newPoint[1], newPoint[2], split[3], split[4],
+                    split[5], split[6], split[7], split[8], split[9], split[10], split[11]).toString();
+            // 去逗号
+            newLine = newLine.replaceAll(",", "");
+            newLine = newLine.replace("[", "");
+            newLine = newLine.replace("]", "");
+            newRoute.add(newLine);
+        }
+        log.info("数据解析成功");
+        return newRoute;
+
+    }
+
+    /**
+     * 本地测试 修改 Route数据
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+//        FixRouteMap fixRouteMap = new FixRouteMap();
+
+        //对应的是datasets表里的orientation
+        double newOrientation = 0;
+
+        //需要转换,将gis坐标转换本地坐标
+        //将datasets表里location的坐标还原成本地坐标
+//        double[] gpsLocation = {113.595719800031, 22.3666054020125, 0.0};
+        double[] gpsLocation = {113.59571980003058, 22.36660540201251, 0};
+        // 将 gps 同 age
+
+        // 控制点
+        ControlPointEntity controlPoint = new ControlPointEntity();
+        double[] controlCoordinate1 = {113.595725873337,22.366579193007}; //gps坐标
+        double[] controlCoordinate2 = {113.595757230122,22.3666213677456};  //gps坐标
+
+        double[] controlLocation1 = {0.617759,-2.904041};  // 四维看看坐标
+        double[] controlLocation2 = {3.859914,1.75765}; // 四维看看坐标
+
+
+        controlPoint.setGpsControlCoordinate1(controlCoordinate1);
+        controlPoint.setGpsControlCoordinate2(controlCoordinate2);
+        controlPoint.setAgeControlLocation1(controlLocation1);
+        controlPoint.setAgeControlLocation2(controlLocation2);
+        double[] ageLocation = GisCoordinateUtil.convertGpsToLocation(gpsLocation, controlPoint);
+
+        // 新的本地坐标
+        JSONObject newLocation = new JSONObject();
+        newLocation.put("x", ageLocation[0]);
+        newLocation.put("y", ageLocation[1]);
+        newLocation.put("z", gpsLocation[2]);
+        log.info("ageLocation: {}", newLocation );
+
+
+
+        double[] newMatrix = getTransfromMatrix(newOrientation, newLocation);
+
+
+        // 读取棋盘的坐标,读文件final_freespace.csv,不要读数据库,最初的坐标
+
+        String path = "F:\\test\\project\\age_laser\\laserData";
+        String routePath = path + "/final_freespace.csv";
+        log.info("routePath: {}", routePath);
+        if (!cn.hutool.core.io.FileUtil.isFile(routePath)){
+            log.info("输入路径有误, path: {}", routePath);
+            throw new BaseRuntimeException(MsgCode.e3001, "final_freespace.csv路径有误,文件不存在");
+        }
+        List<String> list = FileUtil.readFileByLines2(routePath);
+
+        // 修改棋盘每个顶点坐标,然后再入库
+        List<String> newRoute = new ArrayList<>();
+        for (String line : list) {
+            // 将每一行的坐标值获取处理进行修改
+            String[] split = line.split(" ");
+
+            double[] oldPoint = {Double.valueOf(split[0]), Double.valueOf(split[1]), Double.valueOf(split[2])};
+            double[] newPoint =  applyMatrix4(oldPoint,newMatrix);  //修改棋盘每个顶点坐标,然后再入库
+
+            String newLine = Arrays.asList(newPoint[0], newPoint[1], newPoint[2], split[3], split[4],
+                    split[5], split[6], split[7], split[8], split[9], split[10], split[11]).toString();
+
+            // 去逗号
+            newLine = newLine.replaceAll(",", "");
+            newLine = newLine.replace("[", "");
+            newLine = newLine.replace("]", "");
+            System.out.println(newLine);
+            newRoute.add(newLine);
+        }
+
+        System.out.println("执行完成");
+
+
+//        double[] oldPoint = new double[3];     //
+//        double[] newPoint =  fixRouteMap.applyMatrix4(oldPoint,newMatrix);  //修改棋盘每个顶点坐标,然后再入库
+    }
+}

+ 1 - 76
laser/src/main/java/com/fdkankan/indoor/base/convert/GetRoute.java

@@ -92,82 +92,7 @@ public class GetRoute {
 		return null;
 	}
 
-//	private static JSONArray readMap(List<String> list, RouteInputDto dto) throws Exception {
-////    List<String> list = FileUtil.readFileByLines2(inputFilePath);
-//		JSONArray maps = new JSONArray();
-//
-//		Double startX = dto.getSource_longitude();
-//		Double startY = dto.getSource_latitude();
-//		Double startZ = dto.getSource_z();
-//
-//		Double endX = dto.getDestination_longitude();
-//		Double endY = dto.getDestination_latitude();
-//		Double endZ = dto.getDestination_z();
-//
-//
-//		Coord _start = new Coord(startX,startY,startZ);
-//		Coord _end = new Coord(endX,endY,endZ);
-//
-//		double startDistance=1.5;
-//		double endDistance = 1.5;
-//
-//		double minStartDistance = 1000.0;
-//		double minEndDistance = 1000.0;
-//
-//		for(int i=0;i<list.size();++i) {
-//			String str = list.get(i);
-//			String[] strArray = str.trim().split(" ");
-//			JSONObject item = new JSONObject();
-//			//item.put("id", i);
-//			item.put("x", strArray[0]);
-//			item.put("y", strArray[1]);
-//			item.put("z", strArray[2]);
-//			//item.put("weight", strArray[3]);
-//			item.put("weight", 1);
-//			String linkedIds = "";
-//			for(int j = 4;j<strArray.length;++j) {
-//				if(Integer.valueOf(strArray[j])>0) {
-//					linkedIds += strArray[j]+",";
-//				}
-//			}
-//
-//			item.put("linkedIds", linkedIds.substring(0, linkedIds.length()-1));
-//			maps.add(item);
-//
-//			Coord coord = new Coord(Double.valueOf(strArray[0]),Double.valueOf(strArray[1]),Double.valueOf(strArray[2]));
-//			//先找起点附近的点
-//			double _startDistance = g_AStar.calcH(_start, coord);
-//
-//
-//			if(_startDistance<startDistance) {
-//				//附近点里,离终点的距离最小的
-//				if(minStartDistance>g_AStar.calcH(_end, coord)){
-//					minStartId = i;
-//					minStartDistance = g_AStar.calcH(_end, coord);
-//				}
-//			}
-//			//先找终点附近的点
-//			double _endDistance = g_AStar.calcH(_end, coord);
-//			if(_endDistance<endDistance) {
-//				//附近点里,离起点的距离最小的
-//				if(minEndDistance>g_AStar.calcH(_start, coord)){
-//					minEndId = i;
-//					minEndDistance = g_AStar.calcH(_start, coord);
-//				}
-//			}
-//		}
-//
-//		JSONObject virtualStart = maps.getJSONObject(minStartId);
-//		JSONObject virtualEnd = maps.getJSONObject(minEndId);
-//		Coord startVirtualCoord = new Coord(virtualStart.getDouble("x"), virtualStart.getDouble("y"),virtualStart.getDouble("z"));
-//		Coord endVirtualCoord = new Coord(virtualEnd.getDouble("x"), virtualEnd.getDouble("y"),virtualEnd.getDouble("z"));
-//		Double startH = g_AStar.calcH(startVirtualCoord, endVirtualCoord);
-//
-//		start = new Node(minStartId,0.0,startVirtualCoord, null, 0.0, startH);
-//		end = new Node(minEndId,0.0,endVirtualCoord, null, 0.0, 0.0);
-//
-//		return maps;
-//	}
+
 
 	private static JSONArray readMap(List<String> list, RouteInputDto dto) throws Exception {
 //		List<String> list = FileUtil.readFileByLines2(inputFilePath);

+ 50 - 17
laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateUtil.java

@@ -3,6 +3,7 @@ package com.fdkankan.indoor.base.convert;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.indoor.base.convert.GisCoordinateTransform;
+import com.fdkankan.indoor.core.entity.ControlPointEntity;
 
 import java.io.*;
 
@@ -68,6 +69,7 @@ public class GisCoordinateUtil {
     }
 
     /**
+     * 控制点
      * 根据两个控制点计算增量及用于计算角度的两个向量
      * @param alon
      * @param alat
@@ -78,25 +80,8 @@ public class GisCoordinateUtil {
      * @param bX
      * @param bY
      */
-//    public  static  void calculateVariable (double alon,double alat,double aX,double aY,double blon,double blat,double bX,double bY){
-//       double[] a= GisCoordinateTransform.Convert2000BLToGauss(alon,alat);
-//       double[] b= GisCoordinateTransform.Convert2000BLToGauss(blon,blat);
-//       dx=a[0]-aX;
-//       dy=a[1]-aY;
-//        locationplaneVector=new double[2];
-//        locationplaneVector[0]=a[0]-b[0];
-//        locationplaneVector[1]=a[1]-b[1];
-//        geographicplaneVector=new double[2];
-//        geographicplaneVector[0]=aX-bX;
-//        geographicplaneVector[1]=aY-bY;
-//        centerLon=GisCoordinateTransform.getZone3CenterLon(alon);
-//    }
-
     public  static  void calculateVariable (double alon,double alat,double aX,double aY,double blon,double blat,double bX,double bY){
 
-//        double[] a= GisCoordinateTransform.convertByProj4(alon,alat, coordCode4326, coordCode3857);
-//        double[] b= GisCoordinateTransform.convertByProj4(blon,blat, coordCode4326, coordCode3857);
-
         double[] a= GisCoordinateTransform.convert2000BLToGauss(alon,alat);
         double[] b= GisCoordinateTransform.convert2000BLToGauss(blon,blat);
 
@@ -144,5 +129,53 @@ public class GisCoordinateUtil {
     }
 
 
+    /**
+     * 经纬度转本地坐标
+     * @param lon 经度 十进制度
+     * @param lat 纬度 十进制度
+     * @return
+     */
+    public static  double[] transformBLToLocation(double lon,double lat){
+
+
+        double[] gauss= GisCoordinateTransform.convert2000BLToGauss(lon,lat);
+        double x1=locationplaneVector[0];
+        double y1=locationplaneVector[1];
+        double x2=geographicplaneVector[0];
+        double y2=geographicplaneVector[1];
+        double a1=Math.atan2(y1,x1);
+        double a2=Math.atan2(y2,x2);
+//        double a=a1-a2;
+        double a=0;
+        double sinazimuth,cosazimuth;
+        cosazimuth=Math.cos(a);
+        sinazimuth=Math.sin(a);
+        double resultX=gauss[1]*sinazimuth+gauss[0]*cosazimuth;
+        double resultY=gauss[1]*cosazimuth-gauss[0]*sinazimuth;
+        double x=resultX-dx;
+        double y=resultY-dy;
+        double[] location=new double[2];
+        location[0]=x;
+        location[1]=y;
+        return location;
+    }
+
+
+    /**
+     * 经纬度转本地坐标
+     * @param position 经纬度
+     * @param dto 控制点
+     * @return
+     */
+    public static double[] convertGpsToLocation(double[] position, ControlPointEntity dto ) {
+        double[] controlLocation1 = dto.getAgeControlLocation1();
+        double[] controlLocation2 = dto.getAgeControlLocation2();
+
+        double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
+        double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
+        GisCoordinateUtil.calculateVariable (controlCoordinate1[0],controlCoordinate1[1],controlLocation1[0],controlLocation1[1],controlCoordinate2[0],controlCoordinate2[1],controlLocation2[0],controlLocation2[1]);
+        double[] d = GisCoordinateUtil.transformBLToLocation(position[0], position[1]);
+        return d;
+    }
 
 }

+ 8 - 0
laser/src/main/java/com/fdkankan/indoor/base/util/CmdUtils.java

@@ -121,4 +121,12 @@ public class CmdUtils {
         log.info("场景码目录:{} 上传完成, 耗时:{} s" , (end-start)/1000 );
     }
 
+    public static void ossDeleteDir(String cmd) {
+        log.info("ossCmd: " + cmd);
+        long start = System.currentTimeMillis();
+        CmdUtils.callLineSh(cmd);
+        long end = System.currentTimeMillis();
+        log.info("删除目录完成, 耗时:{} s" , (end-start)/1000 );
+
+    }
 }

+ 6 - 6
laser/src/main/java/com/fdkankan/indoor/core/controller/MapController.java

@@ -42,10 +42,10 @@ public class MapController {
     }
 
 
-    @ApiOperation(value = "获取小地图信息")
-    @GetMapping("indoor/{sceneCode}/api/tiled_maps")
-    public Object getTiledMap(@PathVariable String sceneCode){
-        Result result = entityMap.getTiledMap(sceneCode);
-        return result.getData();
-    }
+//    @ApiOperation(value = "获取小地图信息")
+//    @GetMapping("indoor/{sceneCode}/api/tiled_maps")
+//    public Object getTiledMap(@PathVariable String sceneCode){
+//        Result result = entityMap.getTiledMap(sceneCode);
+//        return result.getData();
+//    }
 }

+ 1 - 0
laser/src/main/java/com/fdkankan/indoor/core/controller/MapSmallController.java

@@ -29,6 +29,7 @@ public class MapSmallController {
     MapSmallService entityMap;
 
     /**
+     * 本地测试,需要注释上传oss
      * 多文件上传需要 @RequestParam 这个注解
      * @param sceneCode
      * @param file

+ 14 - 0
laser/src/main/java/com/fdkankan/indoor/core/controller/TestController.java

@@ -1,5 +1,6 @@
 package com.fdkankan.indoor.core.controller;
 
+import com.fdkankan.indoor.base.util.AliYunOssUtil;
 import com.fdkankan.indoor.base.util.CmdUtils;
 import com.fdkankan.indoor.base.util.Result;
 import com.fdkankan.indoor.base.util.SnowFlakeUUidUtils;
@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -40,6 +42,9 @@ public class TestController {
     @Autowired
     MeasurementService measurementService;
 
+    @Autowired
+    AliYunOssUtil aliYunOssUtil;
+
     @ApiOperation("修改数据")
     @PostMapping("edit/{sceneCode}")
     public Result edit(@PathVariable String sceneCode, @RequestBody List<HaoVo> param){
@@ -102,6 +107,15 @@ public class TestController {
 
     }
 
+    @ApiOperation(value = "oss-删除目录", notes = "path: oss目录")
+    @GetMapping("ossDeleteDir")
+    public Result ossDeleteDir(String path) throws IOException {
+//        CmdUtils.ossDeleteDir();
+        return Result.success();
+
+
+    }
+
     @ApiOperation("添加特殊点")
     @GetMapping("spec")
     public Result spec(){

+ 44 - 0
laser/src/main/java/com/fdkankan/indoor/core/controller/TiledMapController.java

@@ -0,0 +1,44 @@
+package com.fdkankan.indoor.core.controller;
+
+import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.dto.TiledEditDto;
+import com.fdkankan.indoor.core.service.TiledMapService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * Created by owen on 2021/8/20 0002 20:39
+ *
+ */
+@Api(tags = "地图-tiledMap")
+@RestController
+public class TiledMapController {
+
+    @Autowired
+    TiledMapService entityMap;
+
+    @ApiOperation(value = "获取全部")
+    @GetMapping("indoor/{sceneCode}/api/tiled_maps")
+    public Object findAllData(@PathVariable String sceneCode){
+        Result result = entityMap.findAll(sceneCode);
+        return result.getData();
+    }
+
+//    @WebControllerLog(description = "小地图初始")
+    @ApiOperation(value = "更新")
+    @PutMapping("indoor/{sceneCode}/api/tiled_maps")
+    public Result updateData(@PathVariable String sceneCode, TiledEditDto param){
+        return entityMap.updateData(sceneCode, param);
+    }
+
+//
+//    @ApiOperation(value = "获取小地图信息")
+//    @GetMapping("indoor/{sceneCode}/api/tiled_maps")
+//    public Object getTiledMap(@PathVariable String sceneCode){
+//        Result result = entityMap.getTiledMap(sceneCode);
+//        return result.getData();
+//    }
+}

+ 21 - 0
laser/src/main/java/com/fdkankan/indoor/core/entity/TiledMapEntity.java

@@ -0,0 +1,21 @@
+package com.fdkankan.indoor.core.entity;
+
+import com.fdkankan.indoor.core.entity.dto.TiledMapDto;
+import lombok.Data;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.List;
+
+/**
+ * Created by owen on 2021/8/20 0027 10:42
+ * 初始化的时候是空的
+ */
+@Document(collection = "t_tiled_map")
+@Data
+public class TiledMapEntity extends BaseEntity {
+
+
+    private List<TiledMapDto> data;
+
+
+}

+ 4 - 2
laser/src/main/java/com/fdkankan/indoor/core/entity/dto/SceneAgePageDto.java

@@ -11,10 +11,12 @@ import lombok.Data;
 public class SceneAgePageDto extends PageDto {
 
 
-//    @ApiModelProperty(value = "用户id", required = true)
-    @ApiModelProperty(value = "用户id")
+    @ApiModelProperty(value = "用户id", required = true)
     private Long userId;
 
+    @ApiModelProperty(value = "sn码")
+    private String snCode;
+
 
 
 

+ 20 - 0
laser/src/main/java/com/fdkankan/indoor/core/entity/dto/TiledEditDto.java

@@ -0,0 +1,20 @@
+package com.fdkankan.indoor.core.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2021/8/20 0020 14:12
+ */
+@Data
+public class TiledEditDto {
+
+    @ApiModelProperty(value = "对应缩放", required = true)
+    private Double map_size_m;
+
+    @ApiModelProperty(value = "坐标", required = true)
+    private Double[] location;
+
+    @ApiModelProperty(value = "角度", required = true)
+    private Double[] orientation;
+}

+ 56 - 0
laser/src/main/java/com/fdkankan/indoor/core/entity/dto/TiledMapDto.java

@@ -0,0 +1,56 @@
+package com.fdkankan.indoor.core.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2021/8/20 0020 11:41
+ */
+@Data
+public class TiledMapDto {
+    /*
+     "bundle_id": 3,
+             "file_path": "data/building_1/mapTest3",
+             "file_name": "$DEPTH/$X/$Y.png",
+             "floor_id": 11,
+             "id": 5,
+             "map_size_m": 123.84682999939342,
+             "max_depth": 3,
+             "quadtree": "fccf7fffcff3bf7f",
+             "location": [113.58819689242937,22.366342173244817,100.5987030136375425],
+             "orientation": [0.7071067811865476, 0, 0, 0.7071067811865475],
+             "tile_size_px": 256,
+             "type": "TILED_PYRAMID"
+
+    */
+
+    private Integer id;
+
+    private Integer bundle_id;
+
+    private String file_path;
+
+    private String file_name;
+
+    private Integer floor_id;
+
+    @ApiModelProperty(value = "对应缩放")
+    private Double map_size_m;
+
+    private Integer max_depth;
+
+    private String quadtree;
+
+    @ApiModelProperty(value = "坐标")
+    private Double[] location;
+
+    @ApiModelProperty(value = "角度")
+    private Double[] orientation;
+
+    private Integer tile_size_px;
+
+    private String type;
+
+
+
+}

+ 14 - 0
laser/src/main/java/com/fdkankan/indoor/core/mapper/TiledMapMapper.java

@@ -0,0 +1,14 @@
+package com.fdkankan.indoor.core.mapper;
+
+import com.fdkankan.indoor.core.entity.MapEntity;
+import com.fdkankan.indoor.core.entity.TiledMapEntity;
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by owen on 2021/7/27 0027 15:19
+ */
+@Component
+public interface TiledMapMapper extends MongoRepository<TiledMapEntity, String> {
+
+}

+ 2 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/RouteService.java

@@ -13,4 +13,6 @@ public interface RouteService {
     Result getRoute(String sceneCode, RouteInputDto param);
 
     void remove(String sceneCode);
+
+    RouteEntity findBySceneCode(String sceneCode);
 }

+ 25 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/TiledMapService.java

@@ -0,0 +1,25 @@
+package com.fdkankan.indoor.core.service;
+
+import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.dto.MapDto;
+import com.fdkankan.indoor.core.entity.dto.TiledEditDto;
+import com.fdkankan.indoor.core.entity.dto.TiledMapDto;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * Created by owen on 2021/7/28 0028 20:05
+ */
+public interface TiledMapService {
+
+
+
+    void init(String sceneCode);
+
+    void remove(String sceneCode);
+
+    Result findAll(String sceneCode);
+
+    Result updateData(String sceneCode, TiledEditDto param);
+}

+ 73 - 1
laser/src/main/java/com/fdkankan/indoor/core/service/impl/DataSetServiceImpl.java

@@ -1,15 +1,23 @@
 package com.fdkankan.indoor.core.service.impl;
 
 import com.fdkankan.indoor.base.constant.MsgCode;
+import com.fdkankan.indoor.base.constant.TypeConstant;
+import com.fdkankan.indoor.base.convert.FixRouteMap;
 import com.fdkankan.indoor.base.exception.BaseRuntimeException;
 import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.ControlPointEntity;
 import com.fdkankan.indoor.core.entity.DataSetEntity;
+import com.fdkankan.indoor.core.entity.InitEntity;
+import com.fdkankan.indoor.core.entity.RouteEntity;
 import com.fdkankan.indoor.core.entity.dto.FilterHotDto;
 import com.fdkankan.indoor.core.entity.dto.PoiHotDto;
 import com.fdkankan.indoor.core.entity.dto.SecurityDto;
 import com.fdkankan.indoor.core.entity.po.DataSetPo;
 import com.fdkankan.indoor.core.mapper.DataSetMapper;
+import com.fdkankan.indoor.core.service.ControlPointService;
 import com.fdkankan.indoor.core.service.DataSetService;
+import com.fdkankan.indoor.core.service.InitService;
+import com.fdkankan.indoor.core.service.RouteService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -19,6 +27,7 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -31,6 +40,17 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
     @Autowired
     DataSetMapper dataSetMapper;
 
+    @Autowired
+    InitService initService;
+
+    @Autowired
+    ControlPointService controlPointService;
+
+    @Autowired
+    RouteService routeService;
+
+
+
     @Override
     public void save(DataSetEntity entity) {
         dataSetMapper.save(entity);
@@ -69,6 +89,10 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
         }
 
         // 合并两个流, 处理id
+
+        int i = 1;
+        Double[] location = null;
+        Double orientation = null;
         for (DataSetPo dto : param) {
             if (dto.getId() == null) {
                 maxId ++;
@@ -76,7 +100,13 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
                 dto.setId(maxId);
             }
 
+            if (i == 1) {
+                location = dto.getLocation();
+                orientation = dto.getOrientation();
+            }
+
             data.add(dto);
+            i ++;
         }
 
         log.info("需要更新db数据量: {}", data.size());
@@ -85,8 +115,50 @@ public class DataSetServiceImpl extends IBaseServiceImpl implements DataSetServi
         entity.setUpdateTime(LocalDateTime.now());
         entity.setData(data);
         dataSetMapper.save(entity);
+        log.info("更新dataSet数据完成");
+
+        // 更新RouteMap并存入数据库
+        try {
+            fixRouteMap(location, orientation, sceneCode);
+            return Result.success(auth(sceneCode).getData());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+
+    private void fixRouteMap(Double[] location, Double orientation, String sceneCode) throws Exception {
+        String initKey = TypeConstant.REDIS_INIT_PATH + sceneCode;
+        log.info("initKey: {}", initKey);
+        String initPath = redisTemplate.opsForValue().get(initKey);
+        if (initPath == null) {
+            InitEntity initEntity = initService.findById(sceneCode);
+            if (initEntity == null) {
+                throw new BaseRuntimeException("init初始化数据不存: {}" +sceneCode);
+            }
+            initPath = initEntity.getPath();
+            redisTemplate.opsForValue().set(initKey, initPath, 24, TimeUnit.HOURS);
+        }
+
+        initPath = initPath + "/laserData";
+        log.info("initPath: {}", initPath);
+
+        ControlPointEntity controlPointEntity = controlPointService.findById(sceneCode);
+        if (controlPointEntity == null) {
+            throw new BaseRuntimeException("控制点数据不存: {}" +sceneCode);
+        }
+        log.info("有控制点");
+        double[] gpsLocation = {location[0], location[1], location[2]};
+        List<String> routeMap = FixRouteMap.updateRouteMap(orientation, gpsLocation, controlPointEntity, initPath);
+
+        RouteEntity routeEntity = routeService.findBySceneCode(sceneCode);
+        routeEntity.setData(routeMap);
+        routeEntity.setUpdateTime(LocalDateTime.now());
+        routeService.save(routeEntity);
+        log.info("更新Route数据完成");
 
-        return Result.success(auth(sceneCode).getData());
     }
 
     @Override

+ 14 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/impl/IBaseServiceImpl.java

@@ -1,10 +1,12 @@
 package com.fdkankan.indoor.core.service.impl;
 
 import com.fdkankan.indoor.base.constant.ConfigConstant;
+import com.fdkankan.indoor.base.constant.TypeConstant;
 import com.fdkankan.indoor.core.entity.dto.PageDto;
 import com.fdkankan.indoor.core.entity.dto.SecurityDto;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -20,6 +22,9 @@ public class IBaseServiceImpl {
     @Autowired
     ConfigConstant configConstant;
 
+    @Autowired
+    RedisTemplate<String, String> redisTemplate;
+
 
 
 
@@ -32,9 +37,18 @@ public class IBaseServiceImpl {
         String token = request.getHeader("X-Authorization");
         log.info("token: {}", token);
         if (token == null) {
+            log.warn("web header token is null");
             // 未登录
             return false;
         }
+        String tokenKey = TypeConstant.REDIS_PREFIX + token;
+        String redisToken = redisTemplate.opsForValue().get(tokenKey);
+        log.info("redisToken: {}", redisToken);
+//        if (redisToken == null) {
+//            log.error("redis token is null");
+//            return false;
+//        }
+
         return true;
 
     }

+ 17 - 38
laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java

@@ -84,6 +84,9 @@ public class InitServiceImpl implements InitService {
     @Autowired
     MeasurementService measurementService;
 
+    @Autowired
+    TiledMapService tiledMapService;
+
     /**
      * initDataStep1
      * 有顺序分,不能乱
@@ -101,7 +104,7 @@ public class InitServiceImpl implements InitService {
 
         String sceneCode = param.getSceneCode();
         if (StrUtil.isAllEmpty(sceneCode)) {
-            return Result.failure("场景码不能为空");
+            throw new BaseRuntimeException("场景码不能为空");
         }
 
         String path = param.getPath();
@@ -145,12 +148,12 @@ public class InitServiceImpl implements InitService {
         initRemove(sceneCode);
 
         // 路径在这里检测
-        if (StrUtil.isAllEmpty(path)) {
-            return Result.failure("路径不能为空");
+        if (StrUtil.isBlank(path)) {
+            throw new BaseRuntimeException("路径不能为空");
         }
 
-        if (StrUtil.isAllEmpty(title)) {
-            return Result.failure("标题不能为空");
+        if (StrUtil.isBlank(title)) {
+            throw new BaseRuntimeException("标题不能为空");
         }
 
 
@@ -179,6 +182,9 @@ public class InitServiceImpl implements InitService {
         // step9 创建 t_measurement表, 测量表,空数据
         createMeasurement(sceneCode);
 
+        // step 10 创建 t_tiled_map表, 空数据
+        tiledMapService.init(sceneCode);
+
         log.info("================== 初始化第一步完成 ==================");
 
         /**
@@ -204,29 +210,6 @@ public class InitServiceImpl implements InitService {
         recount = recount == null ? 1 : recount + 1;
         init.setRecount(recount);
 
-//        // 保存initDataStep1 状态
-//        if (init == null) {
-//             init = new InitEntity();
-//            init.setId(sceneCode);
-//            init.setPath(path);
-//            init.setCreateTime(LocalDateTime.now());
-//            init.setTitle(title);
-//            init.setChildName(param.getChildName());
-//            init.setSnCode(param.getSnCode());
-//            init.setShootTime(param.getCreateTime());
-//            // https://testlaser.4dkankan.com/maxkk/ + 场景码
-//            init.setWebSite(configConstant.webSitePath + sceneCode);
-//
-//        } else {
-//            init.setUpdateTime(LocalDateTime.now());
-//            init.setTitle(title);
-//            Integer recount = init.getRecount();
-//            recount = recount == null ? 1 : recount + 1;
-//            init.setRecount(recount);
-//        }
-
-
-
 
         if (flag){
             init.setStatus(1);
@@ -364,34 +347,25 @@ public class InitServiceImpl implements InitService {
     /**
      * 替换两个文件的c 换成场景码
      * index.html
-     * /locat/addDataSet.html
      * @param sceneCode
      * @param title
      */
     private void replaceHtml(String sceneCode, String title) {
         String indexName = "index.html";
-//        String addDataSetName = "addDataSet.html";
 
         String basePath = configConstant.serverBasePath + "/" + sceneCode + "/" ;
         String indexPath = basePath + indexName;
-//        String addDateSetPath = basePath + "locat/" + addDataSetName;
 
         String indexStr = cn.hutool.core.io.FileUtil.readUtf8String(indexPath);
-//        String dataSetStr = cn.hutool.core.io.FileUtil.readUtf8String(addDateSetPath);
         if (!indexStr.contains("@replace")) {
             throw new BaseRuntimeException(MsgCode.e3001, "index.html不包含默认值, 请查看default文件是否正确");
         }
 
-//        if (!dataSetStr.contains("@replace")) {
-//            throw new BaseRuntimeException(MsgCode.e3001, "addDataSet.html不包含默认值, 请查看default文件是否正确");
-//        }
 
         indexStr = indexStr.replaceAll("@replace", sceneCode);
         indexStr = indexStr.replaceAll("@title", title);
-//        dataSetStr = dataSetStr.replaceAll("@replace", sceneCode);
 
         cn.hutool.core.io.FileUtil.writeUtf8String(indexStr, indexPath);
-//        cn.hutool.core.io.FileUtil.writeUtf8String(dataSetStr, addDateSetPath);
         log.info("html文件替完成");
 
     }
@@ -499,6 +473,9 @@ public class InitServiceImpl implements InitService {
         specialPointService.remove(sceneCode);
         // 2021-08-12
         measurementService.remove(sceneCode);
+
+        // 2021-08-20
+        tiledMapService.remove(sceneCode);
         log.info("删除初始化数据完成");
 
     }
@@ -688,10 +665,12 @@ public class InitServiceImpl implements InitService {
 
         });
 
+        log.info("siteMode数据解析完成");
 //        log.info("更新后的siteModel值: {}", siteModels.toArray());
         SiteModelEntity modelEntity = siteService.findById(sceneCode);
         if (modelEntity != null) {
             siteService.remove(sceneCode);
+            log.info("删除旧siteModel数据完成");
         }
         SiteModelEntity entity = new SiteModelEntity();
         entity.setId(sceneCode);
@@ -871,7 +850,7 @@ public class InitServiceImpl implements InitService {
 
     /**
      * 最优路径算法-使用
-     * @param path F:\test\project\age_laser\routeMap.txt
+     * @param path F:\test\project\age_laser/final_freespace.csv
      */
     private void createRoute(String sceneCode, String path){
         List<String> list = new ArrayList<>();

+ 19 - 15
laser/src/main/java/com/fdkankan/indoor/core/service/impl/MapSmallServiceImpl.java

@@ -58,7 +58,6 @@ public class MapSmallServiceImpl extends IBaseServiceImpl implements MapSmallSer
             // 删除旧数据, 重新上传 , 目录结尾是否有斜杠,会影响删除效果
             log.info("删除目录:{}", basePath);
             FileUtil.del(basePath);
-//            FileUtil.del(new File(basePath));
         }
 
        basePath =  basePath + "/";
@@ -75,7 +74,6 @@ public class MapSmallServiceImpl extends IBaseServiceImpl implements MapSmallSer
                 }
                 log.info("文件名:{}", key );
                 MultipartFile file = entry.getValue();
-//                String originalFilename = file.getOriginalFilename();
                 String savePath = basePath + key;
                 saveFile(file, savePath);
 
@@ -84,14 +82,10 @@ public class MapSmallServiceImpl extends IBaseServiceImpl implements MapSmallSer
 
                 // step3: 把原图删除
                 log.info("删除原文件: {}", savePath);
-//                FileUtil.del(new File(savePath));
                 FileUtil.del(savePath);
 
-
                 // 获取小地图路径
                 path = tilePath(basePath, sceneCode);
-
-
             }
         } else {
             // 上传文件
@@ -106,9 +100,6 @@ public class MapSmallServiceImpl extends IBaseServiceImpl implements MapSmallSer
             }
         }
 
-
-
-
         log.info("小地图上传成功");
 
 
@@ -124,9 +115,28 @@ public class MapSmallServiceImpl extends IBaseServiceImpl implements MapSmallSer
         }
 
         entityMapper.save(entity);
+
+        // 上传oss
+        ossUploadDir(sceneCode, basePath);
+
         return Result.success(findById(sceneCode));
     }
 
+    /**
+     * 上传oss目录
+     * @param sceneCode
+     * @param uploadDir
+     */
+    private void ossUploadDir(String sceneCode, String uploadDir){
+        // /data/t-iksBApb/data/building_1/map/
+        String ossTarget = "data/" +sceneCode + "/data/building_1/map";
+        String cmd = CmdConstant.OSSUTIL_UPLOAD_DIR;
+        cmd = cmd.replaceAll("@uploadDir", uploadDir);
+        cmd = cmd.replaceAll("@target", ossTarget);
+        CmdUtils.ossUploadDir(cmd);
+        log.info("切图上传oss完成");
+    }
+
 
     /**
      * 递归获取剪切后图片地址
@@ -137,8 +147,6 @@ public class MapSmallServiceImpl extends IBaseServiceImpl implements MapSmallSer
             log.info("切图后的目录: {}", inPath);
             throw new BaseRuntimeException("目录为空");
         }
-
-
         return eachFile(inPath,sceneCode);
     }
 
@@ -234,10 +242,6 @@ public class MapSmallServiceImpl extends IBaseServiceImpl implements MapSmallSer
                 String filePath = every.getAbsolutePath();
                 // 需求截取成相对路径
                 filePath = StrUtil.subAfter(filePath, cutPath, true);
-//                if (filePath.contains("mapSmall" + File.separator + filterName)) {
-//                    log.info("filterName: {}", filePath);
-//                    continue;
-//                }
                 filePath = "/maxkk/"  + cutPath  + filePath;
                 path.add(filePath);
 

+ 2 - 1
laser/src/main/java/com/fdkankan/indoor/core/service/impl/RouteServiceImpl.java

@@ -124,7 +124,8 @@ public class RouteServiceImpl implements RouteService {
         entityMapper.deleteById(sceneCode);
     }
 
-    private RouteEntity findBySceneCode(String sceneCode){
+    @Override
+    public RouteEntity findBySceneCode(String sceneCode){
         Optional<RouteEntity> optional = entityMapper.findById(sceneCode);
         if (!optional.isPresent()) {
             throw new BaseRuntimeException(MsgCode.e3001, "Route对象不存在");

+ 26 - 23
laser/src/main/java/com/fdkankan/indoor/core/service/impl/SceneServiceImpl.java

@@ -38,21 +38,23 @@ public class SceneServiceImpl extends IBaseServiceImpl implements SceneService {
 
     @Override
     public Result list(SceneAgePageDto param) {
-        PageDto pageDto = new PageDto();
-        pageDto = startPage(pageDto);
-        param.setPageNum(pageDto.getPageNum());
-        param.setPageSize(pageDto.getPageSize());
+        Integer pageNum = param.getPageNum();
+        Integer pageSize = param.getPageSize();
+
+        pageNum = pageNum == null ? 0 : pageNum;
+        pageSize = pageSize == null ? 10 : pageSize;
 
         // 这里的"recordNo"是实体类的主键,记住一定要是实体类的属性,而不能是数据库的字段
         Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
         // (当前页, 每页记录数, 排序方式)
-        Pageable pageable = PageRequest.of(param.getPageNum() , param.getPageSize(), sort);
+        Pageable pageable = PageRequest.of(pageNum , pageSize, sort);
 
         // 查询条件
         InitEntity search = new InitEntity();
         search.setTitle(param.getSearchKey());
         // 必要的查询条件
         search.setUserId(param.getUserId());
+        search.setSnCode(param.getSnCode());
 
         // 模糊查询条件
         // 参考:https://blog.csdn.net/wonder_dog/article/details/82319216
@@ -60,6 +62,7 @@ public class SceneServiceImpl extends IBaseServiceImpl implements SceneService {
                 .withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)  // 改变默认字符串匹配方式:模糊查询
                 .withIgnoreCase(true) // 改变默认大小写忽略方式: 忽略大小写
                 .withMatcher("title", ExampleMatcher.GenericPropertyMatchers.contains()); // 采用包含匹配
+//                .withMatcher("snCode", ExampleMatcher.GenericPropertyMatchers.contains()); // 采用包含匹配
 
 
         Example<InitEntity> example = Example.of(search, matcher);
@@ -71,24 +74,24 @@ public class SceneServiceImpl extends IBaseServiceImpl implements SceneService {
 
         // 转换对象, 可以有简写,等习惯后再改, 使用箭头函数
         // 参考:https://www.136.la/shida/show-162572.html
-        Page<ResponseScene> map = all.map((new Function<InitEntity, ResponseScene>() {
-            @Override
-            public ResponseScene apply(InitEntity initEntity) {
-                ResponseScene scene = new ResponseScene();
-                scene.setNum(initEntity.getId());
-                scene.setWebSite(initEntity.getWebSite());
-                // 先用这个,到时要改成shootTime;
-                String createTime = DateUtil.format(initEntity.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
-                scene.setCreateTime(createTime);
-                scene.setSnCode(initEntity.getSnCode());
-                scene.setChildName(initEntity.getChildName());
-                scene.setSceneName(initEntity.getTitle());
-
-                return scene;
-            }
-        }));
-
-        return Result.success(map);
+//        Page<ResponseScene> map = all.map((new Function<InitEntity, ResponseScene>() {
+//            @Override
+//            public ResponseScene apply(InitEntity initEntity) {
+//                ResponseScene scene = new ResponseScene();
+//                scene.setNum(initEntity.getId());
+//                scene.setWebSite(initEntity.getWebSite());
+//                // 先用这个,到时要改成shootTime;
+//                String createTime = DateUtil.format(initEntity.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
+//                scene.setCreateTime(createTime);
+//                scene.setSnCode(initEntity.getSnCode());
+//                scene.setChildName(initEntity.getChildName());
+//                scene.setSceneName(initEntity.getTitle());
+//
+//                return scene;
+//            }
+//        }));
+
+        return Result.success(all);
     }
 
 

+ 11 - 4
laser/src/main/java/com/fdkankan/indoor/core/service/impl/SiteServiceImpl.java

@@ -410,13 +410,20 @@ public class SiteServiceImpl implements SiteService {
     }
 
 
+//    @Override
+//    public SiteModelEntity findById(String sceneCode){
+//        Optional<SiteModelEntity> optional = entityMapper.findById(sceneCode);
+//        if (!optional.isPresent()){
+//            throw new BaseRuntimeException("SiteModel数据不存在");
+//        }
+//        return optional.get();
+//    }
+
     @Override
     public SiteModelEntity findById(String sceneCode){
         Optional<SiteModelEntity> optional = entityMapper.findById(sceneCode);
-        if (!optional.isPresent()){
-            throw new BaseRuntimeException("SiteModel数据不存在");
-        }
-        return optional.get();
+
+        return optional.orElse(null);
     }
 
     private List<SiteDto> getDataBySceneCode(String sceneCode){

+ 102 - 0
laser/src/main/java/com/fdkankan/indoor/core/service/impl/TiledMapServiceImpl.java

@@ -0,0 +1,102 @@
+package com.fdkankan.indoor.core.service.impl;
+
+import com.fdkankan.indoor.base.exception.BaseRuntimeException;
+import com.fdkankan.indoor.base.util.Result;
+import com.fdkankan.indoor.core.entity.TiledMapEntity;
+import com.fdkankan.indoor.core.entity.dto.TiledEditDto;
+import com.fdkankan.indoor.core.entity.dto.TiledMapDto;
+import com.fdkankan.indoor.core.mapper.TiledMapMapper;
+import com.fdkankan.indoor.core.service.TiledMapService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Created by owen on 2021/7/28 0028 20:05
+ */
+@Service
+@Slf4j
+public class TiledMapServiceImpl extends IBaseServiceImpl implements TiledMapService {
+
+    @Autowired
+    TiledMapMapper entityMapper;
+
+
+    private TiledMapEntity findById(String sceneCode){
+        Optional<TiledMapEntity> optional = entityMapper.findById(sceneCode);
+        return optional.orElse(null);
+    }
+
+
+    private List<TiledMapDto> getDataBySceneCode(String sceneCode){
+        TiledMapEntity entity = findById(sceneCode);
+        if (entity != null) {
+            return entity.getData();
+        }
+        return null;
+    }
+
+    @Override
+    public void init(String sceneCode) {
+        TiledMapEntity entity = new TiledMapEntity();
+        entity.setId(sceneCode);
+        entity.setCreateTime(LocalDateTime.now());
+        entityMapper.save(entity);
+        log.info("TiledMap数据初始化完成");
+    }
+
+    @Override
+    public void remove(String sceneCode) {
+        entityMapper.deleteById(sceneCode);
+    }
+
+    @Override
+    public Result findAll(String sceneCode) {
+        return Result.success(getDataBySceneCode(sceneCode));
+    }
+
+    @Override
+    public Result updateData(String sceneCode, TiledEditDto param) {
+        TiledMapEntity entity = findById(sceneCode);
+        if (entity == null) {
+            throw new BaseRuntimeException("TiledMap数据不存在: " + sceneCode);
+        }
+        entity.setData(editData(param));
+        entity.setUpdateTime(LocalDateTime.now());
+        entityMapper.save(entity);
+        return Result.success();
+    }
+
+    /**
+     * 基本数据写死
+     * @param param
+     * @return
+     */
+    private List<TiledMapDto> editData(TiledEditDto param){
+        TiledMapDto dto = new TiledMapDto();
+        dto.setId(5);
+        dto.setBundle_id(3);
+        // 小地图oss路径
+
+        dto.setFile_path("data/building_1/map");
+        dto.setFile_name("$DEPTH/$X/$Y.png");
+        dto.setFloor_id(11);
+        dto.setMax_depth(3);
+        dto.setQuadtree("fccf7fffcff3bf7f");
+        dto.setType("TILED_PYRAMID");
+        dto.setTile_size_px(256);
+        dto.setMap_size_m(param.getMap_size_m());
+        dto.setLocation(param.getLocation());
+        dto.setOrientation(param.getOrientation());
+        List<TiledMapDto> list = new ArrayList<>();
+        list.add(dto);
+        return list;
+    }
+
+
+}

+ 19 - 0
laser/src/main/resources/application-dev.properties

@@ -2,6 +2,25 @@ spring.data.mongodb.uri=mongodb://120.25.146.52:27017/json_data
 spring.data.mongodb.username=4dage
 spring.data.mongodb.password=1234
 
+# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
+spring.redis.database=0
+#spring.redis.host=127.0.0.1
+spring.redis.host=120.25.146.52
+
+spring.redis.port=6379
+spring.redis.password=
+# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 \u5355\u4F4D ms\uFF08\u6BEB\u79D2\uFF09
+spring.redis.timeout=3000ms
+# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F8\u3002
+spring.redis.jedis.pool.max-idle=8
+#\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F0\u3002
+spring.redis.jedis.pool.min-idle=0
+# \u5982\u679C\u8D4B\u503C\u4E3A-1\uFF0C\u5219\u8868\u793A\u4E0D\u9650\u5236\uFF1B\u5982\u679Cpool\u5DF2\u7ECF\u5206\u914D\u4E86maxActive\u4E2Ajedis\u5B9E\u4F8B\uFF0C\u5219\u6B64\u65F6pool\u7684\u72B6\u6001\u4E3Aexhausted(\u8017\u5C3D)\u3002
+spring.redis.jedis.pool.max-active=8
+# \u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
+spring.redis.jedis.pool.max-wait=-1ms
+
+
 
 # \uFFFD\uFFFD\uFFFD\uFFFD\u0328sql\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\uFFFD
 logging.level.org.springframework.data.mongodb.core= DEBUG

+ 17 - 0
laser/src/main/resources/application-sit.properties

@@ -2,6 +2,23 @@ spring.data.mongodb.uri=mongodb://127.0.0.1:27017/json_data
 spring.data.mongodb.username=4dage
 spring.data.mongodb.password=1234
 
+
+# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
+spring.redis.database=0
+spring.redis.host=127.0.0.1
+spring.redis.port=6379
+spring.redis.password=
+# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 \u5355\u4F4D ms\uFF08\u6BEB\u79D2\uFF09
+spring.redis.timeout=3000ms
+# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F8\u3002
+spring.redis.jedis.pool.max-idle=8
+#\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u4E5F\u662F0\u3002
+spring.redis.jedis.pool.min-idle=0
+# \u5982\u679C\u8D4B\u503C\u4E3A-1\uFF0C\u5219\u8868\u793A\u4E0D\u9650\u5236\uFF1B\u5982\u679Cpool\u5DF2\u7ECF\u5206\u914D\u4E86maxActive\u4E2Ajedis\u5B9E\u4F8B\uFF0C\u5219\u6B64\u65F6pool\u7684\u72B6\u6001\u4E3Aexhausted(\u8017\u5C3D)\u3002
+spring.redis.jedis.pool.max-active=8
+# \u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
+spring.redis.jedis.pool.max-wait=-1ms
+
 # \uFFFD\uFFFD\uFFFD\uFFFD\u0328sql\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\uFFFD
 logging.level.org.springframework.data.mongodb.core= DEBUG