Bladeren bron

1.7.0 fixjson11

xiewj 1 jaar geleden
bovenliggende
commit
b71582cf40

+ 3 - 0
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/entity/ScenePanoEntity.java

@@ -52,4 +52,7 @@ public class ScenePanoEntity extends BaseEntity implements Serializable  {
 
     @ApiModelProperty("tour.xml")
     private String tour;
+
+    @ApiModelProperty("四维看看场景码")
+    private String num;
 }

+ 47 - 12
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/listener/SceneListener.java

@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -117,11 +118,8 @@ public class SceneListener {
                     if (item.endsWith(".jpg")) {
                     log.info("key:{}",item);
                     Map<String,Object> scene=new HashMap<>();
-                    String sceneCode = RandomUtils.getSceneCode("fd720_");
-                    String newName = sceneCode + ".jpg";
-                    String savePath = configConstant.serverBasePath + sceneCode+ "/" + newName;
-                    aliyunOssUtil.downloadFile("4dkankan",item,savePath );
-                    ScenePanoEntity scenePanoEntity = this.doSlice(traceId, savePath, sceneCode, param.getSceneCode(), workEntity.getId());
+
+                    ScenePanoEntity scenePanoEntity = this.doSlice(traceId ,item, param.getSceneCode(), workEntity.getId(),index+".jpg");
                     scenePanoEntities.add(scenePanoEntity);
 
                     //  "icon": "https://ossxiaoan.4dage.com/720yun_fd_manage/fd720_8nRkFlzpp/vtour/panos/fd720_8nRkFlzpp.tiles/thumb.jpg",
@@ -172,13 +170,50 @@ public class SceneListener {
     public static String generateCustomId() {
         return "s_" + generateRandomId();
     }
-    private ScenePanoEntity doSlice(String traceId,String filePath,String sceneCode,String num,String workId){
-        ScenePanoEntity entity = new ScenePanoEntity();
-        entity.setFilePath(filePath);
-        entity.setFileName(FileUtil.getName(filePath));
-        entity.setSceneCode(num);
-        entity.setWorkId(workId);
-        scenePanoService.save(entity);
+    private ScenePanoEntity doSlice(String traceId,String item, String num, String workId, String imgName){
+        ScenePanoEntity entity=scenePanoService.findByWorkIdAndName(workId,imgName);
+        String sceneCode ="";
+        String newName = "";
+        String filePath = "";
+        if (ObjectUtil.isEmpty(entity)) {
+            //未生成
+            sceneCode = RandomUtils.getSceneCode("fd720_");
+            newName = sceneCode + ".jpg";
+            filePath = configConstant.serverBasePath + sceneCode+ "/" + newName;
+            aliyunOssUtil.downloadFile("4dkankan",item,filePath );
+            entity = new ScenePanoEntity();
+            entity.setFilePath(filePath);
+            entity.setFileName(FileUtil.getName(filePath));
+            entity.setSceneCode(sceneCode);
+            entity.setNum(num);
+            entity.setOssPath(item);
+            entity.setName(imgName);
+            entity.setWorkId(workId);
+            long size = FileUtil.size(new File(filePath));
+            size = size / 1024;
+            log.info("fileSize: " + size);
+            entity.setFileSize(size + "");
+
+            scenePanoService.save(entity);
+        }else {
+            entity.setStatus(0);
+
+            filePath = entity.getFilePath();
+            sceneCode = entity.getSceneCode();
+            boolean exist = FileUtil.exist(filePath);
+            if (exist){
+                FileUtil.del(filePath);
+            }
+            log.info("生成过,重新下载");
+            aliyunOssUtil.downloadFile("4dkankan",item,filePath );
+            log.info("下载完成重新切图");
+            long size = FileUtil.size(new File(filePath));
+            size = size / 1024;
+            log.info("fileSize: " + size);
+            entity.setFileSize(size + "");
+            scenePanoService.update(entity);
+
+        }
 
 
         log.info("切图流程开始 : " + filePath);

+ 1 - 0
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/service/ScenePanoService.java

@@ -11,4 +11,5 @@ import com.gis.entity.ScenePanoEntity;
  */
 public interface ScenePanoService extends IBaseService<ScenePanoEntity,Long> {
 
+    ScenePanoEntity findByWorkIdAndName(String workId, String imgName);
 }

+ 8 - 0
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/service/impl/ScenePanoServiceImpl.java

@@ -23,4 +23,12 @@ public class ScenePanoServiceImpl extends IBaseServiceImpl<ScenePanoEntity, Long
     public IBaseMapper<ScenePanoEntity, Long> getBaseMapper() {
         return this.scenePanoMapper;
     }
+
+    @Override
+    public ScenePanoEntity findByWorkIdAndName(String workId, String imgName) {
+        ScenePanoEntity one=new ScenePanoEntity();
+        one.setWorkId(workId);
+        one.setName(imgName);
+        return getBaseMapper().selectOne(one);
+    }
 }