فهرست منبع

Merge branch 'master' into project-local-jg

192.168.9.165 5 روز پیش
والد
کامیت
a97b1abeee
36فایلهای تغییر یافته به همراه1181 افزوده شده و 71 حذف شده
  1. 2 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneStatus.java
  2. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/EncryptDecrypt.java
  3. 11 4
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/JwtUtil.java
  4. 32 0
      4dkankan-common-web/src/main/java/com/fdkankan/web/util/WebUtil.java
  5. 9 5
      4dkankan-utils-dingtalk/src/main/java/com/fdkankan/dingtalk/DingTalkSendUtils.java
  6. 90 36
      4dkankan-utils-dxf/src/main/java/com/fdkankan/dxf/parse/utils/LaserMeterToDxfUtil.java
  7. 4 2
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/StorageAutoConfiguration.java
  8. 3 0
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/aliyun/AliyunOssTemplate.java
  9. 5 3
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/aws/AwsTemplate.java
  10. 3 0
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/cos/CosTemplate.java
  11. 3 0
      4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/minio/MinioTemplate.java
  12. 30 1
      4dkankan-utils-fyun-cos/src/main/java/com/fdkankan/fyun/oss/CosFileService.java
  13. 10 0
      4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/HttpFileService.java
  14. 17 0
      4dkankan-utils-fyun-local/src/main/java/com/fdkankan/fyun/local/LocalFileService.java
  15. 22 0
      4dkankan-utils-fyun-obs/src/main/java/com/fdkankan/fyun/oss/ObsFileService.java
  16. 28 0
      4dkankan-utils-fyun-oss/src/main/java/com/fdkankan/fyun/oss/OssFileService.java
  17. 1 1
      4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/config/FYunFileConfig.java
  18. 9 0
      4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/AbstractFYunFileService.java
  19. 20 0
      4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/FYunFileServiceInterface.java
  20. 30 0
      4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/S3FileService.java
  21. 2 1
      4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/config/S3Config.java
  22. 30 0
      4dkankan-utils-model/src/main/java/com/fdkankan/model/bean/SymbolBean.java
  23. 4 1
      4dkankan-utils-model/src/main/java/com/fdkankan/model/bean/WallBean.java
  24. 2 1
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateHouseJsonUtil.java
  25. 2 2
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateObjUtil.java
  26. 92 10
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/FloorPlanUserUtil.java
  27. 100 0
      4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/Yingzhang.java
  28. 4 0
      4dkankan-utils-mongodb/src/main/java/com/fdkankan/mongodb/service/MongodbBaseService.java
  29. 8 0
      4dkankan-utils-mongodb/src/main/java/com/fdkankan/mongodb/service/impl/MongodbBaseServiceImpl.java
  30. 2 2
      4dkankan-utils-reg/src/main/java/com/fdkankan/reg/RegCodeUtil.java
  31. 28 0
      4dkankan-utils-sign/pom.xml
  32. 121 0
      4dkankan-utils-sign/src/main/java/com/fdkankan/sign/AesUtil.java
  33. 90 0
      4dkankan-utils-sign/src/main/java/com/fdkankan/sign/Base64Converter.java
  34. 322 0
      4dkankan-utils-sign/src/main/java/com/fdkankan/sign/RsaUtils.java
  35. 43 0
      4dkankan-utils-sign/src/main/java/com/fdkankan/sign/SignUtils.java
  36. 1 0
      pom.xml

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

@@ -6,7 +6,8 @@ public enum SceneStatus {
     SUCCESS(1, "已建好"),
     SUCCESS(1, "已建好"),
     FAILD(-1, "出错"),
     FAILD(-1, "出错"),
     NO_DISPLAY(-2, "不要在官网上显示"),
     NO_DISPLAY(-2, "不要在官网上显示"),
-    EXCEED_SPACE(-3, "超出容量,未计算")
+    EXCEED_SPACE(-3, "超出容量,未计算"),
+    PREVIEW(6, "可预览")
     ;
     ;
 
 
     private Integer code;
     private Integer code;

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

@@ -18,7 +18,7 @@ public class EncryptDecrypt {
    }
    }
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
-        System.out.println(getEncrypt("JK20220120%JIK"));
+        System.out.println(getEncrypt("DOB87VaBCXmk3L3OWiO++iWoevuek7QkC9NrbDvs"));
 //        System.out.println(getEncrypt("LTAI5tJZBJwP5qazE6b3b4Gr"));
 //        System.out.println(getEncrypt("LTAI5tJZBJwP5qazE6b3b4Gr"));
 //        System.out.println(getEncrypt("zSQCG0yyvRJISPokNZGhbhaAfh4hGX"));
 //        System.out.println(getEncrypt("zSQCG0yyvRJISPokNZGhbhaAfh4hGX"));
 //        System.out.println(getEncrypt("4dkankan524%40123*"));
 //        System.out.println(getEncrypt("4dkankan524%40123*"));

+ 11 - 4
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/JwtUtil.java

@@ -59,7 +59,7 @@ public class JwtUtil {
             //设置过期时间
             //设置过期时间
             builder.setExpiration(exp);
             builder.setExpiration(exp);
         }/*else{
         }/*else{
-            //设置过期时间半小时
+            //设置过期时间半小时main
             DateTime expDate = new DateTime().plusMinutes(30);
             DateTime expDate = new DateTime().plusMinutes(30);
             builder.setExpiration(expDate.toDate());
             builder.setExpiration(expDate.toDate());
         }*/
         }*/
@@ -137,9 +137,16 @@ public class JwtUtil {
     }
     }
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
-        long start = System.currentTimeMillis();
-        System.out.println(getUsername("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzUzNjUwMTEyOCIsImxvZ2luVHlwZSI6InVzZXIiLCJ1c2VyTmFtZSI6IjEzNTM2NTAxMTI4IiwiaWF0IjoxNjU4ODI4NjA2LCJqdGkiOiI4NjczYjFiMi0xYjc4LTRmMTEtOGQ5My05OWE0OWRlMGVhMjAifQ.0oYzEwTsV1iLn_cMeiqLc5upJfcYipRbIDSndSxeuK0"));
-        System.out.println(System.currentTimeMillis() - start);
+//        long start = System.currentTimeMillis();
+//        System.out.println(getUsername("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzUzNjUwMTEyOCIsImxvZ2luVHlwZSI6InVzZXIiLCJ1c2VyTmFtZSI6IjEzNTM2NTAxMTI4IiwiaWF0IjoxNjU4ODI4NjA2LCJqdGkiOiI4NjczYjFiMi0xYjc4LTRmMTEtOGQ5My05OWE0OWRlMGVhMjAifQ.0oYzEwTsV1iLn_cMeiqLc5upJfcYipRbIDSndSxeuK0"));
+//        System.out.println(System.currentTimeMillis() - start);
+
+        //eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIiLCJsb2dpblR5cGUiOiJ1c2VyIiwidXNlck5hbWUiOiIiLCJpYXQiOjE3NTE4NzA5MDIsImp0aSI6IjgyMmZiYjE0LTAwMDAtNGZhNC04NzA4LTc0YTI2MDdmZjJiOSJ9.gRIFvIUamFtYvIr5dZJ41dqhx9E3pPW866ZasERL8fw
+
+        String user = JwtUtil.createJWT(-1, "", "user");
+//        Claims claims = JwtUtil.parseJWT("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIiLCJsb2dpblR5cGUiOiJ1c2VyIiwidXNlck5hbWUiOiIiLCJpYXQiOjE3NTE4NzA5MDIsImp0aSI6IjgyMmZiYjE0LTAwMDAtNGZhNC04NzA4LTc0YTI2MDdmZjJiOSJ9.gRIFvIUamFtYvIr5dZJ41dqhx9E3pPW866ZasERL8fw");
+        System.out.println(user);
+
     }
     }
 
 
 }
 }

+ 32 - 0
4dkankan-common-web/src/main/java/com/fdkankan/web/util/WebUtil.java

@@ -7,9 +7,12 @@ import cn.hutool.http.useragent.UserAgent;
 import cn.hutool.http.useragent.UserAgentUtil;
 import cn.hutool.http.useragent.UserAgentUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 
 
+import java.io.BufferedReader;
+import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.JoinPoint;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpHeaders;
@@ -63,6 +66,35 @@ public class WebUtil {
         }
         }
     }
     }
 
 
+    public static Map<String, Object> getParameter(HttpServletRequest request) throws IOException {
+        String contentType = request.getContentType();
+        if (StrUtil.isNotEmpty(contentType) && contentType.contains(ContentType.JSON.getValue())) {
+            BufferedReader reader = request.getReader(); // 对于文本数据,如JSON或XML
+            String json = "";
+            if (reader != null) {
+                json = reader.lines().collect(Collectors.joining()); // 收集所有行到一个字符串中
+            }
+            return JSON.parseObject(json, HashMap.class);
+        } else {
+            Enumeration<String> parameterNames = request.getParameterNames();
+            if(CollUtil.isEmpty(parameterNames)){
+                return null;
+            }
+            Map<String, Object> params = new HashMap<>();
+            String name = null;
+            do {
+                name = parameterNames.nextElement();
+                params.put(name, request.getParameter(name));
+            }while (parameterNames.hasMoreElements());
+            return params;
+        }
+    }
+
+    public static <T> T getParameter(String name, HttpServletRequest request) throws IOException {
+        Map<String, Object> parameters = getParameter(request);
+        return (T) parameters.get(name);
+    }
+
     /**
     /**
      * 获取客户端请求终端地址
      * 获取客户端请求终端地址
      * @param request  客户端请求request
      * @param request  客户端请求request

+ 9 - 5
4dkankan-utils-dingtalk/src/main/java/com/fdkankan/dingtalk/DingTalkSendUtils.java

@@ -40,10 +40,14 @@ public class DingTalkSendUtils {
 
 
 
 
     public void sendActioncardMsgToDingRobot(String content,String title) throws ApiException, UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
     public void sendActioncardMsgToDingRobot(String content,String title) throws ApiException, UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
+        this.sendActioncardMsgToDingRobot(token, secret, content, title);
+    }
+
+    public void sendActioncardMsgToDingRobot(String accessToken, String accessSecret, String content,String title) throws ApiException, UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
         Long timestamp = System.currentTimeMillis();
         Long timestamp = System.currentTimeMillis();
-        String sign = getSign(timestamp);
+        String sign = getSign(timestamp, accessSecret);
         DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?" +
         DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?" +
-                "access_token="+token +
+                "access_token="+accessToken +
                 "&timestamp=".concat(String.valueOf(timestamp)).concat("&sign=").concat(sign));
                 "&timestamp=".concat(String.valueOf(timestamp)).concat("&sign=").concat(sign));
         OapiRobotSendRequest request = new OapiRobotSendRequest();
         OapiRobotSendRequest request = new OapiRobotSendRequest();
         request.setMsgtype("actionCard");
         request.setMsgtype("actionCard");
@@ -60,10 +64,10 @@ public class DingTalkSendUtils {
         System.out.println(re.getBody());
         System.out.println(re.getBody());
     }
     }
 
 
-    public static String getSign(Long timestamp) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
-        String stringToSign = timestamp + "\n" + secret;
+    public static String getSign(Long timestamp, String accessSecret) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
+        String stringToSign = timestamp + "\n" + accessSecret;
         Mac mac = Mac.getInstance("HmacSHA256");
         Mac mac = Mac.getInstance("HmacSHA256");
-        mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
+        mac.init(new SecretKeySpec(accessSecret.getBytes("UTF-8"), "HmacSHA256"));
         byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
         byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
         System.out.println(new String(signData));
         System.out.println(new String(signData));
         return URLEncoder.encode(Base64Converter.encode(signData));
         return URLEncoder.encode(Base64Converter.encode(signData));

+ 90 - 36
4dkankan-utils-dxf/src/main/java/com/fdkankan/dxf/parse/utils/LaserMeterToDxfUtil.java

@@ -2,6 +2,7 @@ package com.fdkankan.dxf.parse.utils;
 
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.thread.ThreadUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.dxf.fdjson.vo.FdPoints;
 import com.fdkankan.dxf.fdjson.vo.FdPoints;
@@ -32,14 +33,30 @@ public class LaserMeterToDxfUtil {
      * @param outPath dxf输出地址
      * @param outPath dxf输出地址
      */
      */
 
 
-    public static void toDxf(File inFile, String outPath) throws Exception{
+    public static void toDxf(File inFile, String outPath ) throws Exception{
         String msg = FileUtil.readString(inFile, StandardCharsets.UTF_8);
         String msg = FileUtil.readString(inFile, StandardCharsets.UTF_8);
         JSONArray jsonObject = JSONArray.parseArray(msg);
         JSONArray jsonObject = JSONArray.parseArray(msg);
-        toDxf(jsonObject,outPath);
+        toDxf(jsonObject,outPath,0);
     }
     }
     public static void toDxf(String inPath, String outPath) throws Exception {
     public static void toDxf(String inPath, String outPath) throws Exception {
         JSONArray jsonObject = JSONArray.parseArray(inPath);
         JSONArray jsonObject = JSONArray.parseArray(inPath);
-        toDxf(jsonObject,outPath);
+        toDxf(jsonObject,outPath,0);
+    }
+    public static void toDxf(JSONArray jsonArray, String outPath) throws Exception{
+        work(jsonArray,outPath,0);
+    }
+
+    public static void toDxf(File inFile, String outPath,Integer viewpoint) throws Exception{
+        String msg = FileUtil.readString(inFile, StandardCharsets.UTF_8);
+        JSONArray jsonObject = JSONArray.parseArray(msg);
+        toDxf(jsonObject,outPath,viewpoint);
+    }
+    public static void toDxf(String inPath, String outPath,Integer viewpoint) throws Exception {
+        JSONArray jsonObject = JSONArray.parseArray(inPath);
+        toDxf(jsonObject,outPath,viewpoint);
+    }
+    public static void toDxf(JSONArray jsonArray, String outPath,Integer viewpoint) throws Exception{
+        work(jsonArray,outPath,viewpoint);
     }
     }
 
 
     /**
     /**
@@ -49,7 +66,7 @@ public class LaserMeterToDxfUtil {
      * @throws Exception
      * @throws Exception
      */
      */
 
 
-    public static void toDxf(JSONArray jsonArray, String outPath) throws Exception{
+    private static void work(JSONArray jsonArray, String outPath,Integer viewpoint) throws Exception{
 
 
         DxfDocWriter dxfDocWriter = new DxfDocWriter();
         DxfDocWriter dxfDocWriter = new DxfDocWriter();
         HashSet<Vector3> pointSet= new HashSet<>();
         HashSet<Vector3> pointSet= new HashSet<>();
@@ -61,8 +78,8 @@ public class LaserMeterToDxfUtil {
             if(type.contains("AREA") || type.contains("RECTANGLE")){
             if(type.contains("AREA") || type.contains("RECTANGLE")){
                 for (int i = 0 ;i < points.size();i ++){
                 for (int i = 0 ;i < points.size();i ++){
                     JSONObject point1 = (JSONObject) points.get(i);
                     JSONObject point1 = (JSONObject) points.get(i);
-                    JSONObject point2 = (JSONObject) points.get(  i+1 >= points.size()? 0 :i+1 );
-                    drawLine(point1,point2,pointSet,dxfDocWriter);
+                    JSONObject point2 = (JSONObject) points.get(i+1 >= points.size()? 0 :i+1);
+                    drawLine(point1,point2,pointSet,dxfDocWriter,viewpoint);
                 }
                 }
             }
             }
             if(type.contains("SERIES") ){
             if(type.contains("SERIES") ){
@@ -71,31 +88,29 @@ public class LaserMeterToDxfUtil {
                         continue;
                         continue;
                     }
                     }
                     JSONObject point1 = (JSONObject) points.get(i);
                     JSONObject point1 = (JSONObject) points.get(i);
-                    JSONObject point2 = (JSONObject) points.get(  i+1 >= points.size()? 0 :i+1 );
-                    drawLine(point1,point2,pointSet,dxfDocWriter);
+                    JSONObject point2 = (JSONObject) points.get( i+1 >= points.size()? 0 :i+1);
+                    drawLine(point1,point2,pointSet,dxfDocWriter,viewpoint);
                 }
                 }
             }
             }
             if(type.contains("LINE") ){
             if(type.contains("LINE") ){
                 JSONObject point1 = (JSONObject) (points.get(0));
                 JSONObject point1 = (JSONObject) (points.get(0));
                 JSONObject point2 = (JSONObject) (points.get(1));
                 JSONObject point2 = (JSONObject) (points.get(1));
-                drawLine(point1,point2,pointSet,dxfDocWriter);
+                drawLine(point1,point2,pointSet,dxfDocWriter,viewpoint);
             }
             }
 
 
-
-
         }
         }
 
 
-        for (Vector3 vector3 : pointSet) {
-            DxfArc dxfArc = new DxfArc();
-            dxfArc.setCenter(vector3);
-            dxfArc.setRadius(0.5);
-            dxfArc.setStartAngle(0);
-            dxfArc.setEndAngle(360);
-            dxfArc.setSolid(true);
-            dxfArc.setSolidColor(new Color(255,255,255));
-            dxfArc.setColor(new Color(255,255,255));
-            dxfDocWriter.addEntity(dxfArc);
-        }
+//        for (Vector3 vector3 : pointSet) {
+//            DxfArc dxfArc = new DxfArc();
+//            dxfArc.setCenter(vector3);
+//            dxfArc.setRadius(0.5);
+//            dxfArc.setStartAngle(0);
+//            dxfArc.setEndAngle(360);
+//            dxfArc.setSolid(true);
+//            dxfArc.setSolidColor(new Color(255,255,255));
+//            dxfArc.setColor(new Color(255,255,255));
+//            //dxfDocWriter.addEntity(dxfArc);
+//        }
         dxfDocWriter.save(outPath, true);
         dxfDocWriter.save(outPath, true);
 
 
     }
     }
@@ -107,32 +122,51 @@ public class LaserMeterToDxfUtil {
      *
      *
      * 正交投影 忽略z
      * 正交投影 忽略z
      */
      */
-    public static void drawLine(JSONObject point1, JSONObject point2, HashSet<Vector3> pointSet,DxfDocWriter dxfDocWriter){
+    public static void drawLine(JSONObject point1, JSONObject point2, HashSet<Vector3> pointSet,DxfDocWriter dxfDocWriter,Integer viewpoint){
         Vector3 point3d1 = new Vector3(point1.getDouble("x"),point1.getDouble("y"),point1.getDouble("z"));
         Vector3 point3d1 = new Vector3(point1.getDouble("x"),point1.getDouble("y"),point1.getDouble("z"));
         Vector3 point3d2 = new Vector3(point2.getDouble("x"),point2.getDouble("y"),point2.getDouble("z"));
         Vector3 point3d2 = new Vector3(point2.getDouble("x"),point2.getDouble("y"),point2.getDouble("z"));
-        Vector3 startPoint = new Vector3((point1.getDouble("x") ) * 100 ,(point1.getDouble("y")) * 100,0);
-        Vector3 endPoint = new Vector3((point2.getDouble("x") ) * 100 ,(point2.getDouble("y")) * 100,0);
+        Vector3 startPoint;
+        Vector3 endPoint ;
+//        if(viewpoint == 0){ //俯视角
+//            startPoint = new Vector3((point1.getDouble("x") ) * 100 ,(point1.getDouble("y")) * 100,(point1.getDouble("z")) * 100);
+//            endPoint = new Vector3((point2.getDouble("x") ) * 100 ,(point2.getDouble("y")) * 100,(point2.getDouble("z")) * 100);
+//        }else if(viewpoint ==1) {
+//            startPoint = new Vector3((point1.getDouble("x") ) * 100 ,(point1.getDouble("z")) * 100,0);
+//            endPoint = new Vector3((point2.getDouble("x") ) * 100 ,(point2.getDouble("z")) * 100,0);
+//        }else {
+//            startPoint = new Vector3((point1.getDouble("y") ) * 100 ,(point1.getDouble("z")) * 100,0);
+//            endPoint = new Vector3((point2.getDouble("y") ) * 100 ,(point2.getDouble("z")) * 100,0);
+//        }
+        startPoint = new Vector3((point1.getDouble("x") ) * 100 ,(point1.getDouble("y")) * 100,(point1.getDouble("z")) * 100);
+        endPoint = new Vector3((point2.getDouble("x") ) * 100 ,(point2.getDouble("y")) * 100,(point2.getDouble("z")) * 100);
         pointSet.add(startPoint);
         pointSet.add(startPoint);
         pointSet.add(endPoint);
         pointSet.add(endPoint);
         drawLinePoint(startPoint,endPoint,dxfDocWriter);
         drawLinePoint(startPoint,endPoint,dxfDocWriter);
-        BigDecimal bigDecimal = BigDecimal.valueOf(distanceTo(point3d1, point3d2) * 100).setScale(5, RoundingMode.UP);
-        int d = bigDecimal.divide(new BigDecimal(100),2, RoundingMode.UP).intValue();
+        BigDecimal bigDecimal = BigDecimal.valueOf(distanceTo(point3d1, point3d2) ).setScale(4, RoundingMode.UP);
         DxfText dxfText = new DxfText();
         DxfText dxfText = new DxfText();
-        Vector3 vector3 = new Vector3((endPoint.getX() + startPoint.getX()) /2 ,
-                (endPoint.getY() + startPoint.getY() )/2 ,
-                0);
+
+        double px = startPoint.getX() + getPointAngle(endPoint.getX() , startPoint.getX());
+        double py = startPoint.getY() + getPointAngle(endPoint.getY() , startPoint.getY());
+        double pz = startPoint.getZ() + getPointAngle(endPoint.getZ() , startPoint.getZ());
+
+        Vector3 vector3 = new Vector3(px   , py  , pz);
         dxfText.setStartPoint(vector3);
         dxfText.setStartPoint(vector3);
-        dxfText.setText(bigDecimal.toString()+"cm");
-        dxfText.setAngle(angleBetween(startPoint,endPoint));
-        dxfText.setHigh(d *2);
+        dxfText.setText(bigDecimal.toString()+"m");
+        //dxfText.setAngle(angleBetweenVectorsRad(startPoint,endPoint));
+        //dxfText.setInclination(angleBetweenVectorsDeg(startPoint,endPoint));
+        dxfText.setHigh(bigDecimal.doubleValue() * 2);
         dxfText.setColor(new Color(255,255,255));
         dxfText.setColor(new Color(255,255,255));
         dxfDocWriter.addEntity(dxfText);
         dxfDocWriter.addEntity(dxfText);
     }
     }
 
 
+    public static double getPointAngle(double x ,double y){
+        return  (2.0/5.0) * (x - y);
+    }
+
     public static void drawLinePoint(Vector3 point,Vector3 point2,DxfDocWriter dxfDocWriter){
     public static void drawLinePoint(Vector3 point,Vector3 point2,DxfDocWriter dxfDocWriter){
         DxfLine dxfLine = new DxfLine();
         DxfLine dxfLine = new DxfLine();
-        dxfLine.setStartPoint(new Vector3(point.getX(), point.getY(), 0));
-        dxfLine.setEndPoint(new Vector3(point2.getX(), point2.getY(), 0));
+        dxfLine.setStartPoint(new Vector3(point.getX(), point.getY(), point.getZ()));
+        dxfLine.setEndPoint(new Vector3(point2.getX(), point2.getY(), point2.getZ()));
         dxfLine.setColor(new Color(255,255,255));
         dxfLine.setColor(new Color(255,255,255));
         dxfDocWriter.addEntity(dxfLine);
         dxfDocWriter.addEntity(dxfLine);
     }
     }
@@ -145,6 +179,26 @@ public class LaserMeterToDxfUtil {
         return atan;
         return atan;
     }
     }
 
 
+    public static double angleBetweenVectorsRad(Vector3 point, Vector3 point2) {
+        // 计算点积
+        double dotProduct = point.getX() * point2.getX() + point.getY() * point2.getY() + point.getZ() * point2.getZ();
+
+        // 计算向量的模
+        double magA = Math.sqrt(point.getX() * point.getX() + point.getY() * point.getY() + point.getZ() * point.getZ());
+        double magB = Math.sqrt(point2.getX() * point2.getX() + point2.getY() * point2.getY() + point2.getZ() * point2.getZ());
+
+        // 计算余弦值,并处理可能的浮点误差
+        double cosTheta = dotProduct / (magA * magB);
+        cosTheta = Math.max(Math.min(cosTheta, 1.0), -1.0);
+
+        return Math.acos(cosTheta);
+    }
+
+    public static double angleBetweenVectorsDeg(Vector3 point, Vector3 point2) {
+        double radians = angleBetweenVectorsRad(point, point2);
+        return Math.toDegrees(radians);
+    }
+
     // 计算两点之间的线段长度
     // 计算两点之间的线段长度
     public static double distanceBetween(Vector3 p1, Vector3 p2) {
     public static double distanceBetween(Vector3 p1, Vector3 p2) {
         double deltaX = p2.getX() - p1.getX();
         double deltaX = p2.getX() - p1.getX();
@@ -163,7 +217,7 @@ public class LaserMeterToDxfUtil {
     public static void main(String[] args) throws Exception{
     public static void main(String[] args) throws Exception{
         String inPath ="D:\\cad\\work\\111\\1.json";
         String inPath ="D:\\cad\\work\\111\\1.json";
         String outPath ="D:\\cad\\work\\111\\"+new Date().getTime()+".dxf";
         String outPath ="D:\\cad\\work\\111\\"+new Date().getTime()+".dxf";
-        LaserMeterToDxfUtil.toDxf(new File(inPath),outPath);
+        LaserMeterToDxfUtil.toDxf(new File(inPath),outPath, 0);  //俯视
     }
     }
 
 
 
 

+ 4 - 2
4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/StorageAutoConfiguration.java

@@ -80,8 +80,10 @@ public class StorageAutoConfiguration {
     public AmazonS3 amazonS3Client(AwsProperties properties) {
     public AmazonS3 amazonS3Client(AwsProperties properties) {
         BasicAWSCredentials awsCreds = new BasicAWSCredentials(properties.getAccessKey(), properties.getAccessKeySecret());
         BasicAWSCredentials awsCreds = new BasicAWSCredentials(properties.getAccessKey(), properties.getAccessKeySecret());
         ClientConfiguration clientConfiguration = new ClientConfiguration();
         ClientConfiguration clientConfiguration = new ClientConfiguration();
-        clientConfiguration.setMaxErrorRetry(4);
-        clientConfiguration.setMaxConnections(200);
+        clientConfiguration.setMaxErrorRetry(5);
+        clientConfiguration.setMaxConnections(300);
+        clientConfiguration.setConnectionTimeout(5000);
+        clientConfiguration.setSocketTimeout(5000);
         AmazonS3 s3 = AmazonS3ClientBuilder.standard()
         AmazonS3 s3 = AmazonS3ClientBuilder.standard()
                 .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                 .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                 .withRegion(Regions.EU_WEST_2)
                 .withRegion(Regions.EU_WEST_2)

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

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

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

@@ -257,6 +257,7 @@ public class AwsTemplate implements FileStorageTemplate {
         } finally {
         } finally {
             if (content != null) {
             if (content != null) {
                 try {
                 try {
+                    object.close();
                     content.close();
                     content.close();
                 } catch (IOException e) {
                 } catch (IOException e) {
                     // Ignore
                     // Ignore
@@ -378,9 +379,10 @@ public class AwsTemplate implements FileStorageTemplate {
     @Override
     @Override
     public boolean doesObjectExist(String bucket, String keyName) {
     public boolean doesObjectExist(String bucket, String keyName) {
         try {
         try {
-            GetObjectRequest request  = new GetObjectRequest(bucket,keyName);
-            S3Object object = amazonS3Client.getObject(request);
-            return true;
+            if("/".equals(keyName.substring(0,1))){
+                keyName = keyName.substring(1);
+            }
+            return amazonS3Client.doesObjectExist(bucket,keyName);
         } catch (AmazonServiceException e) {
         } catch (AmazonServiceException e) {
             if (e.getErrorCode().equalsIgnoreCase("NoSuchKey")) {
             if (e.getErrorCode().equalsIgnoreCase("NoSuchKey")) {
                 log.error("NoSuchKey", e.getMessage());
                 log.error("NoSuchKey", e.getMessage());

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

@@ -349,6 +349,9 @@ public class CosTemplate implements FileStorageTemplate {
 
 
     @Override
     @Override
     public boolean doesObjectExist(String bucket, String keyName) {
     public boolean doesObjectExist(String bucket, String keyName) {
+        if("/".equals(keyName.substring(0,1))){
+            keyName = keyName.substring(1);
+        }
         boolean b = cosClient.doesObjectExist(bucket, keyName);
         boolean b = cosClient.doesObjectExist(bucket, keyName);
         log.info("文件是否存在={}", b);
         log.info("文件是否存在={}", b);
         return 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
     @Override
     public boolean doesObjectExist(String bucket, String keyName) {
     public boolean doesObjectExist(String bucket, String keyName) {
+        if("/".equals(keyName.substring(0,1))){
+            keyName = keyName.substring(1);
+        }
         GetObjectArgs getArgs = GetObjectArgs.builder()
         GetObjectArgs getArgs = GetObjectArgs.builder()
                 .bucket(bucket)
                 .bucket(bucket)
                 .object(keyName)
                 .object(keyName)

+ 30 - 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) {
     public void downloadFileByCommand(String bucket, String filePath, String remoteFilePath) {
         try {
         try {
             String optType = remoteFilePath.contains(".") ? "file" : "folder";
             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);
             log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
             callshell(command);
             callshell(command);
             log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
             log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
@@ -144,6 +144,20 @@ public class CosFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @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 {
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
         try {
             cosClient.deleteObject(bucket, remoteFilePath);
             cosClient.deleteObject(bucket, remoteFilePath);
@@ -250,6 +264,21 @@ public class CosFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                cosClient.copyObject(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+            });
+        } catch (Exception e) {
+            log.error("复制文件或目录失败,key:" + sourcePath, e);
+        }
+    }
+
+    @Override
     public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) {
     public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) {
         if (ObjectUtils.isEmpty(pathMap)) {
         if (ObjectUtils.isEmpty(pathMap)) {
             return;
             return;

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

@@ -142,6 +142,11 @@ public class HttpFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
         try {
             Map<String, Object> params = new HashMap<>();
             Map<String, Object> params = new HashMap<>();
@@ -224,6 +229,11 @@ public class HttpFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+
+    }
+
+    @Override
     public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) {
     public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) {
         if (ObjectUtils.isEmpty(pathMap)) {
         if (ObjectUtils.isEmpty(pathMap)) {
             return;
             return;

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

@@ -93,6 +93,23 @@ public class LocalFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        this.copyFileBetweenBucket(sourceBucketName,sourcePath,targetBucketName, targetPath);
+    }
+
+    @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 {
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         FileUtil.del(getOssPath(bucket, remoteFilePath));
         FileUtil.del(getOssPath(bucket, remoteFilePath));
     }
     }

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

@@ -63,6 +63,28 @@ public class ObsFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+
+    }
+
+    @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                CopyObjectRequest copyObjectRequest = new CopyObjectRequest(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+                copyObjectRequest.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
+                obsClient.copyObject(copyObjectRequest);
+            });
+        } catch (Exception e) {
+            log.error("列举文件目录失败,key:" + sourcePath, e);
+        }
+    }
+
+    @Override
     public String uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) {
     public String uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) {
         try {
         try {
             File file = new File(filePath);
             File file = new File(filePath);

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

@@ -148,6 +148,19 @@ public class OssFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @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 {
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
         try {
             ossClient.deleteObject(bucket, remoteFilePath);
             ossClient.deleteObject(bucket, remoteFilePath);
@@ -230,6 +243,21 @@ public class OssFileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                ossClient.copyObject(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+            });
+        } catch (Exception e) {
+            log.error("列举文件目录失败,key:" + sourcePath, e);
+        }
+    }
+
+    @Override
     public void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
     public void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
         try {
         try {
             List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
             List<String> files = listRemoteFiles(sourceBucketName, sourcePath);

+ 1 - 1
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/config/FYunFileConfig.java

@@ -29,7 +29,7 @@ public class FYunFileConfig {
     @Value("${fyun.host}")
     @Value("${fyun.host}")
     private String host;
     private String host;
 
 
-    @Value("${fyun.region:#{null}}")
+    @Value("${fyun.region:eu-west-2}")
     private String region;
     private String region;
 
 
 }
 }

+ 9 - 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
     @Override
+    public void downloadByCommand(String filePath, String remoteFilePath, boolean isDir) {
+        downloadByCommand(fYunFileConfig.getBucket(),filePath,remoteFilePath, isDir);
+    }
+
+    @Override
     public void deleteFile(String remoteFilePath) throws IOException {
     public void deleteFile(String remoteFilePath) throws IOException {
         deleteFile(fYunFileConfig.getBucket(), remoteFilePath);
         deleteFile(fYunFileConfig.getBucket(), remoteFilePath);
     }
     }
@@ -87,6 +92,10 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
         copyFileBetweenBucket(fYunFileConfig.getBucket(), sourcePath, fYunFileConfig.getBucket(), targetPath);
         copyFileBetweenBucket(fYunFileConfig.getBucket(), sourcePath, fYunFileConfig.getBucket(), targetPath);
     }
     }
 
 
+    public void copyFileInBucketParallel(String sourcePath, String targetPath) {
+        copyFileBetweenBucketParallel(fYunFileConfig.getBucket(), sourcePath, fYunFileConfig.getBucket(), targetPath);
+    }
+
     @Override
     @Override
     public void copyFileToArchive(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
     public void copyFileToArchive(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
         copyFileToArchive(sourceBucketName, sourcePath, targetBucketName, targetPath);
         copyFileToArchive(sourceBucketName, sourcePath, targetBucketName, targetPath);

+ 20 - 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) ;
     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
      * 通过本地脚本上传至系统默认bucket
      *
      *
      * @param filePath
      * @param filePath
@@ -219,6 +235,8 @@ public interface FYunFileServiceInterface {
      **/
      **/
     void copyFileInBucket(String sourcePath, String targetPath) ;
     void copyFileInBucket(String sourcePath, String targetPath) ;
 
 
+    void copyFileInBucketParallel(String sourcePath, String targetPath) ;
+
     /**
     /**
      * <p>
      * <p>
      * 拷贝目录
      * 拷贝目录
@@ -231,6 +249,8 @@ public interface FYunFileServiceInterface {
      **/
      **/
     void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) ;
     void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) ;
 
 
+    void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) ;
+
     /**
     /**
      * <p>
      * <p>
      * 拷贝目录
      * 拷贝目录

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

@@ -131,6 +131,23 @@ public class S3FileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                CopyObjectRequest request = new CopyObjectRequest(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+                request.withCannedAccessControlList(CannedAccessControlList.PublicRead);
+                s3.copyObject(request);
+            });
+        } catch (Exception e) {
+            log.error("列举文件目录失败,key=" + sourcePath);
+        }
+    }
+
+    @Override
     public void downloadFileByCommand(String bucket, String filePath, String remoteFilePath) {
     public void downloadFileByCommand(String bucket, String filePath, String remoteFilePath) {
         try {
         try {
             String optType = remoteFilePath.contains(".") ? "file" : "folder";
             String optType = remoteFilePath.contains(".") ? "file" : "folder";
@@ -144,6 +161,19 @@ public class S3FileService extends AbstractFYunFileService {
     }
     }
 
 
     @Override
     @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){
     public void deleteFile(String bucket, String remoteFilePath){
         if (remoteFilePath.startsWith("/")) {
         if (remoteFilePath.startsWith("/")) {
             remoteFilePath = remoteFilePath.substring(1);
             remoteFilePath = remoteFilePath.substring(1);

+ 2 - 1
4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/config/S3Config.java

@@ -8,6 +8,7 @@ import com.amazonaws.services.s3.AmazonS3;
 import com.amazonaws.services.s3.AmazonS3ClientBuilder;
 import com.amazonaws.services.s3.AmazonS3ClientBuilder;
 import com.fdkankan.fyun.config.FYunFileConfig;
 import com.fdkankan.fyun.config.FYunFileConfig;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
@@ -32,6 +33,6 @@ public class S3Config {
         return AmazonS3ClientBuilder.standard()
         return AmazonS3ClientBuilder.standard()
                 .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                 .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                 .withClientConfiguration(clientConfiguration)
                 .withClientConfiguration(clientConfiguration)
-                .withRegion(Regions.EU_WEST_2).build();
+                .withRegion(fYunFileConfig.getRegion()).build();
     }
     }
 }
 }

+ 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;
 package com.fdkankan.model.bean;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Builder;
 import lombok.Data;
 import lombok.Data;
@@ -25,7 +28,7 @@ public class WallBean implements Serializable {
     private String vectorId;
     private String vectorId;
     private String start;
     private String start;
     private String end;
     private String end;
-    private String[] children;
+    private Set<String> children;
     private Double width;
     private Double width;
 
 
     private String geoType;
     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.io.IOException;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Map;
 
 
 public class CreateHouseJsonUtil {
 public class CreateHouseJsonUtil {
@@ -136,7 +137,7 @@ public class CreateHouseJsonUtil {
 						.vectorId(wallId)
 						.vectorId(wallId)
 						.start(segmentBean.getStartPointId())
 						.start(segmentBean.getStartPointId())
 						.end(segmentBean.getEndPointId())
 						.end(segmentBean.getEndPointId())
-						.children(new String[]{})
+						.children(new HashSet<>())
 						.width(0.2d)
 						.width(0.2d)
 						.build();
 						.build();
 				wallMap.put(wallId, wallBean);
 				wallMap.put(wallId, wallBean);

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

@@ -101,7 +101,7 @@ public class CreateObjUtil {
 
 
 	public static void killMainLoader(){
 	public static void killMainLoader(){
 		log.info("开始杀掉算法进程");
 		log.info("开始杀掉算法进程");
-		String command = "ps -ef | grep 'MainLoader.exe' | grep -v grep | awk '{print $2}' | xargs kill -9";
+		String command = "sudo ps -ef | grep 'MainLoader.exe' | grep -v grep | awk '{print $2}' | xargs kill -9";
 		callshell(command);
 		callshell(command);
 		log.info("开始杀掉算法完毕");
 		log.info("开始杀掉算法完毕");
 	}
 	}
@@ -355,7 +355,7 @@ public class CreateObjUtil {
 //		convertVisionmodeldataToTxt("D:\\test\\test\\vision.modeldata", "D:\\test\\test\\vision.txt");
 //		convertVisionmodeldataToTxt("D:\\test\\test\\vision.modeldata", "D:\\test\\test\\vision.txt");
 //		FileUtil.del("D:\\test\\test");
 //		FileUtil.del("D:\\test\\test");
 
 
-		convertTxtToVisionmodeldata("D:\\test\\vision_100(1).txt", "D:\\test\\vision_100.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.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.util.FileUtils;
 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.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 class FloorPlanUserUtil {
 
 
 	public static void main(String[] args) {
 	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);
 			Map<String, Object> result = createFloorHandler(floor, currentId);
 			JSONArray points = (JSONArray)result.get("pointArr");
 			JSONArray points = (JSONArray)result.get("pointArr");
 			JSONArray walls = (JSONArray)result.get("wallArr");
 			JSONArray walls = (JSONArray)result.get("wallArr");
+			JSONArray symbols = (JSONArray)result.get("symbols");
 			currentId = (int)result.get("currentId");
 			currentId = (int)result.get("currentId");
 			JSONObject targetFloor = new JSONObject();
 			JSONObject targetFloor = new JSONObject();
 			targetFloor.put("points", convertArrToMap(points));
 			targetFloor.put("points", convertArrToMap(points));
 			targetFloor.put("walls", convertArrToMap(walls));
 			targetFloor.put("walls", convertArrToMap(walls));
+			targetFloor.put("symbols", convertArrToMap(symbols));
 			targetFloor.put("id", floor.getInteger("id"));
 			targetFloor.put("id", floor.getInteger("id"));
 			targetFloor.put("name",floor.getString("name"));
 			targetFloor.put("name",floor.getString("name"));
 			targetFloor.put("subgroup", floor.getInteger("subgroup"));
 			targetFloor.put("subgroup", floor.getInteger("subgroup"));
@@ -68,6 +67,7 @@ public class FloorPlanUserUtil {
 		return house;
 		return house;
 	}
 	}
 
 
+
 	private static Map<String, JSONObject> convertArrToMap(JSONArray arr){
 	private static Map<String, JSONObject> convertArrToMap(JSONArray arr){
 		Map<String, JSONObject> result = new HashMap<>();
 		Map<String, JSONObject> result = new HashMap<>();
 		if(CollUtil.isEmpty(arr)){
 		if(CollUtil.isEmpty(arr)){
@@ -133,7 +133,7 @@ public class FloorPlanUserUtil {
 						.vectorId(wallId)
 						.vectorId(wallId)
 						.start(segmentBean.getStartPointId())
 						.start(segmentBean.getStartPointId())
 						.end(segmentBean.getEndPointId())
 						.end(segmentBean.getEndPointId())
-						.children(new String[]{})
+						.children(new HashSet<>())
 						.width(0.2d)
 						.width(0.2d)
 						.build();
 						.build();
 				wallMap.put(wallId, wallBean);
 				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();
 		Collection<PointBean> pointBeans = pointMap.values();
 		for (PointBean pointBean : pointBeans) {
 		for (PointBean pointBean : pointBeans) {
 			Map<String, String> parent = new HashMap<>();
 			Map<String, String> parent = new HashMap<>();
@@ -166,12 +242,18 @@ public class FloorPlanUserUtil {
 		JSONArray wallArr = JSON.parseArray(JSON.toJSONString(wallBeans));
 		JSONArray wallArr = JSON.parseArray(JSON.toJSONString(wallBeans));
 		result.put("wallArr", wallArr);
 		result.put("wallArr", wallArr);
 
 
+		if(CollUtil.isNotEmpty(symbolMap)){
+			JSONArray symbolArr = JSON.parseArray(JSON.toJSONString(symbolMap.values()));
+			result.put("symbols", symbolArr);
+		}
+
 		result.put("currentId", currentId);
 		result.put("currentId", currentId);
 
 
 		return result;
 		return result;
 
 
 	}
 	}
 
 
+
 	private static JSONArray readFloorJson(String filePath) {
 	private static JSONArray readFloorJson(String filePath) {
 		try {
 		try {
 			JSONObject floorplan = FileUtils.readJson(filePath);
 			JSONObject floorplan = FileUtils.readJson(filePath);

+ 100 - 0
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/Yingzhang.java

@@ -0,0 +1,100 @@
+package com.fdkankan.model.utils;
+
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+public class Yingzhang {
+
+    public static void main(String...args) {
+        File file = new File("D:\\test\\yinzhang");
+        if (file.exists()) {
+            File[] images = file.listFiles();//f -> f.getName().toLowerCase().indexOf(".bmp") != 0
+            assert images != null;
+            for (File image : images) {
+                convertImage(image);
+            }
+        }
+        //convertImage(new File("C:/Users/Administrator/Desktop/love.bmp"));
+    }
+
+
+    /**
+     * 将图片白色部分透明化处理,只保留非白色部分
+     * @param imageFile 图片文件
+     */
+    public static void convertImage(File imageFile) {
+        if (imageFile == null || imageFile.isDirectory()) {
+            return;
+        }
+        //获取image buffered
+        BufferedImage image = null;
+        try {
+            image = ImageIO.read(imageFile);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        assert image != null;
+        //获取图片高度
+        int height = image.getHeight();
+        //获取图片宽度
+        int width = image.getWidth();
+        //生成ImageIcon对象
+        ImageIcon imageIcon = new ImageIcon(image);
+        //载入原图片数据
+        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
+        //创建画笔对象
+        Graphics2D graphics2D = (Graphics2D) bufferedImage.getGraphics();
+        //绘制Image图片
+        graphics2D.drawImage(imageIcon.getImage(), 0, 0, null);
+        //图片透明度
+        int alpha = 0;
+        //遍历图片y坐标
+        for (int y = bufferedImage.getMinY(); y < bufferedImage.getHeight(); y++) {
+            //遍历图片x坐标
+            for (int x = bufferedImage.getMinX(); x < bufferedImage.getWidth(); x++) {
+                int rgb = bufferedImage.getRGB(x, y);
+                alpha = includeColor(rgb) ? 0 : 255;
+                rgb = (alpha << 24) | (rgb & 0X00FFFFFF);
+                bufferedImage.setRGB(x, y, rgb);
+            }
+        }
+        //将处理后的色块buffered对象写入缓冲区
+        graphics2D.drawImage(bufferedImage, 0, 0, null);
+        //创建输出路径
+        File outFile = new File(imageFile.getParentFile().getPath() + "/temp/");
+        //检测输出路径是否存在
+        boolean exists = outFile.exists() || outFile.mkdir();
+        if (exists) {
+            //获取文件名不含后缀
+            String fileName = imageFile.getName().substring(0, imageFile.getName().lastIndexOf("."));
+            //创建输出图片文件对象
+            File outImageFile = new File(outFile.getPath() + "/" + fileName + ".png");
+            try {
+                //输出图片
+                ImageIO.write(bufferedImage, "png", outImageFile);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            //输出
+            System.out.println(outImageFile.getPath() + " 转换完成!");
+        }
+    }
+
+    /**
+     * 判断当前色块是否属于设定值的范围
+     * @param color 当前颜色
+     * @return false|true
+     */
+    public static boolean includeColor(int color) {
+        int red = (color & 0xFF0000) >> 16;
+        int green = (color & 0x00FF00) >> 8;
+        int blue = (color & 0x0000FF);
+        int color_range = 215;
+        return (red >= color_range && green >= color_range && blue >= color_range);
+    }
+
+}

+ 4 - 0
4dkankan-utils-mongodb/src/main/java/com/fdkankan/mongodb/service/MongodbBaseService.java

@@ -3,9 +3,11 @@ package com.fdkankan.mongodb.service;
 import com.fdkankan.mongodb.base.MongoPageResult;
 import com.fdkankan.mongodb.base.MongoPageResult;
 import com.fdkankan.mongodb.base.BaseRequestMongo;
 import com.fdkankan.mongodb.base.BaseRequestMongo;
 import com.mongodb.client.result.DeleteResult;
 import com.mongodb.client.result.DeleteResult;
+import com.mongodb.client.result.UpdateResult;
 import org.springframework.data.geo.GeoResults;
 import org.springframework.data.geo.GeoResults;
 import org.springframework.data.mongodb.core.query.NearQuery;
 import org.springframework.data.mongodb.core.query.NearQuery;
 import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
 import org.springframework.data.util.Pair;
 import org.springframework.data.util.Pair;
 
 
 import java.util.List;
 import java.util.List;
@@ -57,4 +59,6 @@ import java.util.List;
 
 
      Query getIdQueryFor(Object object);
      Query getIdQueryFor(Object object);
 
 
+     UpdateResult updateFirst(Query query, Update update);
+
 }
 }

+ 8 - 0
4dkankan-utils-mongodb/src/main/java/com/fdkankan/mongodb/service/impl/MongodbBaseServiceImpl.java

@@ -6,6 +6,7 @@ import com.fdkankan.mongodb.base.BaseRequestMongo;
 import com.fdkankan.mongodb.base.MongoPageResult;
 import com.fdkankan.mongodb.base.MongoPageResult;
 import com.fdkankan.mongodb.service.MongodbBaseService;
 import com.fdkankan.mongodb.service.MongodbBaseService;
 import com.mongodb.client.result.DeleteResult;
 import com.mongodb.client.result.DeleteResult;
+import com.mongodb.client.result.UpdateResult;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.bson.Document;
 import org.bson.Document;
 import org.bson.types.ObjectId;
 import org.bson.types.ObjectId;
@@ -19,6 +20,7 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.NearQuery;
 import org.springframework.data.mongodb.core.query.NearQuery;
 import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
 import org.springframework.data.util.Pair;
 import org.springframework.data.util.Pair;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.util.Assert;
 import org.springframework.util.Assert;
@@ -219,4 +221,10 @@ public class MongodbBaseServiceImpl<T> implements MongodbBaseService<T> {
         return new Query(Criteria.where((String) id.getFirst()).is(id.getSecond()));
         return new Query(Criteria.where((String) id.getFirst()).is(id.getSecond()));
     }
     }
 
 
+    @Override
+    public UpdateResult updateFirst(Query query, Update update){
+        return mongoTemplate.updateFirst(query, update, getTClass());
+    }
+
+
 }
 }

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 2 - 2
4dkankan-utils-reg/src/main/java/com/fdkankan/reg/RegCodeUtil.java


+ 28 - 0
4dkankan-utils-sign/pom.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>4dkankan-utils</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>4dkankan-utils-sign</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.12.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20231013</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 121 - 0
4dkankan-utils-sign/src/main/java/com/fdkankan/sign/AesUtil.java

@@ -0,0 +1,121 @@
+package com.fdkankan.sign;
+
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.util.Base64;
+import java.util.Random;
+import java.util.UUID;
+
+/**
+ * AES 128bit 加密解密工具类,用于密码加密
+ */
+public class AesUtil {
+    //使用AES-128-CBC加密模式,key需要为16位,key和iv可以相同!
+
+    public static String key = "0000000563613487";
+
+    public static String iv = "vyno4ve9shdq937e";
+    /**
+     * 加密方法
+     * @param data  要加密的数据
+     * @param key 加密key
+     * @param iv 加密iv
+     * @return 加密的结果
+     * @throws Exception
+     */
+    public static String encrypt(String data, String key, String iv)  throws Exception{
+        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");//"算法/模式/补码方式"
+        int blockSize = cipher.getBlockSize();
+
+        byte[] dataBytes = data.getBytes();
+        int plaintextLength = dataBytes.length;
+        if (plaintextLength % blockSize != 0) {
+            plaintextLength = plaintextLength + (blockSize - (plaintextLength % blockSize));
+        }
+
+        byte[] plaintext = new byte[plaintextLength];
+        System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length);
+
+        SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
+        IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
+
+        cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
+        byte[] encrypted = cipher.doFinal(plaintext);	// 加密
+
+        return Base64.getEncoder().encodeToString(encrypted); 	//通过Base64转码返回
+    }
+
+    public static String encrypt(String data) throws Exception{
+        return encrypt(data,key,iv);
+    }
+
+        /**
+         * 解密方法
+         * @param data 要解密的数据
+         * @param key  解密key
+         * @param iv 解密iv
+         * @return 解密的结果
+         * @throws Exception
+         */
+    public static String desEncrypt(String data, String key, String iv)  throws Exception{
+        byte[] encrypted1 = Base64.getDecoder().decode(data);
+
+        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
+        SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
+        IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
+
+        cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec); //使用密钥初始化,设置为解密模式
+
+        byte[] original = cipher.doFinal(encrypted1);	//执行操作
+        return new String(original).trim();
+    }
+
+    public static String desEncrypt(String data) throws Exception{
+        return desEncrypt(data,key,iv);
+    }
+
+    /**
+     *   用于生成一组16位随机数 key
+     * @return
+     */
+    public static String getRandomStringKey() {
+        int hashCodeValue = UUID.randomUUID().hashCode();
+        if(hashCodeValue < 0) hashCodeValue = -hashCodeValue;
+        return String.format("%016d",hashCodeValue);//左边补0,16位,进制(d,x)
+    }
+
+    /**
+     *   用于生成16位的随机数 iv
+     * @return
+     */
+    public static String getRandomStringIv(){
+        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
+        Random random=new Random();
+        StringBuffer key = new StringBuffer();
+        for(int i=0;i<16;i++){
+            int keyNumber = random.nextInt(base.length());
+            key.append(base.charAt(keyNumber));
+        }
+        return key.toString();
+    }
+
+
+    /**
+     * 测试
+     */
+    public static void main(String args[]) throws Exception {
+        String data = "Aa111111";
+//        String key = getRandomStringKey();  //0000001210830863
+//        String iv = getRandomStringIv();    //1xo1ub7m2rsz92ev
+
+        System.out.println(key);
+        System.out.println(iv);
+        String enData = encrypt(data, key, iv);
+
+        System.out.println(enData);
+        System.out.println(desEncrypt("vvEsbkugGPaFjGJeZ6MHK2joojv0juIMeUoa\\/oJMUi8=", key, iv));
+    }
+}
+

+ 90 - 0
4dkankan-utils-sign/src/main/java/com/fdkankan/sign/Base64Converter.java

@@ -0,0 +1,90 @@
+package com.fdkankan.sign;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+
+public class Base64Converter {
+
+    public final static Base64.Encoder encoder = Base64.getEncoder();
+    final static Base64.Decoder decoder = Base64.getDecoder();
+    static char[] arr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
+
+    /**
+     * 给字符串加密
+     * @param text
+     * @return
+     */
+    public static String encode(String text) {
+        byte[] textByte = new byte[0];
+        try {
+            textByte = text.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        String encodedText = encoder.encodeToString(textByte);
+        return encodedText;
+    }
+
+    /**
+     * 给字符串加密
+     * @param textByte
+     * @return
+     */
+    public static String encode(byte[] textByte) {
+        return encoder.encodeToString(textByte);
+    }
+
+    /**
+     * 将加密后的字符串进行解密
+     * @param encodedText
+     * @return
+     */
+    public static String decode(String encodedText) {
+        String text = null;
+        try {
+            text = new String(decoder.decode(encodedText), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return text;
+    }
+
+    /**
+     * 根据逻辑截取加密后的密碼
+     * @param text
+     * @return
+     */
+    public static String subText(String text){
+        //去掉前8位字符串
+        text = text.substring(8);
+        //去掉后8位字符串
+        text = text.substring(0, text.length() - 8);
+        //最后两个字符串换到前面,并且去掉剩下的后8位字符串
+        String result = text.substring(text.length() - 2) + text.substring(0, text.length() - 10);
+        return result;
+    }
+
+
+    public static  String getEncode(String str){
+        int num = 2;
+        String front = randomWord(8);
+        String middle = randomWord(8);
+        String end = randomWord(8);
+
+        String str1 = str.substring(0, num);
+        String str2 = str.substring(num);
+
+        return front + str2 + middle + str1 + end ;
+    }
+
+    public static String randomWord ( Integer min) {
+        String str = "";
+        Integer range = min;
+        // 随机产生
+        for (int i = 0; i < range; i++) {
+            int pos = (int) Math.round(Math.random() * (arr.length - 1));
+            str += arr[pos];
+        }
+        return str;
+    }
+}

+ 322 - 0
4dkankan-utils-sign/src/main/java/com/fdkankan/sign/RsaUtils.java

@@ -0,0 +1,322 @@
+package com.fdkankan.sign;
+
+
+import cn.hutool.crypto.digest.MD5;
+import cn.hutool.json.JSON;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.*;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Base64;
+import java.util.Calendar;
+
+public class RsaUtils {
+
+	static final Base64.Decoder decoder = Base64.getDecoder();
+	static final Base64.Encoder encoder = Base64.getEncoder();
+
+
+	/**
+	 * RSA密钥长度必须是64的倍数,在512~65536之间。默认是1024
+	 */
+	public static final int KEY_SIZE = 1024;
+
+	public static void main(String[] args) {
+//		KeyPairInfo keyPair = getKeyPair();
+		String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCaKAIIFQjNK1mziSQkXh1WEg/keWjWlYEOn+LDwjzvpN1wEm+UFGNrv5orccS5iingtIMJxPPFlKBEMPk11TxQKHwFMJqwWDcXCIdarInjdxZXy3cbUOuE6OFgSGh9tBUANcHAiIIOKplIQLdvVc5DpVi5MGmpQVcCNOSQ4KsaDwIDAQAB";
+//		String privateKey = keyPair.getPrivateKey();
+		String appId = "bf6acc5386b1106428fb1096b506661c";
+		System.out.println(appId+":");
+//		System.out.println("appId:"+ MD5.create().digestHex(appId));
+		System.out.println("公钥:"+publicKey);
+//		System.out.println("私钥:"+privateKey);
+		JSONObject params = new JSONObject();
+		params.set("appId", appId);
+		params.set("timestamp", Calendar.getInstance().getTimeInMillis());
+
+
+		String ciphertext = RsaUtils.encipher(JSONUtil.toJsonStr(params), publicKey);
+		System.out.println(String.format("密文:"+ciphertext));
+//		String deTxt = RsaUtils.decipher(ciphertext, privateKey);
+//		System.out.println(deTxt);
+	}
+
+	/**
+	 * 生成公钥、私钥对(keysize=1024)
+	 */
+	public static KeyPairInfo getKeyPair() {
+		return getKeyPair(KEY_SIZE);
+	}
+
+	/**
+	 * 生成公钥、私钥对
+	 *
+	 * @param keySize
+	 * @return
+	 */
+	public static KeyPairInfo getKeyPair(int keySize) {
+		try {
+			KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
+			keyPairGen.initialize(keySize);
+			// 生成一个密钥对,保存在keyPair中
+			KeyPair keyPair = keyPairGen.generateKeyPair();
+			// 得到私钥
+			RSAPrivateKey oraprivateKey = (RSAPrivateKey) keyPair.getPrivate();
+			// 得到公钥
+			RSAPublicKey orapublicKey = (RSAPublicKey) keyPair.getPublic();
+
+			KeyPairInfo pairInfo = new KeyPairInfo(keySize);
+			// 公钥
+			byte[] publicKeybyte = orapublicKey.getEncoded();
+			String publicKeyString = encoder.encodeToString(publicKeybyte);
+			pairInfo.setPublicKey(publicKeyString);
+			// 私钥
+			byte[] privateKeybyte = oraprivateKey.getEncoded();
+			String privateKeyString = encoder.encodeToString(privateKeybyte);
+			pairInfo.setPrivateKey(privateKeyString);
+
+			return pairInfo;
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 获取公钥对象
+	 *
+	 * @param publicKeyBase64
+	 * @return
+	 * @throws InvalidKeySpecException
+	 * @throws NoSuchAlgorithmException
+	 */
+	public static PublicKey getPublicKey(String publicKeyBase64) throws InvalidKeySpecException, NoSuchAlgorithmException {
+
+		KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+		X509EncodedKeySpec publicpkcs8KeySpec = new X509EncodedKeySpec(decoder.decode(publicKeyBase64));
+		PublicKey publicKey = keyFactory.generatePublic(publicpkcs8KeySpec);
+		return publicKey;
+	}
+
+	/**
+	 * 获取私钥对象
+	 *
+	 * @param privateKeyBase64
+	 * @return
+	 * @throws NoSuchAlgorithmException
+	 * @throws InvalidKeySpecException
+	 */
+	public static PrivateKey getPrivateKey(String privateKeyBase64) throws NoSuchAlgorithmException, InvalidKeySpecException {
+		KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+		PKCS8EncodedKeySpec privatekcs8KeySpec = new PKCS8EncodedKeySpec(decoder.decode(privateKeyBase64));
+		PrivateKey privateKey = keyFactory.generatePrivate(privatekcs8KeySpec);
+		return privateKey;
+	}
+
+	/**
+	 * 使用工钥加密
+	 *
+	 * @param content         待加密内容
+	 * @param publicKeyBase64 公钥 base64 编码
+	 * @return 经过 base64 编码后的字符串
+	 */
+	public static String encipher(String content, String publicKeyBase64) {
+		return encipher(content, publicKeyBase64, KEY_SIZE / 8 - 11);
+	}
+
+	/**
+	 * 使用公司钥加密(分段加密)
+	 *
+	 * @param content         待加密内容
+	 * @param publicKeyBase64 公钥 base64 编码
+	 * @param segmentSize     分段大小,一般小于 keySize/8(段小于等于0时,将不使用分段加密)
+	 * @return 经过 base64 编码后的字符串
+	 */
+	public static String encipher(String content, String publicKeyBase64, int segmentSize) {
+		try {
+			PublicKey publicKey = getPublicKey(publicKeyBase64);
+			return encipher(content, publicKey, segmentSize);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 分段加密
+	 *
+	 * @param ciphertext  密文
+	 * @param key         加密秘钥
+	 * @param segmentSize 分段大小,<=0 不分段
+	 * @return
+	 */
+	public static String encipher(String ciphertext, Key key, int segmentSize) {
+		try {
+			// 用公钥加密
+			byte[] srcBytes = ciphertext.getBytes();
+
+			// Cipher负责完成加密或解密工作,基于RSA
+			Cipher cipher = Cipher.getInstance("RSA");
+			// 根据公钥,对Cipher对象进行初始化
+			cipher.init(Cipher.ENCRYPT_MODE, key);
+			byte[] resultBytes = null;
+
+			if (segmentSize > 0)
+				resultBytes = cipherDoFinal(cipher, srcBytes, segmentSize); // 分段加密
+			else
+				resultBytes = cipher.doFinal(srcBytes);
+			String base64Str = Base64.getEncoder().encodeToString(resultBytes);
+			return base64Str;
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 分段大小
+	 *
+	 * @param cipher
+	 * @param srcBytes
+	 * @param segmentSize
+	 * @return
+	 * @throws IllegalBlockSizeException
+	 * @throws BadPaddingException
+	 * @throws IOException
+	 */
+	public static byte[] cipherDoFinal(Cipher cipher, byte[] srcBytes, int segmentSize) throws IllegalBlockSizeException, BadPaddingException, IOException {
+		if (segmentSize <= 0)
+			throw new RuntimeException("分段大小必须大于0");
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		int inputLen = srcBytes.length;
+		int offSet = 0;
+		byte[] cache;
+		int i = 0;
+		// 对数据分段解密
+		while (inputLen - offSet > 0) {
+			if (inputLen - offSet > segmentSize) {
+				cache = cipher.doFinal(srcBytes, offSet, segmentSize);
+			} else {
+				cache = cipher.doFinal(srcBytes, offSet, inputLen - offSet);
+			}
+			out.write(cache, 0, cache.length);
+			i++;
+			offSet = i * segmentSize;
+		}
+		byte[] data = out.toByteArray();
+		out.close();
+		return data;
+	}
+
+	/**
+	 * 使用私钥解密
+	 *
+	 * @param contentBase64    待加密内容,base64 编码
+	 * @param privateKeyBase64 私钥 base64 编码
+	 * @return
+	 * @segmentSize 分段大小
+	 */
+	public static String decipher(String contentBase64, String privateKeyBase64) {
+		return decipher(contentBase64, privateKeyBase64, KEY_SIZE / 8);
+	}
+
+	/**
+	 * 使用私钥解密(分段解密)
+	 *
+	 * @param contentBase64    待加密内容,base64 编码
+	 * @param privateKeyBase64 私钥 base64 编码
+	 * @return
+	 * @segmentSize 分段大小
+	 */
+	public static String decipher(String contentBase64, String privateKeyBase64, int segmentSize) {
+		try {
+			PrivateKey privateKey = getPrivateKey(privateKeyBase64);
+			return decipher(contentBase64, privateKey, segmentSize);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 分段解密
+	 *
+	 * @param contentBase64 密文
+	 * @param key           解密秘钥
+	 * @param segmentSize   分段大小(小于等于0不分段)
+	 * @return
+	 */
+	public static String decipher(String contentBase64, Key key, int segmentSize) {
+		try {
+			// 用私钥解密
+			byte[] srcBytes = Base64.getDecoder().decode(contentBase64);
+			// Cipher负责完成加密或解密工作,基于RSA
+			Cipher deCipher = Cipher.getInstance("RSA");
+			// 根据公钥,对Cipher对象进行初始化
+			deCipher.init(Cipher.DECRYPT_MODE, key);
+			byte[] decBytes = null;// deCipher.doFinal(srcBytes);
+			if (segmentSize > 0)
+				decBytes = cipherDoFinal(deCipher, srcBytes, segmentSize); // 分段加密
+			else
+				decBytes = deCipher.doFinal(srcBytes);
+
+			String decrytStr = new String(decBytes);
+			return decrytStr;
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	/**
+	 * 秘钥对
+	 */
+	public static class KeyPairInfo {
+		String privateKey;
+		String publicKey;
+		int keySize = 0;
+
+		public KeyPairInfo(int keySize) {
+			setKeySize(keySize);
+		}
+
+		public KeyPairInfo(String publicKey, String privateKey) {
+			setPrivateKey(privateKey);
+			setPublicKey(publicKey);
+		}
+
+		public String getPrivateKey() {
+			return privateKey;
+		}
+
+		public void setPrivateKey(String privateKey) {
+			this.privateKey = privateKey;
+		}
+
+		public String getPublicKey() {
+			return publicKey;
+		}
+
+		public void setPublicKey(String publicKey) {
+			this.publicKey = publicKey;
+		}
+
+		public int getKeySize() {
+			return keySize;
+		}
+
+		public void setKeySize(int keySize) {
+			this.keySize = keySize;
+		}
+	}
+}

+ 43 - 0
4dkankan-utils-sign/src/main/java/com/fdkankan/sign/SignUtils.java

@@ -0,0 +1,43 @@
+package com.fdkankan.sign;
+
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONObject;
+
+import java.util.Date;
+
+public class SignUtils {
+
+    public static Boolean checkSign(String sign,String appIdValue,String privateKey) {
+        try {
+            if(StringUtils.isBlank(sign)){
+                return false;
+            }
+            String deTxt = RsaUtils.decipher(sign, privateKey);
+            if(StringUtils.isBlank(deTxt)){
+                return false;
+            }
+            JSONObject jsonObject = new JSONObject(deTxt);
+            String appId = jsonObject.getString("appId");
+            Long timestamp = jsonObject.getLong("timestamp");
+            if(StringUtils.isBlank(appId) || timestamp == null){
+                return false;
+            }
+            if(!appId.equals(appIdValue)){
+                return false;
+            }
+            Long time = new Date().getTime();
+
+//            if(time < timestamp && timestamp - time > 1000 * 60){
+//                return false;
+//            }
+            //app获取时间存在误差,前后五分钟失败
+            if( Math.abs(time -timestamp) >1000 * 60 *5){
+                return false;
+            }
+            return true;
+        }catch (Exception e){
+            return false;
+        }
+    }
+
+}

+ 1 - 0
pom.xml

@@ -34,6 +34,7 @@
         <module>4dkankan-utils-disruptormq</module>
         <module>4dkankan-utils-disruptormq</module>
         <module>4dkankan-utils-dxf</module>
         <module>4dkankan-utils-dxf</module>
         <module>4dkankan-utils-geo-query</module>
         <module>4dkankan-utils-geo-query</module>
+        <module>4dkankan-utils-sign</module>
     </modules>
     </modules>
 
 
     <groupId>com.fdkankan</groupId>
     <groupId>com.fdkankan</groupId>