|
@@ -14,6 +14,7 @@ import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
import com.fdkankan.scene.bean.EulerAngles;
|
|
|
import com.fdkankan.scene.bean.ResponseScene;
|
|
@@ -25,15 +26,16 @@ import com.fdkankan.scene.service.IScene3dfamilyService;
|
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
|
import com.fdkankan.web.response.Result;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import java.io.File;
|
|
|
import java.io.FileWriter;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
|
* Created by Hb_zzZ on 2019/6/28.
|
|
@@ -207,9 +209,9 @@ public class Scene3dfamilyServiceImpl extends ServiceImpl<IScene3dfamilyMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateSceneNumByNum (ScenePro sceneProEntity){
|
|
|
+ public void updateSceneNumByNum (String sceneNum){
|
|
|
this.update(new LambdaUpdateWrapper<Scene3dfamily>().set(Scene3dfamily::getRecStatus,
|
|
|
- RecStatus.DISABLE.code()).eq(Scene3dfamily::getSceneNum, sceneProEntity.getNum()));
|
|
|
+ RecStatus.DISABLE.code()).eq(Scene3dfamily::getSceneNum, sceneNum));
|
|
|
}
|
|
|
|
|
|
private void downloadVisionData(ScenePro sceneProEntity) throws Exception {
|
|
@@ -233,6 +235,22 @@ public class Scene3dfamilyServiceImpl extends ServiceImpl<IScene3dfamilyMapper,
|
|
|
fYunFileService.uploadFile(dataBuffer.toString() + "vision.json", dataBuf.toString() + "vision.json");
|
|
|
}
|
|
|
|
|
|
+ private void downloadVisionData(String sceneNum) throws Exception {
|
|
|
+ String dataBuf = String.format(UploadFilePath.IMG_VIEW_PATH,sceneNum);
|
|
|
+
|
|
|
+ String dataBuffer = String.format(ConstantFilePath.SCENE_IMAGES_PATH_V4,sceneNum);
|
|
|
+
|
|
|
+ fYunFileService.downloadFile(dataBuf.toString() + "vision.modeldata", dataBuffer.toString() + "vision.modeldata");
|
|
|
+
|
|
|
+ File file = new File(dataBuffer.toString() + "vision.modeldata");
|
|
|
+ if(!file.exists()) {
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+ CreateObjUtil.convertVisionmodeldataToTxt(dataBuffer.toString() + "vision.modeldata", dataBuffer.toString() + "vision.json");
|
|
|
+
|
|
|
+ fYunFileService.uploadFile(dataBuffer.toString() + "vision.json", dataBuf.toString() + "vision.json");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param src vision.json 路径
|
|
@@ -277,4 +295,135 @@ public class Scene3dfamilyServiceImpl extends ServiceImpl<IScene3dfamilyMapper,
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result createZip(String sceneNum, String dataSource, String thumb, Long userId) throws Exception {
|
|
|
+ Scene3dfamily scene3dFamilyEntity = this.findSceneNumByNum(sceneNum,0);
|
|
|
+ String path = dataSource + "_3df" + File.separator + sceneNum;
|
|
|
+ try {
|
|
|
+ if(scene3dFamilyEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5032);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("三维家 信息保存 路径 : " + path);
|
|
|
+ //创建文件夹
|
|
|
+ FileUtils.createDir(path);
|
|
|
+
|
|
|
+ //生成vision.json
|
|
|
+ this.downloadVisionData(sceneNum);
|
|
|
+
|
|
|
+ String dataBuffer = String.format(ConstantFilePath.SCENE_IMAGES_PATH_V4,sceneNum);
|
|
|
+
|
|
|
+ String dataBuf = "data" + File.separator + "data" + sceneNum + File.separator;
|
|
|
+
|
|
|
+ this.visionTxtToPano(dataBuffer + "vision.json",path+ File.separator +"scene"+ File.separator+ dataBuf );
|
|
|
+
|
|
|
+ //拉取data
|
|
|
+ fYunFileService.downloadFileByCommand(path + File.separator + "scene" + File.separator + "data" + File.separator + "data" + sceneNum,
|
|
|
+ String.format(UploadFilePath.DATA_VIEW_PATH,sceneNum));
|
|
|
+
|
|
|
+ // 下载用户的户型图数据
|
|
|
+ if (fYunFileService.fileExist(String.format(UploadFilePath.USER_VIEW_PATH, sceneNum) + "houst_floor.json")) {
|
|
|
+ fYunFileService.downloadFile(String.format(UploadFilePath.USER_VIEW_PATH, sceneNum) + "houst_floor.json",
|
|
|
+ path + File.separator + "scene" + File.separator + "data" + File.separator + "data" + sceneNum
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fYunFileService.fileExist(String.format(UploadFilePath.USER_VIEW_PATH, sceneNum) + "floorplan_cad.json")) {
|
|
|
+ fYunFileService.downloadFile(String.format(UploadFilePath.USER_VIEW_PATH, sceneNum) + "floorplan_cad.json",
|
|
|
+ path + File.separator + "scene" + File.separator + "data" + File.separator + "data" + sceneNum
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ //转换house.json
|
|
|
+ Integer bo = JsonToHouseUtil.ToHouseJson(path + File.separator + "scene" + File.separator + dataBuf);
|
|
|
+
|
|
|
+ if (bo != 0) {
|
|
|
+ switch (bo) {
|
|
|
+ case -1:
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5029.code(), "点位数据为空");
|
|
|
+ case -2:
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5029.code(), "点位数据重复");
|
|
|
+ case -3:
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5029.code(), "转换异常");
|
|
|
+ case -4:
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5029.code(), "源文件不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //下载 scene.json 改名为 getinfo.json
|
|
|
+ fYunFileService.downloadFile(String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum) + "scene.json",
|
|
|
+ path + File.separator + "scene" + File.separator + "data" + File.separator + "data"
|
|
|
+ + sceneNum + File.separator + "getinfo.json");
|
|
|
+
|
|
|
+ //下载场景封面图
|
|
|
+ String ossImagePath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
|
|
|
+ String ImagePath = path + File.separator + "scene" + File.separator + "images" + File.separator + "images" + sceneNum;
|
|
|
+ FileUtils.downLoadFromUrl(thumb,"cover.jpg", ImagePath);
|
|
|
+
|
|
|
+ //拉取images
|
|
|
+ fYunFileService.downloadFile(ossImagePath + "floorLogoImg.png", ImagePath + "/floorLogoImg.png");
|
|
|
+ fYunFileService.downloadFile(ossImagePath + "floorplan.png", ImagePath + "/floorplan.png");
|
|
|
+ fYunFileService.downloadFile(ossImagePath + "logo-main.png", ImagePath + "/logo-main.png");
|
|
|
+ fYunFileService.downloadFile(ossImagePath + "logo-main-en.png", ImagePath + "/logo-main-en.png");
|
|
|
+ fYunFileService.downloadFile(ossImagePath + "smallPic.jpg", ImagePath + "/smallPic.jpg");
|
|
|
+ fYunFileService.downloadFile(ossImagePath + "thumbBigImg.jpg", ImagePath + "/thumbBigImg.jpg");
|
|
|
+ fYunFileService.downloadFile(ossImagePath + "thumbSmallImg.jpg", ImagePath + "/thumbSmallImg.jpg");
|
|
|
+ fYunFileService.downloadFileByCommand(ImagePath + "/pan", ossImagePath + "pan");
|
|
|
+
|
|
|
+ // 异步执行
|
|
|
+ CompletableFuture.runAsync(()->{
|
|
|
+ //压缩zip
|
|
|
+ try {
|
|
|
+ log.info("开始异步执行打包逻辑……");
|
|
|
+ //获取六面体图
|
|
|
+ fYunFileService.downloadFileByCommand(ImagePath + "/tiles", ossImagePath + "tiles");
|
|
|
+
|
|
|
+ //拉取video
|
|
|
+ fYunFileService.downloadFileByCommand(path + File.separator + "scene" + File.separator + "video" + File.separator + "video" + sceneNum,
|
|
|
+ String.format(UploadFilePath.VIDEOS_VIEW_PATH, sceneNum));
|
|
|
+
|
|
|
+ //拉取voice
|
|
|
+ fYunFileService.downloadFileByCommand(path + File.separator + "scene" + File.separator + "voice" + File.separator + "voice" + sceneNum,
|
|
|
+ String.format(UploadFilePath.VOICE_VIEW_PATH, sceneNum));
|
|
|
+
|
|
|
+ ZipUtil.zip(path, path + ".zip");
|
|
|
+
|
|
|
+ log.info("三维家 zip完成 : " + path);
|
|
|
+
|
|
|
+ //上传oss
|
|
|
+ // 上传到阿里云sso
|
|
|
+ fYunFileService.uploadFileByCommand(path + ".zip", DIR_NAME + sceneNum + ".zip");
|
|
|
+ log.info("upload success");
|
|
|
+
|
|
|
+ String url = fyunHost + DIR_NAME + sceneNum + ".zip";
|
|
|
+
|
|
|
+ log.info("upload url: {}" + url);
|
|
|
+
|
|
|
+ scene3dFamilyEntity.setZipLink(url);
|
|
|
+ scene3dFamilyEntity.setStatus(1);
|
|
|
+ scene3dFamilyEntity.setZipEndTime(new Date());
|
|
|
+ scene3dFamilyEntity.setUpdateTime(new Date());
|
|
|
+ this.updateById(scene3dFamilyEntity);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ scene3dFamilyEntity.setStatus(2);
|
|
|
+ scene3dFamilyEntity.setZipEndTime(new Date());
|
|
|
+ scene3dFamilyEntity.setUpdateTime(new Date());
|
|
|
+ this.updateById(scene3dFamilyEntity);
|
|
|
+ }finally {
|
|
|
+ FileUtils.deleteDirectory(path);
|
|
|
+ FileUtils.deleteFile(path + ".zip");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }catch (Exception e){
|
|
|
+ scene3dFamilyEntity.setStatus(2);
|
|
|
+ scene3dFamilyEntity.setZipEndTime(new Date());
|
|
|
+ scene3dFamilyEntity.setUpdateTime(new Date());
|
|
|
+ this.updateById(scene3dFamilyEntity);
|
|
|
+ e.printStackTrace();
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
}
|