Bladeren bron

修改bug

houweiyu 5 jaren geleden
bovenliggende
commit
16317e3f33

+ 10 - 5
fdkanfang-application/src/main/resources/application-dev.properties

@@ -1,10 +1,13 @@
 
 #DB
+#DB
+# \u6570\u636E\u6E90\u914D\u7F6E
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.druid.url=jdbc:mysql://localhost:3306/fdkanfang?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.druid.url=jdbc:mysql://39.108.220.65:3306/fdkanfang?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
 spring.datasource.druid.username=root
-spring.datasource.druid.password=root
+#spring.datasource.druid.password=4dkk2019%
+spring.datasource.druid.password=4dkk2020test%
 
 #testDB
 #spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
@@ -39,7 +42,8 @@ spring.datasource.druid.stat-view-servlet.enabled=true
 
 # Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
 spring.redis.database=0
-spring.redis.host=127.0.0.1
+#spring.redis.host=127.0.0.1
+spring.redis.host=39.108.220.65
 spring.redis.port=6379
 spring.redis.password=
 # \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4 \u5355\u4F4D ms\uFF08\u6BEB\u79D2\uFF09
@@ -57,7 +61,7 @@ spring.redis.jedis.pool.max-wait=-1ms
 #image.path=F:\\test\\fdkanfang\\
 
 # \u7B97\u6CD5\u751F\u6210\u6587\u4EF6\u5730\u5740\uFF0C\u8FD9\u4E2A\u662F\u4E16\u8D85\u7684\u7B97\u6CD5\u5730\u5740\uFF0C\u5C06\u6765\u5E94\u8BE5\u653E\u5230\u522B\u7684\u5730\u65B9\u53BB
-output.file.path=F:\\test\\fdkanfang\\
+output.file.path=E:\\data\\fdkanfang\\
 
 #\u7F16\u8F91\u9875\u9762
 server.domain=http://47.115.43.159:8084/fdkanfang/spc.html
@@ -68,7 +72,8 @@ logging.config=classpath:logback-spring.xml
 logging.level.com.fdkanfang=debug
 
 #rabbit MQ
-spring.rabbitmq.host=localhost
+spring.rabbitmq.host=39.108.220.65
+#spring.rabbitmq.host=localhost
 spring.rabbitmq.port=5672
 spring.rabbitmq.username=guest
 spring.rabbitmq.password=guest

+ 42 - 0
fdkanfang-common/src/main/java/com/fdkanfang/common/enums/HouseStatusEnum.java

@@ -0,0 +1,42 @@
+package com.fdkanfang.common.enums;
+
+/**
+ * @author abnerhou
+ * @date 2020/7/24 14:11
+ * @desciption
+ */
+public enum HouseStatusEnum {
+
+      VERTICAL_VALIDATE_INIT(0 , "垂直校验申请提交成功" , false),
+      VERTICAL_VALIDATE_SUCC(1 , "垂直校验成功" , false),
+      VERTICAL_VALIDATE_FAIL(2 , "垂直校验失败功" , false),
+      MODEL_BUILD_ING(3 , "模型生成中", false),
+      MODEL_BUILD_SUCC(4 , "模型生成成功" , true),
+      MODEL_BUILD_FAIL(5, "模型生成失败" , true),
+
+    ;
+    /****状态*****/
+    private Integer status;
+    /****描述*****/
+    private String desc;
+    /****是否终态*****/
+    private boolean isTerminal;
+
+    HouseStatusEnum(Integer status, String desc , boolean isTerminal) {
+        this.status = status;
+        this.desc = desc;
+        this.isTerminal = isTerminal;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public boolean isTerminal() {
+        return isTerminal;
+    }
+}

+ 70 - 0
fdkanfang-common/src/main/java/com/fdkanfang/common/enums/ImageResolutionRate.java

@@ -0,0 +1,70 @@
+package com.fdkanfang.common.enums;
+
+import io.swagger.models.auth.In;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * @author abnerhou
+ * @date 2020/7/23 15:29
+ * @desciption
+ */
+public enum ImageResolutionRate {
+      TWO_K(2048*1024,"2K分辨率" , 1),
+      FOUR_K(4096*2048,"4K分辨率" , 2),
+    ;
+
+    private Integer rate;
+    private  String desc;
+    private Integer order;
+
+    ImageResolutionRate(Integer rate, String desc, Integer order) {
+        this.rate = rate;
+        this.desc = desc;
+        this.order = order;
+    }
+    public static ImageResolutionRate getResolutionRateByRate(Integer rate){
+        if(null == rate){
+            return  null;
+        }
+        if(rate.compareTo(2048*1024) <= 0){
+            return TWO_K;
+        }else{
+            return FOUR_K;
+        }
+    }
+
+    public static ImageResolutionRate getResolutionByName(String name){
+        if(StringUtils.isBlank(name)){
+            return null;
+        }
+        for (ImageResolutionRate resolutionRate : values()){
+            if(StringUtils.equals(name , resolutionRate.name())){
+                return resolutionRate;
+            }
+        }
+        return null;
+    }
+
+    public static Integer getSortByRate(Integer rate){
+        if(null == rate){
+            return  -1;
+        }
+        if(rate.compareTo(2048*1024) <= 0){
+            return TWO_K.getOrder();
+        }else{
+            return FOUR_K.getOrder();
+        }
+    }
+
+    public Integer getRate() {
+        return rate;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public Integer getOrder() {
+        return order;
+    }
+}

+ 64 - 0
fdkanfang-common/src/main/java/com/fdkanfang/common/enums/ResultCodeEnum.java

@@ -0,0 +1,64 @@
+package com.fdkanfang.common.enums;
+
+/**
+ * @author abnerhou
+ * @date 2020/5/6 8:23
+ * @desciption
+ */
+public enum ResultCodeEnum {
+
+    D3001(3001 , "缺少必要参数" , true),
+    D3002(3002 , "token非法" , false),
+    D3003(3003 , "APP ID 缺失" ,false),
+    D3004(3004 , "入参数据缺失" , true),
+    D3005(3005 , "权限不足", true),
+    D3006(3006 , "非法的APP ID" , false),
+    D3007(3007 , "时间超时" , true),
+    D3008(3008 , "解析数据签名失败" , true),
+    D3009(3009 , "数据已经被篡改" , true),
+    D3010(3010 , "终端用户类型非法" , true),
+    D3011(3011 , "非法的用户类型" , true),
+    D3012(3012 , "用户不存在" , true),
+    D3013(3013 , "微信登录返回信息缺失" , true),
+    D3014(3014 , "获取微信token失败" , true),
+    D3015(3015 , "微信二维码生成个数总和到达最大个数限制" , true),
+    D3016(3016 , "获取微信二维码失败" , true),
+    D3017(3017 , "用户ID缺失" , true),
+    D3018(3018 , "token已失效,请重新登录" , true),
+    D3019(3019 , "token非法" , true),
+    D3020(3020 , "微信用户信息解密失败,请重新登录" , true),
+    D3021(3021 , "该手机号已注册" , true),
+    D3022(3022 , "微信返回数据签名校验失败" , true),
+    D3023(3023 , "新增观众失败" , true),
+    D3024(3024 , "新增im用户失败" , true),
+    D3025(3025 , "讲解员不存在" , true),
+    D3026(3026 , "openId不一致" , true),
+    D3027(3027 , "解密讲解员手机号失败" , true),
+    D3028(3028 , "没有有效的展会活动" , true),
+
+    D100(3100 , "系统异常" , true),
+    D101(3101 , "数据异常" , true),
+    ;
+
+    ResultCodeEnum(Integer code, String desc , Boolean canBeReplace) {
+        this.code = code;
+        this.desc = desc;
+        this.canBeReplace = canBeReplace;
+    }
+
+    private Integer code;
+    private String desc;
+    private Boolean canBeReplace;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public Boolean getCanBeReplace() {
+        return canBeReplace;
+    }
+}

+ 45 - 0
fdkanfang-common/src/main/java/com/fdkanfang/common/exception/CommonBaseException.java

@@ -0,0 +1,45 @@
+package com.fdkanfang.common.exception;
+
+import com.fdkanfang.common.enums.ResultCodeEnum;
+import lombok.Data;
+
+/**
+ * @author abnerhou
+ * @date 2020/5/25 11:39
+ * @desciption
+ */
+@Data
+public class CommonBaseException extends RuntimeException{
+    private static final long serialVersionUID = 2899335020273674737L;
+
+    private Integer code;
+
+    private String msg;
+
+    public CommonBaseException(Integer code, String msg){
+        super(msg);
+        this.code = code;
+        this.msg = msg;
+    }
+
+
+    public CommonBaseException(ResultCodeEnum resultCodeEnum){
+        super(resultCodeEnum.getDesc());
+        this.code = resultCodeEnum.getCode();
+        this.msg = resultCodeEnum.getDesc();
+    }
+
+    public CommonBaseException(ResultCodeEnum resultCodeEnum , String replaceMsg){
+        super(resultCodeEnum.getDesc());
+        this.code = resultCodeEnum.getCode();
+        if(resultCodeEnum.getCanBeReplace()){
+            this.msg = replaceMsg;
+        }else{
+            this.msg = resultCodeEnum.getDesc();
+        }
+    }
+
+
+
+
+}

+ 1 - 1
fdkanfang-common/src/main/java/com/fdkanfang/common/util/AliyunOssUtil.java

@@ -226,7 +226,7 @@ public class AliyunOssUtil {
 	 */
 	public static void writeFile(String inputFilePath, String savePath){
 		try {
-			FileUtils.bigFileWrite(getInputStreamByFileUrl(inputFilePath), savePath);
+			FileUtils.downloanAndGetResolutionRate(getInputStreamByFileUrl(inputFilePath), savePath ,false);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}

+ 13 - 1
fdkanfang-common/src/main/java/com/fdkanfang/common/util/ComputerUtil.java

@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
 import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
 
 /**
  * 生成场景和计算场景
@@ -35,7 +36,9 @@ public class ComputerUtil {
 
         // 生成模型oss存放路径
 //        String ossPanoPath = ConstantFilePath.UPLOAD_HOUSE_PATH + projectNum + "/pano/";
-        String ossPanoPath = ConstantFilePath.OSS_IMAGE_PATH + projectNum + "/";
+        //TODO:这里需要加斜杆,不然黏连在一起了
+//        String ossPanoPath = ConstantFilePath.OSS_IMAGE_PATH  + "/" + projectNum + "/";
+        String ossPanoPath = ConstantFilePath.OSS_IMAGE_PATH  + projectNum + "/";
 //        String ossVerticalPath = ossBasePath+"/pan/high/" + filename;
 
         log.info("开始建模:"+projectNum);
@@ -135,4 +138,13 @@ public class ComputerUtil {
         return map;
     }
 
+    public static void createJson(String path, String splitType, String skyboxType, String dataDescribe) throws Exception{
+        JSONObject dataJson = new JSONObject();
+        dataJson.put("split_type", splitType);
+        dataJson.put("skybox_type", skyboxType);
+        dataJson.put("data_describe", dataDescribe);
+        dataJson.put("extras", null);
+        FileUtils.writeFile(path + File.separator + "data.json", dataJson.toString());
+    }
+
 }

+ 48 - 6
fdkanfang-common/src/main/java/com/fdkanfang/common/util/FileUtils.java

@@ -98,25 +98,53 @@ public class FileUtils {
      * path: 保持位置
      */
 
-    public static void bigFileWrite(InputStream in, String path) throws IOException {
-//        long start = System.currentTimeMillis();
+    public static int downloanAndGetResolutionRate(InputStream in, String fileFullPath, boolean needCheckResolutin) throws IOException {
         // 输入缓冲流
+        File file = new File(fileFullPath);
+        if(file.exists()){
+            deleteFile(fileFullPath);
+            file = new File(fileFullPath);
+        }
         BufferedInputStream inputBuff = new BufferedInputStream(in);
-
         // 输出缓冲流
-        BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(path));
+        BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(file));
         int len = 0;
         byte[] buffer = new byte[1024];
         while ((len = inputBuff.read(buffer)) != -1) {
             stream.write(buffer, 0, len);
         }
+
         stream.flush();
         stream.close();
         inputBuff.close();
+        int totalResolutinRate = -1;
+        if(needCheckResolutin){
+            SimpleImageInfo simpleImageInfo = new SimpleImageInfo(file);
+            if(null != simpleImageInfo){
+                totalResolutinRate = simpleImageInfo.getWidth()*simpleImageInfo.getHeight();
+            }
+        }
 
-//        long end = System.currentTimeMillis();
+        return totalResolutinRate;
+    }
 
-//        System.out.println("total: "+ (end-start)/1000);
+    /**
+     * 删除单个文件
+     *
+     * @param fileName 要删除的文件的文件名
+     * @return 单个文件删除成功返回true,否则返回false
+     */
+    public static boolean deleteFile(String fileName) {
+        File file = new File(fileName);
+        if (file.exists() && file.isFile()) {
+            if (file.delete()) {
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
     }
 
 
@@ -194,6 +222,20 @@ public class FileUtils {
         writer.close();
     }
 
+    public static void writeFile(String filePath,String str) throws IOException {
+        File fout = new File(filePath);
+        if(!fout.getParentFile().exists()){
+            fout.getParentFile().mkdirs();
+        }
+        if(!fout.exists()){
+            fout.createNewFile();
+        }
+        FileOutputStream fos = new FileOutputStream(fout);
+        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
+        bw.write(str);
+        bw.close();
+    }
+
     // 获取时间戳
     public static String timeMillisStr() {
         SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");

+ 1 - 1
fdkanfang-common/src/main/java/com/fdkanfang/common/util/PasswordUtils.java

@@ -170,7 +170,7 @@ public class PasswordUtils {
 
     public static void main(String[] args) {
 
-        String userName = "13631262758";
+        String userName = "18718487619";
         String password = "123456";
 
         try {

+ 168 - 0
fdkanfang-common/src/main/java/com/fdkanfang/common/util/SimpleImageInfo.java

@@ -0,0 +1,168 @@
+package com.fdkanfang.common.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author abnerhou
+ * @date 2020/7/23 14:38
+ * @desciption:
+ * 利用Java类,获取图片的类型,宽度和高度,方法有多种,比如:
+ * BufferedImage bimg = ImageIO.read(new File("d:\\image\\org.jpg"));
+ * int width = bimg.getWidth();
+ * int height = bimg.getHeight();
+ *但这方法将整张图片都加载到了内存,如果那些图片比较大,无疑将增加服务的压力。
+ *
+ *************这个类的方法,不需要加载整个图片,从而节省内存空间************
+ * 原作者链接:http://blog.jdk5.com/zh/java-get-image-size-without-loading-the-whole-data/
+ */
+public class SimpleImageInfo {
+
+    private int height;
+    private int width;
+    private String mimeType;
+
+    public static final String TOW_K_RESOLUTION_RATE = "2048*1024";
+    public static final String FOUR_K_RESOLUTION_RATE = "4096*2048";
+
+    public SimpleImageInfo(File file) throws IOException {
+        InputStream is = new FileInputStream(file);
+        try {
+            processStream(is);
+        } finally {
+            is.close();
+        }
+    }
+
+    public SimpleImageInfo(InputStream is) throws IOException {
+        processStream(is);
+    }
+
+    public SimpleImageInfo(byte[] bytes) throws IOException {
+        InputStream is = new ByteArrayInputStream(bytes);
+        try {
+            processStream(is);
+        } finally {
+            is.close();
+        }
+    }
+
+    private void processStream(InputStream is) throws IOException {
+        int c1 = is.read();
+        int c2 = is.read();
+        int c3 = is.read();
+
+        mimeType = null;
+        width = height = -1;
+
+        if (c1 == 'G' && c2 == 'I' && c3 == 'F') { // GIF
+            is.skip(3);
+            width = readInt(is,2,false);
+            height = readInt(is,2,false);
+            mimeType = "image/gif";
+        } else if (c1 == 0xFF && c2 == 0xD8) { // JPG
+            while (c3 == 255) {
+                int marker = is.read();
+                int len = readInt(is,2,true);
+                if (marker == 192 || marker == 193 || marker == 194) {
+                    is.skip(1);
+                    height = readInt(is,2,true);
+                    width = readInt(is,2,true);
+                    mimeType = "image/jpeg";
+                    break;
+                }
+                is.skip(len - 2);
+                c3 = is.read();
+            }
+        } else if (c1 == 137 && c2 == 80 && c3 == 78) { // PNG
+            is.skip(15);
+            width = readInt(is,2,true);
+            is.skip(2);
+            height = readInt(is,2,true);
+            mimeType = "image/png";
+        } else if (c1 == 66 && c2 == 77) { // BMP
+            is.skip(15);
+            width = readInt(is,2,false);
+            is.skip(2);
+            height = readInt(is,2,false);
+            mimeType = "image/bmp";
+        } else {
+            int c4 = is.read();
+            if ((c1 == 'M' && c2 == 'M' && c3 == 0 && c4 == 42)
+                    || (c1 == 'I' && c2 == 'I' && c3 == 42 && c4 == 0)) { //TIFF
+                boolean bigEndian = c1 == 'M';
+                int ifd = 0;
+                int entries;
+                ifd = readInt(is,4,bigEndian);
+                is.skip(ifd - 8);
+                entries = readInt(is,2,bigEndian);
+                for (int i = 1; i <= entries; i++) {
+                    int tag = readInt(is,2,bigEndian);
+                    int fieldType = readInt(is,2,bigEndian);
+                    int valOffset;
+                    if ((fieldType == 3 || fieldType == 8)) {
+                        valOffset = readInt(is,2,bigEndian);
+                        is.skip(2);
+                    } else {
+                        valOffset = readInt(is,4,bigEndian);
+                    }
+                    if (tag == 256) {
+                        width = valOffset;
+                    } else if (tag == 257) {
+                        height = valOffset;
+                    }
+                    if (width != -1 && height != -1) {
+                        mimeType = "image/tiff";
+                        break;
+                    }
+                }
+            }
+        }
+        if (mimeType == null) {
+            throw new IOException("Unsupported image type");
+        }
+    }
+
+    private int readInt(InputStream is, int noOfBytes, boolean bigEndian) throws IOException {
+        int ret = 0;
+        int sv = bigEndian ? ((noOfBytes - 1) * 8) : 0;
+        int cnt = bigEndian ? -8 : 8;
+        for(int i=0;i<noOfBytes;i++) {
+            ret |= is.read() << sv;
+            sv += cnt;
+        }
+        return ret;
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public String getMimeType() {
+        return mimeType;
+    }
+
+    public void setMimeType(String mimeType) {
+        this.mimeType = mimeType;
+    }
+
+    @Override
+    public String toString() {
+        return width + "*" + height;
+    }
+}

+ 3 - 0
fdkanfang-domain/src/main/java/com/fdkanfang/domain/backend/HouseEntity.java

@@ -108,6 +108,9 @@ public class HouseEntity extends BaseModel implements Serializable {
     // 服务器文件位置
     private String filePath;
 
+    // 预审结果: 1 通过 0 未通过
+    private Integer auditResult;
+
 
 
 

+ 3 - 0
fdkanfang-domain/src/main/java/com/fdkanfang/domain/backend/ImageEntity.java

@@ -50,4 +50,7 @@ public class ImageEntity extends BaseModel implements Serializable {
     // 图片类型, 如:客厅 (1-1, 1-2), 厨房(2-1, 2-2)
     private String type;
 
+    // 照片分辨率:2k : TWO_K , 4k : FOUR_K
+    private String resolutionRate;
+
 }

+ 112 - 102
fdkanfang-web/src/main/java/com/fdkanfang/web/backend/HouseController.java

@@ -6,7 +6,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.fdkanfang.common.constant.ConstantFilePath;
 import com.fdkanfang.common.constant.MsgCode;
 import com.fdkanfang.common.constant.TypeCode;
+import com.fdkanfang.common.enums.ImageResolutionRate;
+import com.fdkanfang.common.enums.ResultCodeEnum;
 import com.fdkanfang.common.exception.BaseRuntimeException;
+import com.fdkanfang.common.exception.CommonBaseException;
 import com.fdkanfang.common.model.PageDto;
 import com.fdkanfang.common.util.*;
 import com.fdkanfang.domain.backend.*;
@@ -26,15 +29,15 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.builder.ToStringExclude;
 import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.apache.shiro.authz.annotation.RequiresRoles;
-import org.junit.Test;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import tk.mybatis.mapper.entity.Condition;
@@ -138,64 +141,36 @@ public class HouseController extends BaseController {
     @RequiresRoles(value = {"admin", "edit", "upload"}, logical = Logical.OR)
     @ApiOperation("新增或修改房源信息 + 垂直校验")
     @PostMapping(value = "save", consumes = {"multipart/form-data"})
+    @Transactional(rollbackFor = Exception.class)
     public R save(HouseDto param){
 
         if(StringUtils.isBlank(param.getDistrictName())){
             log.error("小区名称不能为空");
             return new R(MsgCode.e_COMMON_3001, "小区名称不能为空");
         }
-
-//        if(StringUtils.isBlank(param.getAddress())){
-//            log.error("地址不能为空");
-//            return new R(MsgCode.e_COMMON_3001, "地址不能为空");
-//        }
-
-        if(StringUtils.isBlank(param.getUnitType())){
-            log.error("户型不能为空");
-            return new R(MsgCode.e_COMMON_3001, "户型不能为空");
-        }
-
-        if(StringUtils.isBlank(param.getArea())){
-            log.error("面积不能为空");
-            return new R(MsgCode.e_COMMON_3001, "面积不能为空");
-        }
-
-        if(StringUtils.isBlank(param.getOrientation())){
-            log.error("朝向不能为空");
-            return new R(MsgCode.e_COMMON_3001, "朝向不能为空");
-        }
-
-        if (param.getFloor() == null) {
-            log.error("楼层不能为空");
-            return new R(MsgCode.e_COMMON_3001, "楼层不能为空");
+        if(null == param.getFloor() || !StringUtils.isNoneBlank(param.getUnitType() , param.getArea() , param.getOrientation())){
+            return new R(MsgCode.e_COMMON_3001, "楼层/户型/面积/朝向不能为空");
         }
 
-        boolean flag = false;
+        boolean isNewAdd = false;
         HouseEntity house = null;
         if (param.getId() == null) {
             house = new HouseEntity();
             house.setUserId(JWTUtil.getUserId(getToken()));
             param.setId(null);
             BeanUtils.copyProperties(param, house);
-
             Integer byMaxNum = houseService2.findByMaxNum();
-
-
             // 用于第一条数据
             byMaxNum = (byMaxNum == null)? 10000:byMaxNum;
-
             String sceneCode = getSceneCode();
             house.setNum(byMaxNum + 1);
             house.setSceneCode(sceneCode);
             house.setWebSite(domain+"?m="+sceneCode);
             house.setFilePath(OUTPATH + sceneCode);
-
             houseService2.save(house);
-
             SceneProEntity sceneProEntity = new SceneProEntity();
             sceneProEntity.setNum(house.getSceneCode());
             sceneProService.save(sceneProEntity);
-
             SceneProEditEntity sceneProEditEntity = new SceneProEditEntity();
             sceneProEditEntity.setProId(sceneProEntity.getId());
             // 默认是1
@@ -204,7 +179,7 @@ public class HouseController extends BaseController {
             sceneProEditEntity.setM3dVisi(1);
             sceneProEditEntity.setMeasureVisi(1);
             sceneProEditService.save(sceneProEditEntity);
-            flag = true;
+            isNewAdd = true;
         } else {
             house = houseService2.findById(param.getId());
             if (house == null) {
@@ -213,10 +188,8 @@ public class HouseController extends BaseController {
             }
             BeanUtils.copyProperties(param, house);
             house.setUpdateTime(new Date());
-
             houseService2.update(house);
         }
-
         // 处理上传图片
         MultipartFile[] files = param.getFiles();
         if (files == null || files.length <= 0) {
@@ -224,31 +197,32 @@ public class HouseController extends BaseController {
             return new R(MsgCode.e_COMMON_3100, MsgCode.msg_COMMON_3100);
         }
 
-
-
         // 只有新增是才保存图片,修改时另外处理
-        if (flag) {
-
+        if (isNewAdd) {
             //场景码
             String sceneCode = house.getSceneCode();
-
-            boolean flagQ = false;
-
+            boolean needSendMqMsg = false;
             String directoryName = OUTPATH + sceneCode + File.separator + "input_img"+ File.separator;
             FileUtil.mkdir(directoryName);
-
-
             HashMap<String, String> ossVerticalImageHighMap = new HashMap<>();
             HashMap<String, String> ossVerticalImageLowMap = new HashMap<>();
-
-
             String imageHighPath = null;
             String imageLowPath = null;
-
+            //照片分辨率,以最高的为准
+            ImageResolutionRate maxResolutionRate = null;
+            int imageResolutionRateSort = 0;
             for (MultipartFile file : files) {
                 ImageEntity image = new ImageEntity();
                 String filename = file.getOriginalFilename();
-                assert filename != null;
+                if(StringUtils.isBlank(filename)){
+                    throw new CommonBaseException(ResultCodeEnum.D100 , "文件名不能为空");
+                }
+                if(filename.contains(".JPG")){
+                    int index = filename.lastIndexOf(".");
+                    String fileNameWithoutPostfix = filename.substring(0 , index);
+                    filename = fileNameWithoutPostfix + ".jpg";
+                    log.info("照片的格式写成了大写,需要转成小写:{}" , filename);
+                }
                 // 检查一下,测试时,可能会没有"_"
                 if (!filename.contains("_")) {
                     log.error("filename: {}", filename);
@@ -262,55 +236,50 @@ public class HouseController extends BaseController {
                 // 获取图片房间类型
                 String imageType = StringUtils.substringBefore(filename, "_");
 
-                // 本地图片保存位置
-                String filePath = directoryName + filename;
+                // 本地图片保存位置: /root/data/kanfang/场景码/input_img/xxxx.jpg
+                String fileFullPath = directoryName + filename;
 
                 imageHighPath = OUTPATH + sceneCode + "/output_img/" + filename;
                 imageLowPath = OUTPATH + sceneCode + "/output_img_low/" + filename;
-
-                image.setFileName(filename);
-
-                // 这个参数给前端用,只要有文件名就可以了
-                image.setPath(filePath);
-
-                image.setLocalPath(filePath);
-                image.setHouseId(house.getId());
                 // 提前把算法的图片路径存到数据库,但不代表算法运行成功,最后好是要看house的状态;
                 String ossVerticalHighPath = ConstantFilePath.OSS_IMAGE_PATH+ sceneCode+"/pan/high/"+ filename;
                 String ossVerticalLowPath = ConstantFilePath.OSS_IMAGE_PATH+ sceneCode+"/pan/low/"+ filename;
-
                 image.setVerticalPath(ossVerticalHighPath);
-
+                image.setFileName(filename);
+                // 这个参数给前端用,只要有文件名就可以了
+                image.setPath(fileFullPath);
+                image.setLocalPath(fileFullPath);
+                image.setHouseId(house.getId());
                 // 默认所有图片都是一楼
                 image.setFloor(1);
                 image.setType(imageType);
-
-
                 try {
-                    FileUtils.bigFileWrite(file.getInputStream(), filePath);
+                    //将图片保存到本地指定目录filePath eg: /root/data/kanfang/d_9iRDUgn3l/input_img/xxx.jpg
+                    int  resolutionRate = FileUtils.downloanAndGetResolutionRate(file.getInputStream(), fileFullPath , false);
+                    maxResolutionRate = ImageResolutionRate.getResolutionRateByRate(resolutionRate);
+                    image.setResolutionRate(null != maxResolutionRate ? maxResolutionRate.name() : "TWO_K");
                     imageService2.save(image);
-
                     // 封装垂直校验后的图片到信息到oss
                     ossVerticalImageHighMap.put(imageHighPath, ossVerticalHighPath);
                     ossVerticalImageLowMap.put(imageLowPath, ossVerticalLowPath);
-                    flagQ = true;
-
+                    needSendMqMsg = true;
                 } catch (IOException e) {
-                    flagQ = false;
-                    e.printStackTrace();
+                    needSendMqMsg = false;
+                    log.error("保存照片到本地和持久化image对象出现异常:{}" , e);
                 }
             }
 
-            if (flagQ) {
-
+            if (needSendMqMsg) {
                 HashMap<Object, Object> mqMap = new HashMap<>();
-
                 mqMap.put("ossImageHigh", ossVerticalImageHighMap);
                 mqMap.put("ossImageLow", ossVerticalImageLowMap);
                 mqMap.put("id", house.getId());
                 mqMap.put("basePath", OUTPATH);
-                log.info("houseId: {}", house.getId());
 
+
+
+                mqMap.put("dataDescribe", "");
+                log.info("houseId: {}", house.getId());
                 //发消息到mq
                 rabbitTemplate.convertAndSend(RabbitConfig.VERTICAL_EXCHANGE, RabbitConfig.VERTICAL_QUEUE_ROUTING, mqMap);
             }
@@ -363,10 +332,12 @@ public class HouseController extends BaseController {
             }
 
 
-            if ("upload".equals(roleKey) && houseEntity.getStatus() != 0) {
-                log.error("只有upload, 房源id!=0,审批中的房源不能删除");
-                return new R(MsgCode.e_COMMON_3002,"没有权限删除房源,存在审批中的房源");
 
+            if ("upload".equals(roleKey)) {
+                if(null != houseEntity.getAuditResult() && houseEntity.getAuditResult().compareTo(1) == 0){
+                    log.error("只有upload, 房源id!=0,审批通过的房源不能删除");
+                    return new R(MsgCode.e_COMMON_3002,"审批通过的房源不能删除");
+                }
             }
 
             if ("edit".equals(roleKey)) {
@@ -510,6 +481,7 @@ public class HouseController extends BaseController {
     @RequiresRoles(value = {"admin", "edit"}, logical = Logical.OR)
     @ApiOperation("生成模型")
     @PostMapping("rsa/pano")
+    @Transactional(rollbackFor = Exception.class)
     public R rsaPano(@Valid @RequestBody PanoDto param) throws Exception {
         log.info("run rsaPano");
 
@@ -517,20 +489,15 @@ public class HouseController extends BaseController {
             log.error("参数为空");
             return new R(50001, "error");
         }
-
         HouseEntity house = houseService2.findById(param.getHouseId());
         if (house == null) {
             log.error("房源不存在: {}", param.getHouseId());
             return new R(MsgCode.e_COMMON_3002, MsgCode.msg_COMMON_3002);
         }
 
-
-
         String sceneCode = house.getSceneCode();
 
-
         boolean flagQ = false;
-
         // data/kanfang/10001/pano
         String savePath = OUTPATH + sceneCode + "/" + TypeCode.SCENE_PANO;
         // 检查场景码对应的pano文件夹是否存在,存在则删除里面的内容(用户从新编辑场景)
@@ -539,25 +506,45 @@ public class HouseController extends BaseController {
             log.info("删除旧目录重新计算: {}", sceneCode);
         }
 
-
-
         log.warn("savePath: {}", savePath);
         String sourcePath = savePath + "/extras/";
         try {
 
-
-
             FileUtils.createDir(sourcePath);
-
-            // 目前data.json 是空的,算法要使用, 放到场景目录外面
-            String resource = FileUtils.getResource();
-            // pano.json:算法提供
-            resource = resource + "static/pano.json";
-            String content = FileUtils.readFile(resource);
-            FileUtils.fileWriter(content, savePath + "/data.json");
-            log.warn("dataPath: {}", savePath + "/data.json");
-
-
+/*
+          /***
+                 * 以下字段为给算法部传递的参数(data.json),用于生成模型和
+                 * 照片,提供前端使用,完整的参数如下:
+                 * {
+                 * 	"split_type": "SPLIT_V5",
+                 * 	"skybox_type": "SKYBOX_V5",
+                 * 	"extras": {
+                 * 		"has_vision_txt": true,
+                 * 		"has_floorplan_json": true,
+                 * 		"has_source_images": true
+                 *        }
+                 * }
+                 * */
+            String content = "";
+            //生成data.json供算法部使用
+            JSONObject dataJson = new JSONObject();
+            dataJson.put("split_type", "SPLIT_V5");
+            String imageResolution = checkImageResolutionRate(house);
+            if(ImageResolutionRate.TWO_K.name().equals(imageResolution)){
+                //2 K 照片
+                dataJson.put("skybox_type", "SKYBOX_V7");
+            }else{
+                //4 k照片
+                dataJson.put("skybox_type", "SKYBOX_V6");
+            }
+            dataJson.put("extras", null);
+            JSONObject extrasJson = new JSONObject();
+            extrasJson.put("has_vision_txt" , true);
+            extrasJson.put("has_floorplan_json" , true);
+            extrasJson.put("has_source_images" , true);
+            dataJson.put("extras" , extrasJson);
+            FileUtils.fileWriter(dataJson.toJSONString(), savePath + "/data.json");
+            log.warn("dataJson的生成路径: {}", savePath + "/data.json");
 
             // 解析json
             JSONObject original = JSON.parseObject(param.getContent());
@@ -581,6 +568,7 @@ public class HouseController extends BaseController {
             FileUtils.fileWriter(vision, sourcePath + "vision.txt");
 
 
+
             log.info("floorplan.json生成完成");
             log.info("vision.txt生成完成");
 
@@ -651,6 +639,34 @@ public class HouseController extends BaseController {
         return new R(MsgCode.SUCCESS_CODE, house);
     }
 
+    private String checkImageResolutionRate(HouseEntity houseEntity){
+        if(null == houseEntity || null == houseEntity.getId()){
+            return null;
+        }
+        List<ImageEntity> imageEntities = imageService2.findByHouseId(houseEntity.getId());
+        if(CollectionUtils.isEmpty(imageEntities)){
+            log.error("房源[{}]下面无照片,默认返回2k的分辨率");
+            return ImageResolutionRate.TWO_K.name();
+        }
+        int sort = 0;
+        ImageResolutionRate maxResolution = null;
+        for (ImageEntity imageEntity : imageEntities){
+            if(StringUtils.isBlank(imageEntity.getResolutionRate())){
+                log.warn("房源[{}]的照片[{}]没有设置照片分辨率,跳过" , houseEntity.getId() , imageEntity.getId());
+                break;
+            }
+            ImageResolutionRate curResolution = ImageResolutionRate.getResolutionByName(imageEntity.getResolutionRate());
+            if(null != curResolution){
+                if(curResolution.getOrder() > sort){
+                    sort = curResolution.getOrder();
+                    maxResolution = curResolution;
+                }
+            }
+        }
+        log.info("房源[{}]的照片最大的分辨率为:{}" , houseEntity.getId() , null != maxResolution ? maxResolution.name() :"空值");
+        return null != maxResolution ? maxResolution.name() : ImageResolutionRate.TWO_K.name();
+    }
+
 
     /***
      * 获取唯一场景码
@@ -674,12 +690,6 @@ public class HouseController extends BaseController {
     }
 
 
-    public static void main(String[] args) {
-        String path = "C:\\Users\\Administrator\\Desktop\\test\\d_9iRDUgn3l\\pano";
-        boolean file = FileUtil.isDirectory(path);
-        System.out.println(file);
-        FileUtil.del(path);
-    }
 
 
 }

+ 1 - 9
fdkanfang-web/src/main/java/com/fdkanfang/web/backend/TestController.java

@@ -3,35 +3,27 @@ package com.fdkanfang.web.backend;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
-import com.alibaba.fastjson.JSONObject;
 import com.fdkanfang.common.constant.MsgCode;
 import com.fdkanfang.common.util.AliyunOssUtil;
 import com.fdkanfang.common.util.FileUtils;
 import com.fdkanfang.common.util.R;
-import com.fdkanfang.common.util.Result;
 import com.fdkanfang.dao.backend.ResourceMapper;
 import com.fdkanfang.dao.backend.UserMapper;
 import com.fdkanfang.domain.backend.*;
 import com.fdkanfang.domain.dto.HouseDto;
-import com.fdkanfang.domain.response.ResponseScene;
 import com.fdkanfang.service.backend.HouseService2;
-import com.fdkanfang.service.backend.ISceneProEditService;
-import com.fdkanfang.service.backend.ISceneProService;
 import com.fdkanfang.service.backend.ImageService2;
 import com.fdkanfang.web.mq.config.RabbitConfig;
-import com.github.pagehelper.util.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import springfox.documentation.annotations.ApiIgnore;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
 import java.io.File;
 import java.io.IOException;
@@ -201,7 +193,7 @@ public class TestController {
             image.setLocalPath(filePath);
 
             try {
-                FileUtils.bigFileWrite(file.getInputStream(), filePath);
+                FileUtils.downloanAndGetResolutionRate(file.getInputStream(), filePath ,false);
 
             } catch (IOException e) {
                 e.printStackTrace();

+ 5 - 0
fdkanfang-web/src/main/java/com/fdkanfang/web/mq/listener/PanoListener.java

@@ -43,6 +43,9 @@ public class PanoListener {
 
         Long houseId = (Long)mqMap.get("id");
         String basePath = (String)mqMap.get("basePath");
+        String splitType = (String)mqMap.get("splitType");
+        String skyboxType = (String)mqMap.get("skyboxType");
+        String dataDescribe = (String)mqMap.get("dataDescribe");
 
         HouseEntity house = houseService2.findById(houseId);
         if (house == null) {
@@ -52,6 +55,8 @@ public class PanoListener {
         String sceneCode = house.getSceneCode();
 
         try {
+
+
             //计算模型并返回需要上传oss的文件集合
             Map<String, String> map = ComputerUtil.computer(sceneCode, sceneCode, basePath);