Ver código fonte

合并最新代码

tianboguang 2 anos atrás
pai
commit
2cb592ff56

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

@@ -81,6 +81,8 @@ public enum ErrorCode {
     FAILURE_CODE_3033(3033, "60秒内不能重复获取验证码"),
 
     FAILURE_CODE_4001(4001, "缺少必要文件:%s"),
+    FAILURE_CODE_4002(4002, "文件不存在:%s"),
+    FAILURE_CODE_4003(4003, "图片大小不能超过:%s"),
 
 
     FAILURE_CODE_5001(5001, "modeldata.json为空"),

+ 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;
+    }
+
+}

+ 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;
+    }
+
 }

+ 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;
+    }
+
+}

+ 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) {

+ 7 - 1
4dkankan-common-web/src/main/java/com/fdkankan/web/exception/GlobalExceptionHandler.java

@@ -9,6 +9,7 @@ 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.FAILURE_CODE_3001);
+    }
+
 
     /**
      * 参数校验异常拦截处理
@@ -125,7 +132,6 @@ public class GlobalExceptionHandler {
         return ResultData.error(ErrorCode.PARAM_REQUIRED.code(), message);
     }
 
-
     /**
      * 处理业务异常
      */

+ 1 - 1
4dkankan-common-web/src/main/java/com/fdkankan/web/response/ResultData.java

@@ -26,7 +26,7 @@ public class ResultData<T> implements Serializable {
      */
     private T data;
     /**
-     * 后端返回结果
+     * 请求是否成功
      */
     private Boolean success;
     /**

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

@@ -172,6 +172,11 @@ public class RedisKey {
      */
     public static final String SCENE_UPLOAD_MATTERPRO_NUM= "scene:upload:matterpro:num";
 
+    /**
+     * 上传matterprodata状态
+     */
+    public static final String SCENE_BODY_SEGMENT= "scene:body:segment:uuid:%s";
+
 
 
 

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

@@ -35,7 +35,7 @@
         <dependency>
             <groupId>com.aliyun</groupId>
             <artifactId>aliyun-java-sdk-core</artifactId>
-            <version>4.0.3</version>
+            <version>4.5.10</version>
         </dependency>
         <dependency>
             <groupId>com.aliyun</groupId>
@@ -45,7 +45,7 @@
         <dependency>
             <groupId>com.amazonaws</groupId>
             <artifactId>aws-java-sdk</artifactId>
-            <version>1.11.327</version>
+            <version>1.11.1032</version>
         </dependency>
         <dependency>
             <groupId>com.sun.mail</groupId>

+ 99 - 0
4dkankan-utils-sms/src/main/java/com/fdkankan/sms/SendMailAcceUtils.java

@@ -1,5 +1,6 @@
 package com.fdkankan.sms;
 
+import cn.hutool.core.util.StrUtil;
 import com.sun.mail.util.MailSSLSocketFactory;
 import org.apache.commons.lang3.StringUtils;
 
@@ -28,6 +29,7 @@ public class SendMailAcceUtils {
 
     public final static String CN_CODE_SUBJECT = "四维看看验证码";
 
+
     public final static String EN_CODE_SUBJECT = "4Dkankan verification code";
 
     public final static String EN_CODE_SUBJECT_USA = "FALCON VISUAL";
@@ -63,6 +65,103 @@ public class SendMailAcceUtils {
                     "<div> Note: This is an auto-sent Email, please do not reply directly. May you have any questions, please contact our customer service.</div><br>";
 
     /**
+     *
+     * @param userName 发送人账号
+     * @param password 发送人密码
+     * @param stmpHost smtp服务器地址
+     * @param receive  接收人邮箱地址
+     * @param subject  主题
+     * @param msg      消息主题
+     * @param filename 附件地址
+     * @return
+     * @throws GeneralSecurityException
+     */
+    public static boolean sendMail(String userName, String password, String stmpHost,
+                                   String receive, String subject, String msg, String filename)
+            throws GeneralSecurityException {
+        if (StrUtil.isEmpty(userName)
+                || StrUtil.isEmpty(password)
+                || StrUtil.isEmpty(stmpHost)
+                || StrUtil.isEmpty(receive)) {
+            return false;
+        }
+
+
+        // smtp服务器的链接信息
+        Properties properties = new Properties();
+
+        // 设置邮件服务器
+        properties.setProperty("mail.smtp.host", stmpHost);
+
+        properties.put("mail.smtp.auth", "true");
+        MailSSLSocketFactory sf = new MailSSLSocketFactory();
+        sf.setTrustAllHosts(true);
+        properties.put("mail.smtp.ssl.enable", "true");
+        properties.put("mail.smtp.ssl.socketFactory", sf);
+        // 获取默认session对象
+        Session session = Session.getDefaultInstance(properties, new Authenticator() {
+            public PasswordAuthentication getPasswordAuthentication() { // qq邮箱服务器账户、第三方登录授权码
+                return new PasswordAuthentication(userName, password); // 发件人邮件用户名、密码
+            }
+        });
+
+        try {
+            // 创建默认的 MimeMessage 对象
+            MimeMessage message = new MimeMessage(session);
+
+            // Set From: 头部头字段
+            message.setFrom(new InternetAddress(userName));
+
+            // Set To: 头部头字段
+            message.addRecipient(Message.RecipientType.TO, new InternetAddress(receive));
+
+            // Set Subject: 主题文字
+            message.setSubject(subject);
+
+            // 创建消息部分
+            BodyPart messageBodyPart = new MimeBodyPart();
+
+            // 消息
+            messageBodyPart.setText(msg);
+
+            // 创建多重消息
+            MimeMultipart multipart = new MimeMultipart("mixed");
+
+            if(StringUtils.isNotEmpty(filename)){
+                // 附件部分
+                messageBodyPart = new MimeBodyPart();
+                // 设置要发送附件的文件路径
+                DataSource source = new FileDataSource(filename);
+                messageBodyPart.setDataHandler(new DataHandler(source));
+
+                // messageBodyPart.setFileName(filename);
+                // 处理附件名称中文(附带文件路径)乱码问题
+                messageBodyPart.setFileName(MimeUtility.encodeText(filename));
+                multipart.addBodyPart(messageBodyPart);
+            }
+
+            //html代码部分
+            MimeBodyPart htmlPart = new MimeBodyPart();
+            multipart.addBodyPart(htmlPart);
+            //html代码
+            htmlPart.setContent(msg, "text/html;charset=utf-8");
+
+            // 发送完整消息
+            message.setContent(multipart);
+
+            // 发送消息
+            Transport.send(message);
+            // System.out.println("Sent message successfully....");
+            return true;
+        } catch (MessagingException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    /**
      * 发送带附件的邮件
      *
      * @param receive