xiewj 1 rok pred
rodič
commit
aa7c7d2c1b

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

@@ -8,6 +8,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 提供简化上传/下载的基本操作,复杂操作请使用原始客户端OSS.
@@ -21,8 +22,10 @@ public interface FileStorageTemplate {
     // 上传文件
     //------------------------------------------------------------------
     String uploadFile(String pathKey, String filePath);
+    String uploadFile(String pathKey, String filePath, Map<String, String> headers);
 
     String uploadFile(String bucket, String pathKey, String filePath);
+    String uploadFile(String bucket, String pathKey, String filePath, Map<String, String> headers);
 
     String uploadFileText(String pathKey, String text);
 

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

@@ -81,7 +81,7 @@ public class StorageAutoConfiguration {
         BasicAWSCredentials awsCreds = new BasicAWSCredentials(properties.getAccessKey(), properties.getAccessKeySecret());
         ClientConfiguration clientConfiguration = new ClientConfiguration();
         clientConfiguration.setMaxErrorRetry(4);
-        clientConfiguration.setMaxConnections(100);
+        clientConfiguration.setMaxConnections(200);
         AmazonS3 s3 = AmazonS3ClientBuilder.standard()
                 .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                 .withRegion(Regions.EU_WEST_2)

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

@@ -2,6 +2,7 @@ package com.fdkankan.filestorage.aliyun;
 
 
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson2.JSON;
 import com.aliyun.oss.OSS;
@@ -26,6 +27,7 @@ import java.net.URI;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 import java.util.stream.Collectors;
 
@@ -58,6 +60,11 @@ public class AliyunOssTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String pathKey, String filePath, Map<String, String> headers) {
+        return uploadFile(ossProperties.getBucket(), pathKey, filePath,  headers);
+    }
+
+    @Override
     public String uploadFile(String bucket, String pathKey, String filePath) {
         InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
         InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
@@ -67,6 +74,20 @@ public class AliyunOssTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String bucket, String pathKey, String filePath, Map<String, String> headers) {
+        InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
+        InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
+        ObjectMetadata metadata = new ObjectMetadata();
+        if (ObjectUtil.isNotEmpty(headers)) {
+            for (Map.Entry<String, String> header : headers.entrySet()) {
+                metadata.setHeader(header.getKey(), header.getValue());
+            }
+        }
+        ossClient.putObject(bucket, pathKey, new File(filePath), metadata);
+        return calculateUrl(bucket, pathKey);
+    }
+
+    @Override
     public String uploadFileText(String pathKey, String content) {
         return uploadFileText(ossProperties.getBucket(), pathKey, content);
     }

+ 50 - 1
4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/aws/AwsTemplate.java

@@ -4,6 +4,7 @@ package com.fdkankan.filestorage.aws;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson2.JSON;
 import com.amazonaws.AmazonServiceException;
@@ -27,6 +28,7 @@ import java.net.URI;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 import java.util.stream.Collectors;
 
@@ -57,6 +59,11 @@ public class AwsTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String pathKey, String filePath, Map<String, String> headers) {
+        return uploadFile(awsProperties.getBucket(), pathKey, filePath,headers);
+    }
+
+    @Override
     public String uploadFile(String bucket, String pathKey, String filePath) {
         InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
         InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
@@ -65,6 +72,41 @@ public class AwsTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String bucket, String pathKey, String filePath, Map<String, String> headers) {
+        InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
+        InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
+        BufferedInputStream stream =null;
+        try {
+            ObjectMetadata metadata = new ObjectMetadata();
+            if (ObjectUtil.isNotEmpty(headers)) {
+                for (Map.Entry<String, String> header : headers.entrySet()) {
+                    metadata.setHeader(header.getKey(), header.getValue());
+                }
+            }
+             stream = FileUtil.getInputStream(new File(filePath));
+            metadata.setContentLength(stream.available());
+            PutObjectRequest request = new PutObjectRequest(bucket, pathKey,stream ,metadata);
+            request.withCannedAcl(CannedAccessControlList.PublicRead);
+            PutObjectResult putObjectResult = amazonS3Client.putObject(request);
+            if (StrUtil.isNotEmpty(putObjectResult.getETag())) {
+                log.info("s3上传文件成功:" + pathKey);
+            }
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }finally {
+            if (stream != null) {
+                try {
+                    stream.close();
+                } catch (IOException e) {
+                    // Ignore
+                }
+            }
+        }
+        return calculateUrl(bucket, pathKey);
+    }
+
+    @Override
     public String uploadFileText(String pathKey, String content) {
         return uploadFileText(awsProperties.getBucket(), pathKey, content);
     }
@@ -140,9 +182,16 @@ public class AwsTemplate implements FileStorageTemplate {
             if (StrUtil.isNotEmpty(putObjectResult.getETag())) {
                 log.info("s3上传文件成功:" + pathKey);
             }
-
         } catch (Exception e) {
             log.error(e.getMessage(), e);
+        }finally {
+            if (stream != null) {
+                try {
+                    stream.close();
+                } catch (IOException e) {
+                    // Ignore
+                }
+            }
         }
         return calculateUrl(bucket, pathKey);
     }

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

@@ -2,6 +2,7 @@ package com.fdkankan.filestorage.cos;
 
 
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson2.JSON;
 import com.fdkankan.filestorage.Consumer;
@@ -24,6 +25,7 @@ import java.net.URI;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 import java.util.stream.Collectors;
 
@@ -54,6 +56,11 @@ public class CosTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String pathKey, String filePath, Map<String, String> headers) {
+        return uploadFile(cosProperties.getBucket(), pathKey, filePath,headers);
+    }
+
+    @Override
     public String uploadFile(String bucket, String pathKey, String filePath) {
         InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
         InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
@@ -83,6 +90,31 @@ public class CosTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String bucket, String pathKey, String filePath, Map<String, String> headers) {
+        InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
+        InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
+        File file = new File(filePath);
+        if (!file.exists()) {
+            log.warn("要上传的文件不存在,filePath" + filePath);
+            return null;
+        }
+        try (InputStream ins = new FileInputStream(file)){
+            ObjectMetadata metadata = new ObjectMetadata();
+            if (ObjectUtil.isNotEmpty(headers)) {
+                for (Map.Entry<String, String> header : headers.entrySet()) {
+                    metadata.setHeader(header.getKey(), header.getValue());
+                }
+            }
+            cosClient.putObject(bucket, pathKey, ins, metadata);
+            log.info("文件上传成功,path:{}", filePath);
+        } catch (Exception e) {
+            log.error("cos上传文件失败,filePath:"+filePath, e);
+        }
+
+        return calculateUrl(bucket, pathKey);
+    }
+
+    @Override
     public String uploadFileText(String pathKey, String content) {
         return uploadFileText(cosProperties.getBucket(), pathKey, content);
     }

+ 53 - 10
4dkankan-utils-filestorage/src/main/java/com/fdkankan/filestorage/minio/MinioTemplate.java

@@ -28,10 +28,7 @@ import org.springframework.util.ObjectUtils;
 import java.io.*;
 import java.net.URI;
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * 阿里云操作模版类, 简化常见操作
@@ -59,6 +56,11 @@ public class MinioTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String pathKey, String filePath, Map<String, String> headers) {
+        return uploadFile(minioProperties.getBucket(), pathKey, filePath,headers);
+    }
+
+    @Override
     public String uploadFile(String bucket, String pathKey, String filePath) {
         InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
         InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
@@ -67,6 +69,34 @@ public class MinioTemplate implements FileStorageTemplate {
     }
 
     @Override
+    public String uploadFile(String bucket, String pathKey, String filePath, Map<String, String> headers) {
+        InnerUtils.checkArgument(bucket != null && bucket.length() > 0, "bucket can't be empty");
+        InnerUtils.checkArgument(pathKey != null && pathKey.length() > 0, "pathKey can't be empty");
+        BufferedInputStream stream =null;
+        try {
+            stream=FileUtil.getInputStream(new File(filePath));
+            PutObjectArgs objectArgs = PutObjectArgs.builder().object(pathKey)
+                    .bucket(bucket)
+                    .headers(headers)
+                    .stream(stream, stream.available(), -1).build();
+            ObjectWriteResponse objectWriteResponse = minioClient.putObject(objectArgs);
+            log.info(objectWriteResponse.object());
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }finally {
+            if (stream != null) {
+                try {
+                    stream.close();
+                } catch (IOException e) {
+                    // Ignore
+                }
+            }
+        }
+        return calculateUrl(bucket, pathKey);
+    }
+
+    @Override
     public String uploadFileText(String pathKey, String content) {
         return uploadFileText(minioProperties.getBucket(), pathKey, content);
     }
@@ -136,6 +166,14 @@ public class MinioTemplate implements FileStorageTemplate {
 
         } catch (Exception e) {
             log.error(e.getMessage(), e);
+        }finally {
+            if (stream != null) {
+                try {
+                    stream.close();
+                } catch (IOException e) {
+                    // Ignore
+                }
+            }
         }
         return calculateUrl(bucket, pathKey);
     }
@@ -401,8 +439,12 @@ public class MinioTemplate implements FileStorageTemplate {
 
     @Override
     public String getFileContent(String bucket, String keyName) throws Exception {
-        try (GetObjectResponse object = minioClient.getObject(GetObjectArgs.builder().bucket(bucket).object(keyName).build());
-             BufferedReader reader = new BufferedReader(new InputStreamReader(object))){
+        BufferedReader reader =null;
+        InputStreamReader in =null;
+        try {
+            GetObjectResponse object = minioClient.getObject(GetObjectArgs.builder().bucket(bucket).object(keyName).build());
+            in = new InputStreamReader(object);
+            reader = new BufferedReader(in);
             StringBuilder contentJson = new StringBuilder();
             while (true) {
                 String line = reader.readLine();
@@ -412,6 +454,9 @@ public class MinioTemplate implements FileStorageTemplate {
             return contentJson.toString();
         } catch (Exception e) {
             throw e;
+        }finally {
+            IoUtil.close(in);
+            IoUtil.close(reader);
         }
     }
 
@@ -426,7 +471,7 @@ public class MinioTemplate implements FileStorageTemplate {
             List<String> list = new ArrayList<>();
             Long total = 0L;
             ListObjectsArgs objectArgs = ListObjectsArgs.builder()
-                    .bucket(bucket).recursive(true).prefix(key + "/").build();
+                    .bucket(bucket).recursive(true).prefix(key).build();
             Iterator<Result<Item>> iterator = minioClient.listObjects(objectArgs).iterator();
             while (iterator.hasNext()){
                 Item item = iterator.next().get();
@@ -449,9 +494,7 @@ public class MinioTemplate implements FileStorageTemplate {
     @SneakyThrows
     @Override
     public String getInternalEndpoint(String bucket ,String key) {
-        URI uri = new URI(minioProperties.getInternalEndpoint());
-        String host = uri.getHost();
-        return new URI(uri.getScheme(), host, uri.getPath()+"/"+key, uri.getFragment()).toString();
+        return minioProperties.getInternalEndpoint()+"/"+bucket+"/"+key;
     }
 
     @Override

+ 3 - 3
4dkankan-utils-geo-query/src/main/java/com/fdkankan/geo/GeoQueryUtil.java

@@ -41,10 +41,10 @@ import java.nio.file.StandardCopyOption;
 @ConfigurationProperties(prefix = "geoquery")
 public class GeoQueryUtil {
     @Value("${geoquery.dataFilePath:/mnt/geoQuery/GeoJSON.json}")
-    private String dataFilePath;
+    private String dataFilePath="I:\\geoserver\\AreaCity-Query-Geometry\\GeoJSON-Polygon-ok_geo-240508-162233";
 
     @Value("${geoquery.saveWkbsFilePath:/mnt/geoQuery/GeoJSON.wkbs}")
-    private String saveWkbsFilePath;
+    private String saveWkbsFilePath="I:\\geoserver\\AreaCity-Query-Geometry\\GeoJSON.wkbs";
 
     @PostConstruct
     public void init() {
@@ -145,7 +145,7 @@ public class GeoQueryUtil {
     public static void main(String[] args) throws Exception {
         GeoQueryUtil queryUtil  = new GeoQueryUtil();
         queryUtil.init();
-        AreaCityQuery.QueryResult queryResult = queryUtil.queryPointInfo("120.885676,23.544815");
+        AreaCityQuery.QueryResult queryResult = queryUtil.queryPointInfo("113.541139,22.405310");
         System.out.println(queryResult);
 
     }

+ 1 - 1
4dkankan-utils-reg/src/main/java/com/fdkankan/reg/Crypt.java

@@ -97,7 +97,7 @@ public class Crypt {
 
 
    public static void main(String[] args) throws Exception {
-      String value ="A5C140AB33E4F6F1BA6B675875A424BB22BF15DD6DE1A4A5933F627B89BFADCA033FBF152BB9966B8489EDD346201562";
+      String value ="8F7DEOBF155D172C89EF5F4C628A1983F822E82AOCA1EE1ED764DAAD04C7D96FC2EFECE222ECC9F5COD5845830FEEE98";
       //"HmtaYAN+n8dzKifi50/sA4Sv/dLKR5MnfZKcJVSzmST0D7ZkbmM8AebuNNkKBc4Z7DoXDnDwwwap2hg+6ztWQAZdQZOfAHR5bueqpApDN9il6gIuQadcdPcvrurRRiTifOQYsE9nRQKy6smol0jrz0wLEDxyPh3ZfBZG0e5KxrEq6Es6E3/05F4jIBYy+dUtvYBPSrVi3kzkblFex6qZOf/6jbtSlchWJVXMuEgA05LplUlUvNr5vwNC65KIy6beHcyhntIO2wJHx5uknjtidXUft3s87ZlxTzMEiKV6cXU9ejuCxdOz9n0c7UPeAOqHprxW2FvOhytVSMoSPP6No9pSochmKdXBPgOQd15rswBi0ejSZ+qWG4/MrBhVFD5OaQ8Cr7wy9hoWdnYrd0tcxPZv4EiwF3DDqctffYgQjy8=";
       //"openid=ouQdHv18KY5HPhW16cDk43Y5-yyk&nickname=%e6%9d%8e%e5%a8%81&headimg=http%3a%2f%2fthirdwx.qlogo.cn%2fmmopen%2fajNVdqHZLLB6qkUjQibrUJniaBhLf8hjS5L4roMR84T62m7NyHiaIAXKh1cl2vJwfdSfEzju8HicugEXbJQFHx1pZw%2f132&rytype=1&nwflag=1&empno=BEJY3293&stime=1603340863000";
       String key = "4dage1684dage168";

+ 1 - 1
4dkankan-utils-reg/src/main/java/com/fdkankan/reg/DeflaterUtil.java

@@ -100,7 +100,7 @@ public class DeflaterUtil {
          return new String(output, "UTF-8");
       }
    public static void main(String[] args) throws IOException {
-      String data  = "9013E47C4A1181E70B697E956F7D8F16E776FB0F0D14FEF35C31158D889EAED9C0AACA53E67FE3F54468DE6F90B123E24E663E0AED062C1258A2CF937B17451958D115C4DDC7C317E1E06C174B748570F8618BBFD7A5AF56CFDDF48E2112BBD56B714370A75A094E3CADC98B349921755DCDAE2BC2660A29D4E33E34FA6AC5DC9B955DA1E43D35CDCBBB2956440FB83120CFD7E09EB4D8B62F5C981FD8D12798";
+      String data  = "123123123123";
       System.out.println(data.length());
       String formattedString = DeflaterUtil.zipString(data);
       System.out.println(formattedString.length());

+ 16 - 15
4dkankan-utils-reg/src/main/java/com/fdkankan/reg/RegCodeUtil.java

@@ -138,9 +138,9 @@ public class RegCodeUtil {
         }
     }
     public static  void main(String[] args) {
-        RegCodeUtil uat = RegCodeUtil.builder().env("UAT").build();
+        RegCodeUtil uat = RegCodeUtil.builder().env("PROD").build();
 
-        String machineCode="8CA4224EB41BE3AD8998415EA0460F39845AC74625B3158A84AD18CEAC5FD6F4500CCC34309F7045F726AA6968F908C9";
+        String machineCode="E17CB0E629A47B26E455D9D8EF35EEAEBF31E9F4B5F40A253550E9A589897927BE11825E5422400D0BE6BF44C0734743";
 
 
         //读取机器码
@@ -169,24 +169,25 @@ public class RegCodeUtil {
 //        camRegDto.setSn("a0ia7r137");
 //        camRegDto.setCameraType(9);
 
-//        CamRegDto camRegDto=new CamRegDto();
-//        camRegDto.setSn("a123456789");
-//        camRegDto.setCameraType(10);
-//        list.add(camRegDto);
-
-
-        CamRegDto camRegDto1=new CamRegDto();
-        camRegDto1.setSn("dvt600001");
-//        camRegDto1.setToSn("c123456789");
-        camRegDto1.setCameraType(10);
-
-        list.add(camRegDto1);
-
+        CamRegDto camRegDto=new CamRegDto();
+        camRegDto.setSn("90d95cdb5");
+        camRegDto.setCameraType(9);
+        list.add(camRegDto);
 
+//
+//        CamRegDto camRegDto1=new CamRegDto();
+//        camRegDto1.setSn("bpvt00017");
+////        camRegDto1.setToSn("c123456789");
+//        camRegDto1.setCameraType(11);
+//
+//        list.add(camRegDto1);
+//
+//
         CamRegSDto CamReg=new CamRegSDto();
         CamReg.setMachineCode(machineCode);
         CamReg.setCamRegs(list);
         String camCode1 = uat.batchGenRegeditCamCode( CamReg);
+        log.info("生成相机注册码:{}",camCode1);
 
 //        List<CamRegDto> list1 = BatchParseRegeditCamCode(machineCode+"a",camCode1);
         CamRegSDto list1 = uat.BatchParseRegeditCamCode(machineCode,"eNoNkMcRwEAIA1simfAk9l+S78sIsWx9pOA4kEvEq3CERGl9PsI7zEQfiFdxp5E7RW6rBOxAiMaeJ1E1nwultClXAkdeBHwLyCOri2/yRc/6vM2OVPR7Xckc8m5FllZtfLtbMg11WV9Fumne94kjvUjX5w/RCfEjUGtBA/J7a+VggSlrZNqamH4dzaS0eEM5BL6kptXGkodVJxOgEAULAEx4CsnmeOwenoNk2+QGfUi1B1DxSuRBqMLMS4gy803lt4Jl+1KiT8XTgh1YBKul/rju4IuZznMdmJZPbI0H33eneNUNEPDkTyPdbPreA178qgLo43Iz/p5lsK+mZr8fQ+NmEw==");