Преглед на файлове

Merge branch 'feature-v4.10.0-20230714-dsx' into test

# Conflicts:
#	src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java
dsx преди 2 години
родител
ревизия
d381ad105a

+ 81 - 0
src/main/java/com/fdkankan/contro/entity/SceneColdStorageLog.java

@@ -0,0 +1,81 @@
+package com.fdkankan.contro.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 场景冷归档日志表
+ * </p>
+ *
+ * @author 
+ * @since 2023-07-14
+ */
+@Getter
+@Setter
+@TableName("t_scene_cold_storage_log")
+public class SceneColdStorageLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 场景码
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 封存地址
+     */
+    @TableField("path")
+    private String path;
+
+    /**
+     * 操作类型(1-封存,2-解封存)
+     */
+    @TableField("type")
+    private Integer type;
+
+    /**
+     * 0-处理中,1-成功,-1-失败
+     */
+    @TableField("state")
+    private Integer state;
+
+    /**
+     * 失败原因
+     */
+    @TableField("reason")
+    private String reason;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 修改时间
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * A-有效,I-无效
+     */
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+
+}

+ 1 - 1
src/main/java/com/fdkankan/contro/generate/AutoGenerate.java

@@ -17,7 +17,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir");
 
         generate(path,"contro", getTables(new String[]{
-                "t_exceed_space_scene"
+                "t_scene_cold_storage_log"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 18 - 0
src/main/java/com/fdkankan/contro/mapper/ISceneColdStorageLogMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.SceneColdStorageLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 场景冷归档日志表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-07-14
+ */
+@Mapper
+public interface ISceneColdStorageLogMapper extends BaseMapper<SceneColdStorageLog> {
+
+}

+ 26 - 31
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -209,7 +209,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
     }
 
-
     @Override
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
         String sceneCode = message.getBuildContext().get("sceneNum").toString();
@@ -239,12 +238,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
             Map<String, String> uploadFiles = getUploadFiles(scenePlus,path,cameraType,fdageData);
 
-            //计算场景消耗磁盘空间
-            long space = this.calUseSpace(uploadFiles);
-
-
             scenePlus.setPayStatus(PayStatus.PAY.code());
-
             scenePlus.setUpdateTime(new Date());
             scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
 
@@ -254,8 +248,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
             ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
             boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
-            //写入数据库
-            this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
 
             //上传全景图俯视图
             this.uploadFloorCad(path, sceneCode, uploadFiles);
@@ -266,21 +258,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //上传文件
             fYunFileService.uploadMulFiles(uploadFiles);
 
+            //修改oss上dam的内容编码
             Map<String,String> damFileHeaders = new HashMap<>();
             damFileHeaders.put("Content-Encoding","gzip");
-            // dam 文件设置请求头
-            uploadFiles.entrySet().stream().filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
-                .forEach(entry -> {
-                    if (!new File(entry.getKey()).exists()) {
-                        log.error("文件不存在,不予gzip压缩,文件路径:{}", entry.getKey());
-                        return;
-                    }
-                    // gzip压缩
-                    FileUtil.writeBytes(ZipUtil.gzip(new File(entry.getKey())), entry.getKey() + ".gzip");
-                    // 重命名
-                    FileUtil.rename(new File(entry.getKey() + ".gzip"), entry.getKey(), true);
-                    fYunFileService.uploadFile(entry.getKey(), entry.getValue(), damFileHeaders);
-                });
+            String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
+            fYunFileService.uploadFile(damPath,  String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + ConstantFileName.modelUUID + "_50k.dam", damFileHeaders);
 
             //拷贝部分文件到编辑目录,用于用户编辑
             this.copyToEditDir(sceneCode);
@@ -289,11 +271,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 //            this.cachePanorama(path, sceneCode);
 
             //生成houseTypejson并上传
-            boolean existHouseType = this.uploadHouseTypeJson(sceneCode, scenePlusExt.getDataSource());
+            boolean existHouseType = this.uploadHouseTypeJson(sceneCode, path);
             scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
 
             //生成floorpan.json
-            commonService.uploadFloorplanJson(sceneCode, scenePlusExt.getDataSource());
+            commonService.uploadFloorplanJson(sceneCode, path);
 
             //重置异步操作记录
             this.removeSceneAsynOperLog(sceneCode);
@@ -304,8 +286,15 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             bizs.add(UserEditDataType.FLOORPLAN.message());
             commonService.initUserEditData(sceneCode, bizs, null);
 
+            //计算场景消耗磁盘空间
+            long space = this.calUseSpace(uploadFiles);
+
             //上传计算结果文件
-            commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
+            Long cacheSize = commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
+            space += cacheSize;
+
+            //写入数据库
+            this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
 
             Object[] editInfoArr = this.updateEditInfo(scenePlus);
             SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
@@ -314,7 +303,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
             if (cameraType == 14) {
                 //计算成功  激光转台相机 同步 请求
-                fdkkLaserService.syncBuildResult(scenePlus.getNum(), scenePlusExt.getDataSource(),scenePlus.getCreateTime(), Calendar.getInstance().getTime());
+                fdkkLaserService.syncBuildResult(scenePlus.getNum(), path, scenePlus.getCreateTime(), Calendar.getInstance().getTime());
                 sceneEditControlsService.update(new LambdaUpdateWrapper<SceneEditControls>().set(SceneEditControls::getShowMap,0)
                         .eq(SceneEditControls::getEditInfoId,sceneEditInfo.getId()));
                 sceneEditControls.setShowMap(0);
@@ -349,6 +338,9 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             if (cameraType != 14) {
                 scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space));
             }
+
+            this.uploadStatusJson(scenePlus, scenePlusExt);
+
             scenePlusService.updateById(scenePlus);
 
             //国际环境需要发邮件通知
@@ -487,11 +479,10 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
         if(genModel){
             if (!gen3dTiles) {
-                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-                CreateObjUtil.convertDamToLzma(path + File.separator + "results/");
-                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-                map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", imagesPath + ConstantFileName.modelUUID + "_50k.dam.lzma");
-                map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", imagesPath + ConstantFileName.modelUUID + "_50k.dam");
+                String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
+                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", damPath);
+                FileUtil.writeBytes(ZipUtil.gzip(new File(damPath)), damPath);
+                map.put(damPath, imagesPath + ConstantFileName.modelUUID + "_50k.dam");
             }else{
                 List<String> list = FileUtils.list(new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
                 if(CollUtil.isEmpty(list)){
@@ -606,6 +597,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         fYunFileService.uploadFile(sceneJsonStr.getBytes(), dataViewPath + "scene.json");
         //scenejson写入缓存
         redisUtil.set(String.format(RedisKey.SCENE_JSON, num), sceneJsonStr);
+    }
+
+    private void uploadStatusJson(ScenePlus scenePlus, ScenePlusExt scenePlusExt){
+        String num = scenePlus.getNum();
+        String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
 
         Integer status = 1;
         if(scenePlus.getSceneSource() == 4 || scenePlus.getSceneSource() == 5){//如果是激光场景,需要激光系统那边完全处理好之后再发mq通知更新状态
@@ -625,7 +621,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
         fYunFileService.uploadFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json",
                 dataViewPath + "status.json");
-
     }
 
     private void createQrCode(String num, ScenePlusExt scenePlusExt, String qrLogo) {

+ 1 - 1
src/main/java/com/fdkankan/contro/service/ICommonService.java

@@ -14,7 +14,7 @@ public interface ICommonService {
      * @param dataSource
      * @param version
      */
-    public void uploadBuildResultData(String num, String dataSource, String version);
+    public Long uploadBuildResultData(String num, String dataSource, String version);
 
     /**
      * 删除用户编辑数据业务方法

+ 22 - 0
src/main/java/com/fdkankan/contro/service/ISceneColdStorageLogService.java

@@ -0,0 +1,22 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.SceneCleanOrig;
+import com.fdkankan.contro.entity.SceneColdStorageLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 场景冷归档日志表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-07-14
+ */
+public interface ISceneColdStorageLogService extends IService<SceneColdStorageLog> {
+
+    List<SceneColdStorageLog> listFreezeByNumAfterLastCall(String num, Date lastCallTime);
+
+}

+ 13 - 2
src/main/java/com/fdkankan/contro/service/impl/CommonServiceImpl.java

@@ -77,9 +77,10 @@ public class CommonServiceImpl implements ICommonService {
     @Autowired
     private ICameraService cameraService;
 
-
     @Override
-    public void uploadBuildResultData(String num, String dataSource, String version) {
+    public Long uploadBuildResultData(String num, String dataSource, String version) {
+
+        Long cacheSize = 0L;
 
         Map<String, String> uploadMap = new HashMap<>();
 
@@ -93,6 +94,7 @@ public class CommonServiceImpl implements ICommonService {
         String ossCachesImagePath = ossResultPath + "caches/images/";
         //先清除旧的全景图
         if(FileUtil.exist(localCachesImagePath)){
+            cacheSize += FileUtil.size(new File(localCachesImagePath));
             fYunFileServiceInterface.uploadFileByCommand(localCachesImagePath, ossCachesImagePath);
         }
 
@@ -131,21 +133,25 @@ public class CommonServiceImpl implements ICommonService {
         String localReconstruction = dataSource + "/caches/reconstruction/";
         String ossReconstruction = ossResultPath + "caches/reconstruction/";
         if(FileUtil.exist(localReconstruction)){
+            cacheSize += FileUtil.size(new File(localReconstruction));
             fYunFileServiceInterface.uploadFileByCommand(localReconstruction, ossReconstruction);
         }
         String localDepthmap = dataSource + "/caches/depthmap/";
         String ossDepthmap = ossResultPath + "caches/depthmap/";
         if(FileUtil.exist(localDepthmap)){
+            cacheSize += FileUtil.size(new File(localDepthmap));
             fYunFileServiceInterface.uploadFileByCommand(localDepthmap, ossDepthmap);
         }
         String localDepthmapAsc = dataSource + "/caches/depthmap_csc/";
         String ossDepthmapAsc = ossResultPath + "caches/depthmap_csc/";
         if(FileUtil.exist(localDepthmapAsc)){
+            cacheSize += FileUtil.size(new File(localDepthmapAsc));
             fYunFileServiceInterface.uploadFileByCommand(localDepthmapAsc, ossDepthmapAsc);
         }
         String localPanoramaJson =  dataSource + "/caches/panorama.json";
         String ossPanoramaJson =  ossResultPath + "caches/panorama.json";
         if(FileUtil.exist(localPanoramaJson)){
+            cacheSize += FileUtil.size(new File(localPanoramaJson));
             fYunFileServiceInterface.uploadFile(localPanoramaJson, ossPanoramaJson);
         }
 //        String localLaserPly = dataSource + "/results/laserData/laser.ply";
@@ -156,23 +162,28 @@ public class CommonServiceImpl implements ICommonService {
         String localFloorGroupFixJson = dataSource + "/caches/floor_group_fix.json";
         String ossFloorGroupFixJson = ossResultPath + "caches/floor_group_fix.json";
         if(FileUtil.exist(localFloorGroupFixJson)){
+            cacheSize += FileUtil.size(new File(localFloorGroupFixJson));
             fYunFileServiceInterface.uploadFile(localFloorGroupFixJson, ossFloorGroupFixJson);
         }
 
         String localDepthmapVis = dataSource + "/caches/depthmap_vis";
         String ossDepthmapVis = ossResultPath + "caches/depthmap_vis";
         if(FileUtil.exist(localDepthmapVis)){
+            cacheSize += FileUtil.size(new File(localDepthmapVis));
             fYunFileServiceInterface.uploadFileByCommand(localDepthmapVis, ossDepthmapVis);
         }
 
         String localIntensity = dataSource + "/caches/intensity";
         String ossIntensity = ossResultPath + "caches/intensity";
         if(FileUtil.exist(localIntensity)){
+            cacheSize += FileUtil.size(new File(localIntensity));
             fYunFileServiceInterface.uploadFileByCommand(localIntensity, ossIntensity);
         }
 
         //开始上传
         fYunFileServiceInterface.uploadMulFiles(uploadMap);
+
+        return cacheSize;
     }
 
     @Override

+ 5 - 5
src/main/java/com/fdkankan/contro/service/impl/ExceedSpaceSceneServiceImpl.java

@@ -68,11 +68,11 @@ public class ExceedSpaceSceneServiceImpl extends ServiceImpl<IExceedSpaceSceneMa
 //            }
 
             //记录删除原始资源记录
-            SceneCleanOrig sceneCleanOrig = new SceneCleanOrig();
-            sceneCleanOrig.setNum(num);
-            sceneCleanOrig.setType(4);
-            sceneCleanOrig.setState(CommonSuccessStatus.SUCCESS.code());
-            sceneCleanOrigService.save(sceneCleanOrig);
+//            SceneCleanOrig sceneCleanOrig = new SceneCleanOrig();
+//            sceneCleanOrig.setNum(num);
+//            sceneCleanOrig.setType(4);
+//            sceneCleanOrig.setState(CommonSuccessStatus.SUCCESS.code());
+//            sceneCleanOrigService.save(sceneCleanOrig);
 
             //上传计算失败状态文件
             //上传app状态文件

+ 32 - 0
src/main/java/com/fdkankan/contro/service/impl/SceneColdStorageLogServiceImpl.java

@@ -0,0 +1,32 @@
+package com.fdkankan.contro.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.contro.entity.SceneCleanOrig;
+import com.fdkankan.contro.entity.SceneColdStorageLog;
+import com.fdkankan.contro.mapper.ISceneColdStorageLogMapper;
+import com.fdkankan.contro.service.ISceneColdStorageLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 场景冷归档日志表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-07-14
+ */
+@Service
+public class SceneColdStorageLogServiceImpl extends ServiceImpl<ISceneColdStorageLogMapper, SceneColdStorageLog> implements ISceneColdStorageLogService {
+
+    @Override
+    public List<SceneColdStorageLog> listFreezeByNumAfterLastCall(String num, Date lastCallTime) {
+        return this.list(new LambdaQueryWrapper<SceneColdStorageLog>()
+                .eq(SceneColdStorageLog::getNum, num)
+                .eq(SceneColdStorageLog::getType, 1)
+                .gt(SceneColdStorageLog::getCreateTime, lastCallTime));
+    }
+}

+ 10 - 0
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -180,6 +180,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Autowired
     private IExceedSpaceSceneService exceedSpaceSceneService;
 
+    @Autowired
+    private ISceneColdStorageLogService sceneColdStorageLogService;
+
     @Override
     public SceneFileBuild findByFileId(String fileId) {
 
@@ -1166,6 +1169,13 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             laseCallTime = scenePro.getCreateTime();
             cameraId = scenePro.getCameraId();
         }
+
+        //查询最后一次计算时间后是否冻结,如果是,则不支持重算
+        List<SceneColdStorageLog> sceneColdStorageLogList = sceneColdStorageLogService.listFreezeByNumAfterLastCall(num, laseCallTime);
+        if(CollUtil.isNotEmpty(sceneColdStorageLogList)){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5072);
+        }
+
         //查询最后一次计算时间后是否有删除过目录,如果有,则不支持重算
         List<SceneCleanOrig> sceneCleanOrigs = sceneCleanOrigService.lisByNumAfterLastCall(num, laseCallTime);
         if(CollUtil.isNotEmpty(sceneCleanOrigs)){

+ 5 - 0
src/main/resources/mapper/contro/SceneColdStorageLogMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.contro.mapper.ISceneColdStorageLogMapper">
+
+</mapper>