dengsixing 3 lat temu
rodzic
commit
e4f86ebcb2

+ 2 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ErrorCode.java

@@ -137,6 +137,7 @@ public enum ErrorCode {
     FAILURE_CODE_5058(5054, "该场景不存在,无法重置容量"),
     FAILURE_CODE_5059(5059, "该压缩包无可用obj或者mtl文件"),
     FAILURE_CODE_5060(5060, "obj文件名应为mesh.obj"),
+    FAILURE_CODE_5061(5061, "该压缩包无可用jpg文件"),
 
 
     FAILURE_CODE_7001(7001, "激光场景状态同步失败,请重试!"),
@@ -151,7 +152,7 @@ public enum ErrorCode {
     FAILURE_CODE_7010(7010, "相机或者相机详情不存在"),
     FAILURE_CODE_7011(7011, "公司信息不存在"),
     FAILURE_CODE_7012(7012, "上传的文件名错误"),
-    FAILURE_CODE_7013(7013, "上传模型失败"),
+    FAILURE_CODE_7013(7013, "上传失败"),
     FAILURE_CODE_7014(7014, "压缩包中文件不能为空"),
     FAILURE_CODE_7015(7015, "仅支持.zip文件上传"),
     FAILURE_CODE_7016(7016, "仅支持.mp4格式文件"),

+ 87 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ImageUtil.java

@@ -0,0 +1,87 @@
+package com.fdkankan.common.constant;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/8
+ **/
+public class ImageUtil {
+
+    public static final String TYPE_JPG = "jpg";
+    public static final String TYPE_GIF = "gif";
+    public static final String TYPE_PNG = "png";
+    public static final String TYPE_BMP = "bmp";
+    public static final String TYPE_UNKNOWN = "unknown";
+
+    public static boolean isImage(FileInputStream fis){
+        String picType = getPicType(fis);
+        if(TYPE_JPG.equals(picType)
+            || TYPE_GIF.equals(picType)
+            || TYPE_PNG.equals(picType)
+            || TYPE_BMP.equals(picType)){
+            return true;
+        }
+        return false;
+    }
+
+    public static String getPicType(FileInputStream fis) {
+        // 读取文件的前几个字节来判断图片格式
+        byte[] b = new byte[4];
+        try {
+            fis.read(b, 0, b.length);
+            String type = bytesToHexString(b).toUpperCase();
+            if (type.contains("FFD8FF")) {
+                return TYPE_JPG;
+            } else if (type.contains("89504E47")) {
+                return TYPE_PNG;
+            } else if (type.contains("47494638")) {
+                return TYPE_GIF;
+            } else if (type.contains("424D")) {
+                return TYPE_BMP;
+            } else {
+                return TYPE_UNKNOWN;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (fis != null) {
+                try {
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return null;
+    }
+
+    public static String bytesToHexString(byte[] src) {
+        StringBuilder stringBuilder = new StringBuilder();
+        if (src == null || src.length <= 0) {
+            return null;
+        }
+        for (int i = 0; i < src.length; i++) {
+            int v = src[i] & 0xFF;
+            String hv = Integer.toHexString(v);
+            if (hv.length() < 2) {
+                stringBuilder.append(0);
+            }
+            stringBuilder.append(hv);
+        }
+        return stringBuilder.toString();
+    }
+
+    public static void main(String[] args) throws Exception{
+        FileInputStream fis = new FileInputStream(new File("F:\\test\\1.png"));
+        boolean image = ImageUtil.isImage(fis);
+        System.out.println(image);
+    }
+
+}

+ 39 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ModelingBuildStatus.java

@@ -0,0 +1,39 @@
+package com.fdkankan.common.constant;
+
+public enum ModelingBuildStatus {
+    OTHER(-10,"其他原因失败"),
+    REPEAT(-3,"重复计算"),
+    FAILED(-2,"计算失败"),
+    OVERTIME(-1,"计算超时"),
+    CALCULATING(0,"计算中"),
+    SUCCESS(1,"计算成功");
+
+    private Integer code;
+    private String message;
+
+    ModelingBuildStatus(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public Integer code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+    public static ModelingBuildStatus get(Integer code){
+        ModelingBuildStatus[] values = ModelingBuildStatus.values();
+        Integer enumValue = null;
+        for(ModelingBuildStatus eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+}

+ 1 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ServerCode.java

@@ -7,6 +7,7 @@ public enum ServerCode {
 	PARAM_ERROR(-2, "解析请求参数出错"),
 	PARAM_REQUIRED(-3, "缺少必要参数:%s"),
 	FEIGN_REQUEST_FAILD(-4, "跨服务请求失败"),
+	SERVER_CLOSING(-5, "服务正在关闭!"),
 
 	AUTH_FAIL(3000, "鉴权失败!"),
 	NON_TOKEN(3001, "无token,请重新登录"),

+ 5 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/UploadFilePath.java

@@ -44,5 +44,10 @@ public class UploadFilePath {
 
     public static final String DOWNLOADS_QRCODE = "downloads/scene/%s/QRcode/";
 
+    /**
+     * 场景计算日志文件地址
+     */
+    public static final String BUILD_LOG_PATH = "build_log/%s/";
+
 
 }

+ 54 - 4
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateObjUtil.java

@@ -1,5 +1,6 @@
 package com.fdkankan.common.util;
 
+import cn.hutool.core.exceptions.ExceptionUtil;
 import com.fdkankan.common.constant.ConstantFileName;
 import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.proto.BigSceneProto;
@@ -7,6 +8,16 @@ import com.fdkankan.common.proto.Common;
 import com.fdkankan.common.proto.Visionmodeldata;
 import com.fdkankan.common.proto.format.JsonFormat;
 import com.google.protobuf.TextFormat;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.StopWatch;
@@ -15,9 +26,10 @@ import java.io.*;
 import java.util.HashMap;
 import java.util.Map;
 
+@Slf4j
 public class CreateObjUtil {
 
-	private static Logger log = LoggerFactory.getLogger(CreateObjUtil.class);
+//	private static Logger log = LoggerFactory.getLogger(CreateObjUtil.class);
 
 	public void saveuploadImgs(String folderName) throws IOException, Exception
 	{
@@ -310,8 +322,8 @@ public class CreateObjUtil {
 		catch(Exception e)
 		{
 			StringWriter trace=new StringWriter();
-	        e.printStackTrace(new PrintWriter(trace));
-	        log.error(trace.toString());
+			e.printStackTrace(new PrintWriter(trace));
+			log.error(trace.toString());
 		}
 	}
 
@@ -601,8 +613,46 @@ public class CreateObjUtil {
 	}
 
 	public static void main(String[] args) throws Exception{
-		CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\KJ-44g3CBuvof(1).txt", "F:\\visiontest\\vision.modeldata");
+//		CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\KJ-HXMNTDYs1E.txt", "F:\\visiontest\\vision.modeldata");
 //		CreateObjUtil.convertTxtToDam("F:\\visiontest\\modeldata.txt", "F:\\visiontest\\dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
+
+//		String text = "web:web";
+//		byte[] data = text.getBytes("UTF-8");
+//		String s = Base64.getEncoder().encodeToString(data);
+//		System.out.println(s);
+
+//		org.apache.commons.lang3.time.StopWatch stopWatch = new org.apache.commons.lang3.time.StopWatch();
+//		stopWatch.start();
+//		Thread.sleep(2000);
+//		stopWatch.stop();
+//		System.out.println(stopWatch.getTime(TimeUnit.SECONDS));
+		ExecutorService executorService = Executors.newFixedThreadPool(1);
+		Future<String> future = executorService.submit(()->{
+			return CreateObjUtil.test();
+		});
+
+		try {
+			String s = future.get();
+		}catch (Exception e){
+
+			System.out.println(ExceptionUtil.stacktraceToString(e));
+		}
+
+
+
+	}
+
+	private static String test() throws Exception{
+		try {
+			String test = null;
+			test.equals("123");
+		}catch (Exception e){
+			throw e;
+		}finally {
+
+		}
+		return "123";
+
 	}
 
 }

+ 9 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/StrExtUtil.java

@@ -44,7 +44,15 @@ public class StrExtUtil extends StrUtil {
     }
 
     public static void main(String[] args) {
-        StrExtUtil.test();
+
+        String test = null;
+//        System.out.println(test.lastIndexOf("."));
+//        System.out.println(test.substring(test.lastIndexOf(".")));
+
+        System.out.println("123".equals(test));;
+
+
+
     }
 
 }

+ 1 - 1
4dkankan-utils-redis/src/main/java/com/fdkankan/redis/constant/RedisKey.java

@@ -61,7 +61,7 @@ public class RedisKey {
     public static String FDKANKAN_SCENE_NUMS = "4dkankan:scene:nums";
 
 
-    public static final String SCENE_BUILDING = SYSTEM_PREFIX+":scene:building:";
+    public static final String SCENE_BUILDING = SYSTEM_PREFIX+":scene:building:%s";
 
     /**
      * 场景下载进度