|
@@ -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);
|