Browse Source

Merge branch 'feature-v4-20220801'

# Conflicts:
#	4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ErrorCode.java
#	4dkankan-common-utils/src/main/java/com/fdkankan/common/util/OBJToGLBUtil.java
#	4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateHouseJsonUtil.java
#	4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateObjUtil.java
dsx 2 years ago
parent
commit
99b96c9925
100 changed files with 3216 additions and 3058 deletions
  1. 12 1
      .gitignore
  2. 7 57
      4dkankan-common-utils/pom.xml
  3. 27 8
      4dkankan-common-web/src/main/java/com/fdkankan/web/constant/CameraTypeEnum.java
  4. 37 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/CommonOperStatus.java
  5. 44 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/CommonSuccessStatus.java
  6. 0 15
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantUrl.java
  7. 27 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ErrorCode.java
  8. 2 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/FileBizType.java
  9. 38 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/FileSizeUnitType.java
  10. 12 4
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ImageUtil.java
  11. 27 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ModelKind.java
  12. 23 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneAsynFuncType.java
  13. 23 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneAsynModuleType.java
  14. 24 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneAsynOperType.java
  15. 2 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneConstant.java
  16. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneDownloadProgressStatus.java
  17. 13 2
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneFrom.java
  18. 4 15
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneResolution.java
  19. 45 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneScheme.java
  20. 1 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneSource.java
  21. 15 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneStatus.java
  22. 39 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneVersionType.java
  23. 40 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SpaceType.java
  24. 0 645
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/ComputerUtil.java
  25. 1 24
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/DataUtils.java
  26. 4 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/DateExtUtil.java
  27. 41 0
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileSizeUtil.java
  28. 0 435
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtil.java
  29. 426 595
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtils.java
  30. 6 3
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/OBJToGLBUtil.java
  31. 20 15
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/OkHttpUtils.java
  32. 23 16
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/PasswordUtils.java
  33. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/RandomUtil.java
  34. 32 5
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/StrExtUtil.java
  35. 0 61
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/StreamGobbler.java
  36. 0 76
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/TestUtil.java
  37. 0 163
      4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWord.java
  38. 0 169
      4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWordConfig.java
  39. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/ValidationUtils.java
  40. 0 26
      4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/Variable.java
  41. 3 14
      4dkankan-common-web/pom.xml
  42. 14 0
      4dkankan-common-web/src/main/java/com/fdkankan/web/annotation/CheckInnerApiPermit.java
  43. 10 0
      4dkankan-common-web/src/main/java/com/fdkankan/web/annotation/NotResponseAdvice.java
  44. 1 1
      4dkankan-common-web/src/main/java/com/fdkankan/web/config/ShiroConfig.java
  45. 2 2
      4dkankan-common-web/src/main/java/com/fdkankan/web/controller/BaseController.java
  46. 1 1
      4dkankan-common-web/src/main/java/com/fdkankan/web/controller/CustomErrorController.java
  47. 8 2
      4dkankan-common-web/src/main/java/com/fdkankan/web/exception/GlobalExceptionHandler.java
  48. 48 0
      4dkankan-common-web/src/main/java/com/fdkankan/web/interceptor/CheckInnerApiPermitAspect.java
  49. 1 1
      4dkankan-common-web/src/main/java/com/fdkankan/web/jwt/JwtFilter.java
  50. 1 1
      4dkankan-common-web/src/main/java/com/fdkankan/web/realm/UserJwtRealm.java
  51. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/request/RequestBase.java
  52. 10 6
      4dkankan-common-web/src/main/java/com/fdkankan/web/response/BaseResponseAdvice.java
  53. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/response/Result.java
  54. 2 6
      4dkankan-common-utils/src/main/java/com/fdkankan/common/response/ResultData.java
  55. 18 4
      4dkankan-common-web/src/main/java/com/fdkankan/web/user/SSOLoginHelper.java
  56. 29 3
      4dkankan-common-web/src/main/java/com/fdkankan/web/user/SSOLoginStore.java
  57. 2 0
      4dkankan-common-web/src/main/java/com/fdkankan/web/user/SSOUser.java
  58. 4 2
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/BASE64DecodedMultipartFile.java
  59. 4 11
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUpload.java
  60. 22 23
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/RSAEncrypt.java
  61. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/SpringUtil.java
  62. 56 4
      4dkankan-common-web/src/main/java/com/fdkankan/web/util/WebUtil.java
  63. 1 22
      4dkankan-utils-app-push/pom.xml
  64. 0 6
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/App.java
  65. 0 331
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/PushMessageConfig.java
  66. 0 86
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/UmengNotification.java
  67. 0 11
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidBroadcast.java
  68. 0 22
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidCustomizedcast.java
  69. 0 15
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidFilecast.java
  70. 0 16
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidGroupcast.java
  71. 2 1
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/AndroidNotification.java
  72. 0 2
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidUnicast.java
  73. 3 42
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/PushClient.java
  74. 89 0
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/common/UmengNotification.java
  75. 112 0
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/config/PushMessageConfig.java
  76. 0 12
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSBroadcast.java
  77. 0 23
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSCustomizedcast.java
  78. 0 15
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSFilecast.java
  79. 0 16
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSGroupcast.java
  80. 2 1
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/IOSNotification.java
  81. 0 2
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSUnicast.java
  82. 1 1
      4dkankan-utils-app-push/src/main/java/com/fdkankan/push/PushMsgUtil.java
  83. 2 2
      4dkankan-utils-db/pom.xml
  84. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/response/PageInfo.java
  85. 1 1
      4dkankan-common-utils/src/main/java/com/fdkankan/common/util/PageInfoUtils.java
  86. 2 2
      4dkankan-utils-dingtalk/pom.xml
  87. 64 0
      4dkankan-utils-elasticsearch/pom.xml
  88. 115 0
      4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/config/ElasticsearchConfig.java
  89. 60 0
      4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/DocumentService.java
  90. 45 0
      4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/IndexService.java
  91. 149 0
      4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/QueryDataService.java
  92. 141 0
      4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/impl/DocumentServiceImpl.java
  93. 106 0
      4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/impl/IndexServiceImpl.java
  94. 531 0
      4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/impl/QueryDataServiceImpl.java
  95. 1 2
      4dkankan-utils-email/pom.xml
  96. 27 0
      4dkankan-utils-fyun-https/pom.xml
  97. 314 0
      4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/HttpFileService.java
  98. 98 0
      4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/config/HttpFyunConfig.java
  99. 92 0
      4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/entity/Result.java
  100. 0 0
      4dkankan-utils-fyun-local/pom.xml

+ 12 - 1
.gitignore

@@ -30,9 +30,20 @@ hs_err_pid*
 # IntelliJ project files
 .idea
 *.iml
-/**/target/
 out
 gen
+/4dkankan-center-scene/target/
+/4dkankan-common/target/
+/4dkankan-gateway/target/
+/4dkankan-pom/target/
+/4dkankan-center-platform/target/
+/4dkankan-center-modeling/target/
+/4dkankan-center-statistics/target/
+/4dkankan-center-log/target/
+/4dkankan-center-auth/target/
+/4dkankan-sdk-oss/target/
+/**/target/
+
 
 /4dkankan-pom/src/test/java/TestAutoGenerate.java
 

+ 7 - 57
4dkankan-common-utils/pom.xml

@@ -6,7 +6,7 @@
     <parent>
         <groupId>com.fdkankan</groupId>
         <artifactId>4dkankan-utils</artifactId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>3.0.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -17,11 +17,7 @@
     </properties>
 
     <dependencies>
-        <dependency>
-            <groupId>com.google.protobuf</groupId>
-            <artifactId>protobuf-java</artifactId>
-            <version>3.2.0</version>
-        </dependency>
+
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
@@ -32,36 +28,28 @@
             <artifactId>fastjson</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.ant</groupId>
-            <artifactId>ant</artifactId>
-            <version>${ant-version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.bytedeco</groupId>
             <artifactId>javacv</artifactId>
             <version>1.4.3</version>
         </dependency>
 
         <dependency>
-            <groupId>org.bytedeco.javacpp-presets</groupId>
-            <artifactId>ffmpeg-platform</artifactId>
-            <version>4.0.2-1.4.3</version>
+            <groupId>org.bytedeco</groupId>
+            <artifactId>javacpp</artifactId>
+            <version>1.4.3</version>
         </dependency>
 
         <dependency>
             <groupId>org.bytedeco</groupId>
-            <artifactId>javacpp</artifactId>
+            <artifactId>javacv-platform</artifactId>
             <version>1.4.3</version>
         </dependency>
+
         <dependency>
             <groupId>joinery</groupId>
             <artifactId>jave</artifactId>
             <version>1.0.2.2</version>
         </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-        </dependency>
 
         <dependency>
             <groupId>com.alibaba</groupId>
@@ -69,12 +57,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-webmvc</artifactId>
-            <version>5.3.13</version>
-        </dependency>
-
-        <dependency>
             <groupId>com.auth0</groupId>
             <artifactId>java-jwt</artifactId>
             <version>3.10.3</version>
@@ -108,29 +90,6 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-pool2</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>commons-fileupload</groupId>
-            <artifactId>commons-fileupload</artifactId>
-            <version>1.4</version>
-            <scope>compile</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>com.google.zxing</groupId>
-            <artifactId>core</artifactId>
-            <version>2.1</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.google.zxing</groupId>
-            <artifactId>javase</artifactId>
-            <version>2.1</version>
-        </dependency>
 
         <dependency>
             <groupId>joda-time</groupId>
@@ -142,14 +101,5 @@
             <artifactId>okhttp</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-extension</artifactId>
-            <scope>compile</scope>
-            <version>3.4.3.4</version>
-        </dependency>
-
-
-
     </dependencies>
 </project>

+ 27 - 8
4dkankan-common-web/src/main/java/com/fdkankan/web/constant/CameraTypeEnum.java

@@ -1,26 +1,32 @@
-package com.fdkankan.web.constant;
+package com.fdkankan.common.constant;
 
 import java.util.HashMap;
 import java.util.Map;
 
 public enum CameraTypeEnum {
-    DOUBLE_EYE(0,"KK-","4DKKLITE_","旧双目相机"),
-    FDKK_PRO(1,"KK-","4DKKPRO_","四维看看pro八目相机"),
-    FDKK_LITE(2,"KK-","4DKKLITE_","四维看看lite"),
-    ZHIHOUSE_REDHOUSE(5,"KK-","4DKKLITE_","指房宝小红屋相机"),
-    DOUBLE_EYE_TURN(9,"KJ-","4DKKLITE_","双目转台"),
-    LASER_TURN(10,"SS-","4DKKLA_","激光转台");
+    DOUBLE_EYE(0,"KK-","4DKKLITE_","旧双目相机", "4DKanKan"),
+    FDKK_PRO(1,"KK-","4DKKPRO_","四维看看pro八目相机", "4DKanKan"),
+    FDKK_LITE(2,"KK-","4DKKLITE_","四维看看lite", "4DKanKan"),
+    ZHIHOUSE_REDHOUSE(5,"KK-","4DKKLITE_","指房宝小红屋相机", "4DKanKan"),
+    DOUBLE_EYE_TURN(9,"KJ-","4DKKLITE_","双目转台", "4DMinion"),
+    LASER_TURN(10,"SS-","4DKKLA_","激光转台", "4DMega"),
+    LASER_SG(11,"SG-","4DSG_","深光", "4DMega");
 
 
     private int type;
     private String sceneNumPrefix;
     private String wifiNamePrefix;
     private String desc;
+    private String cameraName;
 
     public int getType() {
         return type;
     }
 
+    public String getCameraName() {
+        return cameraName;
+    }
+
     public String getSceneNumPrefix() {
         return sceneNumPrefix;
     }
@@ -33,11 +39,12 @@ public enum CameraTypeEnum {
         }
     }
 
-    CameraTypeEnum(Integer type, String sceneNumPrefix, String wifiNamePrefix, String desc) {
+    CameraTypeEnum(Integer type, String sceneNumPrefix, String wifiNamePrefix, String desc, String cameraName) {
         this.type = type;
         this.sceneNumPrefix = sceneNumPrefix;
         this.wifiNamePrefix = wifiNamePrefix;
         this.desc = desc;
+        this.cameraName = cameraName;
     }
 
     public static String getSceneNumPrefixByType(Integer type){
@@ -47,4 +54,16 @@ public enum CameraTypeEnum {
         return "";
     }
 
+    public static CameraTypeEnum get(int type){
+        CameraTypeEnum[] values = CameraTypeEnum.values();
+        Integer enumValue = null;
+        for(CameraTypeEnum eachValue : values){
+            enumValue = eachValue.getType();
+            if(enumValue.equals(type)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
 }

+ 37 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/CommonOperStatus.java

@@ -0,0 +1,37 @@
+package com.fdkankan.common.constant;
+
+public enum CommonOperStatus {
+
+    WAITING(0, "等待中"),
+    SUCCESS(1, "成功"),
+    FAILD(-1, "失败");
+
+    private Integer code;
+    private String message;
+
+    private CommonOperStatus(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public Integer code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+    public static CommonOperStatus get(Integer code){
+        CommonOperStatus[] values = CommonOperStatus.values();
+        Integer enumValue = null;
+        for(CommonOperStatus eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+}

+ 44 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/CommonSuccessStatus.java

@@ -0,0 +1,44 @@
+package com.fdkankan.common.constant;
+
+/**
+ * <p>
+        是否成功状态枚举
+ * </p>
+ * @author dengsixing
+ * @date 2022/1/28
+ **/
+public enum CommonSuccessStatus {
+
+    FAIL(-1, "失败"),
+    WAITING(0, "等待"),
+    SUCCESS(1, "成功");
+
+    private Integer code;
+    private String message;
+
+    private CommonSuccessStatus(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public static CommonSuccessStatus get(Integer code){
+        CommonSuccessStatus[] values = CommonSuccessStatus.values();
+        Integer enumValue = null;
+        for(CommonSuccessStatus eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+    public Integer code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+}

+ 0 - 15
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ConstantUrl.java

@@ -1,24 +1,9 @@
 package com.fdkankan.common.constant;
 
 public class ConstantUrl {
-
-    //	public static final String MAIN_URL = "https://www.4dkankan.com/";
-//	public static final String MAIN_URL = "http://120.79.15.136:8086/";
-//	public static final String MAIN_URL2 = "https://www.4dkankan.com/";
-//	public static final String DEFAULT_USER_HEAD = "https://scene3d.4dage.com/head.png";
     public static final String DEFAULT_USER_HEAD = "https://4dkk.4dage.com/newHead.png";
     public static final String BBS_TOUPLOAD = "https://scene3d.4dage.com/model/upload/image/";
-    public static final String DEFAULT_PREFIX_QINIU_PIC = "http://orw69myb5.bkt.clouddn.com/";
     public static final String DEFAULT_SCENE_PIC="https://4dkk.4dage.com/loading/thumb.jpg";
-//	public static final String SCENE_URL = MAIN_URL + "show.html?m=";
-//	public static final String SCENE_URL2 = MAIN_URL + "showV2.html?m=";
-
-    //	public static final String PRO_SCENE_URL = MAIN_URL + "showProMobile.html?m=";
-    public static final String PREFIX_ALI = "https://4dkk.4dage.com/";
-    //亚马逊S3
-    public static final String PREFIX_AWS = "https://testeurs3.4dkankan.com/";
-    public static final String PREFIX_QINIU = "https://scene3d.4dage.com/";
-    public static final String PREFIX_QINIU2 = "https://creator.4dkankan.com/";
     public static final String WEIXIN_PAYURL = "https://www.4dkankan.com/weixinmobilepay/weixinInfo?orderId=";
     public static final String WEIXIN_TOKEN_URL1 = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=";
     public static final String WEIXIN_TOKEN_URL2 = "https://api.weixin.qq.com/sns/userinfo?access_token=";

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

@@ -9,6 +9,8 @@ public enum ErrorCode {
     SYSTEM_BUSY(-5, "系统繁忙,请稍后再试!"),
 
     HAVE_NO_RIGHT(1001, "无权访问!"),
+    APP_KEY_IS_NULL(1002, "appkey为空"),
+    APP_KEY_ILLEGAL(1003, "appkey不正确"),
 
 
     AUTH_FAIL(4000, "鉴权失败!"),
@@ -80,6 +82,12 @@ public enum ErrorCode {
     FAILURE_CODE_3032(3032, "当前相机已被授权,请选择另外相机绑定"),
     FAILURE_CODE_3033(3033, "60秒内不能重复获取验证码"),
 
+    FAILURE_CODE_4001(4001, "缺少必要文件:%s"),
+    FAILURE_CODE_4002(4002, "文件不存在:%s"),
+    FAILURE_CODE_4003(4003, "图片大小不能超过:%s"),
+    FAILURE_CODE_4004(4004, "此接口仅支持看看和看见相机场景"),
+    FAILURE_CODE_4005(4005, "已超出容量,不允许重新上传"),
+
 
     FAILURE_CODE_5001(5001, "modeldata.json为空"),
     FAILURE_CODE_5002(5002, "order值为空"),
@@ -144,8 +152,18 @@ public enum ErrorCode {
     FAILURE_CODE_5061(5061, "该压缩包无可用jpg文件"),
     FAILURE_CODE_5062(5062, "无可用jpg文件"),
     FAILURE_CODE_5063(5063, "下载失败"),
-    FAILURE_CODE_5064(5064, "导览视频上传中,请稍后重试"),
+    FAILURE_CODE_5064(5064, "场景版本低于V4,不能执行此操作"),
     FAILURE_CODE_5065(5065, "所有文件如贴图、obj、mtl等需要放在根目录同一个文件夹中"),
+    FAILURE_CODE_5066(5066, "批量上传或下载任务正在处理中"),
+    FAILURE_CODE_5067(5067, "此场景不支持计算"),
+    FAILURE_CODE_5068(5068, "floors.json文件不存在"),
+    FAILURE_CODE_5069(5069, "floors.json文件数据不正常"),
+    FAILURE_CODE_5070(5070, "楼层文件数据不正常"),
+    FAILURE_CODE_5071(5071, "复制场景不支持重算"),
+    FAILURE_CODE_5072(5072, "相机原始资源已被删除,不支持重算"),
+    FAILURE_CODE_5073(5073, "相机原始资源正在被清除"),
+
+    FAILURE_CODE_6003(6003, "该相机未被绑定,请前往 我的相机 先绑定相机后再进行授权 "),
 
 
     FAILURE_CODE_7001(7001, "激光场景状态同步失败,请重试!"),
@@ -185,6 +203,14 @@ public enum ErrorCode {
     FAILURE_CODE_9003(9003, "快递单号不能为空"),
     FAILURE_CODE_9004(9004, "查询不到开票信息"),
 
+    //-----------------openApi----------------------start
+    FAILURE_CODE_10000(10000, "appkey未启用"),
+    FAILURE_CODE_10001(10001, "appkey未生效"),
+    FAILURE_CODE_10002(10002, "账号已存在,请勿重复创建"),
+    FAILURE_CODE_10003(10003, "账号不存在"),
+    FAILURE_CODE_10004(10004, "api次数不能为空")
+    //-----------------openApi----------------------end
+
 
 
     ;

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

@@ -13,7 +13,8 @@ public enum FileBizType {
     TAG_ICON("tag-icon", "热点图标"),
     LINK_STYLE("link-style", "场景关联图标"),
     WATERMARK("waterMark", "水印"),
-    BOX_POSTER("box-poster", "空间视频封面图")
+    BOX_POSTER("box-poster", "空间视频封面图"),
+    BILLBOARD_ICON("billboard-icon", "指示牌")
     ;
 
     private String code;

+ 38 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/FileSizeUnitType.java

@@ -0,0 +1,38 @@
+package com.fdkankan.common.constant;
+
+/**
+ * 文件业务类型
+ */
+public enum FileSizeUnitType {
+
+    B("B"),
+    KB("KB"),
+    MB("MB"),
+    GB("GB"),
+    TB("TB"),
+    PB("PB")
+    ;
+
+    private String code;
+
+    private FileSizeUnitType(String code) {
+        this.code = code;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public static FileSizeUnitType get(String code){
+        FileSizeUnitType[] values = FileSizeUnitType.values();
+        String enumValue = null;
+        for(FileSizeUnitType eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+}

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

@@ -1,5 +1,10 @@
 package com.fdkankan.common.constant;
 
+import cn.hutool.core.img.ImgUtil;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -78,10 +83,13 @@ public class ImageUtil {
         return stringBuilder.toString();
     }
 
-    public static void main(String[] args) throws Exception{
-        FileInputStream fis = new FileInputStream(new File("F:\\test\\1.png"));
-        boolean image = ImageUtil.isImage(fis);
-        System.out.println(image);
+    public static void main(String[] args) throws IOException {
+        ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+        String path = "G:\\home\\backend\\4dkankan_v4\\sale\\file\\sale\\file\\test\\5474a1e8d93747f3aec79e6021c10a3b.png";
+        String picType = getPicType(new FileInputStream(path));
+        System.out.println(picType);
+        BufferedImage read = ImgUtil.read(new File(path));
+        ImageIO.write(read, "png", byteArrayOut);
     }
 
 }

+ 27 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/ModelKind.java

@@ -0,0 +1,27 @@
+package com.fdkankan.common.constant;
+
+/**
+ * 算法计算生成模型类型
+ */
+public enum ModelKind {
+
+    DAM("dam", "dam"),
+    THREE_D_TILE("3dtiles", "3dtiles");
+
+    private String code;
+    private String message;
+
+    private ModelKind(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+}

+ 23 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneAsynFuncType.java

@@ -0,0 +1,23 @@
+package com.fdkankan.common.constant;
+
+public enum SceneAsynFuncType {
+
+    PANORAMIC_IMAGE("panorama", "全景图");
+
+    private String code;
+    private String message;
+
+    private SceneAsynFuncType(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+}

+ 23 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneAsynModuleType.java

@@ -0,0 +1,23 @@
+package com.fdkankan.common.constant;
+
+public enum SceneAsynModuleType {
+
+    UPLOAD_DOWNLOAD("repair", "上传下载");
+
+    private String code;
+    private String message;
+
+    private SceneAsynModuleType(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+}

+ 24 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneAsynOperType.java

@@ -0,0 +1,24 @@
+package com.fdkankan.common.constant;
+
+public enum SceneAsynOperType {
+
+    UPLOAD("upload", "上传"),
+    DOWNLOAD("download", "下载");
+
+    private String code;
+    private String message;
+
+    private SceneAsynOperType(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+}

+ 2 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneConstant.java

@@ -115,4 +115,6 @@ public class SceneConstant {
     public static final int FAILURE_CODE_5037 = 5037;
     public static final String FAILURE_MSG_5037 = "场景正在计算中,请待计算完成后再操作。";
 
+    public static final int FAILURE_CODE_5038 = 5038;
+    public static final String FAILURE_MSG_5038 = "生成 obj 失败,请重算场景。";
 }

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

@@ -4,7 +4,7 @@ package com.fdkankan.common.constant;
  * 场景下载进度码
  */
 public enum SceneDownloadProgressStatus {
-
+    QUEUEING(0, "排队中"),
     DOWNLOADING(1000, "文件正在下载"),
     DOWNLOAD_COMPRESSING(1001, "文件正在压缩"),
     DOWNLOAD_SUCCESS(1002, "文件压缩成功/下载处理成功"),

+ 13 - 2
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneFrom.java

@@ -9,8 +9,7 @@ public enum SceneFrom {
     PRO("pro", "八目相机 "),
     MINION("minion", "双面转台相机"),
     LASER("laser", "激光相机"),
-    VIRTUAL("virtual", "虚拟场景"),
-    SKETCH("sketch", "图片建模场景")
+    SXZ("sxz", "SXZ虚拟场景")
     ;
 
     private String code;
@@ -29,4 +28,16 @@ public enum SceneFrom {
         return message;
     }
 
+    public static SceneFrom get(String code){
+        SceneFrom[] values = SceneFrom.values();
+        String enumValue = null;
+        for(SceneFrom eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
 }

+ 4 - 15
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneResolution.java

@@ -5,29 +5,18 @@ package com.fdkankan.common.constant;
  */
 public enum SceneResolution {
 
-    TILES("tiles", "切片"),
-    TILES_1K("tiles/1k", "1k瓦片图"),
-    TILES_2K("tiles/2k", "2k瓦片图 "),
-    TILES_4K("tiles/4k", "4k瓦片图"),
-    PAN("pan", "全景图"),
-    LOCAL("local", "本地切片"),
-    CUBE("cube", "立体图")
-    ;
+    one_k("1k"),
+    two_K("2k"),
+    four_K("4k"),;
 
     private String code;
-    private String message;
 
-    private SceneResolution(String code, String message) {
+    private SceneResolution(String code) {
         this.code = code;
-        this.message = message;
     }
 
     public String code() {
         return code;
     }
 
-    public String message() {
-        return message;
-    }
-
 }

+ 45 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SceneScheme.java

@@ -0,0 +1,45 @@
+package com.fdkankan.common.constant;
+
+/**
+ * 场景来源
+ */
+public enum SceneScheme {
+
+    SM(1, "双目"),
+    ZT(2, "转台"),
+    LM(3, "六目"),
+    BM(4, "八目"),
+    FOUR_K(10, "获取4K图"),
+    TWO_K(11, "获取2K图"),
+    TWELVE_K(12, "获取1k图"),
+    ;
+
+    private Integer code;
+    private String message;
+
+    private SceneScheme(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public Integer code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+    public static SceneScheme get(Integer code){
+        SceneScheme[] values = SceneScheme.values();
+        Integer enumValue = null;
+        for(SceneScheme eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+}

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

@@ -9,6 +9,7 @@ public enum SceneSource {
     SM(2, "双目"),
     ZT(3, "转台"),
     JG(4, "激光"),
+    SG(5, "深光"),
     YJHZ(11, "一键换装");
 
     private Integer code;

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

@@ -5,7 +5,9 @@ public enum SceneStatus {
     wait(0, "未建好"),
     SUCCESS(1, "已建好"),
     FAILD(-1, "出错"),
-    NO_DISPLAY(-2, "不要在官网上显示");
+    NO_DISPLAY(-2, "不要在官网上显示"),
+    EXCEED_SPACE(-3, "超出容量,未计算")
+    ;
 
     private Integer code;
     private String message;
@@ -23,4 +25,16 @@ public enum SceneStatus {
         return message;
     }
 
+    public static SceneStatus get(Integer code){
+        SceneStatus[] values = SceneStatus.values();
+        Integer enumValue = null;
+        for(SceneStatus eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
 }

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

@@ -0,0 +1,39 @@
+package com.fdkankan.common.constant;
+
+/**
+ * 操作类型枚举
+ */
+public enum SceneVersionType {
+
+    V3("V3", "V3"),
+    V4("V4", "V4");
+
+    private String code;
+    private String message;
+
+    private SceneVersionType(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+    public static SceneVersionType get(String code){
+        SceneVersionType[] values = SceneVersionType.values();
+        String enumValue = null;
+        for(SceneVersionType eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+}

+ 40 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/SpaceType.java

@@ -0,0 +1,40 @@
+package com.fdkankan.common.constant;
+
+/**
+ * 容量统计方式
+ */
+public enum SpaceType {
+
+    GB("GB", "按容量"),
+    SP("SP", "按个数"),
+    ;
+
+    private String code;
+    private String message;
+
+    private SpaceType(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+    public static SpaceType get(String code){
+        SpaceType[] values = SpaceType.values();
+        String enumValue = null;
+        for(SpaceType eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+}

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

@@ -1,645 +0,0 @@
-package com.fdkankan.common.util;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ConstantFileName;
-import com.fdkankan.common.constant.ConstantFilePath;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.constant.UploadFilePath;
-import com.fdkankan.common.exception.BusinessException;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import java.io.File;
-import java.util.*;
-
-/**
- * 生成场景和计算场景
- * Created by Hb_zzZ on 2019/5/8.
- */
-@Slf4j
-@Component
-public class ComputerUtil {
-
-
-    public static Map<String,String> computer(String projectNum, String path, String buildType) throws Exception{
-
-        Map<String,String> map = new HashMap<String,String>();
-        path = path.replace("//", "/");
-        log.info("开始建模:"+projectNum);
-        //构建算法isModel去掉,因此改成空字符串
-        if("V2".equals(buildType)){
-            CreateObjUtil.build3dModelOld(path, "");
-        }
-        if("V3".equals(buildType)){
-            CreateObjUtil.build3dModel(path, "");
-//        CreateObjUtil.build3dModel(unicode, "");
-        }
-        log.info("建模完成转换数据:"+projectNum);
-
-        boolean vision2 = false;
-        //读取upload文件,检验需要上传的文件是否存在
-        String uploadJsonPath = path + File.separator + "results" +File.separator+"upload.json";
-        String uploadData = FileUtils.readFile(uploadJsonPath);
-        log.info("upload.json 文件路径:{}, 内容:{}" , uploadJsonPath, uploadData);
-        JSONObject uploadJson = null;
-        JSONArray array = null;
-        if(uploadData!=null) {
-            uploadJson = JSONObject.parseObject(uploadData);
-            array = uploadJson.getJSONArray("upload");
-        }
-        if(array == null){
-            String instanceId = FileUtils.readFile("/opt/hosts/hosts.txt");
-            FileUtils.writeFile(path + File.separator + "javaErrorNow.log", instanceId + ":计算错误!");
-
-            Thread.sleep(10000L);
-            FileUtils.writeFile(path + File.separator + "javaError.log", instanceId + ":计算错误!");
-            throw new Exception("upload.json数据出错");
-        }
-        JSONObject fileJson = null;
-        String fileName = "";
-        for(int i = 0, len = array.size(); i < len; i++){
-            fileJson = array.getJSONObject(i);
-            fileName = fileJson.getString("file");
-            //文件不存在抛出异常
-            if(!new File(path + File.separator + "results" +File.separator + fileName).exists()){
-                throw new Exception(path + File.separator + "results" +File.separator + fileName+"文件不存在");
-            }
-
-            //判断是否有vision2.txt
-            if("vision2.txt".equals(fileName)){
-                vision2 = true;
-            }
-
-            //tex文件夹
-            if(fileJson.getIntValue("clazz") == 2 ){
-                map.put(path + File.separator + "results" +File.separator+ fileName,
-                        "images/images"+projectNum+"/"+ ConstantFileName.modelUUID+"_50k_texture_jpg_high1/"+fileName.replace("tex/", ""));
-                continue;
-            }
-
-            //high文件夹
-            if(fileJson.getIntValue("clazz") == 3){
-                map.put(path + File.separator + "results" +File.separator+ fileName,
-                        "images/images"+ projectNum+"/pan/high/"+ fileName.replace("high/", ""));
-                continue;
-            }
-            //low文件夹
-            if(fileJson.getIntValue("clazz") == 4){
-                map.put(path + File.separator + "results" +File.separator+ fileName,
-                        "images/images"+ projectNum+"/pan/low/"+ fileName.replace("low/", ""));
-                continue;
-            }
-
-            //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
-//            if(fileJson.getIntValue("clazz") == 5 && !"s3".equals(ossType)){
-//                map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
-//                        projectNum+ File.separator + fileName);
-//                continue;
-//            }
-            if(fileJson.getIntValue("clazz") == 5 ){
-                map.put(path + File.separator + "results" + File.separator+ fileName,
-                        "images/images"+ projectNum+ File.separator + fileName);
-                continue;
-            }
-
-            //tiles文件夹,亚马逊瓦片图
-            if(fileJson.getIntValue("clazz") == 7 ){
-                if(fileName.contains("/4k_")){
-                    continue;
-                }
-                map.put(path + File.separator + "results" + File.separator+ fileName,
-                        "images/images"+ projectNum+ File.separator + fileName);
-                continue;
-            }
-
-            //updown文件复制一份到ecs中并去掉换行符
-            if(fileJson.getIntValue("clazz") == 10){
-                // TODO: 2022/5/6 v3停机后需要删除-----------------------------------------------------------------------start
-                String updown = FileUtils.readFile(path + File.separator + "results" +File.separator+ fileName);
-                JSONObject updownJson = JSONObject.parseObject(updown);
-                FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + projectNum +
-                        File.separator + fileName.replace("updown", "mapping"), updownJson.toString());
-                // TODO: 2022/5/6 v3停机后需要删除-----------------------------------------------------------------------end
-
-                String mappingOssPath = String.format(UploadFilePath.DATA_EDIT_PATH, projectNum) + fileName.replace("updown", "mapping");
-                map.put(path + File.separator + "results" + File.separator+ fileName, mappingOssPath);
-
-                continue;
-            }
-
-            //video视频文件或封面图
-            if(fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("clazz") == 12){
-                map.put(path + File.separator + "results" + File.separator+ fileName,"video/video"+
-                        projectNum+ File.separator + fileName.replace("videos/", ""));
-
-                if(fileName.contains(".mp4")){
-//                    CreateObjUtil.mp4ToFlv(path + File.separator + "results" + File.separator+ fileName,
-//                            path + File.separator + "results" + File.separator+ fileName.replace("mp4", "flv"));
-
-                    map.put(path + File.separator + "results" + File.separator+ fileName.replace("mp4", "flv"),
-                            "video/video"+ projectNum+ File.separator + fileName.replace("videos/", "").replace("mp4", "flv"));
-                }
-            }
-
-            //2048的模型和贴图
-            if(fileJson.getIntValue("clazz") == 16){
-                map.put(path + File.separator + "results" + File.separator+ fileName,
-                        "data/data"+ projectNum+ File.separator + fileName);
-            }
-
-            if(fileJson.getIntValue("clazz") == 18){
-                map.put(path + File.separator + "results" + File.separator+ fileName,
-                        "images/images"+ projectNum+ File.separator + fileName);
-            }
-        }
-
-        CreateObjUtil.convertTxtToDam( path + File.separator + "results" + File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k.dam");
-        CreateObjUtil.convertDamToLzma(path + File.separator + "results");
-        CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k.dam");
-
-        //8目相机有两个vision.txt因此第二个叫vision2.txt
-        CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
-        if(vision2){
-            CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision2.txt",path + File.separator + "results" +File.separator+"vision2.modeldata");
-            map.put(path + File.separator + "results" +File.separator+"vision2.modeldata","images/images"+projectNum+"/"+"vision2.modeldata");
-        }else {
-            CreateObjUtil.convertTxtToVisionmodeldataCommon(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
-        }
-        log.info("数据转换完成:"+projectNum);
-
-        File file = new File(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma");
-        while(!file.exists()){
-            Thread.sleep(60000);
-        }
-
-        map.put(path + File.separator + "results" + File.separator + "vision.modeldata", "images/images" + projectNum + "/" + "vision.modeldata");
-        map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", "images/images" + projectNum + "/" + ConstantFileName.modelUUID + "_50k.dam.lzma");
-        map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", "images/images" + projectNum + "/" + ConstantFileName.modelUUID + "_50k.dam");
-        file = new File(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum);
-        if(!file.exists()){
-            file.mkdir();
-        }
-        FileUtils.copyFile(path + File.separator + "results" +File.separator+"floor.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floor.json", true);
-        FileUtils.copyFile(path + File.separator + "results" +File.separator+"floorplan.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floor.json", true);
-        FileUtils.copyFile(path + File.separator + "results" +File.separator+"floorplan.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floorplan.json", true);
-        log.info("floor.json路径:"+ path + File.separator + "results" +File.separator+"floor.json");
-        map.put(path + File.separator + "results" +File.separator+"floor.json","data/data"+projectNum+"/floor.json");
-        map.put(path + File.separator + "results" +File.separator+"floorplan.json","data/data"+projectNum+"/floor.json");
-        map.put(path + File.separator + "results" +File.separator+"floorplan_cad.json","data/data"+projectNum+"/floorplan_cad.json");
-        log.info("准备上传文件到oss:"+projectNum);
-        return map;
-    }
-
-    public static Map<String,String> computerRebuildVideo(String projectNum, String path) throws Exception{
-
-        String videosPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, projectNum);     //新版本文件路径
-
-        Map<String,String> map = new HashMap<String,String>();
-        path = path.replace("//", "/");
-
-        log.info("开始建模:"+projectNum);
-        //构建算法isModel去掉,因此改成空字符串
-        CreateObjUtil.build3dModel(path, "");
-        log.info("建模完成转换数据:"+projectNum);
-
-        boolean vision2 = false;
-        //读取upload文件,检验需要上传的文件是否存在
-        String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
-        JSONObject uploadJson = null;
-        JSONArray array = null;
-        if(uploadData!=null) {
-            uploadJson = JSONObject.parseObject(uploadData);
-            array = uploadJson.getJSONArray("upload");
-        }
-
-        if(array == null){
-            String instanceId = FileUtils.readFile("/opt/hosts/hosts.txt");
-            FileUtils.writeFile(path + File.separator + "javaErrorNow.log", instanceId + ":计算错误!");
-
-            Thread.sleep(10000L);
-            FileUtils.writeFile(path + File.separator + "javaError.log", instanceId + ":计算错误!");
-            throw new Exception("upload.json数据出错");
-        }
-
-        JSONObject fileJson = null;
-        String fileName = "";
-        for(int i = 0, len = array.size(); i < len; i++) {
-            fileJson = array.getJSONObject(i);
-            fileName = fileJson.getString("file");
-            //文件不存在抛出异常
-            if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
-                throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
-            }
-
-            //video视频文件或封面图
-            if (fileJson.getIntValue("clazz") == 20) {
-                if (fileName.contains(".flv")) {
-                    map.put(path + File.separator + "results" + File.separator + fileName,
-                            "video/video" + projectNum + File.separator + fileName.replace("videos/", ""));
-                    //todo 待删除oldPath
-                    map.put(path + File.separator + "results" + File.separator + fileName,
-                            videosPath + fileName.replace("videos/", ""));
-                }
-
-                if (fileName.contains(".mp4")) {
-                    map.put(path + File.separator + "results" + File.separator + fileName,
-                            "video/video" + projectNum + File.separator + fileName.replace("videos/", ""));
-
-                    map.put(path + File.separator + "results" + File.separator + fileName,
-                            videosPath+ fileName.replace("videos/", ""));
-                }
-            }
-        }
-
-        log.info("准备上传文件到oss:"+projectNum);
-        return map;
-    }
-
-    /**
-     *  标定算法
-     * @param path
-     * @throws Exception
-     */
-    public static Map<String,String> computerCalibration(String path) throws Exception{
-
-        Map<String,String> map = new HashMap<String,String>();
-
-        log.info("开始标定:" );
-        //构建算法isModel去掉,因此改成空字符串
-        CreateObjUtil.build3dModel(path, "");
-//        CreateObjUtil.build3dModel(unicode, "");
-        log.info("标定完成转换数据:" );
-
-        boolean vision2 = false;
-        //读取upload文件,检验需要上传的文件是否存在
-        String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
-        JSONObject uploadJson = null;
-        JSONArray array = null;
-        if(uploadData!=null) {
-            uploadJson = JSONObject.parseObject(uploadData);
-            array = uploadJson.getJSONArray("upload");
-        }
-        if(array == null){
-            throw new Exception("upload.json数据出错");
-        }
-        JSONObject fileJson = null;
-        String fileName = "";
-        for(int i = 0, len = array.size(); i < len; i++) {
-            fileJson = array.getJSONObject(i);
-            fileName = fileJson.getString("file");
-            //文件不存在抛出异常
-            if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
-                throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
-            }
-
-            if(fileJson.getIntValue("clazz") == 13 || fileJson.getIntValue("clazz") == 14){
-                map.put(path + File.separator + "results" +File.separator+ fileName,
-                        ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") +
-                                File.separator + fileName);
-            }
-        }
-        return map;
-    }
-//
-    public static void createJson(String path, String splitType, String skyboxType, String dataDescribe,
-                                  String sceneNum, String dataSource) throws Exception{
-        JSONObject projectJson = new JSONObject();
-        projectJson.put("version", "201909231830");
-        projectJson.put("protocol", "file api 1.4");
-        projectJson.put("uuid", UUID.randomUUID().toString());
-        projectJson.put("description", "");
-        projectJson.put("time", System.currentTimeMillis());
-        projectJson.put("category", "default");
-        projectJson.put("tag", null);
-        projectJson.put("status", null);
-        projectJson.put("sceneNum", sceneNum);
-        projectJson.put("dataSource", dataSource);
-        FileUtils.writeFile(path + File.separator + "project.json", projectJson.toString());
-
-        JSONObject dataJson = new JSONObject();
-        dataJson.put("split_type", splitType);
-        dataJson.put("skybox_type", skyboxType);
-        dataJson.put("extras", null);
-        FileUtils.writeFile(path + File.separator + "data.json", dataJson.toString());
-    }
-
-    public static void createExtras(String rebuildParam, String hdrParam, String path) throws Exception {
-
-        FileUtils.writeFile( path + File.separator + "extras" + File.separator + "videos_hdr_param.json", hdrParam);
-
-        FileUtils.writeFile( path + File.separator + "extras" + File.separator + "required_videos.json", rebuildParam);
-
-    }
-
-    public static void createExtras(String rebuildParam,String path) throws Exception {
-        FileUtils.writeFile( path + File.separator + "extras" + File.separator + "image-ROI.json", rebuildParam);
-    }
-
-    /**
-     * 生成标定数据
-     * @param calPath
-     * @param prefix
-     * @throws Exception
-     */
-    public static void createCalibrationData(String calPath, String prefix) throws Exception{
-        File calFile = new File(calPath);
-        if(calFile.exists()){
-            calFile.mkdirs();
-        }
-        //删除results和capture文件夹
-        FileUtils.deleteDirectory(calPath + "/capture");
-        FileUtils.deleteDirectory(calPath + "/results");
-
-//        CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + prefix, calPath + "/capture");
-        for(File oldFile : new File(prefix).listFiles()){
-            FileUtils.copyFile(oldFile.getAbsolutePath(), calPath + "/capture/" + oldFile.getName(), true);
-        }
-        JSONObject dataJson = new JSONObject();
-        dataJson.put("split_type", "SPLIT_V7");
-        dataJson.put("skybox_type", "SKYBOX_V5");
-        FileUtils.writeFile(calPath + "/data.json", dataJson.toString());
-    }
-
-    public static Map<String, String> getTypeString(String cameraType, String algorithm, String resolution){
-        Map<String, String> map = new HashMap<String, String>();
-        String splitType = "";
-        String skyboxType = "";
-        String dataDescribe = "";
-        if(Integer.parseInt(cameraType) >= 4){
-            if("0".equals(resolution)){
-//            skyboxType = "SKYBOX_V4";  //tiles
-//            skyboxType = "SKYBOX_V6";    //high,low,4k
-                skyboxType = "SKYBOX_V7";    //high,low,2k
-            }else {
-                skyboxType = "SKYBOX_V1";
-            }
-            splitType = "SPLIT_V1";
-//            skyboxType = "SKYBOX_V4";  //tiles
-            dataDescribe = "double spherical";
-
-            if(Integer.parseInt(cameraType) == 5 ){
-                //新双目相机
-//              skyboxType = "SKYBOX_V9";
-                splitType = "SPLIT_V9";
-                skyboxType = "SKYBOX_V1";
-            }
-            if(Integer.parseInt(cameraType) == 6){
-                //小红屋新双目相机
-//                    skyboxType = "SKYBOX_V9";
-                splitType = "SPLIT_V3";
-                skyboxType = "SKYBOX_V7";
-            }
-
-            if(Integer.parseInt(cameraType) == 13){
-                //转台相机
-                skyboxType = "SKYBOX_V6";
-                splitType = "SPLIT_V12";
-            }
-
-            if(Integer.parseInt(cameraType) == 14){
-                //转台相机
-                log.info("激光转台相机调用算法");
-                skyboxType = "SKYBOX_V11";
-                splitType = "SPLIT_V14";
-            }
-
-        }else {
-            if("sfm".equals(algorithm)){
-                splitType = "SPLIT_V2";
-                skyboxType = "SKYBOX_V1";
-                dataDescribe = "old sfm";
-            }else {
-                splitType = "SPLIT_V3";
-                skyboxType = "SKYBOX_V1";
-                dataDescribe = "old slam";
-            }
-        }
-        map.put("splitType", splitType);
-        map.put("skyboxType", skyboxType);
-        map.put("dataDescribe", dataDescribe);
-        return map;
-    }
-
-//    public static SceneEntity createScene(String projectNum, Long cameraId, String cameraName, String phoneId, String scenepsd,
-//                                          String unicode, Long cameraType, String fileId, String prefix,
-//                                          String imgsName, String pic, String isModel, Long userId, String userName,
-//                                          String algorithm, Integer sceneShootCount, String sceneName,
-//                                          String sceneDec, Integer sceneType, String gps, ISceneService sceneService,
-//                                          Integer type, ModelingMsgProducer producer, String url, String ecsType,
-//                                          RubberSheetingUtil rubberSheetingUtil)throws Exception{
-//        //先返回链接地址
-//        SceneEntity scene = new SceneEntity();
-//        scene.setWebSite(url+projectNum);
-//        scene.setCameraId(cameraId);
-//        scene.setPhoneId(phoneId);
-//        scene.setNum(String.valueOf(projectNum));
-//        if(scenepsd == null)
-//        {
-//            scenepsd = "";
-//        }
-//        if(!scenepsd.equals(""))
-//        {
-//            scene.setSceneKey(scenepsd);
-//        }
-//
-//        if(!StringUtils.isEmpty(ecsType)){
-//            scene.setEcs(ecsType);
-//        }
-//
-//        String path =  ConstantFilePath.BUILD_MODEL_PATH + unicode;
-//
-//        if(cameraType.longValue() >= 4){
-//            scene.setDataSource(ConstantFilePath.BUILD_MODEL_PATH +
-//                    cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode);
-//        }else {
-//            scene.setDataSource(prefix+imgsName);
-//        }
-//
-//        if(cameraType.longValue() == 14){
-//
-//            scene.setDataSource(ConstantFilePath.BUILD_MODEL_LASER_PATH +
-//                    cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator +
-//                    fileId + File.separator + unicode);
-//
-//            log.info("激光相机 dataSource :" + scene.getDataSource());
-//
-//        }
-//
-//
-//        if(pic!=null&&pic.length()>5)
-//        {
-//            scene.setThumb(pic);
-//        }
-//        else
-//        {
-//            scene.setThumb(ConstantUrl.DEFAULT_SCENE_PIC);
-//        }
-//
-//        String parametr = "";
-//        parametr+=unicode+":;"+path+":;"+prefix+":;"+imgsName+":;"+projectNum+":;"+isModel;
-//        if(userName!=null&&!userName.trim().equals(""))
-//        {
-//            parametr+=":;"+userName;
-//            scene.setUserId(userId);
-//        }
-//        else
-//        {
-//            parametr+=":;noMan";
-//        }
-//        parametr+=":;"+cameraType;
-//        parametr+=":;"+algorithm;
-//        parametr += ":;" + fileId;
-//        parametr += ":;" + cameraName;
-//        parametr += ":;1";
-//        log.info("大场景添加到队列:"+parametr);
-//        producer.sendMsg(parametr);
-//
-//        if(sceneShootCount == null)
-//        {
-//            scene.setShootCount(0);
-//        }
-//        else
-//        {
-//            scene.setShootCount(sceneShootCount);
-//        }
-//        if(sceneName!=null)
-//        {
-//            scene.setSceneName(sceneName);
-//        }
-//        if(sceneDec!=null)
-//        {
-//            scene.setSceneDec("<p>"+sceneDec+"</p>");
-//        }
-//
-//        if(sceneType!=null)
-//        {
-//            scene.setSceneType(sceneType);
-//        }
-//
-//        if(gps!=null&&!gps.trim().equals(""))
-//        {
-//            scene.setGps(gps);
-//        }
-//
-//        scene.setSceneScheme(cameraType.intValue());
-//        scene.setAlgorithm(algorithm);
-//        log.info("场景记录添加到数据库:"+projectNum);
-//        if(type == 0){
-//            sceneService.save(scene);
-//        }
-//
-//        JSONObject scenejson = JSONObject.parseObject(JSONObject.toJSONString(scene));
-//        scenejson.put("thumbImg", 0);
-//        scenejson.put("version", 0);
-//        scenejson.put("floorLogo", 0);
-//        if(!scenepsd.equals("")){
-//            scenejson.put("scenePsd", scenepsd);
-//            scenejson.put("public", 1);
-//        }else{
-//            scenejson.put("scenePsd", "");
-//            scenejson.put("public", 0);
-//        }
-//        if(cameraType < 4){
-//            scenejson.put("visions", 1);
-//        }else {
-//            scenejson.put("visions", 2);
-//        }
-//        scenejson.put("createTime", new DateTime(new Date()).toString("yyyy-MM-dd HH:mm"));
-//
-//        File file = new File(ConstantFilePath.SCENE_PATH+"data/data"+projectNum);
-//        if(!file.exists()||!file.isDirectory())
-//        {
-//            file.mkdirs();
-//        }
-//        FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", scenejson.toString());
-//
-//        //生成二维码
-//        MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", null);
-//        MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", null);
-//        log.info("二维码生成完成");
-//
-//        return scene;
-//    }
-
-
-    public static String getMQMsg(String projectNum, String cameraName, String unicode, Long cameraType, String fileId,
-                                  String prefix, String imgsName, String isModel,String userName,
-                                  String algorithm, Integer resolution, String buildType, String path) {
-        String parametr = "";
-        parametr+= unicode +":;"+ path +":;"+ prefix +":;"+ imgsName +":;"+ projectNum +":;"+ isModel;
-        if(userName !=null&&!userName.trim().equals("")){
-            parametr+=":;"+ userName;
-        }else{
-            parametr+=":;noMan";
-        }
-        parametr+=":;"+ cameraType;
-        parametr+=":;"+ algorithm;
-        parametr += ":;" + fileId;
-        parametr += ":;" + cameraName;
-        if(resolution == null){
-            parametr += ":;0";
-        }else {
-            parametr += ":;" + resolution.intValue();
-        }
-
-        if(buildType != null){
-            parametr += ":;" + buildType;
-        }
-
-        log.info("pro大场景添加到队列:"+parametr);
-        return parametr;
-    }
-
-    /**
-     * 循环检测算法是否计算成功
-     * @param uploadJsonPath uploadjson路径
-     * @param maxCheckTimes 循环次数
-     * @param waitTime 每次检测间隔时间,毫秒
-     * @return boolean
-     * @throws Exception
-     */
-    public static boolean checkComputeCompleted(String uploadJsonPath, int maxCheckTimes, long waitTime) throws Exception{
-        int checkTimes = 1;
-        boolean exist = false;
-        do {
-            if(new File(uploadJsonPath).exists()){
-                exist = true;
-                break;
-            }
-            Thread.sleep(waitTime);
-            ++checkTimes;
-        }while (checkTimes <= maxCheckTimes);
-
-        return exist;
-    }
-
-    /**
-     * 获取计算完需要上传的文件数组
-     * @param uploadJsonPath uploadjson路径
-     * @param maxCheckTimes 校验upload.json文件是否存在循环次数
-     * @param waitTime 每次检测间隔时间,毫秒
-     * @return boolean
-     * @throws Exception
-     */
-    public static JSONArray getUploadArray(String uploadJsonPath, int maxCheckTimes, long waitTime) throws Exception{
-        boolean buildCompeleted = ComputerUtil.checkComputeCompleted(uploadJsonPath, maxCheckTimes, waitTime);
-        if(!buildCompeleted){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
-        }
-        String uploadData = FileUtil.readUtf8String(uploadJsonPath);
-        JSONObject uploadJson;
-        JSONArray array = null;
-        if(StrUtil.isNotEmpty(uploadData)) {
-            uploadJson = JSONObject.parseObject(uploadData);
-            array = uploadJson.getJSONArray("upload");
-        }
-        if(CollUtil.isEmpty(array)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
-        }
-        return array;
-    }
-}

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

@@ -1,8 +1,7 @@
 package com.fdkankan.common.util;
 
 import cn.hutool.core.util.StrUtil;
-import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 import java.math.BigDecimal;
 import java.util.HashMap;
@@ -13,7 +12,6 @@ import java.util.Map;
  * @date 2020/4/23 17:35
  * @desciption
  */
-@Component
 public class DataUtils {
 
     public static BigDecimal getBigDecimalObj(Object data) {
@@ -112,25 +110,4 @@ public class DataUtils {
         resultMap.put("list", list);
         return resultMap;
     }
-
-//    public static <T> void assembleTimeQueryWrapper(Map<String, Object> constantQuery, String dynamicQuery,
-//                                                    QueryWrapper<T> queryWrapper, String idQuery,
-//                                                    String secondQuery, String thirdQuery) {
-//        assembleConstantQuery(queryWrapper, constantQuery);
-//        if (org.apache.commons.lang3.StringUtils.isNotBlank(dynamicQuery)) {
-//            queryWrapper.and(wrapper -> wrapper
-//                    .or().like(org.apache.commons.lang3.StringUtils.isNotBlank(secondQuery), secondQuery, dynamicQuery)
-//                    .or().like(org.apache.commons.lang3.StringUtils.isNotBlank(thirdQuery), thirdQuery, dynamicQuery)
-//                    .or().like(dynamicQuery.length() <= 32 && org.apache.commons.lang3.StringUtils.isNotBlank(idQuery), idQuery, dynamicQuery));
-//        }
-//
-//    }
-
-//    public static <T> void assembleConstantQuery(QueryWrapper<T> queryWrapper, Map<String, Object> constantQuery) {
-//        if (null != queryWrapper && !CollectionUtils.isEmpty(constantQuery)) {
-//            for (Map.Entry<String, Object> entry : constantQuery.entrySet()) {
-//                queryWrapper.eq(entry.getKey(), entry.getValue());
-//            }
-//        }
-//    }
 }

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

@@ -1,5 +1,6 @@
 package com.fdkankan.common.util;
 
+import cn.hutool.core.date.DateUtil;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.time.Instant;
@@ -13,7 +14,7 @@ import java.util.Set;
 import java.util.TimeZone;
 import lombok.SneakyThrows;
 
-public class DateExtUtil {
+public class DateExtUtil extends DateUtil {
 
     public static final String dateStyle = "yyyy-MM-dd HH:mm:ss";
     public static final String dateStyle2 = "HH:mm:ss";
@@ -24,6 +25,8 @@ public class DateExtUtil {
     public static final String dateStyle7 = "yyMMddHHmm";
     public static final String dateStyle8 = "yyyy-MM-dd HH:mm";
     public static final String dateStyle9 = "yyyy.MM.dd";
+    public static final String dateStyle10 = "yyyyMM";
+    public static final String dateStyle11 = "yyyyMMddHHmmssSSS";
 
     public static Date hoursCalculate(Date beginDate, int hours) {
         return timesCalculate(beginDate, hours, GregorianCalendar.HOUR);

+ 41 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileSizeUtil.java

@@ -1,8 +1,13 @@
 package com.fdkankan.common.util;
 
+import com.fdkankan.common.constant.FileSizeUnitType;
+
 import java.io.File;
 import java.io.FileInputStream;
+import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.util.HashMap;
+import java.util.Objects;
 
 public class FileSizeUtil {
 
@@ -115,6 +120,42 @@ public class FileSizeUtil {
     }
 
     /**
+     * 文件大小单位转换
+     * @param size 原始大小,单位B
+     * @param unit 需要转换的目标单位 B KB MB GB TB PB
+     * @return
+     */
+    public static Integer convert(Long size, String unit) throws Exception {
+        FileSizeUnitType fileSizeUnitType = FileSizeUnitType.get(unit);
+        if(Objects.isNull(fileSizeUnitType)){
+            throw new Exception("单位错误!");
+        }
+        if(size == null || size == 0){
+            return 0;
+        }
+        BigDecimal bigDecimal = new BigDecimal(size);
+        long divisor = 1L;
+        switch (fileSizeUnitType){
+            case KB:
+                divisor = 1024L;
+                break;
+            case MB:
+                divisor = 1048576L;
+                break;
+            case GB:
+                divisor = 1073741824L;
+                break;
+            case TB:
+                divisor = 1099511627776L;
+                break;
+            case PB:
+                divisor = 1125899906842624L;
+                break;
+        }
+        return bigDecimal.divide(new BigDecimal(divisor)).setScale(0, BigDecimal.ROUND_UP).intValue();
+    }
+
+    /**
      * 转换文件大小,指定转换的类型
      */
     public static double formetFileSize(long fileS, int sizeType) {

+ 0 - 435
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtil.java

@@ -1,435 +0,0 @@
-package com.fdkankan.common.util;
-
-import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import java.io.*;
-import java.nio.ByteBuffer;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileChannel.MapMode;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * @author MeepoGuan
- *
- * <p>Description: file_util</p>
- *
- * 2017年4月30日
- *
- */
-@Slf4j
-public class FileUtil {
-
-/*	public static void main(String[] args) {
-		String dirName = "d:/FH/topic/";// 创建目录
-		FileUtil.createDir(dirName);
-	}*/
-
-	/**
-	 * 创建目录
-	 * 
-	 * @param destDirName
-	 *            目标目录名
-	 * @return 目录创建成功返回true,否则返回false
-	 */
-	public static boolean createDir(String destDirName) {
-		File dir = new File(destDirName);
-		if (dir.exists()) {
-			return false;
-		}
-		if (!destDirName.endsWith(File.separator)) {
-			destDirName = destDirName + File.separator;
-		}
-		// 创建单个目录
-		if (dir.mkdirs()) {
-			return true;
-		} else {
-			return false;
-		}
-	}
-
-	/**
-	 * 删除文件
-	 * 
-	 * @param filePathAndName
-	 *            String 文件路径及名称 如c:/fqf.txt
-	 * @return boolean
-	 */
-	public static void delFile(String filePathAndName) {
-		try {
-			String filePath = filePathAndName;
-			filePath = filePath.toString();
-			File myDelFile = new File(filePath);
-			myDelFile.delete();
-
-		} catch (Exception e) {
-			System.out.println("删除文件操作出错");
-			e.printStackTrace();
-
-		}
-
-	}
-
-	/**
-	 * 读取到字节数组0
-	 * 
-	 * @param filePath //路径
-	 * @throws IOException
-	 */
-	public static byte[] getContent(String filePath) throws IOException {
-		File file = new File(filePath);
-		long fileSize = file.length();
-		if (fileSize > Integer.MAX_VALUE) {
-			System.out.println("file too big...");
-			return null;
-		}
-		FileInputStream fi = new FileInputStream(file);
-		byte[] buffer = new byte[(int) fileSize];
-		int offset = 0;
-		int numRead = 0;
-		while (offset < buffer.length
-				&& (numRead = fi.read(buffer, offset, buffer.length - offset)) >= 0) {
-			offset += numRead;
-		}
-		// 确保所有数据均被读取
-		if (offset != buffer.length) {
-			throw new IOException("Could not completely read file "
-					+ file.getName());
-		}
-		fi.close();
-		return buffer;
-	}
-
-	/**
-	 * 读取到字节数组1
-	 * 
-	 * @param filePath
-	 * @return
-	 * @throws IOException
-	 */
-	public static byte[] toByteArray(String filePath) throws IOException {
-
-		File f = new File(filePath);
-		if (!f.exists()) {
-			throw new FileNotFoundException(filePath);
-		}
-		ByteArrayOutputStream bos = new ByteArrayOutputStream((int) f.length());
-		BufferedInputStream in = null;
-		try {
-			in = new BufferedInputStream(new FileInputStream(f));
-			int buf_size = 1024;
-			byte[] buffer = new byte[buf_size];
-			int len = 0;
-			while (-1 != (len = in.read(buffer, 0, buf_size))) {
-				bos.write(buffer, 0, len);
-			}
-			return bos.toByteArray();
-		} catch (IOException e) {
-			e.printStackTrace();
-			throw e;
-		} finally {
-			try {
-				in.close();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			bos.close();
-		}
-	}
-
-	/**
-	 * 读取到字节数组2
-	 * 
-	 * @param filePath
-	 * @return
-	 * @throws IOException
-	 */
-	public static byte[] toByteArray2(String filePath) throws IOException {
-
-		File f = new File(filePath);
-		if (!f.exists()) {
-			throw new FileNotFoundException(filePath);
-		}
-
-		FileChannel channel = null;
-		FileInputStream fs = null;
-		try {
-			fs = new FileInputStream(f);
-			channel = fs.getChannel();
-			ByteBuffer byteBuffer = ByteBuffer.allocate((int) channel.size());
-			while ((channel.read(byteBuffer)) > 0) {
-				// do nothing
-				// System.out.println("reading");
-			}
-			return byteBuffer.array();
-		} catch (IOException e) {
-			e.printStackTrace();
-			throw e;
-		} finally {
-			try {
-				channel.close();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			try {
-				fs.close();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	/**
-	 * Mapped File way MappedByteBuffer 可以在处理大文件时,提升性能
-	 * 
-	 * @param filePath
-	 * @return
-	 * @throws IOException
-	 */
-	public static byte[] toByteArray3(String filePath) throws IOException {
-
-		FileChannel fc = null;
-		RandomAccessFile rf = null;
-		try {
-			rf = new RandomAccessFile(filePath, "r");
-			fc = rf.getChannel();
-			MappedByteBuffer byteBuffer = fc.map(MapMode.READ_ONLY, 0,
-					fc.size()).load();
-			//System.out.println(byteBuffer.isLoaded());
-			byte[] result = new byte[(int) fc.size()];
-			if (byteBuffer.remaining() > 0) {
-				// System.out.println("remain");
-				byteBuffer.get(result, 0, byteBuffer.remaining());
-			}
-			return result;
-		} catch (IOException e) {
-			e.printStackTrace();
-			throw e;
-		} finally {
-			try {
-				rf.close();
-				fc.close();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-    public static File[] sort(File[] s) {
-        //中间值
-        File temp = null;
-        //外循环:我认为最小的数,从0~长度-1
-        for (int j = 0; j < s.length - 1; j++) {
-            //最小值:假设第一个数就是最小的
-            String min = s[j].getName();
-            //记录最小数的下标的
-            int minIndex = j;
-            //内循环:拿我认为的最小的数和后面的数一个个进行比较
-            for (int k = j + 1; k < s.length; k++) {
-                //找到最小值
-                if (Integer.parseInt(min.substring(0, min.indexOf("."))) > Integer.parseInt(s[k].getName().substring(0, s[k].getName().indexOf(".")))) {
-                    //修改最小
-                    min = s[k].getName();
-                    minIndex = k;
-                }
-            }
-            //当退出内层循环就找到这次的最小值
-            //交换位置
-            temp = s[j];
-            s[j] = s[minIndex];
-            s[minIndex] = temp;
-        }
-        return s;
-    }
-
-	/**
-	 * 获取目录下所有文件
-	 * @param directory
-	 */
-	public static List<String> getFileList(String directory) {
-
-		File f = new File(directory);
-
-		File[] files = f.listFiles();
-
-		if(files == null || files.length == 0){
-			return null;
-		}
-
-		List<String> list = new ArrayList<>();
-		for (int i = 0; i < files.length; i++) {
-
-			if (files[i].isFile()) {
-				list.add(files[i].getAbsolutePath());
-			} else {
-				System.out.println("目录:" + files[i]);
-				List<String> fileList = getFileList(files[i].getAbsolutePath());
-				if(CollUtil.isEmpty(fileList)){
-					continue;
-				}
-				list.addAll(fileList);
-			}
-		}
-
-		return list;
-	}
-
-	/**
-	 * <p>
-	        zip包解压缩
-	 * </p>
-	 * @author dengsixing
-	 * @date 2022/2/16
-	 * @param inputFile 解压文件路径
-	 * @param destDirPath 解压目标目录
-	 **/
-	public static void unZip(String inputFile,String destDirPath) throws Exception{
-		File srcFile = new File(inputFile);//获取当前压缩文件
-		// 判断源文件是否存在
-		if (!srcFile.exists()) {
-			throw new Exception("文件不存在:" + srcFile.getPath());
-		}
-		try(
-			//创建压缩文件对象
-			ZipFile zipFile = new ZipFile(srcFile, Charset.forName("GBK"))
-		){
-			//开始解压
-			Enumeration<?> entries = zipFile.entries();
-			while (entries.hasMoreElements()) {
-				ZipEntry entry = (ZipEntry) entries.nextElement();
-				// 如果是文件夹,就创建个文件夹
-				if (entry.isDirectory()) {
-					String dirPath = destDirPath + "/" + entry.getName();
-					srcFile.mkdirs();
-				} else {
-					// 如果是文件,就先创建一个文件,然后用io流把内容copy过去
-					File targetFile = new File(destDirPath + "/" + entry.getName());
-					// 保证这个文件的父文件夹必须要存在
-					if (!targetFile.getParentFile().exists()) {
-						targetFile.getParentFile().mkdirs();
-					}
-					targetFile.createNewFile();
-					// 将压缩文件内容写入到这个文件中
-					try(InputStream is = zipFile.getInputStream(entry);
-						FileOutputStream fos = new FileOutputStream(targetFile)){
-						int len;
-						byte[] buf = new byte[1024];
-						while ((len = is.read(buf)) != -1) {
-							fos.write(buf, 0, len);
-						}
-					}catch (IOException e){
-						log.error("解压缩失败,文件名称" + entry.getName(), e);
-						throw e;
-					}
-				}
-			}
-		} catch (ZipException e) {
-			log.error("解压缩失败,文件路径:" + srcFile.getPath(), e);
-			throw e;
-		} catch (IOException e) {
-			log.error("解压缩失败,文件路径:" + srcFile.getPath(), e);
-			throw e;
-		}
-	}
-
-	/**
-	 * <p>
-	        打包
-	 * </p>
-	 * @author dengsixing
-	 * @date 2022/2/16
-	 * @param inputFile
-	 * @param outputFile
-	 * @param withDir
-	 **/
-	public static void zip(String inputFile, String outputFile, boolean withDir) throws Exception {
-
-		try(
-		//创建zip输出流
-			ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outputFile));
-			//创建缓冲输出流
-			BufferedOutputStream bos = new BufferedOutputStream(out);
-		){
-			File input = new File(inputFile);
-			compress(out, bos, input, null, withDir);
-		}
-	}
-
-	/**
-	 * @param name 压缩文件名,可以写为null保持默认
-	 */
-	//递归压缩
-	public static void compress(ZipOutputStream out, BufferedOutputStream bos, File input, String name, boolean withDir) throws IOException {
-		if (name == null) {
-			name = input.getName();
-		}
-		//如果路径为目录(文件夹)
-		if (input.isDirectory()) {
-			//取出文件夹中的文件(或子文件夹)
-			File[] flist = input.listFiles();
-
-			if (flist.length == 0)//如果文件夹为空,则只需在目的地zip文件中写入一个目录进入
-			{
-				if(withDir){
-					out.putNextEntry(new ZipEntry(name + "/"));
-				}
-			} else//如果文件夹不为空,则递归调用compress,文件夹中的每一个文件(或文件夹)进行压缩
-			{
-				for (int i = 0; i < flist.length; i++) {
-					if(withDir){
-						compress(out, bos, flist[i], name + "/" + flist[i].getName(), withDir);
-					}else{
-						compress(out, bos, flist[i], flist[i].getName(), withDir);
-					}
-				}
-			}
-		}
-		//如果不是目录(文件夹),即为文件,则先写入目录进入点,之后将文件写入zip文件中
-		else
-		{
-			out.putNextEntry(new ZipEntry(name));
-			FileInputStream fos = new FileInputStream(input);
-			BufferedInputStream bis = new BufferedInputStream(fos);
-			int len;
-			//将源文件写入到zip文件中
-			byte[] buf = new byte[1024];
-			while ((len = bis.read(buf)) != -1) {
-				bos.write(buf,0,len);
-			}
-			bis.close();
-			fos.close();
-		}
-	}
-
-	public static JSONObject readJson(String filePath) throws IOException {
-		try {
-			String content = cn.hutool.core.io.FileUtil.readUtf8String(filePath);
-			JSONObject jsonObj = JSON.parseObject(content);
-			return jsonObj;
-
-		} catch (Exception e) {
-			log.error("读取json失败,filePath=" + filePath, e);
-			return null;
-		}
-	}
-
-	public static void main(String[] args) throws Exception {
-
-
-		FileUtil.unZip("F:\\test\\KJ-t-VJNe28ZImv_images_展厅全景图.zip", "F:\\test\\aaa");
-
-
-	}
-}

File diff suppressed because it is too large
+ 426 - 595
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/FileUtils.java


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

@@ -3,6 +3,7 @@ package com.fdkankan.common.util;
 import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.file.FileReader;
+import cn.hutool.core.util.RuntimeUtil;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
 import java.awt.image.BufferedImage;
@@ -23,8 +24,10 @@ public class OBJToGLBUtil {
     public static void objToGlb(String objPath, String glbPath) {
         OBJToGLBUtil.checkObj(objPath);
         objPath = OBJToGLBUtil.getObj(objPath);
-        CreateObjUtil.obj2Glb(objPath, glbPath);
-        log.info("obj转换glb完毕:");
+        String command = "obj2gltf -i " + objPath + " -o " + glbPath;
+        log.info("开始执行obj转换gbl命令-{}", command);
+        Process exec = RuntimeUtil.exec(command);
+        log.info("结束执行obj转换gbl命令-{}", command);
     }
 
     static String getObj(String objPath) {
@@ -105,7 +108,7 @@ public class OBJToGLBUtil {
         LinkedHashSet<String> imgMtl = OBJToGLBUtil.readMtlFile(file.getPath());
         for (String mtlName : imgMtl) {
             if (!imgName.contains(mtlName)) {
-                throw new BusinessException(-1 ,mtlName + "图片缺失!");
+                throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
             }
         }
         return true;

+ 20 - 15
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/OkHttpUtils.java

@@ -1,8 +1,10 @@
 package com.fdkankan.common.util;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.http.HttpUtil;
 import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
-import org.springframework.util.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
 
 import java.io.IOException;
 import java.util.Iterator;
@@ -68,7 +70,7 @@ public class OkHttpUtils {
     }
 
     public static String httpGet(String url, Map<String, String> headers) {
-        if (CollectionUtils.isEmpty(headers)) {
+        if (ObjectUtils.isEmpty(headers)) {
             return httpGet(url);
         }
 
@@ -166,7 +168,7 @@ public class OkHttpUtils {
      * @return
      */
     public static String httpPostJson(String url, Map<String, String> headers, String json) {
-        if (CollectionUtils.isEmpty(headers)) {
+        if (CollectionUtil.isEmpty(headers)) {
             httpPostJson(url, json);
         }
 
@@ -297,18 +299,21 @@ public class OkHttpUtils {
         });
     }
 
-    //test
-    public static void main(String[] args) {
-//        String url = "http://192.168.0.30:8000/pro";
-//        JSONObject jsonObject = new JSONObject();
-//        jsonObject.put("name", "vr-t-2KZ4MQv-001");
-//        jsonObject.put("map", "t-2KZ4MQv");
-//        jsonObject.put("resolution", 1024);
-//        int num[] = new int[1];
-//        num[0] = -1;
-//        jsonObject.put("ids", num);
-//        System.out.println(httpPostJson(url, jsonObject.toJSONString()));
-        System.out.println(httpGet("http://192.168.0.165:8000/check"));
+    public static long downloadFile(String url, String dest,int retryTimes){
+        for (int i = 0; i <= retryTimes; i++) {
+            try {
+                return HttpUtil.downloadFile(url, dest);
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error(String.format("文件第%d次下载失败", i + 1), e);
+                try {
+                    Thread.sleep(3000);
+                } catch (InterruptedException interruptedException) {
+                    interruptedException.printStackTrace();
+                }
+            }
+        }
+        return 0L;
     }
 
 }

+ 23 - 16
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/PasswordUtils.java

@@ -10,6 +10,7 @@ import java.security.SecureRandom;
 
 public class PasswordUtils {
 
+    public 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'};
 
     /**
      * JAVA6支持以下任意一种算法 PBEWITHMD5ANDDES PBEWITHMD5ANDTRIPLEDES
@@ -166,25 +167,31 @@ public class PasswordUtils {
         return (byte) "0123456789ABCDEF".indexOf(c);
     }
 
-    public static void main(String[] args) {
-
-        //管理后台密码加解密
-        String userName = "admin6";
-        String password = "123456";
-
-        try {
-            byte[] salt = PasswordUtils.getStaticSalt();
-            String ciphertext = PasswordUtils.encrypt(userName, password, salt);
-            System.out.println(ciphertext);
-            String plaintext = PasswordUtils.decrypt(ciphertext, password, salt);
-            System.out.println(plaintext);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
 
+    /**
+     * 模拟前端密码加密
+     * @param str
+     */
+    public static String decycptPasswordWeb(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;
+    }
 }

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

@@ -15,7 +15,7 @@ public class RandomUtil {
         StringBuffer shortBuffer = new StringBuffer();
         String uuid = UUID.randomUUID().toString().replace("-", "");
         int index = 0;
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < 11; i++) {
             index = i;
             if(index >= 8){
                 index = i % 8;

+ 32 - 5
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/StrExtUtil.java

@@ -1,7 +1,16 @@
 package com.fdkankan.common.util;
 
+import cn.hutool.captcha.CaptchaUtil;
+import cn.hutool.captcha.LineCaptcha;
+import cn.hutool.captcha.generator.RandomGenerator;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ReUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.fdkankan.common.constant.ErrorCode;
+
+import java.io.File;
+import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import jdk.nashorn.internal.runtime.regexp.joni.Regex;
@@ -43,14 +52,32 @@ public class StrExtUtil extends StrUtil {
 
     }
 
-    public static void main(String[] args) {
+    /**
+     * 判断字符串是否包含中文
+     * @param content
+     * @return
+     */
+    public static boolean containsZh(String content){
+        String regex = "[\u4e00-\u9fa5]+";
+        return ReUtil.contains(regex, content);
+    }
+
+    public static void main(String[] args) throws Exception {
 
-        String test = null;
-//        System.out.println(test.lastIndexOf("."));
-//        System.out.println(test.substring(test.lastIndexOf(".")));
+//        String test = null;
+////        System.out.println(test.lastIndexOf("."));
+////        System.out.println(test.substring(test.lastIndexOf(".")));
+//
+//        System.out.println("123".equals(test));;
 
-        System.out.println("123".equals(test));;
+//        List<String> fileNames = FileUtils.list(new File("C:\\Users\\dsx\\Desktop\\90d95cdb5_202211141023024060"));
+//        System.out.println(JSON.toJSONString(fileNames));
 
+        RandomGenerator randomGenerator = new RandomGenerator("0123456789asdfghjklASDFGHJKL", 10);
+        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(300, 100);
+        lineCaptcha.setGenerator(randomGenerator);
+        lineCaptcha.write("D:\\test2\\1.png");
+        System.out.println(lineCaptcha.getCode());
 
 
     }

+ 0 - 61
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/StreamGobbler.java

@@ -1,61 +0,0 @@
-package com.fdkankan.common.util;
-
-import java.io.*;
-
-public class StreamGobbler extends Thread {
-
-	InputStream is;  
-    String type;  
-    OutputStream os;  
-
-    public StreamGobbler(InputStream is, String type) {  
-        this(is, type, null);  
-    }  
-
-    StreamGobbler(InputStream is, String type, OutputStream redirect) {  
-        this.is = is;  
-        this.type = type;  
-        this.os = redirect;  
-    }  
-
-    public void run() {  
-        InputStreamReader isr = null;  
-        BufferedReader br = null;  
-        PrintWriter pw = null;  
-        try {  
-            if (os != null)  
-                pw = new PrintWriter(os);  
-
-            isr = new InputStreamReader(is);  
-            br = new BufferedReader(isr);  
-            String line=null;  
-            while ( (line = br.readLine()) != null) {  
-                if (pw != null)  
-                    pw.println(line);  
-                System.out.println(type + ">" + line);      
-            }  
-
-            if (pw != null)  
-                pw.flush();  
-        } catch (IOException ioe) {  
-            ioe.printStackTrace();    
-        } finally{  
-            try {  
-            	if(pw!=null)
-            	{
-            		 pw.close();  
-            	}
-            	if(br!=null)
-            	{
-            		br.close();  
-            	}
-            	if(isr!=null)
-            	{
-            		isr.close();  
-            	}
-            } catch (IOException e) {  
-                e.printStackTrace();  
-            }  
-        }  
-    }  
-}

+ 0 - 76
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/TestUtil.java

@@ -1,76 +0,0 @@
-package com.fdkankan.common.util;
-
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.collection.ListUtil;
-import cn.hutool.core.img.ImgUtil;
-import cn.hutool.core.io.IoUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ConstantFilePath;
-import com.fdkankan.common.constant.TbStatus;
-import java.awt.Image;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-import lombok.Data;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/14
- **/
-public class TestUtil {
-
-    public static String hostName = "aaa";
-
-    public static List<String> residenceServiceHostName = new ArrayList<>();
-
-    static{
-        residenceServiceHostName.add("aaa");
-        residenceServiceHostName.add("bbb");
-    }
-
-    public static void main(String[] args) throws Exception {
-
-        test test = new test();
-        test1 test1 = new test1();
-        test1.setTest("test1");
-        test2 test2 = new test2();
-        test2.setTest("test2");
-        BeanUtil.copyProperties(test1, test);
-        BeanUtil.copyProperties(test2, test);
-        System.out.println(test.getTest());
-
-
-    }
-
-}
-
-@Data
-class test{
-    private String test;
-}
-
-@Data
-class test1{
-    private String test;
-}
-
-@Data
-class test2{
-    private String test;
-}

+ 0 - 163
4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWord.java

@@ -1,163 +0,0 @@
-package com.fdkankan.common.validation;
-
-import com.fdkankan.common.constant.ConstantFileName;
-
-import com.fdkankan.common.constant.ServerCode;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import javax.annotation.PostConstruct;
-import lombok.extern.slf4j.Slf4j;
-import net.sf.jsqlparser.schema.Server;
-import org.springframework.core.io.ClassPathResource;
-
-/**
- *  敏感词过滤
- */
-@Slf4j
-public class SensitiveWord {
-    @SuppressWarnings("rawtypes")
-    public Map sensitiveWordMap = null;
-    public static int minMatchTYpe = 1;      //最小匹配规则
-    public static int maxMatchType = 2;      //最大匹配规则
-
-    /**
-     * 构造函数,初始化敏感词库
-     */
-    public SensitiveWord(){
-        if (sensitiveWordMap == null){
-            ClassPathResource classPathResource = new ClassPathResource("static/txt/" + ConstantFileName.BBS_SENSITIVE);
-            try {
-                sensitiveWordMap = new SensitiveWordConfig().initKeyWord(classPathResource.getFile());
-            }catch (Exception e){
-                log.error("初始化敏感词失败!", e);
-            }
-        }
-    }
-
-
-    /**
-     * 判断文字是否包含敏感字符
-     * @author chenming
-     * @date 2014年4月20日 下午4:28:30
-     * @param txt  文字
-     * @param matchType  匹配规则&nbsp;1:最小匹配规则,2:最大匹配规则
-     * @return 若包含返回true,否则返回false
-     * @version 1.0
-     */
-    public boolean isContaintSensitiveWord(String txt,int matchType){
-        boolean flag = false;
-        for(int i = 0 ; i < txt.length() ; i++){
-            int matchFlag = this.CheckSensitiveWord(txt, i, matchType); //判断是否包含敏感字符
-            if(matchFlag > 0){    //大于0存在,返回true
-                flag = true;
-            }
-        }
-        return flag;
-    }
-
-    /**
-     * 获取文字中的敏感词
-     * @author chenming
-     * @date 2014年4月20日 下午5:10:52
-     * @param txt 文字
-     * @param matchType 匹配规则&nbsp;1:最小匹配规则,2:最大匹配规则
-     * @return
-     * @version 1.0
-     */
-    public Set<String> getSensitiveWord(String txt , int matchType){
-        Set<String> sensitiveWordList = new HashSet<String>();
-
-        for(int i = 0 ; i < txt.length() ; i++){
-            int length = CheckSensitiveWord(txt, i, matchType);    //判断是否包含敏感字符
-            if(length > 0){    //存在,加入list中
-                sensitiveWordList.add(txt.substring(i, i+length));
-                i = i + length - 1;    //减1的原因,是因为for会自增
-            }
-        }
-
-        return sensitiveWordList;
-    }
-
-    /**
-     * 替换敏感字字符
-     * @author chenming
-     * @date 2014年4月20日 下午5:12:07
-     * @param txt
-     * @param matchType
-     * @param replaceChar 替换字符,默认*
-     * @version 1.0
-     */
-    public String replaceSensitiveWord(String txt,int matchType,String replaceChar){
-        String resultTxt = txt;
-        Set<String> set = getSensitiveWord(txt, matchType);     //获取所有的敏感词
-        Iterator<String> iterator = set.iterator();
-        String word = null;
-        String replaceString = null;
-        while (iterator.hasNext()) {
-            word = iterator.next();
-            replaceString = getReplaceChars(replaceChar, word.length());
-            resultTxt = resultTxt.replaceAll(word, replaceString);
-        }
-
-        return resultTxt;
-    }
-
-    /**
-     * 获取替换字符串
-     * @author chenming
-     * @date 2014年4月20日 下午5:21:19
-     * @param replaceChar
-     * @param length
-     * @return
-     * @version 1.0
-     */
-    private String getReplaceChars(String replaceChar,int length){
-        String resultReplace = replaceChar;
-        for(int i = 1 ; i < length ; i++){
-            resultReplace += replaceChar;
-        }
-
-        return resultReplace;
-    }
-
-    /**
-     * 检查文字中是否包含敏感字符,检查规则如下:<br>
-     * @author chenming
-     * @date 2014年4月20日 下午4:31:03
-     * @param txt
-     * @param beginIndex
-     * @param matchType
-     * @return,如果存在,则返回敏感词字符的长度,不存在返回0
-     * @version 1.0
-     */
-    @SuppressWarnings({ "rawtypes"})
-    public int CheckSensitiveWord(String txt,int beginIndex,int matchType){
-        boolean  flag = false;    //敏感词结束标识位:用于敏感词只有1位的情况
-        int matchFlag = 0;     //匹配标识数默认为0
-        char word = 0;
-
-        Map nowMap = sensitiveWordMap;
-        for(int i = beginIndex; i < txt.length() ; i++){
-            word = txt.charAt(i);
-            nowMap = (Map) nowMap.get(word);     //获取指定key
-            if(nowMap != null){     //存在,则判断是否为最后一个
-                matchFlag++;     //找到相应key,匹配标识+1
-                if("1".equals(nowMap.get("isEnd"))){       //如果为最后一个匹配规则,结束循环,返回匹配标识数
-                    flag = true;       //结束标志位为true
-                    if(SensitiveWord.minMatchTYpe == matchType){    //最小规则,直接返回,最大规则还需继续查找
-                        break;
-                    }
-                }
-            }
-            else{     //不存在,直接返回
-                break;
-            }
-        }
-        if(matchFlag < 2 || !flag){        //长度必须大于等于1,为词
-            matchFlag = 0;
-        }
-        return matchFlag;
-    }
-}

+ 0 - 169
4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/SensitiveWordConfig.java

@@ -1,169 +0,0 @@
-package com.fdkankan.common.validation;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.*;
-
-/**
- * 初始化敏感词库,将敏感词加入到HashMap中,构建DFA算法模型
- */
-public class SensitiveWordConfig {
-    private String ENCODING = "utf-8";    //字符编码
-    @SuppressWarnings("rawtypes")
-    public HashMap sensitiveWordMap;
-
-    public SensitiveWordConfig(){
-        super();
-    }
-
-    /**
-     * @date 2014年4月20日 下午2:28:32
-     * @version 1.0
-     */
-    @SuppressWarnings("rawtypes")
-    public Map initKeyWord(String filePath){
-        try {
-            //读取敏感词库
-            Set<String> keyWordSet = readSensitiveWordFile(filePath);
-            //将敏感词库加入到HashMap中
-            addSensitiveWordToHashMap(keyWordSet);
-            //spring获取application,然后application.setAttribute("sensitiveWordMap",sensitiveWordMap);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return sensitiveWordMap;
-    }
-
-    public Map initKeyWord(File file){
-        try {
-            //读取敏感词库
-            Set<String> keyWordSet = readSensitiveWordFile(file);
-            //将敏感词库加入到HashMap中
-            addSensitiveWordToHashMap(keyWordSet);
-            //spring获取application,然后application.setAttribute("sensitiveWordMap",sensitiveWordMap);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return sensitiveWordMap;
-    }
-
-    /**
-     * 读取敏感词库,将敏感词放入HashSet中,构建一个DFA算法模型:<br>
-     * 中 = {
-     *      isEnd = 0
-     *      国 = {<br>
-     *      	 isEnd = 1
-     *           人 = {isEnd = 0
-     *                民 = {isEnd = 1}
-     *                }
-     *           男  = {
-     *           	   isEnd = 0
-     *           		人 = {
-     *           			 isEnd = 1
-     *           			}
-     *           	}
-     *           }
-     *      }
-     *  五 = {
-     *      isEnd = 0
-     *      星 = {
-     *      	isEnd = 0
-     *      	红 = {
-     *              isEnd = 0
-     *              旗 = {
-     *                   isEnd = 1
-     *                  }
-     *              }
-     *      	}
-     *      }
-     * @param keyWordSet  敏感词库
-     */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    private void addSensitiveWordToHashMap(Set<String> keyWordSet) {
-        sensitiveWordMap = new HashMap(keyWordSet.size());     //初始化敏感词容器,减少扩容操作
-        String key = null;
-        Map nowMap = null;
-        Map<String, String> newWorMap = null;
-        //迭代keyWordSet
-        Iterator<String> iterator = keyWordSet.iterator();
-        while(iterator.hasNext()){
-            key = iterator.next();    //关键字
-            nowMap = sensitiveWordMap;
-            for(int i = 0 ; i < key.length() ; i++){
-                char keyChar = key.charAt(i);       //转换成char型
-                Object wordMap = nowMap.get(keyChar);       //获取
-
-                if(wordMap != null){        //如果存在该key,直接赋值
-                    nowMap = (Map) wordMap;
-                }
-                else{     //不存在则,则构建一个map,同时将isEnd设置为0,因为他不是最后一个
-                    newWorMap = new HashMap<String,String>();
-                    newWorMap.put("isEnd", "0");     //不是最后一个
-                    nowMap.put(keyChar, newWorMap);
-                    nowMap = newWorMap;
-                }
-
-                if(i == key.length() - 1){
-                    nowMap.put("isEnd", "1");    //最后一个
-                }
-            }
-        }
-    }
-
-    /**
-     * 读取敏感词库中的内容,将内容添加到set集合中
-     */
-    @SuppressWarnings("resource")
-    private Set<String> readSensitiveWordFile(String path) throws Exception{
-        Set<String> set = null;
-        //File file = new File("E:\\2017\\4Dweb\\bug汇总\\过滤敏感词\\敏感词库\\敏感词库\\2012年最新敏感词列表\\论坛需要过滤的不良词语大全.txt");    //读取文件
-        //File file = new File("D:\\SensitiveWord.txt");    //读取文件
-        File file = new File(path);
-        InputStreamReader read = new InputStreamReader(new FileInputStream(file),ENCODING);
-        try {
-            if(file.isFile() && file.exists()){      //文件流是否存在
-                set = new HashSet<String>();
-                BufferedReader bufferedReader = new BufferedReader(read);
-                String txt = null;
-                while((txt = bufferedReader.readLine()) != null){    //读取文件,将文件内容放入到set中
-                    set.add(txt);
-                }
-            }
-            else{         //不存在抛出异常信息
-                throw new Exception("敏感词库文件不存在");
-            }
-        } catch (Exception e) {
-            throw e;
-        }finally{
-            read.close();     //关闭文件流
-        }
-        return set;
-    }
-
-    private Set<String> readSensitiveWordFile(File file) throws Exception{
-        Set<String> set = null;
-        //File file = new File("E:\\2017\\4Dweb\\bug汇总\\过滤敏感词\\敏感词库\\敏感词库\\2012年最新敏感词列表\\论坛需要过滤的不良词语大全.txt");    //读取文件
-        //File file = new File("D:\\SensitiveWord.txt");    //读取文件
-        InputStreamReader read = new InputStreamReader(new FileInputStream(file),ENCODING);
-        try {
-            if(file.isFile() && file.exists()){      //文件流是否存在
-                set = new HashSet<String>();
-                BufferedReader bufferedReader = new BufferedReader(read);
-                String txt = null;
-                while((txt = bufferedReader.readLine()) != null){    //读取文件,将文件内容放入到set中
-                    set.add(txt);
-                }
-            }
-            else{         //不存在抛出异常信息
-                throw new Exception("敏感词库文件不存在");
-            }
-        } catch (Exception e) {
-            throw e;
-        }finally{
-            read.close();     //关闭文件流
-        }
-        return set;
-    }
-}

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/ValidationUtils.java

@@ -1,6 +1,6 @@
 package com.fdkankan.common.validation;
 
-import org.springframework.util.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;

+ 0 - 26
4dkankan-common-utils/src/main/java/com/fdkankan/common/validation/Variable.java

@@ -1,26 +0,0 @@
-package com.fdkankan.common.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-public class Variable {
-
-    //public static Map<String,String> gl_AppSession = new HashMap<String,String>();
-
-    //二维码登录
-    public static Map<String,String> globalCodeLogin = new HashMap<String,String>();
-
-    public static ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<String>();
-    //论坛过滤
-    public static SensitiveWord sensitiveWord = new SensitiveWord();
-
-    //更新浏览大场景次数
-    public static Map<String, Integer> globalViewCount = new ConcurrentHashMap<String, Integer>();
-
-    //微信支付,原始订单对应后面添加了随机数的订单
-    public static Map<String, String> globalOrders = new ConcurrentHashMap<String, String>();
-
-//	public static ComputerModel[] thread_computers = null;
-}

+ 3 - 14
4dkankan-common-web/pom.xml

@@ -5,7 +5,7 @@
   <parent>
     <artifactId>4dkankan-utils</artifactId>
     <groupId>com.fdkankan</groupId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>3.0.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
@@ -16,7 +16,7 @@
     <dependency>
       <groupId>com.fdkankan</groupId>
       <artifactId>4dkankan-common-utils</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
+      <version>3.0.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
@@ -65,7 +65,7 @@
     <dependency>
       <groupId>com.fdkankan</groupId>
       <artifactId>4dkankan-utils-redis</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
+      <version>3.0.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
@@ -147,16 +147,5 @@
 
   </dependencies>
 
-  <build>
-
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-      </plugin>
-    </plugins>
-
-  </build>
-
 
 </project>

+ 14 - 0
4dkankan-common-web/src/main/java/com/fdkankan/web/annotation/CheckInnerApiPermit.java

@@ -0,0 +1,14 @@
+package com.fdkankan.web.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface CheckInnerApiPermit {
+    String description() default "";
+}

+ 10 - 0
4dkankan-common-web/src/main/java/com/fdkankan/web/annotation/NotResponseAdvice.java

@@ -0,0 +1,10 @@
+package com.fdkankan.web.annotation;
+
+import java.lang.annotation.*;
+
+@Target({ElementType.PARAMETER, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface NotResponseAdvice {
+    String description() default "";
+}

+ 1 - 1
4dkankan-common-web/src/main/java/com/fdkankan/web/config/ShiroConfig.java

@@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-@Configuration
+//@Configuration
 public class ShiroConfig {
 
     @Autowired

+ 2 - 2
4dkankan-common-web/src/main/java/com/fdkankan/web/controller/BaseController.java

@@ -46,10 +46,10 @@ public class BaseController {
     }
 
     protected SSOUser getSsoUser(){
-        return ssoLoginHelper.loginCheck(request.getHeader("token"));
+        return ssoLoginHelper.getSsoUser(request.getHeader("token"));
     }
 
-    protected com.fdkankan.web.model.SSOUser getSsoUserV3(){
+    protected SSOUser getSsoUserV3(){
         return ssoLoginHelper.loginCheckV3(request.getHeader("token"));
     }
 

+ 1 - 1
4dkankan-common-web/src/main/java/com/fdkankan/web/controller/CustomErrorController.java

@@ -1,6 +1,6 @@
 package com.fdkankan.web.controller;
 
-import com.fdkankan.common.response.ResultData;
+import com.fdkankan.web.response.ResultData;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.springframework.boot.web.servlet.error.ErrorController;

+ 8 - 2
4dkankan-common-web/src/main/java/com/fdkankan/web/exception/GlobalExceptionHandler.java

@@ -4,11 +4,12 @@ import cn.hutool.core.exceptions.ExceptionUtil;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.common.response.ResultData;
+import com.fdkankan.web.response.ResultData;
 import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.converter.HttpMessageNotReadableException;
 import org.springframework.validation.BindException;
 import org.springframework.validation.BindingResult;
 import org.springframework.validation.FieldError;
@@ -94,6 +95,12 @@ public class GlobalExceptionHandler {
             ServerCode.PARAM_REQUIRED.formatMessage("文件"));
     }
 
+    @ResponseBody
+    @ExceptionHandler(value = HttpMessageNotReadableException.class)
+    public ResultData httpMessageNotReadableException(HttpMessageNotReadableException e){
+        return ResultData.error(ErrorCode.PARAM_ERROR.code(), ExceptionUtil.stacktraceToString(e, 3000));
+    }
+
 
     /**
      * 参数校验异常拦截处理
@@ -125,7 +132,6 @@ public class GlobalExceptionHandler {
         return ResultData.error(ErrorCode.PARAM_REQUIRED.code(), message);
     }
 
-
     /**
      * 处理业务异常
      */

+ 48 - 0
4dkankan-common-web/src/main/java/com/fdkankan/web/interceptor/CheckInnerApiPermitAspect.java

@@ -0,0 +1,48 @@
+package com.fdkankan.web.interceptor;
+
+import cn.hutool.core.util.StrUtil;
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.exception.BusinessException;
+import java.io.IOException;
+import javax.servlet.http.HttpServletRequest;
+import lombok.extern.log4j.Log4j2;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+@Log4j2
+@Aspect
+@Component
+@Order(101)
+public class CheckInnerApiPermitAspect {
+
+	@Value("${inner.customToken}")
+	private String customToken;
+
+	@Pointcut("@annotation(com.fdkankan.web.annotation.CheckInnerApiPermit)")
+	public void checkCooperationPermit() {
+	}
+
+	/**
+	 * 前置通知 用于判断用户协作场景是否有协作权限
+	 *
+	 * @param joinPoint
+	 *            切点
+	 * @throws IOException
+	 */
+	@Before("checkCooperationPermit()")
+	public void doBefore(JoinPoint joinPoint) throws Exception {
+		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+		String customToken = request.getHeader("custom-token");
+		if(StrUtil.isEmpty(customToken) || !customToken.equals(this.customToken)){
+			throw new BusinessException(ErrorCode.HAVE_NO_RIGHT);
+		}
+	}
+
+}

+ 1 - 1
4dkankan-common-web/src/main/java/com/fdkankan/web/jwt/JwtFilter.java

@@ -2,7 +2,7 @@ package com.fdkankan.web.jwt;
 
 import com.alibaba.fastjson.JSON;
 import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.common.response.ResultData;
+import com.fdkankan.web.response.ResultData;
 import java.io.IOException;
 import java.io.PrintWriter;
 import javax.servlet.ServletRequest;

+ 1 - 1
4dkankan-common-web/src/main/java/com/fdkankan/web/realm/UserJwtRealm.java

@@ -77,7 +77,7 @@ public class UserJwtRealm extends AuthorizingRealm {
             throw new BusinessException(ErrorCode.TOKEN_ILLEGAL);
         }
         // TODO: 2021/12/21
-        SSOUser ssoUser = this.ssoLoginHelper.loginCheck(token);
+        SSOUser ssoUser = this.ssoLoginHelper.getSsoUser(token);
         if (ssoUser == null){
             throw new BusinessException(ErrorCode.TOKEN_NOT_FOUND);
         }

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/request/RequestBase.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.request;
+package com.fdkankan.web.request;
 
 import lombok.Data;
 import org.apache.commons.lang3.StringUtils;

+ 10 - 6
4dkankan-common-web/src/main/java/com/fdkankan/web/response/BaseResponseAdvice.java

@@ -3,9 +3,9 @@ package com.fdkankan.web.response;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fdkankan.common.response.PageInfo;
-import com.fdkankan.common.response.ResultData;
+import com.fdkankan.web.annotation.NotResponseAdvice;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.core.MethodParameter;
 import org.springframework.http.MediaType;
 import org.springframework.http.converter.HttpMessageConverter;
@@ -14,11 +14,18 @@ import org.springframework.http.server.ServerHttpResponse;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
 
+import java.util.Objects;
+
+@ConditionalOnMissingBean(name = "customResponseAdvice")
 @RestControllerAdvice
 @Slf4j
 public class BaseResponseAdvice implements ResponseBodyAdvice<Object> {
     @Override
     public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
+        NotResponseAdvice methodAnnotation = methodParameter.getMethodAnnotation(NotResponseAdvice.class);
+        if(Objects.nonNull(methodAnnotation)){
+            return false;
+        }
         return true;
     }
 
@@ -41,14 +48,11 @@ public class BaseResponseAdvice implements ResponseBodyAdvice<Object> {
         if(body instanceof String){
             return JSONObject.toJSONString(ResultData.ok(body));
         }
-        if(body instanceof Page){
-            Page page = (Page) body;
-            return ResultData.ok(new PageInfo(page.getCurrent(), page.getSize(), page.getTotal(), page.getRecords()));
-        }
         if (body instanceof ResultData) {
             return body;
         } else {
             return ResultData.ok(body);
         }
     }
+
 }

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/response/Result.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.response;
+package com.fdkankan.web.response;
 
 import java.io.Serializable;
 import lombok.AllArgsConstructor;

+ 2 - 6
4dkankan-common-utils/src/main/java/com/fdkankan/common/response/ResultData.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.response;
+package com.fdkankan.web.response;
 
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.constant.ServerCode;
@@ -26,7 +26,7 @@ public class ResultData<T> implements Serializable {
      */
     private T data;
     /**
-     * 后端返回结果
+     * 请求是否成功
      */
     private Boolean success;
     /**
@@ -44,10 +44,6 @@ public class ResultData<T> implements Serializable {
         return base(ServerCode.SUCCESS.code(), msg, data,true);
     }
 
-    public static ResultData ok(int page,int pageSize,int total,Object data){
-        return  ok(new PageInfo(page, pageSize, total, data));
-    }
-
     public static ResultData error(int code, String msg) {
         return error(code, msg, null); }
     public static ResultData error(int code, String msg, Object data) {

+ 18 - 4
4dkankan-common-web/src/main/java/com/fdkankan/web/user/SSOLoginHelper.java

@@ -13,8 +13,7 @@ public class SSOLoginHelper {
 
     public SSOUser loginCheck(String token) {
         if (token != null && token.trim().length() > 0) {
-            String username = JwtUtil.getUsername(token);
-            SSOUser ssoUser = ssoLoginStore.get(username);
+            SSOUser ssoUser = ssoLoginStore.get(token);
             if (ssoUser != null) {
                 return ssoUser;
             }
@@ -22,9 +21,19 @@ public class SSOLoginHelper {
         return null;
     }
 
-    public com.fdkankan.web.model.SSOUser loginCheckV3(String token) {
+    public SSOUser getSsoUser(String token) {
         if (token != null && token.trim().length() > 0) {
-            com.fdkankan.web.model.SSOUser ssoUser = ssoLoginStore.getV3(token);
+            SSOUser ssoUser = ssoLoginStore.getSsoUser(token);
+            if (ssoUser != null) {
+                return ssoUser;
+            }
+        }
+        return null;
+    }
+
+    public SSOUser loginCheckV3(String token) {
+        if (token != null && token.trim().length() > 0) {
+            SSOUser ssoUser = ssoLoginStore.getSsoUser(token);
             if (ssoUser != null) {
                 return ssoUser;
             }
@@ -70,4 +79,9 @@ public class SSOLoginHelper {
     public  void logout(String loginType,String userName) {
         ssoLoginStore.remove(loginType,userName);
     }
+
+    public void loginV3(String token, com.fdkankan.web.model.SSOUser ssoUser) {
+        ssoLoginStore.putV3(token, ssoUser);
+    }
+
 }

+ 29 - 3
4dkankan-common-web/src/main/java/com/fdkankan/web/user/SSOLoginStore.java

@@ -1,5 +1,6 @@
 package com.fdkankan.web.user;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.constant.LoginType;
 import com.fdkankan.redis.constant.RedisKey;
@@ -18,6 +19,11 @@ public class SSOLoginStore {
 
     @Resource
     private RedisUtil redisUtil;
+
+    @Resource
+    @Qualifier("redisTemplate2")
+    private RedisTemplate redisTemplate2;
+
     /**
      * get
      * @param userName
@@ -32,10 +38,15 @@ public class SSOLoginStore {
         return null;
     }
 
+    public SSOUser getSsoUser(String token){
+        String tokenKey = getSSoUserTokenKey(token);
+        String objectValue =  redisUtil.get(tokenKey);
+        if (objectValue != null) {
+            return JSONObject.parseObject(objectValue, SSOUser.class);
+        }
+        return null;
+    }
 
-    @Resource
-    @Qualifier("redisTemplate2")
-    private RedisTemplate redisTemplate2;
 
     public com.fdkankan.web.model.SSOUser getV3(String token) {
         String redisKey = "token#".concat(token);
@@ -93,5 +104,20 @@ public class SSOLoginStore {
         return String.format(RedisKey.SSO_USER,userName);
     }
 
+    private static String getSSoUserTokenKey(String token){
+        return String.format(RedisKey.USER_TOKEN_KEY, token);
+    }
+
+    /**
+     * put
+     *
+     * @param sessionId
+     * @param ssoUser
+     */
+    public void putV3(String sessionId, com.fdkankan.web.model.SSOUser ssoUser) {
+        String redisKey = String.format(RedisKey.TOKEN_V3, sessionId);
+        redisUtil.set(redisKey, JSON.toJSONString(ssoUser), 216000);
+    }
+
 
 }

+ 2 - 0
4dkankan-common-web/src/main/java/com/fdkankan/web/user/SSOUser.java

@@ -34,5 +34,7 @@ public class SSOUser implements Serializable {
      */
     private Long cameraId;
 
+    private Long companyId;
+
 
 }

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

@@ -1,4 +1,4 @@
-package com.fdkankan.common.util;
+package com.fdkankan.web.util;
 
 import org.springframework.web.multipart.MultipartFile;
 import sun.misc.BASE64Decoder;
@@ -54,7 +54,9 @@ public class BASE64DecodedMultipartFile implements MultipartFile {
 
     @Override
     public void transferTo(File dest) throws IOException, IllegalStateException {
-        new FileOutputStream(dest).write(imgContent);
+        try (FileOutputStream ios = new FileOutputStream(dest)){
+            ios.write(imgContent);
+        }
     }
 
 

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

@@ -1,5 +1,6 @@
-package com.fdkankan.common.util;
+package com.fdkankan.web.util;
 
+import cn.hutool.core.io.FileUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -41,16 +42,8 @@ public class FileUpload {
 	 * @param realName
 	 * @throws IOException
 	 */
-	private static String copyFile(InputStream in, String dir, String realName)
-			throws IOException {
-		File file = new File(dir, realName);
-		if (!file.exists()) {
-			if (!file.getParentFile().exists()) {
-				file.getParentFile().mkdirs();
-			}
-			file.createNewFile();
-		}
-        org.apache.commons.io.FileUtils.copyInputStreamToFile(in, file);
+	private static String copyFile(InputStream in, String dir, String realName){
+		FileUtil.writeFromStream(in,dir);
 		return realName;
 	}
 

+ 22 - 23
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/RSAEncrypt.java

@@ -1,7 +1,6 @@
-package com.fdkankan.common.util;
+package com.fdkankan.web.util;
 
 import org.apache.commons.codec.binary.Base64;
-import org.springframework.util.ResourceUtils;
 import sun.misc.BASE64Decoder;
 
 import javax.crypto.BadPaddingException;
@@ -80,27 +79,27 @@ public class RSAEncrypt {
      *
      * @throws Exception 加载公钥时产生的异常
      */
-    public static String loadPublicKeyByFile() throws Exception {
-        try {
-            BufferedReader br = new BufferedReader(new FileReader(ResourceUtils.getFile(PUBLIC_KEY)));
-            String readLine = null;
-            StringBuilder sb = new StringBuilder();
-            while ((readLine = br.readLine()) != null) {
-                if (readLine.charAt(0) == '-') {
-                    continue;
-                } else {
-                    sb.append(readLine);
-                    sb.append('\r');
-                }
-            }
-            br.close();
-            return sb.toString();
-        } catch (IOException e) {
-            throw new Exception("公钥数据流读取错误");
-        } catch (NullPointerException e) {
-            throw new Exception("公钥输入流为空");
-        }
-    }
+//    public static String loadPublicKeyByFile() throws Exception {
+//        try {
+//            BufferedReader br = new BufferedReader(new FileReader(ResourceUtils.getFile(PUBLIC_KEY)));
+//            String readLine = null;
+//            StringBuilder sb = new StringBuilder();
+//            while ((readLine = br.readLine()) != null) {
+//                if (readLine.charAt(0) == '-') {
+//                    continue;
+//                } else {
+//                    sb.append(readLine);
+//                    sb.append('\r');
+//                }
+//            }
+//            br.close();
+//            return sb.toString();
+//        } catch (IOException e) {
+//            throw new Exception("公钥数据流读取错误");
+//        } catch (NullPointerException e) {
+//            throw new Exception("公钥输入流为空");
+//        }
+//    }
 
     /**
      * 从文件中输入流中加载公钥

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

@@ -1,4 +1,4 @@
-package com.fdkankan.common.util;
+package com.fdkankan.web.util;
 
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;

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

@@ -1,10 +1,15 @@
 package com.fdkankan.web.util;
 
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.ContentType;
+import cn.hutool.http.useragent.UserAgent;
+import cn.hutool.http.useragent.UserAgentUtil;
 import com.alibaba.fastjson.JSON;
 import java.util.HashMap;
 import javax.servlet.http.HttpServletRequest;
 import org.aspectj.lang.JoinPoint;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.reactive.ServerHttpRequest;
 
 /**
  * <p>
@@ -16,20 +21,67 @@ import org.aspectj.lang.JoinPoint;
  **/
 public class WebUtil {
 
+    private final static String UNKNOWN = "unknown";
+
     /**
-     * 获取请求参数中的场景码
+     * aop中获取请求参数中的参数值
      * @param pjp
      * @param request
      * @return
      */
-    public static String getNum(JoinPoint pjp, HttpServletRequest request){
+    public static String getParameter(String paramName, JoinPoint pjp, HttpServletRequest request){
         Object[] args = pjp.getArgs();
         String contentType = request.getContentType();
         if(contentType.contains(ContentType.JSON.getValue())){
             HashMap hashMap = JSON.parseObject(JSON.toJSONString(args[0]), HashMap.class);
-            return (String) hashMap.get("num");
+            return (String) hashMap.get(paramName);
+        }
+        return request.getParameter(paramName);
+    }
+
+    /**
+     * 获取客户端请求终端地址
+     * @param request  客户端请求request
+     * @return  终端ip地址
+     */
+    public static String getIpAddress(HttpServletRequest request) {
+        String ip = request.getHeader("X-Forwarded-For");
+        if(StrUtil.isNotBlank(ip) && UNKNOWN.equalsIgnoreCase(ip)){
+            if(ip.indexOf(",") != -1){
+                ip = ip.split(",")[0];
+                return ip;
+            }
         }
-        return request.getParameter("num");
+            ip = request.getHeader("Proxy-Client-IP");
+        if(StrUtil.isNotBlank(ip)) return ip;
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        if(StrUtil.isNotBlank(ip)) return ip;
+            ip = request.getHeader("HTTP-CLIENT-IP");
+        if(StrUtil.isNotBlank(ip)) return ip;
+            ip = request.getHeader("HTTP-X-FORWARDED-FOR");
+        if(StrUtil.isNotBlank(ip)) return ip;
+            ip = request.getHeader("X-Real-IP");
+        if(StrUtil.isNotBlank(ip)) return ip;
+            ip = request.getRemoteAddr();
+        return ip;
+    }
+
+    /**
+     * <p>
+            获取浏览器版本
+     * </p>
+     * @author dengsixing
+     * @date 2022/8/19
+     * @param request
+     * @return java.lang.String
+     **/
+    public static  String getBrowser(HttpServletRequest request){
+        String userAgentStr = request.getHeader("User-Agent");
+        UserAgent userAgent = UserAgentUtil.parse(userAgentStr);
+        String browserType = userAgent.getBrowser().toString();
+        String browserVersion = userAgent.getVersion();
+        String browserFormat = "%s(版本%s)";
+        return  String.format(browserFormat, browserType, browserVersion);
     }
 
 }

+ 1 - 22
4dkankan-utils-app-push/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>4dkankan-utils</artifactId>
         <groupId>com.fdkankan</groupId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>3.0.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -33,27 +33,6 @@
             <artifactId>commons-lang3</artifactId>
         </dependency>
         <dependency>
-            <groupId>com.aliyun</groupId>
-            <artifactId>aliyun-java-sdk-core</artifactId>
-            <version>4.0.3</version>
-        </dependency>
-        <dependency>
-            <groupId>com.aliyun</groupId>
-            <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
-            <version>1.1.0</version>
-        </dependency>
-        <dependency>
-            <groupId>com.amazonaws</groupId>
-            <artifactId>aws-java-sdk</artifactId>
-            <version>1.11.327</version>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.mail</groupId>
-            <artifactId>javax.mail</artifactId>
-            <version>1.5.4</version>
-        </dependency>
-
-        <dependency>
             <groupId>com.google.firebase</groupId>
             <artifactId>firebase-admin</artifactId>
             <version>6.8.1</version>

+ 0 - 6
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/App.java

@@ -1,6 +0,0 @@
-package com.fdkankan.modeling.push;
-
-
-public class App {
-
-}

+ 0 - 331
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/PushMessageConfig.java

@@ -1,331 +0,0 @@
-package com.fdkankan.push;
-
-
-import cn.hutool.core.date.DateUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.push.android.*;
-import com.fdkankan.push.ios.*;
-import lombok.extern.slf4j.Slf4j;
-
-import java.util.Date;
-
-@Slf4j
-public class PushMessageConfig {
-	private String appkey = null;
-	private String appMasterSecret = null;
-	private String timestamp = null;
-	private PushClient client = new PushClient();
-
-	public static final String ANDROID_KEY = "5ee71c03dbc2ec076dd488cb";
-	public static final String ANDROID_SECRET = "gzw4r8frbhq6eigxrvgjkdrm7wgtu83g";
-	public static final String IOS_KEY = "5ee71ca9978eea081640f22a";
-	public static final String IOS_SECRET = "tpuhyojch16pcha2qmpidlbnzkielv9w";
-
-	//转台双目使用
-	public static final String ANDROID_KEY_Z = "60efd777a6f90557b7b97c25";
-	public static final String ANDROID_SECRET_Z = "ll85ov3qzeuas0ig7cw0v5bgzq1bdl07";
-	public static final String IOS_KEY_Z = "60efd7c9a6f90557b7b97d10";
-	public static final String IOS_SECRET_Z = "li62b5f3d9kn8idvy6qva3c5gyidmqwl";
-
-	public PushMessageConfig(String key, String secret) {
-		try {
-			appkey = key;
-			appMasterSecret = secret;
-		} catch (Exception e) {
-			e.printStackTrace();
-			System.exit(1);
-		}
-	}
-	
-	public void sendAndroidBroadcast() throws Exception {
-		AndroidBroadcast broadcast = new AndroidBroadcast(appkey,appMasterSecret);
-		broadcast.setTicker( "Android broadcast ticker");
-		broadcast.setTitle(  "中文的title");
-		broadcast.setText(   "Android broadcast text");
-		broadcast.goAppAfterOpen();
-		broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
-		// TODO Set 'production_mode' to 'false' if it's a test device. 
-		// For how to register a test device, please see the developer doc.
-		broadcast.setProductionMode();
-		// Set customized fields
-		broadcast.setExtraField("test", "helloworld");
-		//厂商通道相关参数
-		broadcast.setChannelActivity("your channel activity");
-		broadcast.setChannelProperties("abc");
-		client.send(broadcast);
-	}
-	
-	public void sendAndroidUnicast(String token, String ticker, String title, String text, String url) throws Exception {
-		AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret);
-		// TODO Set your device token
-		unicast.setDeviceToken(token);
-		unicast.setTicker(ticker);
-		unicast.setTitle(title);
-		unicast.setText(text);
-		unicast.goUrlAfterOpen(url);
-		unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
-		// TODO Set 'production_mode' to 'false' if it's a test device. 
-		// For how to register a test device, please see the developer doc.
-		unicast.setProductionMode();
-		// Set customized fields
-		unicast.setExtraField("test", "helloworld");
-		unicast.setChannelActivity("com.fdage.eight.module.EightPushMsgHandlerActivity");
-//		unicast.setChannelProperties("abc");
-
-		client.send(unicast);
-	}
-
-	//转台相机
-	public void sendAndroidUnicast2(String token, String ticker, String title, String text, String url) throws Exception {
-		AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret);
-		// TODO Set your device token
-		unicast.setDeviceToken(token);
-		unicast.setTicker(ticker);
-		unicast.setTitle(title);
-		unicast.setText(text);
-		unicast.goUrlAfterOpen(url);
-		unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
-		// TODO Set 'production_mode' to 'false' if it's a test device.
-		// For how to register a test device, please see the developer doc.
-		unicast.setProductionMode();
-		// Set customized fields
-		unicast.setExtraField("test", "helloworld");
-		unicast.setChannelActivity("io.github.zileyuan.umeng_analytics_push.OfflineNotifyClickActivity");
-//		unicast.setChannelProperties("abc");
-
-		client.send(unicast);
-	}
-	
-	public void sendAndroidGroupcast() throws Exception {
-		AndroidGroupcast groupcast = new AndroidGroupcast(appkey,appMasterSecret);
-		/*  TODO
-		 *  Construct the filter condition:
-		 *  "where": 
-		 *	{
-    	 *		"and": 
-    	 *		[
-      	 *			{"tag":"test"},
-      	 *			{"tag":"Test"}
-    	 *		]
-		 *	}
-		 */
-		JSONObject filterJson = new JSONObject();
-		JSONObject whereJson = new JSONObject();
-		JSONArray tagArray = new JSONArray();
-		JSONObject testTag = new JSONObject();
-		JSONObject TestTag = new JSONObject();
-		testTag.put("tag", "test");
-		TestTag.put("tag", "Test");
-		tagArray.add(testTag);
-		tagArray.add(TestTag);
-		whereJson.put("and", tagArray);
-		filterJson.put("where", whereJson);
-
-		groupcast.setFilter(filterJson);
-		groupcast.setTicker( "Android groupcast ticker");
-		groupcast.setTitle(  "中文的title");
-		groupcast.setText(   "Android groupcast text");
-		groupcast.goAppAfterOpen();
-		groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
-		groupcast.setChannelActivity("your channel activity");
-		// TODO Set 'production_mode' to 'false' if it's a test device. 
-		// For how to register a test device, please see the developer doc.
-		groupcast.setProductionMode();
-		//厂商通道相关参数
-		groupcast.setChannelActivity("your channel activity");
-		groupcast.setChannelProperties("abc");
-		client.send(groupcast);
-	}
-	
-	public void sendAndroidCustomizedcast() throws Exception {
-		AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
-		// TODO Set your alias here, and use comma to split them if there are multiple alias.
-		// And if you have many alias, you can also upload a file containing these alias, then 
-		// use file_id to send customized notification.
-		customizedcast.setAlias("alias", "alias_type");
-		customizedcast.setTicker( "Android customizedcast ticker");
-		customizedcast.setTitle(  "中文的title");
-		customizedcast.setText(   "Android customizedcast text");
-		customizedcast.goAppAfterOpen();
-		customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
-		// TODO Set 'production_mode' to 'false' if it's a test device. 
-		// For how to register a test device, please see the developer doc.
-		customizedcast.setProductionMode();
-		//厂商通道相关参数
-		customizedcast.setChannelActivity("your channel activity");
-		customizedcast.setChannelProperties("abc");
-		client.send(customizedcast);
-	}
-	
-	public void sendAndroidCustomizedcastFile() throws Exception {
-		AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
-		// TODO Set your alias here, and use comma to split them if there are multiple alias.
-		// And if you have many alias, you can also upload a file containing these alias, then 
-		// use file_id to send customized notification.
-		String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb"+"\n"+"alias");
-		customizedcast.setFileId(fileId, "alias_type");
-		customizedcast.setTicker( "Android customizedcast ticker");
-		customizedcast.setTitle(  "中文的title");
-		customizedcast.setText(   "Android customizedcast text");
-		customizedcast.goAppAfterOpen();
-		customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
-		// TODO Set 'production_mode' to 'false' if it's a test device. 
-		// For how to register a test device, please see the developer doc.
-		customizedcast.setProductionMode();
-		//厂商通道相关参数
-		customizedcast.setChannelActivity("your channel activity");
-		customizedcast.setChannelProperties("abc");
-		client.send(customizedcast);
-	}
-	
-	public void sendAndroidFilecast() throws Exception {
-		AndroidFilecast filecast = new AndroidFilecast(appkey,appMasterSecret);
-		// TODO upload your device tokens, and use '\n' to split them if there are multiple tokens 
-		String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb");
-		filecast.setFileId( fileId);
-		filecast.setTicker( "Android filecast ticker");
-		filecast.setTitle(  "中文的title");
-		filecast.setText(   "Android filecast text");
-		filecast.goAppAfterOpen();
-		filecast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
-		//厂商通道相关参数
-		filecast.setChannelActivity("your channel activity");
-		filecast.setChannelProperties("abc");
-		client.send(filecast);
-	}
-	
-	public void sendIOSBroadcast() throws Exception {
-		IOSBroadcast broadcast = new IOSBroadcast(appkey,appMasterSecret);
-        //alert值设置为字符串
-		//broadcast.setAlert("IOS 广播测试");
-		//alert的值设置为字典
-//		broadcast.setAlert("今日天气" , "" , "今日可能下雨🌂");
-		broadcast.setBadge( 0);
-		broadcast.setSound( "default");
-		// TODO set 'production_mode' to 'true' if your app is under production mode
-		broadcast.setTestMode();
-		// Set customized fields
-		broadcast.setCustomizedField("test", "helloworld");
-		client.send(broadcast);
-	}
-	
-	public void sendIOSUnicast(String token, String title ,String subtitle , String body, String url) throws Exception {
-		IOSUnicast unicast = new IOSUnicast(appkey,appMasterSecret);
-		// TODO Set your device token
-		unicast.setDeviceToken(token);
-		//alert值设置为字符串
-		//unicast.setAlert("IOS 单播测试");
-		//alert的值设置为字典
-		unicast.setAlert(title, subtitle, body, url);
-//		unicast.setBadge( 0);
-		unicast.setSound( "default");
-		// TODO set 'production_mode' to 'true' if your app is under production mode
-		unicast.setProductionMode();
-//		unicast.setTestMode();
-		unicast.setDescription(title);
-		unicast.setExpireTime(DateUtil.formatTime(DateUtil.offsetDay(new Date(), 1)));
-		// Set customized fields
-//		unicast.setCustomizedField("url", url);
-		client.send(unicast);
-	}
-
-	
-	public void sendIOSGroupcast() throws Exception {
-		IOSGroupcast groupcast = new IOSGroupcast(appkey,appMasterSecret);
-		/*  TODO
-		 *  Construct the filter condition:
-		 *  "where": 
-		 *	{
-    	 *		"and": 
-    	 *		[
-      	 *			{"tag":"iostest"}
-    	 *		]
-		 *	}
-		 */
-		JSONObject filterJson = new JSONObject();
-		JSONObject whereJson = new JSONObject();
-		JSONArray tagArray = new JSONArray();
-		JSONObject testTag = new JSONObject();
-		testTag.put("tag", "iostest");
-		tagArray.add(testTag);
-		whereJson.put("and", tagArray);
-		filterJson.put("where", whereJson);
-		log.info(filterJson.toString());
-		
-		// Set filter condition into rootJson
-		groupcast.setFilter(filterJson);
-		//groupcast.setAlert("IOS 组播测试");
-		//alert的值设置为字典
-//		groupcast.setAlert("今日天气" , "subtitle" , "今日可能下雨🌂");
-		groupcast.setBadge( 0);
-		groupcast.setSound( "default");
-		// TODO set 'production_mode' to 'true' if your app is under production mode
-		groupcast.setTestMode();
-		client.send(groupcast);
-	}
-	
-	public void sendIOSCustomizedcast() throws Exception {
-		IOSCustomizedcast customizedcast = new IOSCustomizedcast(appkey,appMasterSecret);
-		// TODO Set your alias and alias_type here, and use comma to split them if there are multiple alias.
-		// And if you have many alias, you can also upload a file containing these alias, then 
-		// use file_id to send customized notification.
-		customizedcast.setAlias("alias", "alias_type");
-		//customizedcast.setAlert("IOS 个性化测试");
-		//alert的值设置为字典
-//		customizedcast.setAlert("今日天气" , "" , "今日可能下雨🌂");
-		customizedcast.setBadge( 0);
-		customizedcast.setSound( "default");
-		// TODO set 'production_mode' to 'true' if your app is under production mode
-		customizedcast.setTestMode();
-		client.send(customizedcast);
-	}
-	
-	public void sendIOSFilecast() throws Exception {
-		IOSFilecast filecast = new IOSFilecast(appkey,appMasterSecret);
-		// TODO upload your device tokens, and use '\n' to split them if there are multiple tokens 
-		String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb");
-		filecast.setFileId( fileId);
-		//filecast.setAlert("IOS 文件播测试");
-		//alert的值设置为字典
-//		filecast.setAlert("今日天气" , "" , "今日可能下雨🌂");
-		filecast.setBadge( 0);
-		filecast.setSound( "default");
-		// TODO set 'production_mode' to 'true' if your app is under production mode
-		filecast.setTestMode();
-		client.send(filecast);
-	}
-	
-	public static void main(String[] args) {
-		// TODO set your appkey and master secret here
-		//安卓
-//		Demo demo = new Demo(ANDROID_KEY, ANDROID_SECRET);
-		//ios
-		PushMessageConfig pushMessageConfig = new PushMessageConfig(IOS_KEY, IOS_SECRET);
-		try {
-//			demo.sendAndroidUnicast("AneqkEZahjbW3cF7gu8juNYqz54ZFfK7kjMpTOiQL9dl",
-//					"测试项目计算完成", "四维看看Pro", "您上传的测试项目计算完成,点击查看",
-//					"https://test.4dkankan.com/smobile.html?m=t-e9uHHdn");
-			pushMessageConfig.sendIOSUnicast("ec61a2aa52673c96c12024e07ce267e391ca560e0c60f15ee09e65c8843ef7f4",
-					"四维看看Pro", "测试项目计算完成", "您上传的测试项目计算完成,点击查看",
-					"https://test.4dkankan.com/smobile.html?m=t-e9uHHdn");
-			/* TODO these methods are all available, just fill in some fields and do the test
-			 * demo.sendAndroidCustomizedcastFile();
-			 * demo.sendAndroidBroadcast();
-			 * demo.sendAndroidGroupcast();
-			 * demo.sendAndroidCustomizedcast();
-			 * demo.sendAndroidFilecast();
-			 * 
-			 * demo.sendIOSBroadcast();
-			 * demo.sendIOSUnicast();
-			 * demo.sendIOSGroupcast();
-			 * demo.sendIOSCustomizedcast();
-			 * demo.sendIOSFilecast();
-			 */
-		} catch (Exception ex) {
-			ex.printStackTrace();
-		}
-	}
-	
-
-}

+ 0 - 86
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/UmengNotification.java

@@ -1,86 +0,0 @@
-package com.fdkankan.push;
-
-import com.alibaba.fastjson.JSONObject;
-
-import java.util.Arrays;
-import java.util.HashSet;
-
-public abstract class UmengNotification {
-	// This JSONObject is used for constructing the whole request string.
-	protected final JSONObject rootJson = new JSONObject();
-	
-	
-	// The app master secret
-	protected String appMasterSecret;
-	
-	// Keys can be set in the root level
-	protected static final HashSet<String> ROOT_KEYS = new HashSet<String>(Arrays.asList(new String[]{
-			"appkey", "timestamp", "type", "device_tokens", "alias", "alias_type", "file_id", 
-			"filter", "production_mode", "feedback", "description", "thirdparty_id" , "mipush" , "mi_activity" , "channel_properties"}));
-	
-	// Keys can be set in the policy level
-	protected static final HashSet<String> POLICY_KEYS = new HashSet<String>(Arrays.asList(new String[]{
-			"start_time", "expire_time", "max_send_num"
-	}));
-	
-	// Set predefined keys in the rootJson, for extra keys(Android) or customized keys(IOS) please 
-	// refer to corresponding methods in the subclass.
-	public abstract boolean setPredefinedKeyValue(String key, Object value) throws Exception;
-	public void setAppMasterSecret(String secret) {
-		appMasterSecret = secret;
-	}
-	
-	public String getPostBody(){
-		return rootJson.toString();
-	}
-	
-	protected final String getAppMasterSecret(){
-		return appMasterSecret;
-	}
-	
-	protected void setProductionMode(Boolean prod) throws Exception {
-    	setPredefinedKeyValue("production_mode", prod.toString());
-    }
-
-	///正式模式
-    public void setProductionMode() throws Exception {
-    	setProductionMode(true);
-    }
-
-    ///测试模式
-    public void setTestMode() throws Exception {
-    	setProductionMode(false);
-    }
-
-    ///发送消息描述,建议填写。
-    public void setDescription(String description) throws Exception {
-    	setPredefinedKeyValue("description", description);
-    }
-
-    ///定时发送时间,若不填写表示立即发送。格式: "YYYY-MM-DD hh:mm:ss"。
-    public void setStartTime(String startTime) throws Exception {
-    	setPredefinedKeyValue("start_time", startTime);
-    }
-    ///消息过期时间,格式: "YYYY-MM-DD hh:mm:ss"。
-    public void setExpireTime(String expireTime) throws Exception {
-    	setPredefinedKeyValue("expire_time", expireTime);
-    }
-    ///发送限速,每秒发送的最大条数。
-    public void setMaxSendNum(Integer num) throws Exception {
-    	setPredefinedKeyValue("max_send_num", num);
-    }
-
-    //厂商弹窗activity
-	public void setChannelActivity(String activity) throws Exception{
-       setPredefinedKeyValue("mipush", "true");
-       setPredefinedKeyValue("mi_activity",activity );
-	}
-
-	//厂商属性配置
-	public void setChannelProperties(String xiaoMiChannelId) throws Exception{
-		JSONObject object = new JSONObject();
-		object.put("xiaomi_channel_id" , xiaoMiChannelId);
-		setPredefinedKeyValue("channel_properties", object);
-	}
-
-}

+ 0 - 11
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidBroadcast.java

@@ -1,11 +0,0 @@
-package com.fdkankan.push.android;
-
-import com.fdkankan.push.AndroidNotification;
-
-public class AndroidBroadcast extends AndroidNotification {
-	public AndroidBroadcast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "broadcast");	
-	}
-}

+ 0 - 22
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidCustomizedcast.java

@@ -1,22 +0,0 @@
-package com.fdkankan.push.android;
-
-import com.fdkankan.push.AndroidNotification;
-
-public class AndroidCustomizedcast extends AndroidNotification {
-	public AndroidCustomizedcast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "customizedcast");	
-	}
-	
-	public void setAlias(String alias,String aliasType) throws Exception {
-    	setPredefinedKeyValue("alias", alias);
-    	setPredefinedKeyValue("alias_type", aliasType);
-    }
-			
-	public void setFileId(String fileId,String aliasType) throws Exception {
-    	setPredefinedKeyValue("file_id", fileId);
-    	setPredefinedKeyValue("alias_type", aliasType);
-    }
-
-}

+ 0 - 15
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidFilecast.java

@@ -1,15 +0,0 @@
-package com.fdkankan.push.android;
-
-import com.fdkankan.push.AndroidNotification;
-
-public class AndroidFilecast extends AndroidNotification {
-	public AndroidFilecast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "filecast");	
-	}
-	
-	public void setFileId(String fileId) throws Exception {
-    	setPredefinedKeyValue("file_id", fileId);
-    }
-}

+ 0 - 16
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidGroupcast.java

@@ -1,16 +0,0 @@
-package com.fdkankan.push.android;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.push.AndroidNotification;
-
-public class AndroidGroupcast extends AndroidNotification {
-	public AndroidGroupcast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "groupcast");	
-	}
-	
-	public void setFilter(JSONObject filter) throws Exception {
-    	setPredefinedKeyValue("filter", filter);
-    }
-}

+ 2 - 1
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/AndroidNotification.java

@@ -1,6 +1,7 @@
-package com.fdkankan.push;
+package com.fdkankan.push.android;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.push.common.UmengNotification;
 
 import java.util.Arrays;
 import java.util.HashSet;

+ 0 - 2
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/android/AndroidUnicast.java

@@ -1,7 +1,5 @@
 package com.fdkankan.push.android;
 
-import com.fdkankan.push.AndroidNotification;
-
 public class AndroidUnicast extends AndroidNotification {
 	public AndroidUnicast(String appkey,String appMasterSecret) throws Exception {
 			setAppMasterSecret(appMasterSecret);

+ 3 - 42
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/PushClient.java

@@ -1,6 +1,7 @@
-package com.fdkankan.push;
+package com.fdkankan.push.common;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.push.common.UmengNotification;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.http.HttpResponse;
@@ -31,6 +32,7 @@ public class PushClient {
 	protected static final String postPath = "/api/send";
 
 	public boolean send(UmengNotification msg) throws Exception {
+	    log.info("开始推送app消息,{}",JSONObject.toJSONString(msg));
 		String timestamp = Integer.toString((int)(System.currentTimeMillis() / 1000));
 		msg.setPredefinedKeyValue("timestamp", timestamp);
         String url = host + postPath;
@@ -59,45 +61,4 @@ public class PushClient {
         }
         return true;
     }
-
-	// Upload file with device_tokens to Umeng
-	public String uploadContents(String appkey,String appMasterSecret,String contents) throws Exception {
-		// Construct the json string
-		JSONObject uploadJson = new JSONObject();
-		uploadJson.put("appkey", appkey);
-		String timestamp = Integer.toString((int)(System.currentTimeMillis() / 1000));
-		uploadJson.put("timestamp", timestamp);
-		uploadJson.put("content", contents);
-		// Construct the request
-		String url = host + uploadPath;
-		String postBody = uploadJson.toString();
-		String sign = DigestUtils.md5Hex(("POST" + url + postBody + appMasterSecret).getBytes("utf8"));
-		url = url + "?sign=" + sign;
-		HttpPost post = new HttpPost(url);
-		post.setHeader("User-Agent", USER_AGENT);
-		StringEntity se = new StringEntity(postBody, "UTF-8");
-		post.setEntity(se);
-		// Send the post request and get the response
-		HttpResponse response = client.execute(post);
-		log.info("Response Code : " + response.getStatusLine().getStatusCode());
-		BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-		StringBuffer result = new StringBuffer();
-		String line = "";
-		while ((line = rd.readLine()) != null) {
-			result.append(line);
-		}
-		log.info(result.toString());
-		// Decode response string and get file_id from it
-		JSONObject respJson = JSONObject.parseObject(result.toString());
-		String ret = respJson.getString("ret");
-		if (!ret.equals("SUCCESS")) {
-			throw new Exception("Failed to upload file");
-		}
-		JSONObject data = respJson.getJSONObject("data");
-		String fileId = data.getString("file_id");
-		// Set file_id into rootJson using setPredefinedKeyValue
-		
-		return fileId;
-	}
-
 }

+ 89 - 0
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/common/UmengNotification.java

@@ -0,0 +1,89 @@
+package com.fdkankan.push.common;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+public abstract class UmengNotification {
+    // This JSONObject is used for constructing the whole request string.
+    protected final JSONObject rootJson = new JSONObject();
+
+
+    // The app master secret
+    protected String appMasterSecret;
+
+    // Keys can be set in the root level
+    protected static final HashSet<String> ROOT_KEYS = new HashSet<String>(Arrays.asList(new String[]{
+            "appkey", "timestamp", "type", "device_tokens", "alias", "alias_type", "file_id",
+            "filter", "production_mode", "feedback", "description", "thirdparty_id", "mipush", "mi_activity", "channel_properties"}));
+
+    // Keys can be set in the policy level
+    protected static final HashSet<String> POLICY_KEYS = new HashSet<String>(Arrays.asList(new String[]{
+            "start_time", "expire_time", "max_send_num"
+    }));
+
+    // Set predefined keys in the rootJson, for extra keys(Android) or customized keys(IOS) please
+    // refer to corresponding methods in the subclass.
+    public abstract boolean setPredefinedKeyValue(String key, Object value) throws Exception;
+
+    public void setAppMasterSecret(String secret) {
+        appMasterSecret = secret;
+    }
+
+    public String getPostBody() {
+        return rootJson.toString();
+    }
+
+    protected final String getAppMasterSecret() {
+        return appMasterSecret;
+    }
+
+    protected void setProductionMode(Boolean prod) throws Exception {
+        setPredefinedKeyValue("production_mode", prod.toString());
+    }
+
+    ///正式模式
+    public void setProductionMode() throws Exception {
+        setProductionMode(true);
+    }
+
+    ///测试模式
+    public void setTestMode() throws Exception {
+        setProductionMode(false);
+    }
+
+    ///发送消息描述,建议填写。
+    public void setDescription(String description) throws Exception {
+        setPredefinedKeyValue("description", description);
+    }
+
+    ///定时发送时间,若不填写表示立即发送。格式: "YYYY-MM-DD hh:mm:ss"。
+    public void setStartTime(String startTime) throws Exception {
+        setPredefinedKeyValue("start_time", startTime);
+    }
+
+    ///消息过期时间,格式: "YYYY-MM-DD hh:mm:ss"。
+    public void setExpireTime(String expireTime) throws Exception {
+        setPredefinedKeyValue("expire_time", expireTime);
+    }
+
+    ///发送限速,每秒发送的最大条数。
+    public void setMaxSendNum(Integer num) throws Exception {
+        setPredefinedKeyValue("max_send_num", num);
+    }
+
+    //厂商弹窗activity
+    public void setChannelActivity(String activity) throws Exception {
+        setPredefinedKeyValue("mipush", "true");
+        setPredefinedKeyValue("mi_activity", activity);
+    }
+
+    //厂商属性配置
+    public void setChannelProperties(String xiaoMiChannelId) throws Exception {
+        JSONObject object = new JSONObject();
+        object.put("xiaomi_channel_id", xiaoMiChannelId);
+        setPredefinedKeyValue("channel_properties", object);
+    }
+
+}

+ 112 - 0
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/config/PushMessageConfig.java

@@ -0,0 +1,112 @@
+package com.fdkankan.push.config;
+
+
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.push.android.*;
+import com.fdkankan.push.common.PushClient;
+import com.fdkankan.push.ios.*;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.Date;
+
+@Slf4j
+public class PushMessageConfig {
+	private String appkey = null;
+	private String appMasterSecret = null;
+	private PushClient client = new PushClient();
+
+	public static final String ANDROID_KEY = "5ee71c03dbc2ec076dd488cb";
+	public static final String ANDROID_SECRET = "gzw4r8frbhq6eigxrvgjkdrm7wgtu83g";
+	public static final String IOS_KEY = "5ee71ca9978eea081640f22a";
+	public static final String IOS_SECRET = "tpuhyojch16pcha2qmpidlbnzkielv9w";
+
+	//转台双目使用
+	public static final String ANDROID_KEY_Z = "60efd777a6f90557b7b97c25";
+	public static final String ANDROID_SECRET_Z = "ll85ov3qzeuas0ig7cw0v5bgzq1bdl07";
+	public static final String IOS_KEY_Z = "60efd7c9a6f90557b7b97d10";
+	public static final String IOS_SECRET_Z = "li62b5f3d9kn8idvy6qva3c5gyidmqwl";
+
+	public PushMessageConfig(String key, String secret) {
+		appkey = key;
+		appMasterSecret = secret;
+	}
+
+	public String getAppkey() {
+		return appkey;
+	}
+
+	public void setAppkey(String appkey) {
+		this.appkey = appkey;
+	}
+
+	public String getAppMasterSecret() {
+		return appMasterSecret;
+	}
+
+	public void setAppMasterSecret(String appMasterSecret) {
+		this.appMasterSecret = appMasterSecret;
+	}
+
+	public void sendAndroidUnicast(String token, String ticker, String title, String text, String url) throws Exception {
+		AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret);
+		// TODO Set your device token
+		unicast.setDeviceToken(token);
+		unicast.setTicker(ticker);
+		unicast.setTitle(title);
+		unicast.setText(text);
+		unicast.goUrlAfterOpen(url);
+		unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
+		// TODO Set 'production_mode' to 'false' if it's a test device. 
+		// For how to register a test device, please see the developer doc.
+		unicast.setProductionMode();
+		// Set customized fields
+		unicast.setExtraField("test", "helloworld");
+		unicast.setChannelActivity("com.fdage.eight.module.EightPushMsgHandlerActivity");
+//		unicast.setChannelProperties("abc");
+
+		client.send(unicast);
+	}
+
+	//转台相机
+	public void sendAndroidUnicast2(String token, String ticker, String title, String text, String url) throws Exception {
+		AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret);
+		// TODO Set your device token
+		unicast.setDeviceToken(token);
+		unicast.setTicker(ticker);
+		unicast.setTitle(title);
+		unicast.setText(text);
+		unicast.goUrlAfterOpen(url);
+		unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
+		// TODO Set 'production_mode' to 'false' if it's a test device.
+		// For how to register a test device, please see the developer doc.
+		unicast.setProductionMode();
+		// Set customized fields
+		unicast.setExtraField("test", "helloworld");
+		unicast.setChannelActivity("io.github.zileyuan.umeng_analytics_push.OfflineNotifyClickActivity");
+//		unicast.setChannelProperties("abc");
+
+		client.send(unicast);
+	}
+	
+	public void sendIOSUnicast(String token, String title ,String subtitle , String body, String url) throws Exception {
+		IOSUnicast unicast = new IOSUnicast(appkey,appMasterSecret);
+		// TODO Set your device token
+		unicast.setDeviceToken(token);
+		//alert值设置为字符串
+		//unicast.setAlert("IOS 单播测试");
+		//alert的值设置为字典
+		unicast.setAlert(title, subtitle, body, url);
+//		unicast.setBadge( 0);
+		unicast.setSound( "default");
+		// TODO set 'production_mode' to 'true' if your app is under production mode
+		unicast.setProductionMode();
+//		unicast.setTestMode();
+		unicast.setDescription(title);
+		unicast.setExpireTime(DateUtil.formatTime(DateUtil.offsetDay(new Date(), 1)));
+		// Set customized fields
+//		unicast.setCustomizedField("url", url);
+		client.send(unicast);
+	}
+}

+ 0 - 12
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSBroadcast.java

@@ -1,12 +0,0 @@
-package com.fdkankan.push.ios;
-
-import com.fdkankan.push.IOSNotification;
-
-public class IOSBroadcast extends IOSNotification {
-	public IOSBroadcast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "broadcast");	
-		
-	}
-}

+ 0 - 23
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSCustomizedcast.java

@@ -1,23 +0,0 @@
-package com.fdkankan.push.ios;
-
-
-import com.fdkankan.push.IOSNotification;
-
-public class IOSCustomizedcast extends IOSNotification {
-	public IOSCustomizedcast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "customizedcast");	
-	}
-	
-	public void setAlias(String alias,String aliasType) throws Exception {
-    	setPredefinedKeyValue("alias", alias);
-    	setPredefinedKeyValue("alias_type", aliasType);
-    }
-		
-	public void setFileId(String fileId, String aliasType) throws Exception {
-		setPredefinedKeyValue("file_id", fileId);
-		setPredefinedKeyValue("alias_type", aliasType);
-	}
-
-}

+ 0 - 15
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSFilecast.java

@@ -1,15 +0,0 @@
-package com.fdkankan.push.ios;
-
-import com.fdkankan.push.IOSNotification;
-
-public class IOSFilecast extends IOSNotification {
-	public IOSFilecast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "filecast");	
-	}
-	
-	public void setFileId(String fileId) throws Exception {
-    	setPredefinedKeyValue("file_id", fileId);
-    }
-}

+ 0 - 16
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSGroupcast.java

@@ -1,16 +0,0 @@
-package com.fdkankan.push.ios;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.push.IOSNotification;
-
-public class IOSGroupcast extends IOSNotification {
-	public IOSGroupcast(String appkey,String appMasterSecret) throws Exception {
-			setAppMasterSecret(appMasterSecret);
-			setPredefinedKeyValue("appkey", appkey);
-			this.setPredefinedKeyValue("type", "groupcast");	
-	}
-	
-	public void setFilter(JSONObject filter) throws Exception {
-    	setPredefinedKeyValue("filter", filter);
-    }
-}

+ 2 - 1
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/IOSNotification.java

@@ -1,6 +1,7 @@
-package com.fdkankan.push;
+package com.fdkankan.push.ios;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.push.common.UmengNotification;
 
 import java.util.Arrays;
 import java.util.HashSet;

+ 0 - 2
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/ios/IOSUnicast.java

@@ -1,7 +1,5 @@
 package com.fdkankan.push.ios;
 
-import com.fdkankan.push.IOSNotification;
-
 public class IOSUnicast extends IOSNotification {
 	public IOSUnicast(String appkey,String appMasterSecret) throws Exception{
 			setAppMasterSecret(appMasterSecret);

+ 1 - 1
4dkankan-utils-app-push/src/main/java/com/fdkankan/push/PushMsgUtil.java

@@ -1,4 +1,4 @@
-package com.fdkankan.push;
+package com.fdkankan.push.utils;
 
 import com.google.auth.oauth2.GoogleCredentials;
 import com.google.firebase.FirebaseApp;

+ 2 - 2
4dkankan-utils-db/pom.xml

@@ -6,12 +6,12 @@
     <parent>
         <groupId>com.fdkankan</groupId>
         <artifactId>4dkankan-utils</artifactId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>3.0.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>4dkankan-utils-db</artifactId>
-    <version>2.0.0-SNAPSHOT</version>
+    <version>3.0.0-SNAPSHOT</version>
     <dependencies>
 
         <dependency>

+ 1 - 1
4dkankan-common-utils/src/main/java/com/fdkankan/common/response/PageInfo.java

@@ -1,4 +1,4 @@
-package com.fdkankan.common.response;
+package com.fdkankan.db.response;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.AllArgsConstructor;

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

@@ -1,4 +1,4 @@
-package com.fdkankan.common.util;
+package com.fdkankan.db.utils;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import java.util.LinkedList;

+ 2 - 2
4dkankan-utils-dingtalk/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>4dkankan-utils</artifactId>
         <groupId>com.fdkankan</groupId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>3.0.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -23,7 +23,7 @@
         <dependency>
             <groupId>com.fdkankan</groupId>
             <artifactId>4dkankan-common-utils</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <version>3.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>

+ 64 - 0
4dkankan-utils-elasticsearch/pom.xml

@@ -0,0 +1,64 @@
+<?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-elasticsearch</artifactId>
+
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+
+        <!--引入es-high-level-client相关依赖  start-->
+        <dependency>
+            <groupId>org.elasticsearch</groupId>
+            <artifactId>elasticsearch</artifactId>
+            <version>7.6.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.elasticsearch.client</groupId>
+            <artifactId>elasticsearch-rest-client</artifactId>
+            <version>7.6.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.elasticsearch.client</groupId>
+            <artifactId>elasticsearch-rest-high-level-client</artifactId>
+            <version>7.6.2</version>
+        </dependency>
+        <!--引入es-high-level-client相关依赖  end-->
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.83</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.2</version>
+        </dependency>
+
+    </dependencies>
+
+</project>

+ 115 - 0
4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/config/ElasticsearchConfig.java

@@ -0,0 +1,115 @@
+package com.fdkankan.elasticsearch.config;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author yanfengzhang
+ * @description restHighLevelClient 客户端配置类
+ * @date 2022/12/7  23:34
+ */
+
+@Slf4j
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "elasticsearch")
+public class ElasticsearchConfig {
+    /**
+     * es host ip 地址(集群)
+     */
+    private String hosts;
+    /**
+     * es用户名
+     */
+    private String userName;
+    /**
+     * es密码
+     */
+    private String password;
+    /**
+     * es 请求方式
+     */
+    private String scheme;
+    /**
+     * es集群名称
+     */
+    private String clusterName;
+    /**
+     * es 连接超时时间
+     */
+    private int connectTimeOut;
+    /**
+     * es socket 连接超时时间
+     */
+    private int socketTimeOut;
+    /**
+     * es 请求超时时间
+     */
+    private int connectionRequestTimeOut;
+    /**
+     * es 最大连接数
+     */
+    private int maxConnectNum;
+    /**
+     * es 每个路由的最大连接数
+     */
+    private int maxConnectNumPerRoute;
+
+    /**
+     * 如果@Bean没有指定bean的名称,那么这个bean的名称就是方法名
+     */
+    @Bean(name = "restHighLevelClient")
+    public RestHighLevelClient restHighLevelClient() {
+        /** 拆分地址
+         /**        List<HttpHost> hostLists = new ArrayList<>();
+         /**        String[] hostList = hosts.split(",");
+         /**        for (String addr : hostList) {
+         /**            String host = addr.split(":")[0];
+         /**            String port = addr.split(":")[1];
+         /**            hostLists.add(new HttpHost(host, Integer.parseInt(port), scheme));
+         /**        }
+         /**        /** 转换成 HttpHost 数组
+         /**        HttpHost[] httpHost = hostLists.toArray(new HttpHost[]{});*/
+
+        /*此处为单节点es*/
+        String host = hosts.split(":")[0];
+        String port = hosts.split(":")[1];
+        HttpHost httpHost = new HttpHost(host, Integer.parseInt(port));
+
+        /*构建连接对象*/
+        RestClientBuilder builder = RestClient.builder(httpHost);
+
+        /*设置用户名、密码*/
+        CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+        credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
+
+        /*连接延时配置*/
+        builder.setRequestConfigCallback(requestConfigBuilder -> {
+            requestConfigBuilder.setConnectTimeout(connectTimeOut);
+            requestConfigBuilder.setSocketTimeout(socketTimeOut);
+            requestConfigBuilder.setConnectionRequestTimeout(connectionRequestTimeOut);
+            return requestConfigBuilder;
+        });
+
+        /*连接数配置*/
+        builder.setHttpClientConfigCallback(httpClientBuilder -> {
+            httpClientBuilder.setMaxConnTotal(maxConnectNum);
+            httpClientBuilder.setMaxConnPerRoute(maxConnectNumPerRoute);
+            httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
+            return httpClientBuilder;
+        });
+
+        return new RestHighLevelClient(builder);
+    }
+}

+ 60 - 0
4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/DocumentService.java

@@ -0,0 +1,60 @@
+package com.fdkankan.elasticsearch.service;
+
+import com.alibaba.fastjson.JSONObject;
+import org.elasticsearch.rest.RestStatus;
+
+import java.io.IOException;
+import java.util.List;
+
+public interface  DocumentService {
+
+    /**
+     * 增加文档信息
+     *
+     * @param indexName 索引名
+     * @param keyId     主键
+     * @param data      json数据
+     * @return 增加文档信息状态
+     * @throws IOException 异常信息
+     */
+    RestStatus addDocument(String indexName, String keyId,String data) throws IOException;
+
+    /**
+     * 获取文档信息
+     *
+     * @param indexName 索引名
+     * @param id        文档ID
+     * @return 商品数据
+     * @throws Exception 异常信息
+     */
+    String getDocument(String indexName, String id) throws Exception;
+
+    /**
+     * 更新文档信息
+     *
+     * @param indexName 索引名
+     * @param data      数据
+     * @return 更新文档信息状态
+     * @throws IOException 异常信息
+     */
+    RestStatus updateDocument(String indexName, String id ,String data) throws IOException;
+
+    /**
+     * 删除文档信息
+     *
+     * @param indexName 索引名
+     * @param id        文档ID
+     * @return 删除文档信息状态
+     * @throws IOException 异常信息
+     */
+    RestStatus deleteDocument(String indexName, String id) throws IOException;
+
+    /**
+     * 批量导入
+     *
+     * @param dataList 商品列表
+     * @return 批量导入状态
+     * @throws IOException 异常信息
+     */
+    RestStatus batchImportGoodsData(List<JSONObject> dataList, String index) throws IOException;
+}

+ 45 - 0
4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/IndexService.java

@@ -0,0 +1,45 @@
+package com.fdkankan.elasticsearch.service;
+
+
+import java.util.Map;
+
+public interface IndexService {
+
+
+    /**
+     * 创建索引
+     *
+     * @param indexName 索引名
+     * @param mapping   映射结构配置
+     * @return true-创建成功
+     * @throws Exception 异常
+     */
+    boolean indexCreate(String indexName, String mapping) throws Exception;
+
+    /**
+     * 获取索引结构
+     *
+     * @param indexName 索引名
+     * @return 索引结构
+     * @throws Exception 异常
+     */
+    Map<String, Object> getMapping(String indexName) throws Exception;
+
+    /**
+     * 删除索引库
+     *
+     * @param indexName 索引名
+     * @return true-删除成功
+     * @throws Exception 异常
+     */
+    boolean indexDelete(String indexName) throws Exception;
+
+    /**
+     * 判断索引是否存在
+     *
+     * @param indexName 索引名
+     * @return true-存在
+     * @throws Exception 异常
+     */
+    boolean indexExists(String indexName) throws Exception;
+}

+ 149 - 0
4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/QueryDataService.java

@@ -0,0 +1,149 @@
+package com.fdkankan.elasticsearch.service;
+
+import java.util.List;
+
+public interface QueryDataService {
+
+    /**
+     * 精确查询(termQuery)
+     *
+     * @param indexName  索引名
+     * @param columnName 列名或字段名
+     * @param value      查询内容
+     * @param classz     数据结构
+     * @param <T>        数据结构
+     * @return 精确查询内容数据
+     */
+    <T> List<T> termQuery(String indexName, String columnName, Object value, Class<T> classz);
+
+    /**
+     * terms:多个查询内容在一个字段中进行查询
+     *
+     * @param indexName  索引名
+     * @param columnName 列名或字段名
+     * @param dataArgs   查询内容集合
+     * @param classz     数据结构
+     * @param <T>        数据结构
+     * @return 多个查询内容在一个字段中进行查询对应结果
+     */
+    <T> List<T> termsQuery(String indexName, String columnName, Object[] dataArgs, Class<T> classz);
+
+    /**
+     * 匹配查询符合条件的所有数据,并设置分页
+     *
+     * @param indexName  索引名
+     * @param classz     数据结构
+     * @param startIndex 起始下标
+     * @param pageSize   页大小
+     * @param orderList  设置排序
+     * @param columnName 列名或字段名
+     * @param value      列名或字段名指定内容
+     * @param <T>        数据结构
+     * @return 符合条件的所有数据
+     */
+    <T> List<T> matchAllQuery(String indexName, Class<T> classz, int startIndex, int pageSize, List<String> orderList, String columnName, Object value);
+
+    /**
+     * 词语匹配查询
+     *
+     * @param indexName  索引名
+     * @param classz     数据结构
+     * @param columnName 列名或字段名
+     * @param value      指定内容
+     * @param <T>        数据结构
+     * @return 词语匹配查询结果
+     */
+    <T> List<T> matchPhraseQuery(String indexName, Class<T> classz, String columnName, Object value);
+
+    /**
+     * 内容在多字段中进行查询
+     *
+     * @param indexName 索引名
+     * @param classz    数据结构
+     * @param fields    列名或字段名集合
+     * @param text      指定内容
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    <T> List<T> matchMultiQuery(String indexName, Class<T> classz, String[] fields, Object text);
+
+    /**
+     * 通配符查询(wildcard):会对查询条件进行分词。还可以使用通配符 ?(任意单个字符) 和 * (0个或多个字符)
+     *
+     * @param indexName 索引名
+     * @param classz    数据结构
+     * @param field     列名或字段名集合
+     * @param text      指定内容
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    <T> List<T> wildcardQuery(String indexName, Class<T> classz, String field, String text);
+
+    /**
+     * 模糊查询商品信息
+     *
+     * @param indexName 索引名
+     * @param classz    数据结构
+     * @param field     列名或字段名集合
+     * @param text      指定内容
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    <T> List<T> fuzzyQuery(String indexName, Class<T> classz, String field, String text);
+
+    /**
+     * boolQuery 查询
+     * 高亮展示标题搜索字段
+     * 设置出参返回字段
+     * 案例:查询从2018-2022年间标题含 三星 的商品信息
+     *
+     * @param indexName 索引名
+     * @param beanClass 数据结构
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    <T> List<T> boolQuery(String indexName, Class<T> beanClass);
+
+    /**
+     * 聚合查询 : 聚合查询一定是【先查出结果】,然后对【结果使用聚合函数】做处理.
+     * Metric 指标聚合分析。常用的操作有:avg:求平均、max:最大值、min:最小值、sum:求和等
+     * 案例:分别获取最贵的商品和获取最便宜的商品
+     *
+     * @param indexName 索引名
+     */
+    void metricQuery(String indexName);
+
+    /**
+     * 聚合查询: 聚合查询一定是【先查出结果】,然后对【结果使用聚合函数】做处理
+     * Bucket 分桶聚合分析 : 对查询出的数据进行分组group by,再在组上进行游标聚合
+     * 案例:根据品牌进行聚合查询
+     *
+     * @param indexName        索引名
+     * @param bucketField
+     * @param bucketFieldAlias
+     */
+    void bucketQuery(String indexName, String bucketField, String bucketFieldAlias);
+
+    /**
+     * 子聚合聚合查询  Bucket 分桶聚合分析
+     * <p>
+     * 案例:根据商品分类进行分组查询,并且获取分类商品中的平均价格
+     *
+     * @param indexName        索引名
+     * @param bucketField
+     * @param bucketFieldAlias
+     * @param avgFiled
+     * @param avgFiledAlias
+     */
+    void subBucketQuery(String indexName, String bucketField, String bucketFieldAlias, String avgFiled, String avgFiledAlias);
+
+    /**
+     * 综合聚合查询
+     * <p>
+     * 根据商品分类聚合,获取每个商品类的平均价格,并且在商品分类聚合之上子聚合每个品牌的平均价格
+     *
+     * @param indexName 索引名
+     */
+    void subSubAgg(String indexName);
+
+}

+ 141 - 0
4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/impl/DocumentServiceImpl.java

@@ -0,0 +1,141 @@
+package com.fdkankan.elasticsearch.service.impl;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.elasticsearch.service.DocumentService;
+import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.delete.DeleteRequest;
+import org.elasticsearch.action.delete.DeleteResponse;
+import org.elasticsearch.action.get.GetRequest;
+import org.elasticsearch.action.get.GetResponse;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.update.UpdateRequest;
+import org.elasticsearch.action.update.UpdateResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.xcontent.XContentType;
+import org.elasticsearch.rest.RestStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+@Service
+public class DocumentServiceImpl implements DocumentService {
+
+    @Autowired
+    private RestHighLevelClient restHighLevelClient;
+
+    /**
+     * 增加文档信息
+     *
+     * @param indexName 索引名
+     * @param keyId     主键
+     * @param data      json数据
+     * @return 增加文档信息状态
+     * @throws IOException 异常信息
+     */
+    @Override
+    public RestStatus addDocument(String indexName, String keyId, String data) throws IOException {
+        /*2.将对象转为json*/
+        /*3.创建索引请求对象*/
+        IndexRequest indexRequest = new IndexRequest(indexName).id(keyId).source(data, XContentType.JSON);
+        /*4.执行增加文档*/
+        IndexResponse response = restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
+
+        return response.status();
+    }
+
+    /**
+     * 获取文档信息
+     *
+     * @param indexName 索引名
+     * @param id        文档ID
+     * @return 商品数据
+     * @throws Exception 异常信息
+     */
+    @Override
+    public String getDocument(String indexName, String id) throws Exception {
+        /*2.创建获取请求对象*/
+        GetRequest getRequest = new GetRequest(indexName, id);
+        GetResponse response = restHighLevelClient.get(getRequest, RequestOptions.DEFAULT);
+
+        return response.getSourceAsString();
+    }
+
+    /**
+     * 更新文档信息
+     *
+     * @param indexName 索引名
+     * @param data      数据
+     * @return 更新文档信息状态
+     * @throws IOException 异常信息
+     */
+    @Override
+    public RestStatus updateDocument(String indexName, String id ,String data) throws IOException {
+
+        /*2.创建索引请求对象*/
+        UpdateRequest updateRequest = new UpdateRequest(indexName, id);
+        /*3.设置更新文档内容*/
+        updateRequest.doc(data, XContentType.JSON);
+        /*4.执行更新文档*/
+        UpdateResponse response = restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);
+
+        return response.status();
+    }
+
+    /**
+     * 删除文档信息
+     *
+     * @param indexName 索引名
+     * @param type      文档类型
+     * @param id        文档ID
+     * @return 删除文档信息状态
+     * @throws IOException 异常信息
+     */
+    @Override
+    public RestStatus deleteDocument(String indexName, String id) throws IOException {
+        /*2.创建删除请求对象*/
+        DeleteRequest deleteRequest = new DeleteRequest(indexName, id);
+        /*3.执行删除文档*/
+        DeleteResponse response = restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);
+
+        return response.status();
+    }
+
+    /**
+     * 批量导入
+     *
+     * @param dataList 列表
+     * @return 批量导入状态
+     * @throws IOException 异常信息
+     */
+    @Override
+    public RestStatus batchImportGoodsData(List<JSONObject> dataList, String index) throws IOException {
+        if (CollectionUtils.isEmpty(dataList)) {
+            return RestStatus.CREATED;
+        }
+
+        /*bulk导入 循环goodsList,创建IndexRequest添加数据*/
+        BulkRequest bulkRequest = new BulkRequest();
+        for (JSONObject data : dataList) {
+            //将goods对象转换为json字符串
+            IndexRequest indexRequest = new IndexRequest(index);
+            indexRequest.id(data.getString("id")).source(JSON.toJSONString(data), XContentType.JSON);
+            bulkRequest.add(indexRequest);
+        }
+
+        BulkResponse response = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
+        return response.status();
+    }
+
+}

+ 106 - 0
4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/impl/IndexServiceImpl.java

@@ -0,0 +1,106 @@
+package com.fdkankan.elasticsearch.service.impl;
+
+
+import com.fdkankan.elasticsearch.service.IndexService;
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
+import org.elasticsearch.client.IndicesClient;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.CreateIndexResponse;
+import org.elasticsearch.client.indices.GetIndexRequest;
+import org.elasticsearch.client.indices.GetIndexResponse;
+import org.elasticsearch.cluster.metadata.MappingMetaData;
+import org.elasticsearch.common.xcontent.XContentType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+
+@Service
+public class IndexServiceImpl implements IndexService {
+
+    @Autowired
+    private RestHighLevelClient restHighLevelClient;
+
+
+
+    /**
+     * 创建索引
+     *
+     * @param indexName 索引名
+     * @param mapping   映射结构配置
+     * @return true-创建成功
+     * @throws Exception 异常
+     */
+    @Override
+    public boolean indexCreate(String indexName, String mapping) throws Exception {
+        CreateIndexRequest indexRequest = new CreateIndexRequest(indexName);
+
+        IndicesClient indicesClient = restHighLevelClient.indices();
+        indexRequest.mapping(mapping, XContentType.JSON);
+
+        // 请求服务器
+        CreateIndexResponse response = indicesClient.create(indexRequest, RequestOptions.DEFAULT);
+
+        return response.isAcknowledged();
+    }
+
+    /**
+     * 获取索引结构
+     *
+     * @param indexName 索引名
+     * @return 索引结构
+     * @throws Exception 异常
+     */
+    @Override
+    public Map<String, Object> getMapping(String indexName) throws Exception {
+        IndicesClient indicesClient = restHighLevelClient.indices();
+
+        // 创建get请求
+        GetIndexRequest request = new GetIndexRequest(indexName);
+        // 发送get请求
+        GetIndexResponse response = indicesClient.get(request, RequestOptions.DEFAULT);
+        // 获取表结构
+        Map<String, MappingMetaData> mappings = response.getMappings();
+        Map<String, Object> sourceAsMap = mappings.get(indexName).getSourceAsMap();
+        return sourceAsMap;
+    }
+
+    /**
+     * 删除索引库
+     *
+     * @param indexName 索引名
+     * @return true-删除成功
+     * @throws Exception 异常
+     */
+    @Override
+    public boolean indexDelete(String indexName) throws Exception {
+        IndicesClient indicesClient = restHighLevelClient.indices();
+        // 创建delete请求方式
+        DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName);
+        // 发送delete请求
+        AcknowledgedResponse response = indicesClient.delete(deleteIndexRequest, RequestOptions.DEFAULT);
+
+        return response.isAcknowledged();
+    }
+
+    /**
+     * 判断索引是否存在
+     *
+     * @param indexName 索引名
+     * @return true-存在
+     * @throws Exception 异常
+     */
+    @Override
+    public boolean indexExists(String indexName) throws Exception {
+        IndicesClient indicesClient = restHighLevelClient.indices();
+        // 创建get请求
+        GetIndexRequest request = new GetIndexRequest(indexName);
+        // 判断索引库是否存在
+        return indicesClient.exists(request, RequestOptions.DEFAULT);
+    }
+
+}

+ 531 - 0
4dkankan-utils-elasticsearch/src/main/java/com/fdkankan/elasticsearch/service/impl/QueryDataServiceImpl.java

@@ -0,0 +1,531 @@
+package com.fdkankan.elasticsearch.service.impl;
+
+
+import com.alibaba.fastjson.JSON;
+import com.fdkankan.elasticsearch.service.QueryDataService;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.text.Text;
+import org.elasticsearch.common.unit.Fuzziness;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
+import org.elasticsearch.index.query.MatchQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.rest.RestStatus;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.SearchHits;
+import org.elasticsearch.search.aggregations.AggregationBuilder;
+import org.elasticsearch.search.aggregations.AggregationBuilders;
+import org.elasticsearch.search.aggregations.Aggregations;
+import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
+import org.elasticsearch.search.aggregations.bucket.terms.Terms;
+import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
+import org.elasticsearch.search.aggregations.metrics.ParsedAvg;
+import org.elasticsearch.search.aggregations.metrics.ParsedMax;
+import org.elasticsearch.search.aggregations.metrics.ParsedMin;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
+import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
+import org.elasticsearch.search.sort.SortOrder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author yanfengzhang
+ * @description
+ * @date 2022/12/8  23:37
+ */
+@Service
+@Log4j2
+public class QueryDataServiceImpl implements QueryDataService {
+    @Autowired
+    private RestHighLevelClient restHighLevelClient;
+
+    /**
+     * 精确查询(termQuery)
+     *
+     * @param indexName  索引名
+     * @param columnName 列名或字段名
+     * @param value      查询内容
+     * @param classz     数据结构
+     * @param <T>        数据结构
+     * @return 精确查询内容数据
+     */
+    @Override
+    public <T> List<T> termQuery(String indexName, String columnName, Object value, Class<T> classz) {
+        /* 查询的数据列表 */
+        List<T> list = new ArrayList<>();
+        try {
+            /*构建查询条件(注意:termQuery 支持多种格式查询,如 boolean、int、double、string 等,这里使用的是 string 的查询)*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(QueryBuilders.termQuery(columnName, value));
+            /*执行查询es数据*/
+            queryEsData(indexName, classz, list, searchSourceBuilder);
+        } catch (IOException e) {
+            log.error("精确查询数据失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * terms:多个查询内容在一个字段中进行查询
+     *
+     * @param indexName  索引名
+     * @param columnName 列名或字段名
+     * @param dataArgs   查询内容集合
+     * @param classz     数据结构
+     * @param <T>        数据结构
+     * @return 多个查询内容在一个字段中进行查询对应结果
+     */
+    @Override
+    public <T> List<T> termsQuery(String indexName, String columnName, Object[] dataArgs, Class<T> classz) {
+        /*查询的数据列表*/
+        List<T> list = new ArrayList<>();
+        try {
+            /* 构建查询条件(注意:termsQuery 支持多种格式查询,如 boolean、int、double、string 等,这里使用的是 string 的查询)*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(QueryBuilders.termsQuery(columnName, dataArgs));
+            /*展示100条,默认只展示10条记录*/
+            searchSourceBuilder.size(100);
+            /*执行查询es数据*/
+            queryEsData(indexName, classz, list, searchSourceBuilder);
+        } catch (IOException e) {
+            log.error("单字段多内容查询数据失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * 匹配查询符合条件的所有数据,并设置分页
+     *
+     * @param indexName  索引名
+     * @param classz     数据结构
+     * @param startIndex 起始下标
+     * @param pageSize   页大小
+     * @param orderList  设置排序
+     * @param columnName 列名或字段名
+     * @param value      列名或字段名指定内容
+     * @param <T>        数据结构
+     * @return 符合条件的所有数据
+     */
+    @Override
+    public <T> List<T> matchAllQuery(String indexName, Class<T> classz, int startIndex, int pageSize, List<String> orderList, String columnName, Object value) {
+        /*查询的数据列表*/
+        List<T> list = new ArrayList<>();
+        try {
+            /*创建查询源构造器*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+
+            /*构建查询条件*/
+            if (StringUtils.isNotBlank(columnName) && Objects.nonNull(value)) {
+                MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery(columnName, value);
+                searchSourceBuilder.query(matchQueryBuilder);
+            } else {
+                MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();
+                searchSourceBuilder.query(matchAllQueryBuilder);
+            }
+
+            /*设置分页*/
+            searchSourceBuilder.from(startIndex);
+            searchSourceBuilder.size(pageSize);
+
+            /*设置排序*/
+            if (orderList != null) {
+                for (String order : orderList) {
+                    /*开头代表:倒序*/
+                    boolean flag = order.startsWith("-");
+                    SortOrder sort = flag ? SortOrder.DESC : SortOrder.ASC;
+                    order = flag ? order.substring(1) : order;
+                    searchSourceBuilder.sort(order, sort);
+                }
+            }
+            /*执行查询es数据*/
+            queryEsData(indexName, classz, list, searchSourceBuilder);
+        } catch (IOException e) {
+            log.error("查询所有数据失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * 词语匹配查询
+     *
+     * @param indexName  索引名
+     * @param classz     数据结构
+     * @param columnName 列名或字段名
+     * @param value      指定内容
+     * @param <T>        数据结构
+     * @return 词语匹配查询结果
+     */
+    @Override
+    public <T> List<T> matchPhraseQuery(String indexName, Class<T> classz, String columnName, Object value) {
+        /*查询的数据列表*/
+        List<T> list = new ArrayList<>();
+        try {
+            /*构建查询条件*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(QueryBuilders.matchPhraseQuery(columnName, value));
+            /*执行查询es数据*/
+            queryEsData(indexName, classz, list, searchSourceBuilder);
+        } catch (IOException e) {
+            log.error("词语匹配查询失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * 内容在多字段中进行查询
+     *
+     * @param indexName 索引名
+     * @param classz    数据结构
+     * @param fields    列名或字段名集合
+     * @param text      指定内容
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    @Override
+    public <T> List<T> matchMultiQuery(String indexName, Class<T> classz, String[] fields, Object text) {
+        /*查询的数据列表*/
+        List<T> list = new ArrayList<>();
+        try {
+            /*构建查询条件*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            /*设置查询条件*/
+            searchSourceBuilder.query(QueryBuilders.multiMatchQuery(text, fields));
+            /*执行查询es数据*/
+            queryEsData(indexName, classz, list, searchSourceBuilder);
+        } catch (IOException e) {
+            log.error("词语匹配查询失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * 通配符查询(wildcard):会对查询条件进行分词。还可以使用通配符 ?(任意单个字符) 和 * (0个或多个字符)
+     *
+     * @param indexName 索引名
+     * @param classz    数据结构
+     * @param field     列名或字段名集合
+     * @param text      指定内容
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    @Override
+    public <T> List<T> wildcardQuery(String indexName, Class<T> classz, String field, String text) {
+        /*查询的数据列表*/
+        List<T> list = new ArrayList<>();
+        try {
+            /*构建查询条件*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(QueryBuilders.wildcardQuery(field, text));
+            /*执行查询es数据*/
+            queryEsData(indexName, classz, list, searchSourceBuilder);
+        } catch (IOException e) {
+            log.error("通配符查询失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * 模糊查询商品信息
+     *
+     * @param indexName 索引名
+     * @param classz    数据结构
+     * @param field     列名或字段名集合
+     * @param text      指定内容
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    @Override
+    public <T> List<T> fuzzyQuery(String indexName, Class<T> classz, String field, String text) {
+        /*查询的数据列表*/
+        List<T> list = new ArrayList<>();
+        try {
+            /*构建查询条件*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(QueryBuilders.fuzzyQuery(field, text).fuzziness(Fuzziness.AUTO));
+            /*执行查询es数据*/
+            queryEsData(indexName, classz, list, searchSourceBuilder);
+        } catch (IOException e) {
+            log.error("通配符查询失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * boolQuery 查询
+     * 高亮展示标题搜索字段
+     * 设置出参返回字段
+     * 案例:查询从2018-2022年间标题含 三星 的商品信息
+     *
+     * @param indexName 索引名
+     * @param beanClass 数据结构
+     * @param <T>       数据结构
+     * @return 查询结果
+     */
+    @Override
+    public <T> List<T> boolQuery(String indexName, Class<T> beanClass) {
+        /*查询的数据列表*/
+        List<T> list = new ArrayList<>();
+        try {
+            /*创建 Bool 查询构建器*/
+            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
+            /*构建查询条件*/
+            /*构建查询源构建器*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(boolQueryBuilder);
+            searchSourceBuilder.size(100);
+            /*甚至返回字段
+            如果查询的属性很少,那就使用includes,而excludes设置为空数组
+            如果排序的属性很少,那就使用excludes,而includes设置为空数组*/
+            /*创建查询请求对象,将查询对象配置到其中*/
+            SearchRequest searchRequest = new SearchRequest(indexName);
+            searchRequest.source(searchSourceBuilder);
+            /*执行查询,然后处理响应结果*/
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            /*根据状态和数据条数验证是否返回了数据*/
+            if (RestStatus.OK.equals(searchResponse.status()) && searchResponse.getHits().getTotalHits().value > 0) {
+                SearchHits hits = searchResponse.getHits();
+                for (SearchHit hit : hits) {
+                    /* 将 JSON 转换成对象*/
+                    T bean = JSON.parseObject(hit.getSourceAsString(), beanClass);
+                    /*获取高亮的数据*/
+                    HighlightField highlightField = hit.getHighlightFields().get("title");
+                    log.info("高亮名称:{}", highlightField.getFragments()[0].string());
+                    /*替换掉原来的数据*/
+                    Text[] fragments = highlightField.getFragments();
+                    if (fragments != null && fragments.length > 0) {
+                        StringBuilder title = new StringBuilder();
+                        for (Text fragment : fragments) {
+                            title.append(fragment);
+                        }
+                        /* 获取method对象,其中包含方法名称和参数列表*/
+                        Method setTitle = beanClass.getMethod("setTitle", String.class);
+                        if (setTitle != null) {
+                            /*执行method,bean为实例对象,后面是方法参数列表;setTitle没有返回值*/
+                            setTitle.invoke(bean, title.toString());
+                        }
+                    }
+                    list.add(bean);
+                }
+            }
+        } catch (Exception e) {
+            log.error("布尔查询失败,错误信息:", e);
+        }
+        return list;
+    }
+
+    /**
+     * 聚合查询 : 聚合查询一定是【先查出结果】,然后对【结果使用聚合函数】做处理.
+     * Metric 指标聚合分析。常用的操作有:avg:求平均、max:最大值、min:最小值、sum:求和等
+     * 案例:分别获取最贵的商品和获取最便宜的商品
+     *
+     * @param indexName 索引名
+     */
+    @Override
+    public void metricQuery(String indexName) {
+        try {
+            /* 构建查询条件*/
+            MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();
+            /*创建查询源构造器*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(matchAllQueryBuilder);
+
+            /*获取最贵的商品*/
+            AggregationBuilder maxPrice = AggregationBuilders.max("maxPrice").field("price");
+            searchSourceBuilder.aggregation(maxPrice);
+            /*获取最便宜的商品*/
+            AggregationBuilder minPrice = AggregationBuilders.min("minPrice").field("price");
+            searchSourceBuilder.aggregation(minPrice);
+
+            /*创建查询请求对象,将查询对象配置到其中*/
+            SearchRequest searchRequest = new SearchRequest(indexName);
+            searchRequest.source(searchSourceBuilder);
+            /*执行查询,然后处理响应结果*/
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            Aggregations aggregations = searchResponse.getAggregations();
+            ParsedMax max = aggregations.get("maxPrice");
+            log.info("最贵的价格:" + max.getValue());
+            ParsedMin min = aggregations.get("minPrice");
+            log.info("最便宜的价格:" + min.getValue());
+        } catch (Exception e) {
+            log.error("指标聚合分析查询失败,错误信息:", e);
+        }
+    }
+
+    /**
+     * 聚合查询: 聚合查询一定是【先查出结果】,然后对【结果使用聚合函数】做处理
+     * Bucket 分桶聚合分析 : 对查询出的数据进行分组group by,再在组上进行游标聚合
+     * 案例:根据品牌进行聚合查询
+     *
+     * @param indexName        索引名
+     * @param bucketField
+     * @param bucketFieldAlias
+     */
+    @Override
+    public void bucketQuery(String indexName, String bucketField, String bucketFieldAlias) {
+        try {
+            /*构建查询条件*/
+            MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();
+            /*创建查询源构造器*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(matchAllQueryBuilder);
+
+            /*根据bucketField进行分组查询*/
+            TermsAggregationBuilder aggBrandName = AggregationBuilders.terms(bucketFieldAlias).field(bucketField);
+            searchSourceBuilder.aggregation(aggBrandName);
+
+            /*创建查询请求对象,将查询对象配置到其中*/
+            SearchRequest searchRequest = new SearchRequest(indexName);
+            searchRequest.source(searchSourceBuilder);
+            /*执行查询,然后处理响应结果*/
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            Aggregations aggregations = searchResponse.getAggregations();
+            /*分组结果数据*/
+            ParsedStringTerms aggBrandName1 = aggregations.get(bucketFieldAlias);
+            for (Terms.Bucket bucket : aggBrandName1.getBuckets()) {
+                log.info(bucket.getKeyAsString() + "====" + bucket.getDocCount());
+            }
+        } catch (IOException e) {
+            log.error("分桶聚合分析查询失败,错误信息:", e);
+        }
+    }
+
+    /**
+     * 子聚合聚合查询  Bucket 分桶聚合分析
+     * <p>
+     * 案例:根据商品分类进行分组查询,并且获取分类商品中的平均价格
+     *
+     * @param indexName        索引名
+     * @param bucketField
+     * @param bucketFieldAlias
+     * @param avgFiled
+     * @param avgFiledAlias
+     */
+    @Override
+    public void subBucketQuery(String indexName, String bucketField, String bucketFieldAlias, String avgFiled, String avgFiledAlias) {
+        try {
+            /*构建查询条件*/
+            MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();
+            /*创建查询源构造器*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(matchAllQueryBuilder);
+
+            /* 根据 bucketField进行分组查询,并且获取分类信息中 指定字段的平均值*/
+            TermsAggregationBuilder subAggregation = AggregationBuilders.terms(bucketFieldAlias).field(bucketField)
+                    .subAggregation(AggregationBuilders.avg(avgFiledAlias).field(avgFiled));
+            searchSourceBuilder.aggregation(subAggregation);
+
+            /* 创建查询请求对象,将查询对象配置到其中*/
+            SearchRequest searchRequest = new SearchRequest(indexName);
+            searchRequest.source(searchSourceBuilder);
+            /*执行查询,然后处理响应结果*/
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            Aggregations aggregations = searchResponse.getAggregations();
+            ParsedStringTerms aggBrandName1 = aggregations.get(bucketFieldAlias);
+            for (Terms.Bucket bucket : aggBrandName1.getBuckets()) {
+                /*获取聚合后的 组内字段平均值,注意返回值不是Aggregation对象,而是指定的ParsedAvg对象*/
+                ParsedAvg avgPrice = bucket.getAggregations().get(avgFiledAlias);
+                log.info(bucket.getKeyAsString() + "====" + avgPrice.getValueAsString());
+            }
+        } catch (IOException e) {
+            log.error("分桶聚合分析查询失败,错误信息:", e);
+        }
+    }
+
+    /**
+     * 综合聚合查询
+     * <p>
+     * 根据商品分类聚合,获取每个商品类的平均价格,并且在商品分类聚合之上子聚合每个品牌的平均价格
+     *
+     * @param indexName 索引名
+     */
+    @Override
+    public void subSubAgg(String indexName) {
+        try {
+            /*构建查询条件*/
+            MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();
+            /*创建查询源构造器*/
+            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+            searchSourceBuilder.query(matchAllQueryBuilder);
+
+            /*注意这里聚合写的位置不要写错,很容易搞混,错一个括号就不对了*/
+            TermsAggregationBuilder subAggregation = AggregationBuilders.terms("categoryNameAgg").field("categoryName")
+                    .subAggregation(AggregationBuilders.avg("categoryNameAvgPrice").field("price"))
+                    .subAggregation(AggregationBuilders.terms("brandNameAgg").field("brandName")
+                            .subAggregation(AggregationBuilders.avg("brandNameAvgPrice").field("price")));
+            searchSourceBuilder.aggregation(subAggregation);
+
+            /*创建查询请求对象,将查询对象配置到其中*/
+            SearchRequest searchRequest = new SearchRequest(indexName);
+            searchRequest.source(searchSourceBuilder);
+            /*执行查询,然后处理响应结果*/
+            SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+            /*获取总记录数*/
+            log.info("totalHits = " + searchResponse.getHits().getTotalHits().value);
+            /*获取聚合信息*/
+            Aggregations aggregations = searchResponse.getAggregations();
+            ParsedStringTerms categoryNameAgg = aggregations.get("categoryNameAgg");
+
+            /*获取值返回*/
+            for (Terms.Bucket bucket : categoryNameAgg.getBuckets()) {
+                /*获取聚合后的分类名称*/
+                String categoryName = bucket.getKeyAsString();
+                /*获取聚合命中的文档数量*/
+                long docCount = bucket.getDocCount();
+                /*获取聚合后的分类的平均价格,注意返回值不是Aggregation对象,而是指定的ParsedAvg对象*/
+                ParsedAvg avgPrice = bucket.getAggregations().get("categoryNameAvgPrice");
+                log.info(categoryName + "======平均价:" + avgPrice.getValue() + "======数量:" + docCount);
+
+                ParsedStringTerms brandNameAgg = bucket.getAggregations().get("brandNameAgg");
+                for (Terms.Bucket brandeNameAggBucket : brandNameAgg.getBuckets()) {
+                    /*获取聚合后的品牌名称*/
+                    String brandName = brandeNameAggBucket.getKeyAsString();
+                    /*获取聚合后的品牌的平均价格,注意返回值不是Aggregation对象,而是指定的ParsedAvg对象*/
+                    ParsedAvg brandNameAvgPrice = brandeNameAggBucket.getAggregations().get("brandNameAvgPrice");
+                    log.info("     " + brandName + "======" + brandNameAvgPrice.getValue());
+                }
+            }
+        } catch (IOException e) {
+            log.error("综合聚合查询失败,错误信息:", e);
+        }
+    }
+
+
+    /**
+     * 执行es查询
+     *
+     * @param indexName
+     * @param beanClass
+     * @param list
+     * @param searchSourceBuilder
+     * @param <T>
+     * @throws IOException
+     */
+    private <T> void queryEsData(String indexName, Class<T> beanClass, List<T> list, SearchSourceBuilder searchSourceBuilder) throws IOException {
+        /*创建查询请求对象,将查询对象配置到其中*/
+        SearchRequest searchRequest = new SearchRequest(indexName);
+        searchRequest.source(searchSourceBuilder);
+        /*执行查询,然后处理响应结果*/
+        SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
+        /*根据状态和数据条数验证是否返回了数据*/
+        if (RestStatus.OK.equals(searchResponse.status()) && searchResponse.getHits().getTotalHits().value > 0) {
+            SearchHits hits = searchResponse.getHits();
+            for (SearchHit hit : hits) {
+                /*将 JSON 转换成对象*/
+                T bean = JSON.parseObject(hit.getSourceAsString(), beanClass);
+                list.add(bean);
+            }
+        }
+    }
+}

+ 1 - 2
4dkankan-utils-email/pom.xml

@@ -5,10 +5,9 @@
     <parent>
         <artifactId>4dkankan-utils</artifactId>
         <groupId>com.fdkankan</groupId>
-        <version>2.0.0-SNAPSHOT</version>
+        <version>3.0.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <version>1.0.0-SNAPSHOT</version>
 
     <artifactId>4dkankan-utils-email</artifactId>
 

+ 27 - 0
4dkankan-utils-fyun-https/pom.xml

@@ -0,0 +1,27 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>4dkankan-utils</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>4dkankan-utils-fyun-https</artifactId>
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-fyun-parent</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+            <version>5.2.15.RELEASE</version>
+        </dependency>
+    </dependencies>
+
+</project>

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

@@ -0,0 +1,314 @@
+package com.fdkankan.fyun.http;
+
+import cn.hutool.core.io.FileUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.fyun.face.AbstractFYunFileService;
+import com.fdkankan.fyun.http.config.HttpFyunConfig;
+import com.fdkankan.fyun.http.entity.Result;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+@ConditionalOnProperty(name = "fyun.type", havingValue = "https")
+public class HttpFileService extends AbstractFYunFileService {
+
+    private Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+    private RestTemplate restTemplate = new RestTemplate();
+
+    @Autowired
+    private HttpFyunConfig httpFyunConfig;
+
+    @Override
+    public String uploadFile(String bucket, byte[] data, String remoteFilePath) {
+        try {
+            // 先将文件保存至本地
+            String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/")+1);
+            FileUtils.writeFile(httpFyunConfig.getLocalTempPath(), fileName, data);
+            uploadFile(bucket,httpFyunConfig.getLocalTempPath() + fileName,remoteFilePath,null);
+            FileUtils.deleteFile(httpFyunConfig.getLocalTempPath() + fileName);
+        } catch (Exception e) {
+            log.error("oss上传文件失败", e);
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public String uploadFile(String bucket, String filePath, String remoteFilePath) {
+        return uploadFile(bucket, filePath, remoteFilePath, null);
+    }
+
+    @Override
+    public String uploadFile(String bucket, InputStream inputStream, String remoteFilePath) {
+        try {
+            // 先将文件保存至本地
+            String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/") + 1);
+            FileUtil.writeFromStream(inputStream, httpFyunConfig.getLocalTempPath() + fileName);
+            uploadFile(bucket,httpFyunConfig.getLocalTempPath() + fileName,remoteFilePath,null);
+            FileUtils.deleteFile(httpFyunConfig.getLocalTempPath() + fileName);
+        } catch (Exception e) {
+            log.error("oss上传文件失败", e);
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public String uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) {
+        try {
+            File file = new File(filePath);
+            if (!file.exists()) {
+                log.error("要上传的文件不存在:" + filePath);
+                return null;
+            }
+            Map<String, Object> params = new HashMap<>();
+            params.put("appName", fYunFileConfig.getKey());
+            params.put("secret", fYunFileConfig.getSecret());
+            params.put("fileName", filePath);
+            params.put("targetPath", remoteFilePath);
+            String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getUploadFile();
+            ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+            log.info("Fyun Http Utils upload,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+                log.error("Fyun Http Utils upload failed!");
+            }
+            log.info("文件上传成功,path:{}", filePath);
+        } catch (Exception e) {
+            log.error("oss上传文件失败", e);
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public String uploadFileByCommand(String bucket, String filePath, String remoteFilePath) {
+        // 上传文件夹
+        Map<String, Object> params = new HashMap<>();
+        params.put("appName", fYunFileConfig.getKey());
+        params.put("secret", fYunFileConfig.getSecret());
+        params.put("dirName", filePath);
+        params.put("targetPath", remoteFilePath);
+        String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getUploadDir();
+        ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+        log.info("Fyun Http Utils upload folder,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+            log.error("Fyun Http Utils upload folder failed!");
+        }
+        return null;
+    }
+
+    @Override
+    public void downloadFileByCommand(String bucket, String localPath, String remoteFilePath) {
+        // 下载文件夹
+        File localFile = new File(localPath);
+        if(localFile.isDirectory()){
+            if(!localFile.exists()){
+                localFile.mkdirs();
+            }
+            String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/")+1);
+            log.info("未配置文件名,使用默认文件名:{}",fileName);
+            localPath = localPath.concat(File.separator).concat(fileName);
+        }else if(!localFile.getParentFile().exists()){
+            localFile.getParentFile().mkdirs();
+        }
+        Map<String, Object> params = new HashMap<>();
+        params.put("appName", fYunFileConfig.getKey());
+        params.put("secret", fYunFileConfig.getSecret());
+        params.put("fileName", remoteFilePath);
+        params.put("targetPath", localPath);
+        String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getDownloadDir();
+        ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+        log.info("Fyun Http Utils download folder,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+            log.error("Fyun Http Utils download folder failed!");
+        }
+    }
+
+    @Override
+    public void deleteFile(String bucket, String remoteFilePath) throws IOException {
+        try {
+            Map<String, Object> params = new HashMap<>();
+            params.put("appName", fYunFileConfig.getKey());
+            params.put("secret", fYunFileConfig.getSecret());
+            params.put("fileName", remoteFilePath);
+            String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getDeleteFile();
+            ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+            log.info("Fyun Http Utils delete file,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+                log.error("Fyun Http Utils delete file failed!");
+            }
+            log.info("文件删除成功,path:{}", remoteFilePath);
+        } catch (Exception e) {
+            log.error("OSS删除文件失败,key=" + remoteFilePath);
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void deleteFolder(String bucket, String remoteFolderPath) {
+        try {
+            Map<String, Object> params = new HashMap<>();
+            params.put("appName", fYunFileConfig.getKey());
+            params.put("secret", fYunFileConfig.getSecret());
+            params.put("dirName", remoteFolderPath);
+            String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getDeleteDir();
+            ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+            log.info("Fyun Http Utils delete folder,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+                log.error("Fyun Http Utils delete folder failed!");
+            }
+            log.info("文件夹删除成功,path:{}", remoteFolderPath);
+        } catch (Exception e) {
+            log.error("OSS删除文件失败,key=" + remoteFolderPath);
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void uploadMulFiles(String bucket, Map<String, String> filepaths) {
+        try {
+            for (Map.Entry<String, String> entry : filepaths.entrySet()) {
+                uploadFile(bucket, entry.getKey(), entry.getValue(), null);
+            }
+        } catch (Exception e) {
+            log.error("OSS批量上传文件失败!");
+        }
+    }
+
+    @Override
+    public List<String> listRemoteFiles(String bucket, String sourcePath) {
+        throw new UnsupportedOperationException("不支持列举文件列表!");
+    }
+
+    @Override
+    public void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            Map<String, Object> params = new HashMap<>();
+            params.put("appName", fYunFileConfig.getKey());
+            params.put("secret", fYunFileConfig.getSecret());
+            params.put("targetDir", targetPath);
+            String url;
+            if(new File(sourcePath).isDirectory()){
+                params.put("dirName", sourcePath);
+                url = fYunFileConfig.getEndPoint() + httpFyunConfig.getCopyDir();
+            }else{
+                params.put("fileName", sourcePath);
+                url = fYunFileConfig.getEndPoint() + httpFyunConfig.getCopyFile();
+            }
+            ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+            log.info("Fyun Http Utils copy file or dir,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+                log.error("Fyun Http Utils copy file or dir failed!");
+            }
+            log.info("文件拷贝成功,path:{}", targetPath);
+        } catch (Exception e) {
+            log.error("列举文件目录失败,key=" + sourcePath);
+        }
+    }
+
+    @Override
+    public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) {
+        if (ObjectUtils.isEmpty(pathMap)) {
+            return;
+        }
+        try {
+            for (Map.Entry<String, String> entry : pathMap.entrySet()) {
+                copyFileBetweenBucket(sourceBucketName, entry.getKey(), targetBucketName, entry.getValue());
+            }
+        } catch (Exception e) {
+            log.error("批量复制文件失败!");
+        }
+    }
+
+    @Override
+    public String getFileContent(String bucketName, String remoteFilePath) {
+        try {
+            // 先将文件下载到本地
+            String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/")+1);
+            downloadFile(remoteFilePath, httpFyunConfig.getLocalTempPath() + fileName);
+            String content =FileUtils.readFile(httpFyunConfig.getLocalTempPath() + fileName);
+            FileUtils.deleteFile(httpFyunConfig.getLocalTempPath() + fileName);
+            return content;
+        } catch (Exception e) {
+            log.error("获取文件内容失败:{}", remoteFilePath);
+            return null;
+        }
+    }
+
+    @Override
+    public boolean fileExist(String bucket, String objectName) {
+        try {
+            Map<String, Object> params = new HashMap<>();
+            params.put("appName", fYunFileConfig.getKey());
+            params.put("secret", fYunFileConfig.getSecret());
+            params.put("fileName", objectName);
+            String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getFileExist();
+            ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+            log.info("Fyun Http Utils file exist,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+                log.error("Fyun Http Utils copy file failed!");
+            }
+            return Boolean.parseBoolean(responseEntity.getBody().getData().toString());
+        } catch (Exception e) {
+            log.error("判断文件是否存在失败:{}", objectName);
+            return false;
+        }
+    }
+
+    @Override
+    public void downloadFile(String bucket, String remoteFilePath, String localPath) {
+        try {
+            File localFile = new File(localPath);
+            if (!localFile.getParentFile().exists()) {
+                localFile.getParentFile().mkdirs();
+            }
+            if(localFile.isDirectory()){
+                String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/")+1);
+                log.info("未配置文件名,使用默认文件名:{}",fileName);
+                localPath = localPath.concat(File.separator).concat(fileName);
+            }
+            Map<String, Object> params = new HashMap<>();
+            params.put("appName", fYunFileConfig.getKey());
+            params.put("secret", fYunFileConfig.getSecret());
+            params.put("fileName", remoteFilePath);
+            params.put("targetPath", localPath);
+            String url = fYunFileConfig.getEndPoint() + httpFyunConfig.getDownloadFile();
+            ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
+            log.info("Fyun Http Utils file exist,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
+            if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != Result.CODE_SUCCESS) {
+                log.error("Fyun Http Utils copy file failed!");
+            }
+        } catch (Throwable throwable) {
+            log.error("文件下载失败:{}", remoteFilePath);
+            throwable.printStackTrace();
+        }
+    }
+
+    @Override
+    public URL getPresignedUrl(String bucket, String url) {
+        throw new UnsupportedOperationException("不支持此操作!");
+    }
+
+    @Override
+    public long getSubFileNums(String bucket, String url) {
+        return 0;
+    }
+
+}

+ 98 - 0
4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/config/HttpFyunConfig.java

@@ -0,0 +1,98 @@
+package com.fdkankan.fyun.http.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+
+@Component
+public class HttpFyunConfig {
+
+    private Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+    private String localTempPath;
+
+    @Value("${fyun.https.file.upload}")
+    private String uploadFile;
+
+    @Value("${fyun.https.file.download}")
+    private String downloadFile;
+
+    @Value("${fyun.https.file.exist}")
+    private String fileExist;
+
+    @Value("${fyun.https.file.delete}")
+    private String deleteFile;
+
+    @Value("${fyun.https.file.copy}")
+    private String copyFile;
+
+    @Value("${fyun.https.dir.upload}")
+    private String uploadDir;
+
+    @Value("${fyun.https.dir.download}")
+    private String downloadDir;
+
+    @Value("${fyun.https.dir.delete}")
+    private String deleteDir;
+
+    @Value("${fyun.https.dir.copy}")
+    private String copyDir;
+
+
+    @Value("${fyun.https.local_temp_path:/fyun/temp/}")
+    private void setLocalTempPath(String localTempPath) {
+        this.localTempPath = localTempPath;
+        if (new File(localTempPath).exists()) {
+            new File(localTempPath).mkdirs();
+        }
+        log.info("创建临时文件目录成功:{}", localTempPath);
+    }
+
+    public String getLocalTempPath() {
+        return localTempPath;
+    }
+
+    public String getUploadFile() {
+        return uploadFile;
+    }
+
+    public String getDownloadFile() {
+        return downloadFile;
+    }
+
+
+    public String getFileExist() {
+        return fileExist;
+    }
+
+
+    public String getDeleteFile() {
+        return deleteFile;
+    }
+
+
+    public String getCopyFile() {
+        return copyFile;
+    }
+
+
+    public String getUploadDir() {
+        return uploadDir;
+    }
+
+
+    public String getDownloadDir() {
+        return downloadDir;
+    }
+
+    public String getDeleteDir() {
+        return deleteDir;
+    }
+
+    public String getCopyDir() {
+        return copyDir;
+    }
+}

+ 92 - 0
4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/entity/Result.java

@@ -0,0 +1,92 @@
+package com.fdkankan.fyun.http.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Result<T> {
+    public static final String SUCCESS_MSG = "操作成功";
+    public static int CODE_SUCCESS = 0;
+    public static int CODE_FAILURE = -1;
+    public static String[] NOOP = new String[]{};
+
+    /**
+     * 处理状态:0: 成功, 1: 失败
+     */
+    /**"处理状态:0: 成功, 1: 失败", name = "code*/
+    private int code;
+    /**
+     * 消息
+     */
+    /**"消息", name = "msg*/
+    private String message;
+    /**
+     * 返回数据
+     */
+    /**"返回数据", name = "data*/
+    private T data;
+    /**
+     * 处理成功,并返回数据
+     *
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(Object data) {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, data);
+    }
+    /**
+     * 处理成功
+     *
+     * @return data
+     */
+    public static Result success() {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result success(String msg) {
+        return new Result(CODE_SUCCESS, msg, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg  消息
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(String msg, Object data) {
+        return new Result(CODE_SUCCESS, msg, data);
+    }
+    /**
+     * 处理失败,并返回数据(一般为错误信息)
+     *
+     * @param code 错误代码
+     * @param msg  消息
+     * @return data
+     */
+    public static Result failure(int code, String msg) {
+        return new Result(code, msg, NOOP);
+    }
+    /**
+     * 处理失败
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result failure(String msg) {
+        return failure(CODE_FAILURE, msg);
+    }
+
+    @Override
+    public String toString() {
+        return "JsonResult [code=" + code + ", msg=" + message + ", data="
+                + data + "]";
+    }
+}

+ 0 - 0
4dkankan-utils-fyun-local/pom.xml


Some files were not shown because too many files changed in this diff