소스 검색

素材库缩略图不需要压缩, 前端使用oss截取缩略图

wuweihao 2 년 전
부모
커밋
5a53a19881

+ 2 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/TestService.java

@@ -15,4 +15,6 @@ public interface TestService  {
     Result getSceneCode(String ids);
 
     Result updatePanoTourXml(String all);
+
+    Result updateDbFodderTourXml(String isAll);
 }

+ 14 - 11
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -164,17 +164,20 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
 
                 if (type.equals("image")) {
                     // 2022-10-27,图片大于1MB生成缩略图, 小于1MB使用原图作为缩略图
-                    if (size > 1024){
-                        savePath = savePath  + "/fodder/image/" + newName;
-                        log.info("savePath: {}", savePath);
-                        FileUtil.writeFromStream(file.getInputStream(), savePath);
-                        iconPath = convertAndUploadOss(
-                                savePath, configConstant.ossBasePath + "fodder", configConstant.ossDomain, 800, 800, "/thumb_" + newName);
-                        log.info("图片压缩完成");
-
-                    } else {
-                        iconPath = ossUrl;
-                    }
+//                    if (size > 1024){
+//                        savePath = savePath  + "/fodder/image/" + newName;
+//                        log.info("savePath: {}", savePath);
+//                        FileUtil.writeFromStream(file.getInputStream(), savePath);
+//                        iconPath = convertAndUploadOss(
+//                                savePath, configConstant.ossBasePath + "fodder", configConstant.ossDomain, 800, 800, "/thumb_" + newName);
+//                        log.info("图片压缩完成");
+//
+//                    } else {
+//                        iconPath = ossUrl;
+//                    }
+
+                    // 2022-11-02 素材库缩略图不需要压缩, 前端使用oss截取缩略图。 当图片过大自定义logo时, 生成二维码会变慢
+                    iconPath = ossUrl;
 
                     // todo 这个是很耗新能的,如果新能有问题,改用前端
                     dpi = ImageUtil.dpi(file);

+ 31 - 2
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/TestServiceImpl.java

@@ -138,7 +138,33 @@ public class TestServiceImpl implements TestService {
         return Result.success("更新完成");
     }
 
+    @Override
+    public Result updateDbFodderTourXml(String isAll) {
+
+        // 1.获取素材表,type=pano
+        List<FodderEntity> list = fodderService.findByType("pano");
+        log.info("场景数量:{}", list.size());
+
+        int i = 0;
+        for (FodderEntity entity : list) {
+            String tour = entity.getTour();
+            if (StrUtil.isBlank(tour)){
+                continue;
+            }
+            String sceneCode = entity.getSceneCode();
+            if (tour.contains("%CURRENTXML%")){
+                continue;
+            }
+            i ++ ;
+            String basePath = "%CURRENTXML%../" + sceneCode + "/vtour/panos/";
+            tour = tour.replaceAll("panos/", basePath);
+            entity.setTour(tour);
+            fodderService.update(entity);
+            log.info("更新第 {} 个场景: {}", i, sceneCode);
+        }
 
+        return Result.success("共更新了:" + i);
+    }
 
 
     /**
@@ -156,7 +182,6 @@ public class TestServiceImpl implements TestService {
         int n = 0;
         for (WorkEntity workEntity : list) {
             String id = workEntity.getId();
-//            String sceneCodes = workEntity.getSceneCodes();
             List<String> sceneCodes = downLoadSomeData(id);
             createTour(sceneCodes, id);
             n ++;
@@ -209,8 +234,12 @@ public class TestServiceImpl implements TestService {
         return list;
     }
 
+    /**
+     * 创建tour.xml并上传oss
+     * @param scenes
+     * @param id
+     */
     private void createTour(List<String> scenes, String id) {
-//        List<String> scenes = filterSceneCodesByPano(sceneCodes);
         List<FodderEntity> list = fodderService.batchBySceneCodes(scenes);
 
         // 读取tour.xml模板

+ 2 - 2
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/ExceptionController.java

@@ -2,7 +2,7 @@ package com.gis.web.controller;
 
 import com.gis.common.exception.BaseRuntimeException;
 import com.gis.common.util.Result;
-import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.ShiroException;
 import org.apache.shiro.authz.UnauthorizedException;
 import org.springframework.dao.DuplicateKeyException;
@@ -22,7 +22,7 @@ import javax.validation.ValidationException;
  * 统一捕捉异常,自定义返回参数
  * 这里只可以捕获controller层的异常。
  */
-@Log4j2
+@Slf4j
 @RestControllerAdvice
 public class ExceptionController {
 

+ 14 - 0
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -245,6 +245,20 @@ public class TestController extends BaseController {
     }
 
 
+    /**
+     * 2022-11-2
+     * @param
+     * @return
+     * 逻辑 1.20需求
+     * 更新数据库tour字段历史数据里CURRENTXML 相对路径的问题
+     */
+    @GetMapping("updateDbFodderTourXml")
+    @ApiOperation(value = "v1.2-20221102-批量更新全景图Tour字段值", notes = "isAll:不传为更新1个, 传1为更新全部")
+    public Result updateDbFodderTourXml(String isAll){
+        return testService.updateDbFodderTourXml(isAll);
+    }
+
+