dengsixing 3 vuotta sitten
vanhempi
commit
0160f4f991

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

@@ -133,7 +133,10 @@ public enum ErrorCode {
     FAILURE_CODE_5054(5054, "该场景不存在无法扣除容量"),
     FAILURE_CODE_5055(5055, "该场景不属于八目相机无法扣除容量"),
     FAILURE_CODE_5056(5056, "双目相机异常"),
-    FAILURE_CODE_5057(5057, "该场景不属于八目相机,无法更改容量"),
+    FAILURE_CODE_5057(5057, "该场景不属于八目相机,无法重置容量"),
+    FAILURE_CODE_5058(5054, "该场景不存在,无法重置容量"),
+    FAILURE_CODE_5059(5059, "该压缩包无可用obj或者mtl文件"),
+    FAILURE_CODE_5060(5060, "obj文件名应为mesh.obj"),
 
 
     FAILURE_CODE_7001(7001, "激光场景状态同步失败,请重试!"),
@@ -147,6 +150,12 @@ public enum ErrorCode {
     FAILURE_CODE_7009(7009, "球幕视频文件不存在"),
     FAILURE_CODE_7010(7010, "相机或者相机详情不存在"),
     FAILURE_CODE_7011(7011, "公司信息不存在"),
+    FAILURE_CODE_7012(7012, "上传的文件名错误"),
+    FAILURE_CODE_7013(7013, "上传模型失败"),
+    FAILURE_CODE_7014(7014, "压缩包中文件不能为空"),
+    FAILURE_CODE_7015(7015, "仅支持.zip文件上传"),
+    FAILURE_CODE_7016(7016, "仅支持.mp4格式文件"),
+
 
 
 

+ 8 - 5
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ServerCode.java

@@ -5,7 +5,7 @@ public enum ServerCode {
 	SUCCESS(0, "操作成功"),
 	SYSTEM_ERROR(-1, "服务器异常"),
 	PARAM_ERROR(-2, "解析请求参数出错"),
-	PARAM_REQUIRED(-3, "缺少必要参数"),
+	PARAM_REQUIRED(-3, "缺少必要参数:%s"),
 	FEIGN_REQUEST_FAILD(-4, "跨服务请求失败"),
 
 	AUTH_FAIL(3000, "鉴权失败!"),
@@ -14,9 +14,8 @@ public enum ServerCode {
 	TOKEN_NOT_FOUND(3003, "用户未登录"),
 
 
-	APP_ID_ILLEGAL(3100 , "非法的APP ID")
-	;
-	
+	APP_ID_ILLEGAL(3100, "非法的APP ID");
+
 	private Integer code;
 	private String message;
 
@@ -32,4 +31,8 @@ public enum ServerCode {
 	public String message() {
 		return message;
 	}
-}
+
+	public String formatMessage(Object... args) {
+		return String.format(message, args);
+	}
+}

+ 9 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/exception/BusinessException.java

@@ -2,6 +2,7 @@ package com.fdkankan.common.exception;
 
 import com.fdkankan.common.constant.CameraConstant;
 import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
 import lombok.Data;
 
 /**
@@ -16,6 +17,10 @@ public class BusinessException extends RuntimeException {
         this.code = errorCode.code();
         this.message = errorCode.message();
     }
+    public BusinessException(ServerCode serverCode){
+        this.code = serverCode.code();
+        this.message = serverCode.message();
+    }
     public BusinessException(CameraConstant errorCode){
         this.code = errorCode.code();
         this.message = errorCode.message();
@@ -24,4 +29,8 @@ public class BusinessException extends RuntimeException {
         this.code = code;
         this.message = msg;
     }
+    public BusinessException(ServerCode serverCode, Object...args){
+        this.code = serverCode.code();
+        this.message = serverCode.formatMessage(args);
+    }
 }

+ 3 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/response/ResultData.java

@@ -53,6 +53,9 @@ public class ResultData<T> implements Serializable {
     public static ResultData error(int code, String msg, Object data) {
         return base(code, msg, data,false);
     }
+    public static ResultData error(ErrorCode errorCode, Object data) {
+        return base(errorCode.code(), errorCode.message(), data,false);
+    }
 
     public static ResultData error(ErrorCode errorCode) {
         return error(errorCode.code(), errorCode.message());

+ 25 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ComputerUtil.java

@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.constant.ConstantFileName;
 import com.fdkankan.common.constant.ConstantFilePath;
+import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.constant.UploadFilePath;
+import com.fdkankan.common.exception.BusinessException;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
@@ -604,4 +606,27 @@ public class ComputerUtil {
         log.info("pro大场景添加到队列:"+parametr);
         return parametr;
     }
+
+    /**
+     * 循环检测算法是否计算成功
+     * @param uploadJsonPath uploadjson路径
+     * @param maxCheckTimes 循环次数
+     * @param waitTime 每次检测间隔时间,毫秒
+     * @return boolean
+     * @throws Exception
+     */
+    public static boolean checkComputeCompleted(String uploadJsonPath, int maxCheckTimes, long waitTime) throws Exception{
+        int checkTimes = 1;
+        boolean exist = false;
+        do {
+            if(new File(uploadJsonPath).exists()){
+                exist = true;
+                break;
+            }
+            Thread.sleep(waitTime);
+            ++checkTimes;
+        }while (checkTimes <= maxCheckTimes);
+
+        return exist;
+    }
 }

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

@@ -601,7 +601,8 @@ public class CreateObjUtil {
 	}
 
 	public static void main(String[] args) throws Exception{
-		CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\jaBgoe9uyx-vision-1.txt", "F:\\visiontest\\vision.modeldata");
+		CreateObjUtil.convertTxtToVisionmodeldata("F:\\visiontest\\KJ-44g3CBuvof(1).txt", "F:\\visiontest\\vision.modeldata");
+//		CreateObjUtil.convertTxtToDam("F:\\visiontest\\modeldata.txt", "F:\\visiontest\\dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam");
 	}
 
 }

+ 10 - 9
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtils.java

@@ -1028,8 +1028,8 @@ public class FileUtils {
         }
     }
 
-    public static void main(String[] args) {
-        try{
+    public static void main(String[] args) throws Exception {
+//        try{
 //            String path = "H:\\test";
 //            InputStream is = null;
 //            String url = "https://file.api.weixin.qq.com/cgi-bin/media/get?access_token=41_veJ0V1PKdwBerxV6qcgty6opVroUYq5xgGG2uaK2f3PNBZNYttxNkTAHWyMt3AYb7iNn7cvpm87sXQhxBlhd6dBekczYR8-j49Hv85HMIV6HVsaMhjYE0QKtJ1C-HFfmsICMaSuvOBczkro5GDEeACAZWX&media_id=mXE_24SEX4-xfg0vB36KnfnkAHaFla5Fz4app1rgFiZDUtUJv04cQgJTOXHN32mm";
@@ -1079,15 +1079,16 @@ public class FileUtils {
 //            FileOutputStream out = new FileOutputStream(new File("F:\\texture1.jpg"));
 //            out.write(bytesFromUrl);
 
-            List<String> test = null;
-            List<String> collect = test.stream().map(t -> {
-                return t;
-            }).collect(Collectors.toList());
+//            List<String> test = null;
+//            List<String> collect = test.stream().map(t -> {
+//                return t;
+//            }).collect(Collectors.toList());
 
 
-        }catch (Exception e){
-            e.printStackTrace();
-        }
+//        }catch (Exception e){
+//            e.printStackTrace();
+//        }
+        FileUtil.unZip("F:\\test\\t-ja9iBPz.asdf", "F:\\test\\unzip");
     }
 
     public static List<String> list(File file) throws Exception{

+ 39 - 41
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/LogoConfig.java

@@ -24,53 +24,51 @@ public class LogoConfig {
      * @throws IOException 
      * @author Administrator sangwenhao 
      */  
-     public BufferedImage LogoMatrix(BufferedImage matrixImage, String logoPath) throws IOException{
+     public BufferedImage LogoMatrix(BufferedImage matrixImage, boolean logo, String logoPath) throws IOException{
          /** 
           * 读取二维码图片,并构建绘图对象 
           */  
-         Graphics2D g2 = matrixImage.createGraphics();  
-           
-         int matrixWidth = matrixImage.getWidth();  
-         int matrixHeigh = matrixImage.getHeight();
-         File file = null;
-         BufferedImage logo = null;
-         try {
-             /**
-              * 读取Logo图片
-              */
-             if(StrUtil.isEmpty(logoPath)){
-                 ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
-                 Resource[] resources = resolver.getResources("static/img/logo.jpg");
-                 Resource resource = resources[0];
-                //获得文件流,因为在jar文件中,不能直接通过文件资源路径拿到文件,但是可以在jar包中拿到文件流
-                 InputStream inputStream = resource.getInputStream();
-                 logo = ImageIO.read(inputStream);
-             }else {
-                 file = new File(logoPath);
-                 logo = ImageIO.read(file);
-             }
-
+         Graphics2D g2 = matrixImage.createGraphics();
 
+         if(logo){
+             int matrixWidth = matrixImage.getWidth();
+             int matrixHeigh = matrixImage.getHeight();
+             File file = null;
+             BufferedImage logoBuffer = null;
+             try {
+                 /**
+                  * 读取Logo图片
+                  */
+                     if(StrUtil.isEmpty(logoPath)){
+                         ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+                         Resource[] resources = resolver.getResources("static/img/logo.jpg");
+                         Resource resource = resources[0];
+                         //获得文件流,因为在jar文件中,不能直接通过文件资源路径拿到文件,但是可以在jar包中拿到文件流
+                         InputStream inputStream = resource.getInputStream();
+                         logoBuffer = ImageIO.read(inputStream);
+                     }else {
+                         file = new File(logoPath);
+                         logoBuffer = ImageIO.read(file);
+                     }
+             }catch (IOException e){
+                log.info("读取图片流失败,path="+ logoPath, e);
+             }
 
-         }catch (IOException e){
-            log.info("读取图片流失败,path="+ logoPath, e);
+             //开始绘制图片
+             g2.drawImage(logoBuffer,matrixWidth/5*2,matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5, null);//绘制
+             BasicStroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
+             g2.setStroke(stroke);// 设置笔画对象  44
+             //指定弧度的圆角矩形
+             RoundRectangle2D.Float round = new RoundRectangle2D.Float(matrixWidth/5*2, matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5,20,20);
+             g2.setColor(Color.white);
+             g2.draw(round);// 绘制圆弧矩形
+             //设置logo 有一道灰色边框
+             BasicStroke stroke2 = new BasicStroke(1,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
+             g2.setStroke(stroke2);// 设置笔画对象
+             RoundRectangle2D.Float round2 = new RoundRectangle2D.Float(matrixWidth/5*2+2, matrixHeigh/5*2+2, matrixWidth/5-4, matrixHeigh/5-4,20,20);
+             g2.setColor(new Color(128,128,128));
+             g2.draw(round2);// 绘制圆弧矩形
          }
-
-         //开始绘制图片  
-         g2.drawImage(logo,matrixWidth/5*2,matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5, null);//绘制       
-         BasicStroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);   
-         g2.setStroke(stroke);// 设置笔画对象  
-         //指定弧度的圆角矩形  
-         RoundRectangle2D.Float round = new RoundRectangle2D.Float(matrixWidth/5*2, matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5,20,20);  
-         g2.setColor(Color.white);  
-         g2.draw(round);// 绘制圆弧矩形  
-           
-         //设置logo 有一道灰色边框  
-         BasicStroke stroke2 = new BasicStroke(1,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);   
-         g2.setStroke(stroke2);// 设置笔画对象  
-         RoundRectangle2D.Float round2 = new RoundRectangle2D.Float(matrixWidth/5*2+2, matrixHeigh/5*2+2, matrixWidth/5-4, matrixHeigh/5-4,20,20);  
-         g2.setColor(new Color(128,128,128));  
-         g2.draw(round2);// 绘制圆弧矩形  
            
          g2.dispose();  
          matrixImage.flush() ;  

+ 6 - 6
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/MatrixToImageWriterUtil.java

@@ -35,11 +35,11 @@ public class MatrixToImageWriterUtil {
         return image;
     }
 
-    public static boolean writeToFile(BitMatrix matrix, String format, File file, String logoPath) throws IOException {
+    public static boolean writeToFile(BitMatrix matrix, String format, File file, boolean logo, String logoPath) throws IOException {
         BufferedImage image = toBufferedImage(matrix);
         //设置logo图标  
         LogoConfig logoConfig = new LogoConfig();
-        image = logoConfig.LogoMatrix(image, logoPath);
+        image = logoConfig.LogoMatrix(image, logo, logoPath);
 
         File parFile = new File(file.getParent() + File.separator);
         if (!parFile.exists()){
@@ -60,7 +60,7 @@ public class MatrixToImageWriterUtil {
         BufferedImage image = toBufferedImage(matrix);
         //设置logo图标  
         LogoConfig logoConfig = new LogoConfig();
-        image = logoConfig.LogoMatrix(image, null);
+        image = logoConfig.LogoMatrix(image, true,null);
 
         if (!ImageIO.write(image, format, stream)) {
             throw new IOException("Could not write an image of format " + format);
@@ -68,7 +68,7 @@ public class MatrixToImageWriterUtil {
     }
 
     //url
-    public static boolean createQRCode(String url, String outPath, String logoPath) throws Exception {
+    public static boolean createQRCode(String url, String outPath, boolean logo, String logoPath) throws Exception {
         // 生成二维码
 
         int width = 3000; // 二维码图片宽度 300
@@ -97,11 +97,11 @@ public class MatrixToImageWriterUtil {
         //File outputFile = new File("d:" + File.separator + "new-1.gif");//指定输出路径
         File outputFile = new File(outPath);//指定输出路径
         FileUtils.deleteFile(outPath);
-        return writeToFile(bitMatrix, format, outputFile, logoPath);
+        return writeToFile(bitMatrix, format, outputFile, logo, logoPath);
     }
 
     public static void main(String[] args) throws Exception{
-        MatrixToImageWriterUtil.createQRCode("https://www.4dkankan.com/spc.html?m=t-pnj0IJX", "F:/桌面/t-pnj0IJX.png", "G:\\javaProject\\4dkankan_v2-mini\\4dkankan-application\\target\\4dkankan_v2_mini\\WEB-INF\\classes\\static\\img\\logo.png");
+        MatrixToImageWriterUtil.createQRCode("https://www.4dkankan.com/spc.html?m=t-pnj0IJX", "F:\\test\\4Dkankan_share.png", true, "F:\\test\\8.jpg");
 //        MatrixToImageWriterUtil.createQRCode("https://www.4dkankan.com/spc.html?m=t-pnj0IJX&lang=en", "F:/桌面/t-pnj0IJX_en.png", null);
     }
 }