浏览代码

Merge branch 'master' of http://192.168.0.115:3000/4dkankan-v4/4dkankan-utils

lyhzzz 1 月之前
父节点
当前提交
10e93ec081
共有 18 个文件被更改,包括 227 次插入16 次删除
  1. 3 0
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/aliyun/AliyunOssTemplate.java
  2. 3 0
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/aws/AwsTemplate.java
  3. 3 0
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/cos/CosTemplate.java
  4. 3 0
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/minio/MinioTemplate.java
  5. 15 1
      4dkankan-utils-fyun-cos/src/main/java/com/fdkankan/fyun/oss/CosFileService.java
  6. 5 0
      4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/HttpFileService.java
  7. 12 0
      4dkankan-utils-fyun-local/src/main/java/com/fdkankan/fyun/local/LocalFileService.java
  8. 5 0
      4dkankan-utils-fyun-obs/src/main/java/com/fdkankan/fyun/oss/ObsFileService.java
  9. 13 0
      4dkankan-utils-fyun-oss/src/main/java/com/fdkankan/fyun/oss/OssFileService.java
  10. 5 0
      4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/AbstractFYunFileService.java
  11. 16 0
      4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/FYunFileServiceInterface.java
  12. 13 0
      4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/S3FileService.java
  13. 30 0
      4dkankan-utils-model/src/main/java/com/fdkankan/model/bean/SymbolBean.java
  14. 4 1
      4dkankan-utils-model/src/main/java/com/fdkankan/model/bean/WallBean.java
  15. 2 1
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateHouseJsonUtil.java
  16. 1 1
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateObjUtil.java
  17. 92 10
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/FloorPlanUserUtil.java
  18. 2 2
      4dkankan-utils-reg/src/main/java/com/fdkankan/reg/RegCodeUtil.java

+ 3 - 0
4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/aliyun/AliyunOssTemplate.java

@@ -339,6 +339,9 @@ public class AliyunOssTemplate implements FileStorageTemplate {
 
     @Override
     public boolean doesObjectExist(String bucket, String keyName) {
+        if("/".equals(keyName.substring(0,1))){
+            keyName = keyName.substring(1);
+        }
         boolean b = ossClient.doesObjectExist(bucket, keyName);
         log.info("文件是否存在={}", b);
         return b;

+ 3 - 0
4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/aws/AwsTemplate.java

@@ -378,6 +378,9 @@ public class AwsTemplate implements FileStorageTemplate {
     @Override
     public boolean doesObjectExist(String bucket, String keyName) {
         try {
+            if("/".equals(keyName.substring(0,1))){
+                keyName = keyName.substring(1);
+            }
             GetObjectRequest request  = new GetObjectRequest(bucket,keyName);
             S3Object object = amazonS3Client.getObject(request);
             return true;

+ 3 - 0
4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/cos/CosTemplate.java

@@ -349,6 +349,9 @@ public class CosTemplate implements FileStorageTemplate {
 
     @Override
     public boolean doesObjectExist(String bucket, String keyName) {
+        if("/".equals(keyName.substring(0,1))){
+            keyName = keyName.substring(1);
+        }
         boolean b = cosClient.doesObjectExist(bucket, keyName);
         log.info("文件是否存在={}", b);
         return b;

+ 3 - 0
4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/minio/MinioTemplate.java

@@ -355,6 +355,9 @@ public class MinioTemplate implements FileStorageTemplate {
 
     @Override
     public boolean doesObjectExist(String bucket, String keyName) {
+        if("/".equals(keyName.substring(0,1))){
+            keyName = keyName.substring(1);
+        }
         GetObjectArgs getArgs = GetObjectArgs.builder()
                 .bucket(bucket)
                 .object(keyName)

+ 15 - 1
4dkankan-utils-fyun-cos/src/main/java/com/fdkankan/fyun/oss/CosFileService.java

@@ -134,7 +134,7 @@ public class CosFileService extends AbstractFYunFileService {
     public void downloadFileByCommand(String bucket, String filePath, String remoteFilePath) {
         try {
             String optType = remoteFilePath.contains(".") ? "file" : "folder";
-            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.OSS.code(), optType);
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.COS.code(), optType);
             log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
             callshell(command);
             log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
@@ -144,6 +144,20 @@ public class CosFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+        try {
+            String optType = isDir ? "folder" : "file";
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.COS.code(), optType);
+            log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            callshell(command);
+            log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+        } catch (Exception e) {
+            log.error(String.format("下载文件失败, ossPath:%s, srcPath:%s", remoteFilePath, filePath), e);
+        }
+    }
+
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
             cosClient.deleteObject(bucket, remoteFilePath);

+ 5 - 0
4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/HttpFileService.java

@@ -142,6 +142,11 @@ public class HttpFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
             Map<String, Object> params = new HashMap<>();

+ 12 - 0
4dkankan-utils-fyun-local/src/main/java/com/fdkankan/fyun/local/LocalFileService.java

@@ -93,6 +93,18 @@ public class LocalFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+        try {
+            String optType = isDir ? "folder" : "file";
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.LOCAL.code(), optType);
+            log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            callshell(command);
+        } catch (Exception e) {
+            log.error("上传文件失败, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+        }
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         FileUtil.del(getOssPath(bucket, remoteFilePath));
     }

+ 5 - 0
4dkankan-utils-fyun-obs/src/main/java/com/fdkankan/fyun/oss/ObsFileService.java

@@ -63,6 +63,11 @@ public class ObsFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+
+    }
+
+    @Override
     public String uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) {
         try {
             File file = new File(filePath);

+ 13 - 0
4dkankan-utils-fyun-oss/src/main/java/com/fdkankan/fyun/oss/OssFileService.java

@@ -148,6 +148,19 @@ public class OssFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket,  String filePath, String remoteFilePath, boolean isDir) {
+        try {
+            String optType = isDir ? "folder" : "file";
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.OSS.code(), optType);
+            log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            callshell(command);
+            log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+        } catch (Exception e) {
+            log.error(String.format("下载文件失败, ossPath:%s, srcPath:%s", remoteFilePath, filePath), e);
+        }
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
             ossClient.deleteObject(bucket, remoteFilePath);

+ 5 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/AbstractFYunFileService.java

@@ -64,6 +64,11 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
     }
 
     @Override
+    public void downloadByCommand(String filePath, String remoteFilePath, boolean isDir) {
+        downloadByCommand(fYunFileConfig.getBucket(),filePath,remoteFilePath, isDir);
+    }
+
+    @Override
     public void deleteFile(String remoteFilePath) throws IOException {
         deleteFile(fYunFileConfig.getBucket(), remoteFilePath);
     }

+ 16 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/FYunFileServiceInterface.java

@@ -119,6 +119,22 @@ public interface FYunFileServiceInterface {
     void downloadFileByCommand(String filePath, String remoteFilePath) ;
 
     /**
+     * 通过本地脚本上传
+     *
+     * @param filePath
+     * @param remoteFilePath
+     */
+    void downloadByCommand(String filePath, String remoteFilePath, boolean isDir) ;
+
+    /**
+     * 通过本地脚本上传
+     *
+     * @param filePath
+     * @param remoteFilePath
+     */
+    void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) ;
+
+    /**
      * 通过本地脚本上传至系统默认bucket
      *
      * @param filePath

+ 13 - 0
4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/S3FileService.java

@@ -144,6 +144,19 @@ public class S3FileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+        try {
+            String optType = isDir ? "folder" : "file";
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.AWS.code(), optType);
+            log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            callshell(command);
+        } catch (Exception e) {
+            log.error("上传文件失败, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            e.printStackTrace();
+        }
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath){
         if (remoteFilePath.startsWith("/")) {
             remoteFilePath = remoteFilePath.substring(1);

+ 30 - 0
4dkankan-utils-model/src/main/java/com/fdkankan/model/bean/SymbolBean.java

@@ -0,0 +1,30 @@
+package com.fdkankan.model.bean;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
+public class SymbolBean implements Serializable {
+
+    private JSONObject endPoint;
+    private JSONObject startPoint;
+    private String parent;
+    private Double len;
+
+    //算法给不出是什么类型的门窗,目前暂定为SingleDoor、SingleWindow
+    private String geoType;
+    //单开门\单开窗
+    private String name;
+    private String vectorId;
+    //门固定为LEFT,窗固定为RIGHT
+    private String openSide;
+
+}

+ 4 - 1
4dkankan-utils-model/src/main/java/com/fdkankan/model/bean/WallBean.java

@@ -1,6 +1,9 @@
 package com.fdkankan.model.bean;
 
 import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -25,7 +28,7 @@ public class WallBean implements Serializable {
     private String vectorId;
     private String start;
     private String end;
-    private String[] children;
+    private Set<String> children;
     private Double width;
 
     private String geoType;

+ 2 - 1
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateHouseJsonUtil.java

@@ -15,6 +15,7 @@ import com.fdkankan.model.bean.WallBean;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 
 public class CreateHouseJsonUtil {
@@ -136,7 +137,7 @@ public class CreateHouseJsonUtil {
 						.vectorId(wallId)
 						.start(segmentBean.getStartPointId())
 						.end(segmentBean.getEndPointId())
-						.children(new String[]{})
+						.children(new HashSet<>())
 						.width(0.2d)
 						.build();
 				wallMap.put(wallId, wallBean);

+ 1 - 1
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateObjUtil.java

@@ -355,7 +355,7 @@ public class CreateObjUtil {
 //		convertVisionmodeldataToTxt("D:\\test\\test\\vision.modeldata", "D:\\test\\test\\vision.txt");
 //		FileUtil.del("D:\\test\\test");
 
-		convertTxtToVisionmodeldata("D:\\test\\vision.txt", "D:\\test\\vision.modeldata");
+		convertTxtToVisionmodeldata("D:\\test\\vision(7).txt", "D:\\test\\vision.modeldata");
 
 	}
 

+ 92 - 10
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/FloorPlanUserUtil.java

@@ -7,21 +7,18 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.model.bean.PointBean;
-import com.fdkankan.model.bean.SegmentBean;
-import com.fdkankan.model.bean.VertexBean;
-import com.fdkankan.model.bean.WallBean;
+import com.fdkankan.model.bean.*;
 
+import java.awt.geom.Point2D;
 import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 public class FloorPlanUserUtil {
 
 	public static void main(String[] args) {
-		JSONObject floorPlanUserJson = FloorPlanUserUtil.createFloorPlanUserJson("D:\\Downloads\\floorplan_cad.json");
-		FileUtil.writeUtf8String(floorPlanUserJson.toJSONString(), "D:\\Downloads\\floorplan.json");
+		JSONObject floorPlanUserJson = FloorPlanUserUtil.createFloorPlanUserJson("D:\\Downloads\\floorplan_cad(3).json");
+		FileUtil.writeUtf8String(floorPlanUserJson.toJSONString(), "D:\\Downloads\\demo.json");
 
 	}
 
@@ -53,10 +50,12 @@ public class FloorPlanUserUtil {
 			Map<String, Object> result = createFloorHandler(floor, currentId);
 			JSONArray points = (JSONArray)result.get("pointArr");
 			JSONArray walls = (JSONArray)result.get("wallArr");
+			JSONArray symbols = (JSONArray)result.get("symbols");
 			currentId = (int)result.get("currentId");
 			JSONObject targetFloor = new JSONObject();
 			targetFloor.put("points", convertArrToMap(points));
 			targetFloor.put("walls", convertArrToMap(walls));
+			targetFloor.put("symbols", convertArrToMap(symbols));
 			targetFloor.put("id", floor.getInteger("id"));
 			targetFloor.put("name",floor.getString("name"));
 			targetFloor.put("subgroup", floor.getInteger("subgroup"));
@@ -68,6 +67,7 @@ public class FloorPlanUserUtil {
 		return house;
 	}
 
+
 	private static Map<String, JSONObject> convertArrToMap(JSONArray arr){
 		Map<String, JSONObject> result = new HashMap<>();
 		if(CollUtil.isEmpty(arr)){
@@ -133,7 +133,7 @@ public class FloorPlanUserUtil {
 						.vectorId(wallId)
 						.start(segmentBean.getStartPointId())
 						.end(segmentBean.getEndPointId())
-						.children(new String[]{})
+						.children(new HashSet<>())
 						.width(0.2d)
 						.build();
 				wallMap.put(wallId, wallBean);
@@ -146,6 +146,82 @@ public class FloorPlanUserUtil {
 			}
 		}
 
+		//处理门窗
+		Map<String, SymbolBean> symbolMap = new HashMap<>();
+		JSONArray shapesArr = floor.getJSONArray("shapes");
+		if(CollUtil.isNotEmpty(shapesArr)){
+			List<JSONObject> windowAndDoors = shapesArr.stream().filter(v->{
+				JSONObject obj = (JSONObject) v;
+				String category = obj.getString("category");
+				if(StrUtil.isNotEmpty(category) && (category.contains("Window") || category.contains("Door"))){
+					return true;
+				}
+				return false;
+			}).map(v->(JSONObject)v).collect(Collectors.toList());
+			if(CollUtil.isNotEmpty(windowAndDoors)){
+				for (int i = 0; i < windowAndDoors.size(); i++){
+
+					JSONObject jsonObject = windowAndDoors.get(i);
+					String category = jsonObject.getString("category");
+					String geoType = null;
+					String name = null;
+					String openSide = null;
+					if(category.contains("Window")){
+						geoType = category;
+						name = jsonObject.getString("name");
+						openSide = "RIGHT";
+					}
+					if(category.contains("Door")){
+						geoType = "SingleDoor";
+						name = "单开门";
+						openSide = "LEFT";
+					}
+
+					//vectorId
+					String symbolId = geoType + currentId;
+
+					JSONObject line = jsonObject.getJSONObject("line");
+					String openSideAi = line.getString("openSide");
+					if(StrUtil.isNotEmpty(openSideAi)){
+						if("L".equals(openSideAi)){
+							openSide = "LEFT";
+						}
+						if("R".equals(openSideAi)){
+							openSide = "RIGHT";
+						}
+					}
+					JSONObject point0 = line.getJSONObject("point_0");
+					Integer segmentId0 = point0.getInteger("segment_id");
+					point0.remove("segment_id");
+
+					JSONObject point1 = line.getJSONObject("point_1");
+					Integer segmentId1 = point1.getInteger("segment_id");
+					point1.remove("segment_id");
+
+					//求两点之间的距离
+					Point2D p0 = new Point2D.Double(point0.getDouble("x"), point0.getDouble("y"));
+					Point2D p1 = new Point2D.Double(point1.getDouble("x"), point1.getDouble("y"));
+					double distance = p0.distance(p1);
+
+					//设置墙的children
+					String wall0 = swMap.get(segmentId0);
+					String wall1 = swMap.get(segmentId1);
+					WallBean wallBean0 = wallMap.get(wall0);
+					wallBean0.getChildren().add(symbolId);
+					WallBean wallBean1 = wallMap.get(wall1);
+					wallBean1.getChildren().add(symbolId);
+
+					SymbolBean symbolBean = SymbolBean.builder().name(name).geoType(geoType)
+							.vectorId(symbolId).openSide(openSide).startPoint(point0).endPoint(point1).len(distance)
+							.parent(wall0).build();
+					symbolMap.put(symbolId, symbolBean);
+
+					++currentId;
+				}
+			}
+		}
+
+
 		Collection<PointBean> pointBeans = pointMap.values();
 		for (PointBean pointBean : pointBeans) {
 			Map<String, String> parent = new HashMap<>();
@@ -166,12 +242,18 @@ public class FloorPlanUserUtil {
 		JSONArray wallArr = JSON.parseArray(JSON.toJSONString(wallBeans));
 		result.put("wallArr", wallArr);
 
+		if(CollUtil.isNotEmpty(symbolMap)){
+			JSONArray symbolArr = JSON.parseArray(JSON.toJSONString(symbolMap.values()));
+			result.put("symbols", symbolArr);
+		}
+
 		result.put("currentId", currentId);
 
 		return result;
 
 	}
 
+
 	private static JSONArray readFloorJson(String filePath) {
 		try {
 			JSONObject floorplan = FileUtils.readJson(filePath);

文件差异内容过多而无法显示
+ 2 - 2
4dkankan-utils-reg/src/main/java/com/fdkankan/reg/RegCodeUtil.java