ソースを参照

上传相机压缩包接口

dsx 2 年 前
コミット
5212b2c89f

+ 6 - 0
pom.xml

@@ -140,6 +140,12 @@
       <version>3.0.0-SNAPSHOT</version>
     </dependency>
 
+    <dependency>
+      <groupId>net.lingala.zip4j</groupId>
+      <artifactId>zip4j</artifactId>
+      <version>1.3.2</version>
+    </dependency>
+
   </dependencies>
   <build>
     <finalName>${artifactId}</finalName>

+ 14 - 1
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -1,19 +1,27 @@
 package com.fdkankan.contro.controller;
 
+import cn.hutool.core.util.ZipUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.contro.entity.User;
 import com.fdkankan.contro.service.ISceneFileBuildService;
 import com.fdkankan.contro.vo.ResponseSceneFile;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.web.response.ResultData;
 import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 场景文件上传模块
@@ -91,4 +99,9 @@ public class SceneFileController{
         file.transferTo(new File("/home/backend/tomcat/modeling-control/logs/" + file.getOriginalFilename()));
         return ResultData.ok();
     }
+
+    @PostMapping("sendCallAlgorithm")
+    public ResultData sendCallAlgorithm(@RequestBody Map<String,String> params) throws Exception {
+        return sceneFileBuildService.sendCallAlgorithm(params);
+    }
 }

+ 81 - 0
src/main/java/com/fdkankan/contro/entity/ScenePre.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-04-12
+ */
+@Getter
+@Setter
+@TableName("t_scene_pre")
+public class ScenePre implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 场景名称
+     */
+    @TableField("zip_path")
+    private String zipPath;
+
+    /**
+     * 场景描述
+     */
+    @TableField("username")
+    private String username;
+
+    /**
+     * 场景的链接地址
+     */
+    @TableField("file_id")
+    private String fileId;
+
+    /**
+     * 原始的大场景数据(七牛)
+     */
+    @TableField("oss_path")
+    private String ossPath;
+
+    /**
+     * 0:解压中,1:上传中, 2数据准备中,3:处理完成
+     */
+    @TableField("status")
+    private Integer status;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 记录的状态,A: 生效,I: 禁用
+     */
+    @TableField("rec_status")
+    @TableLogic
+    private String recStatus;
+
+
+}

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

@@ -0,0 +1,97 @@
+package com.fdkankan.contro.generate;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.generator.FastAutoGenerator;
+import com.baomidou.mybatisplus.generator.config.OutputFile;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class AutoGenerate {
+
+
+    public static void main(String[] args) {
+
+        String path =System.getProperty("user.dir");
+
+        generate(path,"contro", getTables(new String[]{
+                "t_scene_pre"
+        }));
+
+//        generate(path,"goods", getTables(new String[]{
+//                        "t_camera","t_camera_detail","t_camera_out","t_camera_space","t_camera_version",
+//                        "t_company","t_goods","t_goods_sku","t_cart","t_goods_spec",
+//                        "t_goods_spec_value","t_goods_spu_spec","t_sn_code"
+//        }));
+//
+//        generate(path,"order", getTables(new String[]{
+//                        "t_increment_order","t_invoice","t_order","t_order_item",
+//                        "t_pre_sale","t_space_sdk","t_trade_log","t_commerce_order","t_download_order","t_expansion_order"
+//        }));
+//        generate(path,"order", getTables(new String[]{
+//                        "t_virtual_order"
+//        }));
+//
+//        generate(path,"user", getTables(new String[]{
+//                        "t_user","t_user_increment","t_manager","t_province","t_increment_type","t_intercom_message","t_receiver_info"
+//        }));
+    }
+
+    public static List<String> getTables(String [] tableNames){
+        return new ArrayList<>(Arrays.asList(tableNames));
+    }
+
+
+    public static void  generate(String path,String moduleName,  List<String> tables){
+        FastAutoGenerator.create("jdbc:mysql://192.168.0.25:3306/4dkankan_v4",
+            "root","4dkk2023cuikuan%")
+                .globalConfig(builder -> {
+                    builder.author("")               //作者
+                            .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)
+                            //.enableSwagger()           //开启swagger
+                            .commentDate("yyyy-MM-dd")
+                            .dateType(DateType.ONLY_DATE)
+                            .fileOverride();            //开启覆盖之前生成的文件
+
+                })
+                .packageConfig(builder -> {
+                    builder.parent("com.fdkankan")
+                            .moduleName(moduleName)
+                            .entity("entity")
+                            .service("service")
+                            .serviceImpl("service.impl")
+                            .controller("controller")
+                            .mapper("mapper")
+                            .xml("test.mapper")
+                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml,path+"\\src\\main\\resources\\mapper\\"+moduleName));
+                })
+                .strategyConfig(builder -> {
+                    builder.addInclude(tables)
+                            .addTablePrefix("t_")
+
+                            .serviceBuilder()
+                            .formatServiceFileName("I%sService")
+                            .formatServiceImplFileName("%sServiceImpl")
+
+                            .entityBuilder()
+                            .enableLombok()
+                            .logicDeleteColumnName("rec_status")
+                            .enableTableFieldAnnotation()
+//                            .superClass(BaseEntity.class)
+
+                            .controllerBuilder()
+                            .formatFileName("%sController")
+                            .enableRestStyle()
+
+                            .mapperBuilder()
+                            .superClass(BaseMapper.class)
+                            .formatMapperFileName("I%sMapper")
+                            .enableMapperAnnotation()
+                            .formatXmlFileName("%sMapper");
+                })
+                // .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
+                .execute();
+    }
+}

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

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.ScenePre;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 场景表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-12
+ */
+@Mapper
+public interface IScenePreMapper extends BaseMapper<ScenePre> {
+
+}

+ 4 - 0
src/main/java/com/fdkankan/contro/service/ISceneFileBuildService.java

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.contro.entity.SceneFileBuild;
 import com.fdkankan.contro.vo.ResponseSceneFile;
 import com.fdkankan.web.response.ResultData;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
+import java.util.Map;
 
 /**
  * <p>
@@ -29,4 +31,6 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
     ResultData rebuildScene(String num,Boolean force) throws IOException;
 
     ResultData uploadFile(MultipartFile file, String params) throws Exception;
+
+    ResultData sendCallAlgorithm(@RequestBody Map<String,String> params) throws Exception;
 }

+ 5 - 0
src/main/java/com/fdkankan/contro/service/IScenePlusService.java

@@ -3,8 +3,11 @@ package com.fdkankan.contro.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.contro.entity.ScenePlus;
 import com.fdkankan.web.response.ResultData;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.util.Map;
+
 /**
  * <p>
  * 场景主表 服务类
@@ -23,4 +26,6 @@ public interface IScenePlusService extends IService<ScenePlus> {
 
     ScenePlus getByFileId(String fileId);
 
+
+
 }

+ 16 - 0
src/main/java/com/fdkankan/contro/service/IScenePreService.java

@@ -0,0 +1,16 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.ScenePre;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 场景表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-12
+ */
+public interface IScenePreService extends IService<ScenePre> {
+
+}

+ 285 - 3
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.util.ZipUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -29,24 +30,26 @@ import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.web.response.ResultData;
 import com.fdkankan.web.util.RSAEncrypt;
 import lombok.extern.slf4j.Slf4j;
+import net.lingala.zip4j.core.ZipFile;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * <p>
@@ -121,6 +124,15 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Autowired
     private FYunFileConfig fYunFileConfig;
 
+    @Autowired
+    private RedisLockUtil redisLockUtil;
+
+    @Autowired
+    private IScenePreService scenePreService;
+
+    @Autowired
+    private ICompanyService companyService;
+
     @Override
     public SceneFileBuild findByFileId(String fileId) {
 
@@ -827,4 +839,274 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         }
         return result;
     }
+
+    @Override
+    public ResultData sendCallAlgorithm(@RequestBody Map<String,String> params) throws Exception {
+        log.info("sendCallAlgorithm 参数为:{}", JSONObject.toJSONString(params));
+        String filePath = params.get("filePath");
+        String userName = params.get("userName");
+        if(org.apache.commons.lang3.ObjectUtils.isEmpty(filePath)){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
+        }
+        if(!filePath.endsWith(File.separator)){
+            filePath = filePath.concat(File.separator);
+        }
+        // 读取本地文件并校验文件
+        // 读取config.json
+//        if(!new File(filePath+"config.json").exists()){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_4001,filePath+"config.json");
+//        }
+
+        JSONObject configJson = JSONObject.parseObject(FileUtils.readFile(filePath + "config.json"));
+        String folderName = configJson.getString("id");
+        String sncode = configJson.getString("sn");
+        String zipFileName = configJson.getString("zipFileName");
+        if(org.apache.commons.lang3.ObjectUtils.isEmpty(folderName) || org.apache.commons.lang3.ObjectUtils.isEmpty(sncode) || org.apache.commons.lang3.ObjectUtils.isEmpty(zipFileName)){
+            throw new BusinessException(ErrorCode.PARAM_ERROR,"config.json 文件有误!");
+        }
+
+        ScenePre scenePre = new ScenePre();
+
+        // 检测是否有生成
+        String fileId = getFileIdByFolderName(folderName);
+        String subFolder = sncode.concat(File.separator).concat(fileId).concat(File.separator).concat(folderName);
+        // 解压获取dataSource 并上传资源到OSS
+        String dataSource = ConstantFilePath.BUILD_MODEL_PATH.concat(subFolder);
+        log.info("dataSource 为:{}", dataSource);
+
+        scenePre.setFileId(fileId);
+        scenePre.setUsername(userName);
+        scenePre.setZipPath(filePath);
+        scenePre.setCreateTime(new Date());
+        scenePre.setUpdateTime(new Date());
+        scenePre.setStatus(0);
+        scenePreService.save(scenePre);
+
+        // 异步解压资源文件上传
+        String finalFilePath = filePath;
+        CompletableFuture.runAsync(() -> {
+            try {
+                log.info("开始异步解压文件");
+                ZipFile zipFile = new ZipFile(new File(finalFilePath.concat(zipFileName)));
+                if (zipFile.isEncrypted()) {
+                    String pwd = zipFileName.substring(0, 5).concat(zipFileName.substring(0, 5));
+                    zipFile.setPassword(pwd);
+                    zipFile.extractAll(finalFilePath);
+                } else {
+                    ZipUtil.unzip(finalFilePath.concat(zipFileName), finalFilePath);
+                }
+
+                scenePre.setStatus(1);
+                scenePre.setUpdateTime(new Date());
+                scenePreService.updateById(scenePre);
+                log.info("异步开始上传文件");
+                // 上传oaas
+                fYunFileService.uploadFileByCommand(finalFilePath.concat(folderName), ConstantFilePath.OSS_PREFIX.concat(subFolder));
+
+                scenePre.setOssPath(ConstantFilePath.OSS_PREFIX.concat(subFolder));
+
+                scenePre.setStatus(2);
+                scenePre.setUpdateTime(new Date());
+                scenePreService.updateById(scenePre);
+                log.info("文件上传成功,开始通知计算");
+                // 通知计算
+                this.copyDataAndBuild(null, dataSource, "V4", null);
+                log.info("通知计算成功");
+
+                scenePre.setStatus(3);
+                scenePre.setUpdateTime(new Date());
+                scenePreService.updateById(scenePre);
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("上传失败", e);
+            }
+        });
+        return ResultData.ok();
+    }
+
+    private String getFileIdByFolderName(String folderName) {
+        // 检测是否有生成
+        String fileId = redisUtil.get(String.format(RedisConstants.FOLDER_FILEID_BUILD, folderName));
+        if (!org.springframework.util.ObjectUtils.isEmpty(fileId)) {
+            return fileId;
+        }
+
+        SceneFileBuild sceneFileBuild = this.findByUnicode(folderName);
+        if (sceneFileBuild != null) {
+            fileId = sceneFileBuild.getFileId();
+            redisUtil.set(String.format(RedisConstants.FOLDER_FILEID_BUILD, folderName), fileId, 2 * 24 * 60 * 60);
+            return fileId;
+        }
+
+        // 加锁
+        boolean lock = redisLockUtil.lock(String.format(RedisConstants.FOLDER_LOCK_BUILD, folderName), 120);
+        if (!lock) {
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5052);
+        }
+
+        String dataSource =  scenePlusService.getDataSourceLikeUnicode("/" + folderName);
+
+        if (!org.springframework.util.ObjectUtils.isEmpty(dataSource)) {
+            log.info("从数据库中查到与 fileId:{} 匹配的路径为:{}", fileId, dataSource);
+            int n = dataSource.split("/").length;
+            if (n > 1) {
+                fileId = dataSource.split("/")[n - 2];
+            }
+        }
+
+        if (org.springframework.util.ObjectUtils.isEmpty(fileId)) {
+            fileId = new SnowflakeIdGenerator(0, 0).nextId() + "";
+            log.info("新生成build数据,{}", fileId);
+        }
+
+        sceneFileBuild = new SceneFileBuild();
+        sceneFileBuild.setChildName(folderName.split("_")[0]);
+        sceneFileBuild.setFileId(fileId);
+        sceneFileBuild.setRecStatus("A");
+        sceneFileBuild.setUnicode(folderName);
+        sceneFileBuild.setCreateTime(new Date());
+        this.save(sceneFileBuild);
+        redisUtil.set(String.format(RedisConstants.FOLDER_FILEID_BUILD, folderName), fileId, 2 * 24 * 60 * 60);
+        redisUtil.set(String.format(RedisConstants.FILEID_FOLDER_BUILD, fileId), folderName, 2 * 24 * 60 * 60);
+        return fileId;
+    }
+
+    public ResultData copyDataAndBuild(String sourceBucet,String dataSource,String sceneVer,User user) throws Exception {
+        if(!StringUtils.equals(sceneVer,"V3") && ! StringUtils.equals(sceneVer,"V4")){
+            throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR.code(),"版本有误,请填写 V3 或者 V4");
+        }
+
+        String fYunPath = ConstantFilePath.OSS_PREFIX + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+        if(!ObjectUtils.isEmpty(sourceBucet)){
+            fYunFileService.copyFileBetweenBucket(sourceBucet,fYunPath,fYunFileConfig.getBucket(),fYunPath);
+        }
+        // 下载data.fdage
+        JSONObject fdageData = JSONObject.parseObject(fYunFileService.getFileContent(fYunPath + "/data.fdage"));
+        if(ObjectUtils.isEmpty(fdageData)){
+            throw new BusinessException(ErrorCode.SYSTEM_ERROR.code(),"4dage 文件不存在");
+        }
+        String cameraName = fdageData.getJSONObject("cam").getString("uuid");
+        Camera cameraEntity = cameraService.getByChildName(cameraName);
+        if(cameraEntity ==  null){
+            log.error("该相机不存在:" + cameraName);
+            throw new BusinessException(ErrorCode.FAILURE_CODE_6003);
+        }
+
+        CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraEntity.getId());
+        if(detailEntity ==  null){
+            log.error("该相机详情不存在:" + cameraName);
+            throw new BusinessException(ErrorCode.FAILURE_CODE_6003);
+        }
+
+        Long cameraType = 11L;
+        //判断是否转台相机
+        if (detailEntity.getType() == 9) {
+            cameraType = 13L;
+        }
+
+        if (detailEntity.getType() == 10) {
+            cameraType = 14L;
+        }
+        String sceneNum = scene3dNumService.generateSceneNum(detailEntity.getType());
+
+        String icon = null;
+        String imgViewPath = null;
+        switch (sceneVer) {
+            case "V3":
+            case "V4":
+                int rebuild = 0;
+                ScenePlus scenePlus = scenePlusService.getByFileId(dataSource);
+                if (!ObjectUtils.isEmpty(scenePlus)) {
+                    log.info("该场景资源已存在,执行补拍逻辑!");
+                    rebuild = 1;
+                    sceneNum = scenePlus.getNum();
+                }
+
+                imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
+                if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
+                    String ossPath = ConstantFilePath.OSS_PREFIX + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                            .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+                    fYunFileService.copyFileInBucket(ossPath + File.separator + fdageData.getString("icon"),imgViewPath + fdageData.getString("icon"));
+                    icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
+                    log.info("上传icon成功....");
+                }
+                buildScenePost(dataSource, fdageData, "V3", cameraType, sceneNum, cameraEntity, detailEntity, rebuild, icon,user);
+                break;
+        }
+        Map<String,Object> result = new HashMap<>();
+        result.put("code",sceneNum);
+        return ResultData.ok(result);
+    }
+
+    private ScenePlusVO buildScenePost(String dataSource, JSONObject jsonObject, String buildType, long cameraType,
+                                       String sceneNum, Camera camera, CameraDetail cameraDetail, int rebuild,String icon,User user) throws Exception {
+        String localDataPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, sceneNum);
+        String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
+        String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum);
+
+        JSONObject firmwareVersion = new JSONObject();
+        if (!ObjectUtils.isEmpty(jsonObject.getString("camSoftwareVersion"))) {
+            firmwareVersion.put("camSoftwareVersion", jsonObject.getString("camSoftwareVersion"));
+        }
+
+        if (!ObjectUtils.isEmpty(jsonObject.getString("version"))) {
+            firmwareVersion.put("version", jsonObject.getString("version"));
+        }
+
+        String sceneUrl = mainUrl + "/" + sceneProNewUrl;
+
+        //重算的场景,先移除该场景对应的容量
+        if (rebuild == 1) {
+            scenePlusService.resetSpace(sceneNum);
+            //删除oss的houst_floor.json(国际版可能会卡住)
+            fYunFileService.deleteFile(dataViewPath + "houst_floor.json");
+        } else {
+            //上传log-main.png
+            fYunFileService.uploadFile(ConstantFilePath.LOGO_PATH + "logo-main.png", imgViewPath + "logo-main.png");
+            fYunFileService.uploadFile(ConstantFilePath.LOGO_PATH + "logo-main-en.png", imgViewPath + "logo-main-en.png");
+        }
+        String algorithm = jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam";
+        String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
+
+        ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
+                jsonObject.getString("pwd"), unicode, cameraType, fileId, icon,  cameraDetail.getUserId(), userName,algorithm,
+                jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
+                jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
+                jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
+
+        ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
+                jsonObject.getString("pwd"), unicode, cameraType, dataSource, icon,user.getId() , user.getUserName(),algorithm,
+                jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
+                jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
+                jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
+
+        if (Objects.nonNull(scenePlusVO)) {
+            JSONObject statusJson = new JSONObject();
+            //临时将-2改成1,app还没完全更新
+            statusJson.put("status", scenePlusVO.getSceneStatus() == -2 ? 1 : scenePlusVO.getSceneStatus());
+            statusJson.put("webSite", scenePlusVO.getWebSite());
+            statusJson.put("sceneNum", scenePlusVO.getNum());
+            statusJson.put("thumb", scenePlusVO.getThumb());
+            statusJson.put("payStatus", 0);
+            statusJson.put("recStatus", 'A');
+            FileUtils.writeFile(localDataPath + "status.json", statusJson.toString());
+            fYunFileService.uploadFile(localDataPath + "status.json", dataViewPath + "status.json");
+        }
+
+        BuildSceneCallMessage mqMessage = getBuildSceneMqMessage(sceneNum, cameraType, algorithm, jsonObject.getInteger("resolution"), buildType,
+                scenePlusVO.getDataSource());
+
+        if (cameraDetail.getCompanyId() != null) {
+            Company company = companyService.getById(cameraDetail.getCompanyId());
+            if (company != null && !ObjectUtils.isEmpty(company.getCalculateFlexibility()) && !company.getCalculateFlexibility()) {
+                mqMessage.setFlexibility(-1);
+            }
+        }
+        mqMessage.getExt().put("deleteExtras", true);
+        rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
+
+        return scenePlusVO;
+    }
+
 }

+ 2 - 0
src/main/java/com/fdkankan/contro/service/impl/ScenePlusServiceImpl.java

@@ -86,4 +86,6 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
         return this.getById(scenePlusExt.getPlusId());
     }
 
+
+
 }

+ 20 - 0
src/main/java/com/fdkankan/contro/service/impl/ScenePreServiceImpl.java

@@ -0,0 +1,20 @@
+package com.fdkankan.contro.service.impl;
+
+import com.fdkankan.contro.entity.ScenePre;
+import com.fdkankan.contro.mapper.IScenePreMapper;
+import com.fdkankan.contro.service.IScenePreService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 场景表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-12
+ */
+@Service
+public class ScenePreServiceImpl extends ServiceImpl<IScenePreMapper, ScenePre> implements IScenePreService {
+
+}

+ 5 - 0
src/main/resources/mapper/contro/ScenePreMapper.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.IScenePreMapper">
+
+</mapper>