Selaa lähdekoodia

新增 全景图需要预览图功能

wuweihao 4 vuotta sitten
vanhempi
commit
e9a83143e8

+ 43 - 0
720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -500,6 +500,49 @@ public class FileUtils {
 
 
     /**
+     * 压缩图片
+     * 固定名称: 名称固定是xxx.jpg
+     * @param inputFilePath
+     * @param ossBasePath
+     * @param ossDomain
+     * @param width 宽
+     * @param height 高
+     * @return 完整的oss访问地址
+     */
+    public  String compressImgAndUploadOss2(String inputFilePath, String ossBasePath, String ossDomain, Integer width, Integer height, String imgName){
+        String serverBasePath = StringUtils.substringBeforeLast(inputFilePath, "/");
+
+//        String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
+//        String suffix = StringUtils.substringAfterLast(inputFilePath, ".");
+//        String fileName ="/thumb_"+ time  + "."  +suffix;
+
+        // 保存图片位置
+        String saveCompressImgPath = serverBasePath + imgName;
+        String ossUrl = null;
+        try {
+            Img.from(new File(inputFilePath)).scale(width, height).write(new File(saveCompressImgPath));
+            log.info("图片压缩成功: " + saveCompressImgPath);
+
+            if (FileUtil.isFile(saveCompressImgPath)) {
+                // 上传oss
+                String ossPath = ossBasePath + imgName;
+                log.info("ossPath: " + ossPath);
+                aliyunOssUtil.upload(saveCompressImgPath, ossPath);
+                ossUrl = ossDomain + ossPath;
+                log.info("图片上传成功: " + ossUrl);
+            } else {
+                log.error("缩略图不存在: " + saveCompressImgPath);
+            }
+
+        } catch (Exception e) {
+            log.error("图片格式有误,不支持此图片");
+            e.printStackTrace();
+        }
+        return ossUrl;
+    }
+
+
+    /**
      * 按比例缩放
      * @param inputFilePath
      * @param ossBasePath

+ 3 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/FodderEntity.java

@@ -35,6 +35,9 @@ public class FodderEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "封面图")
     private String icon;
 
+    @ApiModelProperty(value = "预览图(全景图使用)")
+    private String previewIcon;
+
     @ApiModelProperty(value = "文件名")
     private String fileName;
 

+ 3 - 0
720yun_fd_manage/gis_domain/src/main/java/com/gis/domain/entity/WorkEntity.java

@@ -63,6 +63,9 @@ public class WorkEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "二维码")
     private String qrCode;
 
+    @ApiModelProperty(value = "分享地址(二维码扫描后地址)")
+    private String share;
+
     @ApiModelProperty(value = "初始场景id(场景id)")
     private Long sceneIndex;
 

+ 6 - 1
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -90,6 +90,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         String dpi = "0";
         String ossPath = configConstant.ossBasePath+dirType+newName;
         String savePath = configConstant.serverBasePath;
+        String ossPreviewIcon = null;
 
         FodderEntity entity = new FodderEntity();
         if (type.equals("pano")) {
@@ -105,6 +106,10 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
                 // 压缩图片并上传oss
                 iconPath = fileUtils.compressImgAndUploadOss2(savePath, configConstant.ossBasePath + sceneCode , configConstant.ossDomain);
 
+                // 全景图的预览图
+                ossPreviewIcon = fileUtils.compressImgAndUploadOss2(
+                       savePath, configConstant.ossBasePath + sceneCode , configConstant.ossDomain, 1920, 960, "preview.jpg");
+
 
                 ossUrl = configConstant.ossDomain+configConstant.ossBasePath + sceneCode;
 
@@ -153,6 +158,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         entity.setUserId(getUserNameForToken());
         entity.setFileSize(size+"");
         entity.setDpi(dpi);
+        entity.setPreviewIcon(ossPreviewIcon);
 
         save(entity);
 
@@ -195,7 +201,6 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
     @Override
     public Result selectFodderPano(PageDto param, Long workId) {
         startPage(param);
-//        List<FodderEntity> list = entityMapper.findByStatusAndTypeAndUserId(3, "pano", getUserNameForToken());
 
         List<FodderEntity> list = entityMapper.searchPano(param, getUserNameForToken());
 

+ 7 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -103,6 +103,13 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
 
             reJson = JSONObject.parseObject(restResult);
             int code = reJson.getInteger("code");
+
+            if (code == 3004) {
+                String msg = reJson.getString("msg");
+                log.info("获取四维看看列表失败,{}", msg);
+                return Result.failure(5001, msg);
+            }
+
             if (code != 0) {
                 String msg = reJson.getString("msg");
                 log.info("获取四维看看列表失败,{}", msg);

+ 4 - 5
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/WorkServiceImpl.java

@@ -1,8 +1,6 @@
 package com.gis.service.impl;
 
-import com.gis.common.config.RabbitConfig;
 import com.gis.common.constant.ConfigConstant;
-import com.gis.common.task.AsyncTask;
 import com.gis.common.util.*;
 import com.gis.domain.dto.PageDto;
 import com.gis.domain.dto.WorkDto;
@@ -13,7 +11,6 @@ import com.gis.service.WorkService;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -74,11 +71,13 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
             // 创建二维码
             String qrCode = entity.getQrCode();
             if (StringUtils.isBlank(qrCode)) {
-                 qrCode = qrCodeUtils.generateLogoQrCode("https://www.baidu.com", configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain);
+                // 二维码url
+                String url = configConstant.domain4dKK + "/panorama/show.html?id=" + id;
+                 qrCode = qrCodeUtils.generateLogoQrCode(url, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain);
                  entity.setQrCode(qrCode);
+                 entity.setShare(url);
             }
 
-
             // 设置为显示状态
             entity.setStatus(1);
             entity.setUpdateTime(new Date());

+ 0 - 30
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/WebController.java

@@ -28,9 +28,6 @@ public class WebController extends BaseController {
     private CatalogService catalogService;
 
     @Autowired
-    private SceneService sceneService;
-
-    @Autowired
     WorkService workService;
 
     @ApiOperation(value = "作品列表", position = 1)
@@ -55,31 +52,4 @@ public class WebController extends BaseController {
         return Result.success(entity);
     }
 
-
-//    @ApiOperation(value = "检查token是否有效" , position = 3)
-//    @GetMapping("checkToken")
-//    public Result checkToken() {
-//        String token = getToken();
-//        if (token == null) {
-//            log.error("token is null");
-//            return Result.failure(5001, "Token为空");
-//        }
-//
-//        String redisToken = redisTemplate.opsForValue().get(token);
-//        if (redisToken != null) {
-//            return Result.success();
-//        }
-//
-//        log.error("redis token is null");
-//        return Result.failure(5001, "Token无效");
-//
-//    }
-
-
-
-
-
-
-
-
 }