|
@@ -0,0 +1,125 @@
|
|
|
+package com.fdkankan.scene.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.CharsetUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.core.util.ZipUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
+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.model.utils.SceneUtil;
|
|
|
+import com.fdkankan.scene.entity.SceneAsynOperLog;
|
|
|
+import com.fdkankan.scene.entity.ScenePlus;
|
|
|
+import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
+import com.fdkankan.scene.service.*;
|
|
|
+import com.fdkankan.scene.vo.UploadPanoramaVO;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class RemovePortraitServiceImpl implements IRemovePortraitService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fileServiceInterface;
|
|
|
+ @Autowired
|
|
|
+ private ISceneEditInfoService sceneEditInfoService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneAsynOperLogService sceneAsynOperLogService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removePortrait(JSONObject param) throws Exception {
|
|
|
+ String num = param.getString("num");
|
|
|
+
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ if(scenePlus.getRemovePortrait() == CommonOperStatus.WAITING.code()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ String bucket = scenePlusExt.getYunFileBucket();
|
|
|
+ //原始计算根目录
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+ //全景图计算根目录
|
|
|
+ String target = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + uuid;
|
|
|
+ //解压缩文件存放目录
|
|
|
+ String targetImagesPath = target + "/extras/images/";
|
|
|
+ //更新状态为进行中
|
|
|
+ scenePlus.setRemovePortrait(CommonOperStatus.WAITING.code());
|
|
|
+ scenePlusService.updateById(scenePlus);
|
|
|
+ try {
|
|
|
+ //下载文件
|
|
|
+ String cacheImagesPath = String.format(UploadFilePath.scene_result_data_path, num) + "caches/images/";
|
|
|
+ List<String> imagesList = fileServiceInterface.listRemoteFiles(cacheImagesPath);
|
|
|
+ if(CollUtil.isEmpty(imagesList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ imagesList.stream().forEach(key->{
|
|
|
+ if(key.endsWith(".jpg")){
|
|
|
+ fileServiceInterface.downloadFile(key, targetImagesPath + FileUtil.getName(key));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
+ fileServiceInterface.downloadFile(imgViewPath + "vision.txt", target + File.separator + "extras" + File.separator + "vision.txt");
|
|
|
+
|
|
|
+ //data.json增加extras为执行重建算法
|
|
|
+ JSONObject floorplanJson = new JSONObject();
|
|
|
+ floorplanJson.put("has_source_images", true);
|
|
|
+ floorplanJson.put("has_vision_txt", true);
|
|
|
+
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
+ dataJson.put("extras", floorplanJson);
|
|
|
+ dataJson.put("split_type", "SPLIT_V28");
|
|
|
+ //V5表示不需要生成high,low文件
|
|
|
+ String skyboxType = "SKYBOX_V6";
|
|
|
+ if(scenePlusExt.getSceneScheme() == 11){
|
|
|
+ skyboxType = "SKYBOX_V7";
|
|
|
+ }
|
|
|
+ //sceneScheme为3切成瓦片图
|
|
|
+ if(scenePlusExt.getSceneScheme() == 3){
|
|
|
+ if("4k".equals(scenePlusExt.getSceneResolution())){
|
|
|
+ skyboxType = "SKYBOX_V14";
|
|
|
+ }else{
|
|
|
+ skyboxType = "SKYBOX_V13";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataJson.put("skybox_type", skyboxType);
|
|
|
+ FileUtil.writeUtf8String(dataJson.toJSONString(), target + File.separator+"data.json");
|
|
|
+
|
|
|
+ sceneEditInfoService.uploadPanoramaHandler(num,bucket,target,imgViewPath,new ArrayList<>(),targetImagesPath, "removePortrait");
|
|
|
+ scenePlus.setRemovePortrait(CommonOperStatus.SUCCESS.code());
|
|
|
+
|
|
|
+ //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
|
|
|
+ sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("抹除人像失败,num:{}", num, e);
|
|
|
+ scenePlus.setRemovePortrait(CommonOperStatus.FAILD.code());
|
|
|
+ }finally {
|
|
|
+ FileUtil.del(target);
|
|
|
+ scenePlusService.updateById(scenePlus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|