Jelajahi Sumber

Merge branch 'release'

dsx 2 tahun lalu
induk
melakukan
ec45a65bb9
44 mengubah file dengan 1711 tambahan dan 413 penghapusan
  1. 6 0
      pom.xml
  2. 5 0
      src/main/java/com/fdkankan/contro/bean/SceneJsonBean.java
  3. 39 0
      src/main/java/com/fdkankan/contro/constant/UserEditDataType.java
  4. 1 1
      src/main/java/com/fdkankan/contro/controller/SceneFileController.java
  5. 11 4
      src/main/java/com/fdkankan/contro/controller/TestController.java
  6. 90 0
      src/main/java/com/fdkankan/contro/entity/MailTemplate.java
  7. 3 3
      src/main/java/com/fdkankan/contro/entity/Scene3dNum.java
  8. 81 0
      src/main/java/com/fdkankan/contro/entity/SceneBuildProcessLog.java
  9. 69 0
      src/main/java/com/fdkankan/contro/entity/SceneCopyDistinctEnv.java
  10. 6 0
      src/main/java/com/fdkankan/contro/entity/SceneEditInfo.java
  11. 6 0
      src/main/java/com/fdkankan/contro/entity/ScenePlus.java
  12. 6 0
      src/main/java/com/fdkankan/contro/entity/ScenePlusExt.java
  13. 4 0
      src/main/java/com/fdkankan/contro/factory/DemoFactory.java
  14. 65 0
      src/main/java/com/fdkankan/contro/factory/UserEditData/BoxModelHandler.java
  15. 9 0
      src/main/java/com/fdkankan/contro/factory/UserEditData/UserEditDataHandler.java
  16. 9 0
      src/main/java/com/fdkankan/contro/factory/UserEditData/UserEditDataHandlerFactory.java
  17. 1 1
      src/main/java/com/fdkankan/contro/generate/AutoGenerate.java
  18. 18 0
      src/main/java/com/fdkankan/contro/mapper/IMailTemplateMapper.java
  19. 18 0
      src/main/java/com/fdkankan/contro/mapper/ISceneBuildProcessLogMapper.java
  20. 18 0
      src/main/java/com/fdkankan/contro/mapper/ISceneCopyDistinctEnvMapper.java
  21. 32 7
      src/main/java/com/fdkankan/contro/mq/listener/AbstrackBuildSceneListener.java
  22. 67 0
      src/main/java/com/fdkankan/contro/mq/listener/BuildSceneProcessLogListener.java
  23. 1 1
      src/main/java/com/fdkankan/contro/mq/service/IBuildSceneService.java
  24. 29 0
      src/main/java/com/fdkankan/contro/mq/service/ICommonService.java
  25. 180 74
      src/main/java/com/fdkankan/contro/mq/service/impl/BuildObjServiceImpl.java
  26. 164 114
      src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java
  27. 68 58
      src/main/java/com/fdkankan/contro/mq/service/impl/BuildV3SceneServiceImpl.java
  28. 228 0
      src/main/java/com/fdkankan/contro/mq/service/impl/CommonServiceImpl.java
  29. 11 0
      src/main/java/com/fdkankan/contro/schedule/ScheduleJob.java
  30. 3 1
      src/main/java/com/fdkankan/contro/service/IFdkkLaserService.java
  31. 16 0
      src/main/java/com/fdkankan/contro/service/IMailTemplateService.java
  32. 3 1
      src/main/java/com/fdkankan/contro/service/IScene3dNumService.java
  33. 20 0
      src/main/java/com/fdkankan/contro/service/ISceneBuildProcessLogService.java
  34. 16 0
      src/main/java/com/fdkankan/contro/service/ISceneCopyDistinctEnvService.java
  35. 0 5
      src/main/java/com/fdkankan/contro/service/impl/FdkkV4Service.java
  36. 38 2
      src/main/java/com/fdkankan/contro/service/impl/IFdkkLaserServiceImpl.java
  37. 20 0
      src/main/java/com/fdkankan/contro/service/impl/MailTemplateServiceImpl.java
  38. 76 58
      src/main/java/com/fdkankan/contro/service/impl/Scene3dNumServiceImpl.java
  39. 50 0
      src/main/java/com/fdkankan/contro/service/impl/SceneBuildProcessLogServiceImpl.java
  40. 20 0
      src/main/java/com/fdkankan/contro/service/impl/SceneCopyDistinctEnvServiceImpl.java
  41. 189 83
      src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java
  42. 5 0
      src/main/resources/mapper/contro/MailTemplateMapper.xml
  43. 5 0
      src/main/resources/mapper/contro/SceneBuildProcessLogMapper.xml
  44. 5 0
      src/main/resources/mapper/contro/SceneCopyDistinctEnvMapper.xml

+ 6 - 0
pom.xml

@@ -102,6 +102,12 @@
     </dependency>
 
     <dependency>
+      <groupId>com.fdkankan</groupId>
+      <artifactId>4dkankan-utils-sms</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
       <groupId>org.projectlombok</groupId>
       <artifactId>lombok</artifactId>
     </dependency>

+ 5 - 0
src/main/java/com/fdkankan/contro/bean/SceneJsonBean.java

@@ -118,6 +118,11 @@ public class SceneJsonBean {
     private String sceneKind;
 
     /**
+     * dam,3dtiles
+     */
+    private String modelKind;
+
+    /**
      * 空间视频数据
      */
     private String boxVideos;

+ 39 - 0
src/main/java/com/fdkankan/contro/constant/UserEditDataType.java

@@ -0,0 +1,39 @@
+package com.fdkankan.contro.constant;
+
+/**
+ * 文件业务类型
+ */
+public enum UserEditDataType {
+
+    BOX_MODEL("boxModel", "boxModelHandler"),
+    ;
+
+    private String code;
+    private String message;
+
+    private UserEditDataType(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String code() {
+        return code;
+    }
+
+    public String message() {
+        return message;
+    }
+
+    public static UserEditDataType get(Integer code){
+        UserEditDataType[] values = UserEditDataType.values();
+        String enumValue = null;
+        for(UserEditDataType eachValue : values){
+            enumValue = eachValue.code();
+            if(enumValue.equals(code)){
+                return eachValue;
+            }
+        }
+        return null;
+    }
+
+}

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

@@ -116,7 +116,7 @@ public class SceneFileController{
 
     @GetMapping("copyDataAndBuild")
     public ResultData copyDataAndBuild(@RequestParam(value = "dataSource") String dataSource,@RequestParam(value = "sceneVer") String sceneVer,
-                                       @RequestParam(value = "sourceBucket",required = false) String sourceBucket) throws Exception {
+                                       @RequestParam(value = "sourceBucket") String sourceBucket) throws Exception {
         return sceneFileBuildService.copyDataAndBuild(sourceBucket,dataSource ,sceneVer);
     }
 }

+ 11 - 4
src/main/java/com/fdkankan/contro/controller/TestController.java

@@ -1,6 +1,9 @@
 package com.fdkankan.contro.controller;
 
+import com.fdkankan.contro.mq.service.ICommonService;
+import com.fdkankan.contro.service.IScene3dNumService;
 import com.fdkankan.web.response.ResultData;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -11,16 +14,20 @@ import org.springframework.web.bind.annotation.RestController;
  * </p>
  *
  * @author dengsixing
- * @since 2022/12/13
+ * @since 2022/12/12
  **/
 @RestController
 @RequestMapping("/test")
 public class TestController {
 
+    @Autowired
+    private IScene3dNumService scene3dNumService;
+    @Autowired
+    private ICommonService commonService;
+
     @GetMapping("/test")
-    public ResultData test(){
-        String test = null;
-        test.equals("");
+    public ResultData test(String num) throws Exception {
+        commonService.sendEmail(num);
         return ResultData.ok();
     }
 

+ 90 - 0
src/main/java/com/fdkankan/contro/entity/MailTemplate.java

@@ -0,0 +1,90 @@
+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-03-01
+ */
+@Getter
+@Setter
+@TableName("t_mail_template")
+public class MailTemplate implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 发件人邮箱
+     */
+    @TableField("send_mail")
+    private String sendMail;
+
+    /**
+     * 发件人邮箱密码
+     */
+    @TableField("send_password")
+    private String sendPassword;
+
+    /**
+     * 发件人主机
+     */
+    @TableField("send_host")
+    private String sendHost;
+
+    /**
+     * 收件主题
+     */
+    @TableField("subject")
+    private String subject;
+
+    /**
+     * 邮件内容
+     */
+    @TableField("msg")
+    private String msg;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 备注
+     */
+    @TableField("remark")
+    private String remark;
+
+    /**
+     * 0订单发票,1深时演示场景,2验证码,3权益会员过期
+     */
+    @TableField("type")
+    private Integer type;
+
+    /**
+     * zh 中文,en英文
+     */
+    @TableField("lang")
+    private String lang;
+
+
+}

+ 3 - 3
src/main/java/com/fdkankan/contro/entity/Scene3dNum.java

@@ -40,8 +40,8 @@ public class Scene3dNum implements Serializable {
     /**
      * 记录的状态,A: 生效,I: 禁用
      */
-    @TableField("num")
-    private String num;
+    @TableField("code")
+    private String code;
 
     /**
      * 更新时间
@@ -59,7 +59,7 @@ public class Scene3dNum implements Serializable {
      * A正常,I删除
      */
     @TableField("rec_status")
-    @TableLogic("A")
+    @TableLogic(value = "A", delval = "I")
     private String recStatus;
 
 

+ 81 - 0
src/main/java/com/fdkankan/contro/entity/SceneBuildProcessLog.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-01-28
+ */
+@Getter
+@Setter
+@TableName("t_scene_build_process_log")
+public class SceneBuildProcessLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 场景码
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 计算流程(pre-前置处理,call-计算,post-后置处理)
+     */
+    @TableField("process")
+    private String process;
+
+    /**
+     * mq消息队列名称
+     */
+    @TableField("queue_name")
+    private String queueName;
+
+    /**
+     * 处理状态(0-处理中,1-成功,2-失败)
+     */
+    @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;
+
+
+}

+ 69 - 0
src/main/java/com/fdkankan/contro/entity/SceneCopyDistinctEnv.java

@@ -0,0 +1,69 @@
+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-03-21
+ */
+@Getter
+@Setter
+@TableName("t_scene_copy_distinct_env")
+public class SceneCopyDistinctEnv implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 场景码
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 原资源路径
+     */
+    @TableField("src_data_source")
+    private String srcDataSource;
+
+    /**
+     * 目标资源路径
+     */
+    @TableField("target_data_source")
+    private String targetDataSource;
+
+    /**
+     * 创建时间
+     */
+    @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;
+
+
+}

+ 6 - 0
src/main/java/com/fdkankan/contro/entity/SceneEditInfo.java

@@ -113,6 +113,12 @@ public class SceneEditInfo implements Serializable {
     private Integer imgVersion;
 
     /**
+     * 场景关联版本
+     */
+    @TableField("link_version")
+    private Integer linkVersion;
+
+    /**
      * 是否上传模型
      */
     @TableField("is_upload_obj")

+ 6 - 0
src/main/java/com/fdkankan/contro/entity/ScenePlus.java

@@ -92,6 +92,12 @@ public class ScenePlus implements Serializable {
     private Integer recommend;
 
     /**
+     * 是否有housetype文件(0-否,1-是)
+     */
+    @TableField("house_type")
+    private Integer houseType;
+
+    /**
      * 创建时间
      */
     @TableField("create_time")

+ 6 - 0
src/main/java/com/fdkankan/contro/entity/ScenePlusExt.java

@@ -125,6 +125,12 @@ public class ScenePlusExt implements Serializable {
     private String sceneKind;
 
     /**
+     * 算法模型类型(dam,3dtiles)
+     */
+    @TableField("model_kind")
+    private String modelKind;
+
+    /**
      * 计算耗时
      */
     @TableField("compute_time")

+ 4 - 0
src/main/java/com/fdkankan/contro/factory/DemoFactory.java

@@ -0,0 +1,4 @@
+package com.fdkankan.contro.factory;
+
+public interface DemoFactory {
+}

+ 65 - 0
src/main/java/com/fdkankan/contro/factory/UserEditData/BoxModelHandler.java

@@ -0,0 +1,65 @@
+package com.fdkankan.contro.factory.UserEditData;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.contro.entity.SceneEditInfo;
+import com.fdkankan.contro.entity.ScenePlus;
+import com.fdkankan.contro.service.ISceneEditInfoService;
+import com.fdkankan.contro.service.IScenePlusService;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.UploadFilePath;
+import com.fdkankan.redis.constant.RedisKey;
+import com.fdkankan.redis.util.RedisUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+/**
+ * 初始化空间模型
+ */
+@Component("boxModelHandler")
+public class BoxModelHandler implements UserEditDataHandler {
+
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private ISceneEditInfoService sceneEditInfoService;
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Override
+    public void init(String num, Map<String, Object> params) {
+        String modelEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels";
+        String modelViewPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "boxModels";
+        String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
+
+        //修改数据库,将boxModels字段置为空
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+        SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+        sceneEditInfoService.update(new LambdaUpdateWrapper<SceneEditInfo>().set(SceneEditInfo::getBoxModels, null).eq(SceneEditInfo::getId, sceneEditInfo.getId()));
+
+        //更新scene.json
+        if(fYunFileService.fileExist(sceneJsonPath)){
+            String sceneJsonStr = fYunFileService.getFileContent(sceneJsonPath);
+            JSONObject sceneJson = JSON.parseObject(sceneJsonStr);
+            sceneJson.remove("boxModels");
+            sceneJsonStr = sceneJson.toJSONString();
+            fYunFileService.uploadFile(sceneJsonStr.getBytes(StandardCharsets.UTF_8), sceneJsonPath);
+            //scenejson写入缓存
+            redisUtil.set(String.format(RedisKey.SCENE_JSON, num), sceneJsonStr);
+        }
+
+        //删除oss资源
+        if(fYunFileService.fileExist(modelEditPath)){
+            fYunFileService.deleteFolder(modelEditPath);
+        }
+        if(fYunFileService.fileExist(modelViewPath)){
+            fYunFileService.deleteFolder(modelViewPath);
+        }
+    }
+}

+ 9 - 0
src/main/java/com/fdkankan/contro/factory/UserEditData/UserEditDataHandler.java

@@ -0,0 +1,9 @@
+package com.fdkankan.contro.factory.UserEditData;
+
+import java.util.Map;
+
+public interface UserEditDataHandler {
+
+    void init(String num, Map<String, Object> params);
+
+}

+ 9 - 0
src/main/java/com/fdkankan/contro/factory/UserEditData/UserEditDataHandlerFactory.java

@@ -0,0 +1,9 @@
+package com.fdkankan.contro.factory.UserEditData;
+
+import cn.hutool.extra.spring.SpringUtil;
+
+public class UserEditDataHandlerFactory {
+    public static UserEditDataHandler getHandler(String name){
+        return SpringUtil.getBean(name);
+    }
+}

+ 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_scene_asyn_oper_log"
+                "t_mail_template"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

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

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.MailTemplate;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-01
+ */
+@Mapper
+public interface IMailTemplateMapper extends BaseMapper<MailTemplate> {
+
+}

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

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.SceneBuildProcessLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 场景计算流程状态表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-01-28
+ */
+@Mapper
+public interface ISceneBuildProcessLogMapper extends BaseMapper<SceneBuildProcessLog> {
+
+}

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

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.SceneCopyDistinctEnv;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-21
+ */
+@Mapper
+public interface ISceneCopyDistinctEnvMapper extends BaseMapper<SceneCopyDistinctEnv> {
+
+}

+ 32 - 7
src/main/java/com/fdkankan/contro/mq/listener/AbstrackBuildSceneListener.java

@@ -1,8 +1,12 @@
 package com.fdkankan.contro.mq.listener;
 
+import cn.hutool.core.exceptions.ExceptionUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.CommonOperStatus;
 import com.fdkankan.contro.constant.RedisConstants;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.service.ISceneBuildProcessLogService;
+import com.fdkankan.model.constants.SceneBuildProcessType;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.redis.util.RedisLockUtil;
@@ -21,6 +25,8 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
 
     @Autowired
     private RedisLockUtil redisLockUtil;
+    @Autowired
+    private ISceneBuildProcessLogService sceneBuildProcessLogService;
 
     @Override
     public void preHandle(Channel channel, String queueName, Message message, IBuildSceneService buildSceneService) throws IOException {
@@ -39,13 +45,23 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
         String msg = new String(message.getBody(), StandardCharsets.UTF_8);
         log.info("开始准备场景计算资源,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
         BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
-        if(ObjectUtils.isEmpty(buildSceneMessage.getBuildContext())){
-            buildSceneMessage.setBuildContext(new HashMap<>());
-        }
-        if(!ObjectUtils.isEmpty(buildSceneMessage.getSceneNum())){
-            buildSceneMessage.getBuildContext().put("sceneNum",buildSceneMessage.getSceneNum());
+        String num = buildSceneMessage.getSceneNum();
+        try {
+            if(ObjectUtils.isEmpty(buildSceneMessage.getBuildContext())){
+                buildSceneMessage.setBuildContext(new HashMap<>());
+            }
+            if(!ObjectUtils.isEmpty(buildSceneMessage.getSceneNum())){
+                buildSceneMessage.getBuildContext().put("sceneNum",buildSceneMessage.getSceneNum());
+            }
+            //记录日志
+            sceneBuildProcessLogService.clearSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueName);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueName, CommonOperStatus.WAITING.code(), null);
+            buildSceneService.buildScenePre(buildSceneMessage);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueName, CommonOperStatus.SUCCESS.code(), null);
+        }catch (Exception e){
+            log.error("场景计算前置处理出错,num=" + num, e);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueName, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000));
         }
-        buildSceneService.buildScenePre(buildSceneMessage);
         log.info("准备场景计算资源完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
         channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
     }
@@ -67,7 +83,16 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
         String msg = new String(message.getBody(), StandardCharsets.UTF_8);
         log.info("场景计算完成,开始处理场景计算结果,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
         BuildSceneResultMqMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneResultMqMessage.class);
-        buildSceneService.buildScenePost(buildSceneMessage);
+        String num = buildSceneMessage.getBuildContext().get("sceneNum").toString();
+        try {
+            sceneBuildProcessLogService.clearSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueName);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueName, CommonOperStatus.WAITING.code(), null);
+            buildSceneService.buildScenePost(buildSceneMessage);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueName, CommonOperStatus.SUCCESS.code(), null);
+        }catch (Exception e){
+            log.error("场景计算结果处理出错,num=" + num, e);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueName, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000));
+        }
         log.info("场景计算结果处理完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
         channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
     }

+ 67 - 0
src/main/java/com/fdkankan/contro/mq/listener/BuildSceneProcessLogListener.java

@@ -0,0 +1,67 @@
+package com.fdkankan.contro.mq.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.CommonOperStatus;
+import com.fdkankan.common.constant.ModelingBuildStatus;
+import com.fdkankan.contro.service.ISceneBuildProcessLogService;
+import com.fdkankan.model.constants.SceneBuildProcessType;
+import com.fdkankan.rabbitmq.bean.BuildSceneProcessLogMessage;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.nio.charset.StandardCharsets;
+
+@Slf4j
+@Component
+public class BuildSceneProcessLogListener{
+
+    @Value("${queue.modeling.modeling-process-log}")
+    private String queueModelingProcessLog;
+    @Value("${queue.modeling.modeling-call}")
+    private String queueModelingCall;
+
+    @Autowired
+    private ISceneBuildProcessLogService sceneBuildProcessLogService;
+
+    /**
+     * 场景计算状态日志记录
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.modeling-process-log}")
+    )
+    public void buildScenePreHandler(Channel channel, Message message) throws Exception {
+        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+        BuildSceneProcessLogMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneProcessLogMessage.class);
+        String num = buildSceneMessage.getNum();
+        try {
+            String reason = null;
+            int status = CommonOperStatus.SUCCESS.code();
+            int buildStatus = buildSceneMessage.getBuildStatus();
+            //新的计算开始,需要将之前的记录置为失效
+            if(buildStatus == ModelingBuildStatus.CALCULATING.code()){
+                sceneBuildProcessLogService.clearSceneBuildProcessLog(num, SceneBuildProcessType.CALL.code(),queueModelingCall);
+                status = CommonOperStatus.WAITING.code();
+            }else{
+                if(buildStatus != ModelingBuildStatus.SUCCESS.code()){
+                    status = CommonOperStatus.FAILD.code();
+                    reason = ModelingBuildStatus.get(buildStatus).message();
+                }
+            }
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.CALL.code(), queueModelingCall, status, reason);
+        }catch (Exception e){
+            log.error("场景计算流程状态日志记录出错, num="+num, e);
+        }finally {
+            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+        }
+    }
+
+}

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

@@ -13,7 +13,7 @@ import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
  **/
 public interface IBuildSceneService {
 
-    void buildScenePre(BuildSceneCallMessage message);
+    void buildScenePre(BuildSceneCallMessage message) throws Exception;
 
     void downLoadSource(BuildSceneCallMessage buildSceneMqMessage, String path) throws Exception;
 

+ 29 - 0
src/main/java/com/fdkankan/contro/mq/service/ICommonService.java

@@ -0,0 +1,29 @@
+package com.fdkankan.contro.mq.service;
+
+import java.util.Map;
+import java.util.Set;
+
+public interface ICommonService {
+
+    /**
+     * 上传计算结果文件
+     * @param num
+     * @param dataSource
+     * @param version
+     */
+    public void uploadBuildResultData(String num, String dataSource, String version);
+
+    /**
+     * 删除用户编辑数据业务方法
+     * @param num 场景码
+     * @param bizs 业务集合
+     * @param params 业务处理所需参数
+     *               key : bizType
+     *               value: Map<String ,Object> 参数map
+     */
+    public void initUserEditData(String num, Set<String> bizs, Map<String, Map<String ,Object>> params);
+
+    public void uploadFloorplanJson(String num, String dataSource) throws Exception;
+
+    public void sendEmail(String num);
+}

+ 180 - 74
src/main/java/com/fdkankan/contro/mq/service/impl/BuildObjServiceImpl.java

@@ -1,22 +1,32 @@
 package com.fdkankan.contro.mq.service.impl;
 
+import cn.hutool.core.exceptions.ExceptionUtil;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.common.constant.*;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.entity.ScenePlus;
+import com.fdkankan.contro.entity.ScenePlusExt;
 import com.fdkankan.contro.entity.ScenePro;
 import com.fdkankan.contro.entity.SceneProEdit;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.mq.service.ICommonService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.service.impl.FdkkV4Service;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.constants.ConstantFileName;
 import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.constants.SceneBuildProcessType;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.model.utils.CreateObjUtil;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import com.fdkankan.redis.constant.RedisKey;
+import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -24,6 +34,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
 import java.io.File;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
@@ -43,6 +55,18 @@ public class BuildObjServiceImpl implements IBuildSceneService {
     @Value("${queue.modeling.obj.modeling-post}")
     private String queueObjModelingPost;
 
+    @Value("${queue.modeling.obj.modeling-pre}")
+    private String queueObjModelingPre;
+
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
+    @Value("#{'${model.3dtiles.sceneSource:}'.split(',')}")
+    private List<Integer> sdTilesSceneSourceList;
+
+    @Value("${env:gn}")
+    private String env;
+
     @Autowired
     private RabbitMqProducer mqProducer;
 
@@ -64,25 +88,36 @@ public class BuildObjServiceImpl implements IBuildSceneService {
     @Autowired
     private ISceneProEditService sceneProEditService;
 
-
     @Autowired
     private IScenePlusService scenePlusService;
 
+    @Autowired
+    private ISceneBuildProcessLogService sceneBuildProcessLogService;
+
+    @Autowired
+    private ICommonService commonService;
+
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Autowired
+    private RedisUtil redisUtil;
+
     @Override
-    public void buildScenePre(BuildSceneCallMessage message) {
+    public void buildScenePre(BuildSceneCallMessage message) throws Exception{
         boolean success = false;
+        String num = message.getSceneNum();
         try {
             String path = message.getPath();
-            //根据相机类型,组装资源路径
             String laserObjFilePath = path + "_laser_obj";
+            //根据相机类型,组装资源路径
             log.info("开始准备生成OBJ场景资源,路径:{}", laserObjFilePath);
 
             FileUtils.delAllFile(laserObjFilePath);
 
             //获取解压后的资源的data.fdage中的数据
             File folderPath = new File(path);
-            fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage", path + "/capture/data.fdage");
-            JSONObject jsonObject = FileUtils.readJson(folderPath.getAbsolutePath() + File.separator + "capture" + File.separator + "data.fdage");
+            fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage", laserObjFilePath + "/capture/data.fdage");
+            JSONObject jsonObject = FileUtils.readJson(laserObjFilePath + File.separator + "capture" + File.separator + "data.fdage");
             if(ObjectUtils.isEmpty(jsonObject)){
                 log.error("data.fdage文件不存在");
                 return ;
@@ -90,8 +125,7 @@ public class BuildObjServiceImpl implements IBuildSceneService {
             if (!jsonObject.containsKey("exportMeshObj") || jsonObject.getIntValue("exportMeshObj") != 1) {
                 // 写入data.fdage 防止重算
                 jsonObject.put("exportMeshObj", 1);
-                FileUtils.writeFile(folderPath.getAbsolutePath() + File.separator + "capture" + File.separator + "data.fdage", jsonObject.toJSONString());
-                fYunFileService.uploadFile(folderPath.getAbsolutePath() + File.separator + "capture" + File.separator + "data.fdage",
+                fYunFileService.uploadFile(laserObjFilePath + File.separator + "capture" + File.separator + "data.fdage",
                         ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage");
             }
             // 重新构造datafdage文件,添加生成obt文件选项
@@ -115,102 +149,174 @@ public class BuildObjServiceImpl implements IBuildSceneService {
             log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
 
         }catch (Exception e){
-            log.error("场景计算前置处理出错", e);
-        }finally {
-            //如果前置处理失败,发送钉钉消息
-            if(!success){
-                buildSceneDTService.handBaseFail("生成OBJ场景资源准备异常", message.getPath(), message.getSceneNum(), "计算控制服务器");
-            }
-
+            log.error("生成OBJ场景资源准备异常,num=" + num, e);
+            buildSceneDTService.handBaseFail("生成OBJ场景资源准备异常", message.getPath(), message.getSceneNum(), "计算控制服务器");
+            throw e;
         }
     }
 
     @Override
     public void downLoadSource(BuildSceneCallMessage message,String path) throws Exception{
 
-        String prevoisPath = message.getBuildContext().get("previousPath").toString();
-        FileUtils.copyFile(prevoisPath + "/caches/reconstruction/final.bin", path + "/caches/reconstruction/final.bin", true);
-        FileUtils.copyFile(prevoisPath + "/caches/reconstruction/chunk.json", path + "/caches/reconstruction/chunk.json", true);
-        FileUtils.copyDirectiory(prevoisPath + "/caches/images", path + "/caches/images");
+        ScenePro scenePro = sceneProService.getByNum(message.getSceneNum());
+        String version = "V4";
+        if(Objects.nonNull(scenePro) && scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue()){
+            version = "V3";
+        }
 
-        FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap_csc", path + "/caches/depthmap_csc");
-        FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap_vis", path + "/caches/depthmap_vis");
-        FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap", path + "/caches/depthmap");
-        FileUtils.copyFile(prevoisPath + "/caches/panorama.json", path + "/caches/panorama.json", true);
-        FileUtils.copyFile(prevoisPath + "/results/laserData/laser.ply", path + "/results/laserData/laser.ply", true);
+        if(SceneVersionType.V4.code().equals(version)){
+            String ossResultPath = String.format(UploadFilePath.scene_result_data_path, message.getSceneNum());
+            fYunFileService.downloadFile(ossResultPath + "caches/reconstruction/final.bin", path + "/caches/reconstruction/final.bin");
+            fYunFileService.downloadFile(ossResultPath + "caches/reconstruction/chunk.json", path + "/caches/reconstruction/chunk.json");
+            fYunFileService.downloadFile(ossResultPath + "caches/floor_group_fix.json", path + "/caches/floor_group_fix.json");
+            fYunFileService.downloadFileByCommand(path + "/caches/images/", ossResultPath + "caches/images/");
+            fYunFileService.downloadFileByCommand( path + "/caches/depthmap_csc/" , ossResultPath + "caches/depthmap_csc/");
+            fYunFileService.downloadFileByCommand( path + "/caches/depthmap_vis/", ossResultPath + "caches/depthmap_vis/");
+            fYunFileService.downloadFileByCommand( path + "/caches/depthmap/", ossResultPath + "caches/depthmap/");
+            fYunFileService.downloadFile(ossResultPath + "caches/panorama.json", path + "/caches/panorama.json");
+            fYunFileService.downloadFile(ossResultPath + "results/laserData/laser.ply", path + "/results/laserData/laser.ply");
+        }else{
+            String prevoisPath = message.getBuildContext().get("previousPath").toString();
+            FileUtils.copyFile(prevoisPath + "/caches/reconstruction/final.bin", path + "/caches/reconstruction/final.bin", true);
+            FileUtils.copyFile(prevoisPath + "/caches/reconstruction/chunk.json", path + "/caches/reconstruction/chunk.json", true);
+            FileUtils.copyFile(prevoisPath + "/caches/floor_group_fix.json", path + "/caches/floor_group_fix.json", true);
+            FileUtils.copyDirectiory(prevoisPath + "/caches/images", path + "/caches/images");
+            FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap_csc", path + "/caches/depthmap_csc");
+            FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap_vis", path + "/caches/depthmap_vis");
+            FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap", path + "/caches/depthmap");
+            FileUtils.copyFile(prevoisPath + "/caches/panorama.json", path + "/caches/panorama.json", true);
+            FileUtils.copyFile(prevoisPath + "/results/laserData/laser.ply", path + "/results/laserData/laser.ply", true);
+        }
     }
 
     @Override
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
 
-        if (!message.getBuildSuccess()) {
-            log.error("生成OBJ场景计算失败!");
-            // 发送钉钉消息,计算失败
-            buildSceneDTService.handModelFail("生成OBJ场景计算失败!", message.getPath(), message.getBuildContext().get("sceneNum").toString(), message.getHostName());
-            return;
-        }
-
         String path = message.getPath();
         String projectNum = message.getBuildContext().get("sceneNum").toString();
-
         String laserObjFilePath = path;
-        CreateObjUtil.convertTxtToDam(laserObjFilePath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-        CreateObjUtil.convertDamToLzma(laserObjFilePath + File.separator + "results/");
-        CreateObjUtil.convertTxtToDam(laserObjFilePath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-        File file = new File(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma");
-        while (!file.exists()) {
-            Thread.sleep(60000);
-        }
+        boolean success = false;
+        try {
 
-        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + ConstantFileName.modelUUID + "_50k.dam.lzma");
-        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + ConstantFileName.modelUUID + "_50k.dam");
+            //上传计算日志
+            String buildLogPath = String.format(UploadFilePath.BUILD_LOG_PATH, projectNum);
+            fYunFileService.uploadFile(path + File.separator + "console.log", buildLogPath + "console.log");
 
-        String texPath = laserObjFilePath + File.separator + "results" + File.separator + "tex";
+            if (!message.getBuildSuccess()) {
+                log.error("生成OBJ场景计算失败!");
+                // 发送钉钉消息,计算失败
+                buildSceneDTService.handModelFail("生成OBJ场景计算失败!", message.getPath(), message.getBuildContext().get("sceneNum").toString(), message.getHostName());
+                return;
+            }
 
-        File texFile = new File(texPath);
-        if(texFile.exists()){
-            for (File textureFile : texFile.listFiles()) {
-                if(textureFile.getName().endsWith(".jpg")){
-                    fYunFileService.uploadFile(textureFile.getAbsolutePath(),
-                            String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
+            ScenePro scenePro = sceneProService.getByNum(projectNum);
+            String version = "v4";
+            String ossImagePath = String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum);
+            //如果是微服务上线之前的存量场景且未生成过obj(未升级过),需要上传到v3的目录,在函数最后调用升级接口进行文件拷贝
+            if(Objects.nonNull(scenePro) && scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue()){
+                ossImagePath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, projectNum);
+                version = "v3";
+            }
+            //上传obj
+            String resultsPath = path + File.separator + "results" + File.separator;
+            if(this.modelKind.equals(ModelKind.DAM.code())){
+                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");
+                File file = new File(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma");
+                while (!file.exists()) {
+                    Thread.sleep(60000);
                 }
+                fYunFileService.uploadFile(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", ossImagePath + ConstantFileName.modelUUID + "_50k.dam.lzma");
+                fYunFileService.uploadFile(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", ossImagePath + ConstantFileName.modelUUID + "_50k.dam");
+            }
+            if(this.modelKind.equals(ModelKind.THREE_D_TILE.code())
+                    && CollUtil.isNotEmpty(sdTilesSceneSourceList)
+                    && sdTilesSceneSourceList.contains(SceneSource.JG.code())){
+                String threedtilesPath = resultsPath + ModelKind.THREE_D_TILE.code();
+                String oss3dtilesPath = ossImagePath + ModelKind.THREE_D_TILE.code();
+                List<String> list = FileUtils.list(new File(threedtilesPath));
+                if(CollUtil.isEmpty(list)){
+                    log.error("3dtiles目录异常,3dtiles地址:{}", new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
+                    throw new Exception("3dtiles目录异常");
+                }
+                //上传3dtiles文件
+                fYunFileService.uploadFileByCommand(threedtilesPath, oss3dtilesPath);
             }
-        }
 
-        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + "tex/texture1.jpg",
-                String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + "/" + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/texture1.jpg");
+            String texPath = laserObjFilePath + File.separator + "results" + File.separator + "tex";
 
-        // 拷贝结果
-        log.info("开始拷贝obj文件");
-        FileUtils.copyFolderAllFiles(laserObjFilePath + "/results/mesh", laserObjFilePath + "/laserData/mesh/", true);
+            File texFile = new File(texPath);
+            if(texFile.exists()){
+                for (File textureFile : texFile.listFiles()) {
+                    if(textureFile.getName().endsWith(".jpg")){
+                        fYunFileService.uploadFile(textureFile.getAbsolutePath(),
+                            ossImagePath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
+                    }
+                }
+            }
 
-        File meshFolder = new File(laserObjFilePath + "/results/mesh");
+            fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + "tex/texture1.jpg",
+                    ossImagePath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/texture1.jpg");
 
-        for (File meshFile : meshFolder.listFiles()) {
-            fYunFileService.uploadFile(meshFile.getAbsolutePath(), String.format(UploadFilePath.DATA_VIEW_PATH,  projectNum) + "mesh/" + meshFile.getName());
-        }
+            // 拷贝结果
+            log.info("开始拷贝obj文件");
+            FileUtils.copyFolderAllFiles(laserObjFilePath + "/results/mesh", laserObjFilePath + "/laserData/mesh/", true);
 
-        fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/mesh");
+            //上传mesh文件
+            fYunFileService.uploadFileByCommand(laserObjFilePath + "/results/mesh", String.format(UploadFilePath.DATA_VIEW_PATH,  projectNum) + "mesh");
 
+            if(!ObjectUtils.isEmpty(scenePro)){
+                LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<ScenePro>()
+                        .set(ScenePro::getStatus, -2).eq(ScenePro::getNum, projectNum);
+                sceneProService.update(updateWrapper);
+                sceneProEditService.update(new LambdaUpdateWrapper<SceneProEdit>().set(SceneProEdit::getMapVisi,0)
+                        .eq(SceneProEdit::getProId,scenePro.getId()));
+            }
 
-        ScenePro scenePro = sceneProService.getByNum(projectNum);
-        if(!ObjectUtils.isEmpty(scenePro)){
-            LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<ScenePro>()
-                    .set(ScenePro::getStatus, -2).eq(ScenePro::getNum, projectNum);
-            sceneProService.update(updateWrapper);
-            sceneProEditService.update(new LambdaUpdateWrapper<SceneProEdit>().set(SceneProEdit::getMapVisi,0)
-                    .eq(SceneProEdit::getProId,scenePro.getId()));
-        }
+            ScenePlus scenePlus = scenePlusService.getScenePlusByNum(projectNum);
+            if(!ObjectUtils.isEmpty(scenePlus)){
+                LambdaUpdateWrapper<ScenePlus> plusUpdateWrapper = new LambdaUpdateWrapper<ScenePlus>()
+                        .set(ScenePlus::getSceneStatus, -2).eq(ScenePlus::getNum, projectNum);
+                scenePlusService.update(plusUpdateWrapper);
+
+                if(this.modelKind.equals(ModelKind.THREE_D_TILE.code())
+                        && CollUtil.isNotEmpty(sdTilesSceneSourceList)
+                        && sdTilesSceneSourceList.contains(SceneSource.JG.code())){
+                    ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+                    scenePlusExt.setModelKind(ModelKind.THREE_D_TILE.code());
+                    scenePlusExtService.updateById(scenePlusExt);
+
+                    String sceneJsonStr = fYunFileService.getFileContent(String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "scene.json");
+                    if(StrUtil.isNotEmpty(sceneJsonStr)){
+                        JSONObject sceneJson = JSON.parseObject(sceneJsonStr);
+                        sceneJson.put("modelKind", ModelKind.THREE_D_TILE.code());
+                        fYunFileService.uploadFile(sceneJson.toJSONString().getBytes(), String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "scene.json");
+                        redisUtil.del(String.format(RedisKey.SCENE_JSON, projectNum));
+                    }
 
-        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(projectNum);
-        if(!ObjectUtils.isEmpty(scenePlus)){
-            LambdaUpdateWrapper<ScenePlus> plusUpdateWrapper = new LambdaUpdateWrapper<ScenePlus>()
-                    .set(ScenePlus::getSceneStatus, -2).eq(ScenePlus::getNum, projectNum);
-            scenePlusService.update(plusUpdateWrapper);
-        }
+                }
+            }
+
+            // 如果未升级V4,则升级V4
+            if("v3".equals(version)){
+                fdkkV4Service.upgradeToV4(projectNum);
+            }
+
+            success = true;
 
-        // 如果未升级V4,则升级V4
-        fdkkV4Service.upgradeToV4(projectNum);
+            //国际环境需要发邮件通知
+            if("eur".equals(env)){
+                commonService.sendEmail(projectNum);
+            }
+
+        }catch (Exception e){
+            log.error("生成OBJ场景计算结果处理异常,num=" + projectNum, e);
+            buildSceneDTService.handBaseFail("生成OBJ场景计算结果处理异常", message.getPath(), projectNum, "计算控制服务器");
+            throw e;
+        }finally {
+            fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/mesh", success ? CommonOperStatus.SUCCESS.code() : CommonOperStatus.FAILD.code());
+        }
     }
 
 }

+ 164 - 114
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -2,6 +2,7 @@ package com.fdkankan.contro.mq.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.file.FileNameUtil;
 import cn.hutool.core.util.StrUtil;
@@ -17,8 +18,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.*;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.bean.SceneJsonBean;
+import com.fdkankan.contro.constant.UserEditDataType;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.mq.service.ICommonService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.vo.SceneEditControlsVO;
 import com.fdkankan.fyun.config.FYunFileConfig;
@@ -26,10 +29,12 @@ import com.fdkankan.fyun.constant.FYunTypeEnum;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.constants.ConstantFileName;
 import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.constants.SceneBuildProcessType;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.model.enums.ModelTypeEnums;
 import com.fdkankan.model.utils.CreateHouseJsonUtil;
 import com.fdkankan.model.utils.CreateObjUtil;
+import com.fdkankan.model.utils.FloorPlanUserUtil;
 import com.fdkankan.model.utils.SceneUtil;
 import com.fdkankan.push.config.PushMessageConfig;
 import com.fdkankan.push.utils.PushMsgUtil;
@@ -38,6 +43,7 @@ import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
+import com.sun.org.apache.xpath.internal.operations.Plus;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -73,6 +79,15 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     @Value("${model.type:#{null}}")
     private String modelType;
 
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
+    @Value("#{'${model.3dtiles.sceneSource:}'.split(',')}")
+    private List<Integer> sdTilesSceneSourceList;
+
+    @Value("${env:gn}")
+    private String env;
+
     @Autowired
     private RabbitMqProducer mqProducer;
 
@@ -115,10 +130,15 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private ICompanyService companyService;
     @Autowired
     private ISceneAsynOperLogService sceneAsynOperLogService;
+    @Autowired
+    private ICommonService commonService;
+    @Autowired
+    private ISceneBuildProcessLogService sceneBuildProcessLogService;
 
     @Override
-    public void buildScenePre(BuildSceneCallMessage message) {
+    public void buildScenePre(BuildSceneCallMessage message) throws Exception{
         boolean success = false;
+        String num = message.getSceneNum();
         try {
             //重新计算时需要删除文件夹,否知使用缓存
             if(new File(message.getPath() + File.separator + "results").exists()){
@@ -168,13 +188,9 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
 
         }catch (Exception e){
-            log.error("场景计算前置处理出错", e);
-        }finally {
-            //如果前置处理失败,发送钉钉消息
-            if(!success){
-                buildSceneDTService.handBaseFail("场景计算资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
-            }
-
+            log.error("场景计算前置处理出错,num"+num, e);
+            buildSceneDTService.handBaseFail("场景计算资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
+            throw e;
         }
     }
 
@@ -235,8 +251,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             }
             scenePlus.setUpdateTime(new Date());
             scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
-            scenePlusService.updateById(scenePlus);
-
 
             Integer videoVersion = fdageData.getInteger("videoVersion");
             //读取计算结果文件生成videosJson
@@ -247,56 +261,59 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //写入数据库
             this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
 
-            Object[] editInfoArr = this.updateEditInfo(scenePlus);
-            SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
-            SceneEditInfoExt sceneEditInfoExt = (SceneEditInfoExt)editInfoArr[1];
-            SceneEditControls sceneEditControls = (SceneEditControls)editInfoArr[2];
-
             //上传全景图俯视图
             this.uploadFloorCad(path, sceneCode, uploadFiles);
 
-            //上传文件
             log.info("开始上传场景计算结果数据,num:{}", sceneCode);
+            //由于3dtiles算法mesh文件发生变化,所以这里需要先清除一下oss的mesh目录,避免存在旧算法obj文件
+            fYunFileService.deleteFolder(String.format(UploadFilePath.DATA_VIEW_PATH, sceneCode) + "mesh");
+            //上传文件
             fYunFileService.uploadMulFiles(uploadFiles);
 
             Map<String,String> damFileHeaders = new HashMap<>();
             damFileHeaders.put("Content-Encoding","gzip");
-
-            if (!fYunFileService.getFyunType().equals(FYunTypeEnum.LOCAL.code())) {
-                // 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);
-                        });
-            }
+            // 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);
+                });
 
             //拷贝部分文件到编辑目录,用于用户编辑
             this.copyToEditDir(sceneCode);
 
             //计算完毕后,同步全景图到缓存目录
-            this.cachePanorama(path, sceneCode);
+//            this.cachePanorama(path, sceneCode);
 
             //生成houseTypejson并上传
-            uploadFiles.entrySet().stream().filter(entry-> FileNameUtil.getName(entry.getKey()).equals("floorplan_cad.json"))
-                    .forEach(entry-> uploadHouseTypeJson(sceneCode,entry.getKey()));
+            boolean existHouseType = this.uploadHouseTypeJson(sceneCode, scenePlusExt.getDataSource());
+            scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
+
+            //生成floorpan.json
+            commonService.uploadFloorplanJson(sceneCode, scenePlusExt.getDataSource());
 
             //重置异步操作记录
             this.removeSceneAsynOperLog(sceneCode);
 
-            //写scene.json
+            //清除用户编辑业务数据
+            Set<String> bizs = new HashSet<>();
+            bizs.add(UserEditDataType.BOX_MODEL.message());
+            commonService.initUserEditData(sceneCode, bizs, null);
 
+            //上传计算结果文件
+            commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
 
-            log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
-            CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
-            Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
+            Object[] editInfoArr = this.updateEditInfo(scenePlus);
+            SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
+            SceneEditInfoExt sceneEditInfoExt = (SceneEditInfoExt)editInfoArr[1];
+            SceneEditControls sceneEditControls = (SceneEditControls)editInfoArr[2];
 
             if (cameraType == 14) {
                 //计算成功  激光转台相机 同步 请求
@@ -304,8 +321,14 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 sceneEditControlsService.update(new LambdaUpdateWrapper<SceneEditControls>().set(SceneEditControls::getShowMap,0)
                         .eq(SceneEditControls::getEditInfoId,sceneEditInfo.getId()));
                 sceneEditControls.setShowMap(0);
+            } else if (new File(path + "/results/laserData/vision_edit.txt").exists()) {
+                fdkkLaserService.cloudPointBuild(sceneCode,path);
             }
 
+            log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
+            CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
+            Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
+            //写scene.json
             this.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
 
             String qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
@@ -319,15 +342,23 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             String pushToken = fdageData.getString("pushToken");
             this.pushMsgToApp(pushChannel,pushToken, cameraType, scenePlus.getTitle(), scenePlusExt.getWebSite());
 
+            //更新场景主表
+            scenePlusService.updateById(scenePlus);
 
+            //删除计算目录
+            CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
 
-            CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
+            //国际环境需要发邮件通知
+            if("eur".equals(env)){
+                commonService.sendEmail(sceneCode);
+            }
 
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 
         }catch (Exception e){
-            log.error("场景计算结果处理出错!", e);
+            log.error("场景计算结果处理出错,num"+sceneCode, e);
             buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
+            throw e;
         }
     }
 
@@ -351,23 +382,23 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         });
     }
 
-    private void cachePanorama(String dataSource, String num){
-        String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
-        //将全景图缓存到缓存目录
-        List<String> imagesList = FileUtil.listFileNames(dataSource + "/caches/images");
-        //先清除旧的全景图
-        cn.hutool.core.io.FileUtil.del(cachedImagesPath);
-        String visionPath = dataSource + "/results/vision.txt";
-        List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
-        imagesList.stream().forEach(fileName -> {
-            if (panoramaImageList.contains(fileName)) {
-                String srcPath = dataSource + "/caches/images/" + fileName;
-                String targetPath = cachedImagesPath + fileName;
-                log.info("源文件:{}, 目标文件:{}", srcPath, targetPath);
-                cn.hutool.core.io.FileUtil.copy(srcPath, targetPath, true);
-            }
-        });
-    }
+//    private void cachePanorama(String dataSource, String num){
+//        String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
+//        //将全景图缓存到缓存目录
+//        List<String> imagesList = FileUtil.listFileNames(dataSource + "/caches/images");
+//        //先清除旧的全景图
+//        cn.hutool.core.io.FileUtil.del(cachedImagesPath);
+//        String visionPath = dataSource + "/results/vision.txt";
+//        List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
+//        imagesList.stream().forEach(fileName -> {
+//            if (panoramaImageList.contains(fileName)) {
+//                String srcPath = dataSource + "/caches/images/" + fileName;
+//                String targetPath = cachedImagesPath + fileName;
+//                log.info("源文件:{}, 目标文件:{}", srcPath, targetPath);
+//                cn.hutool.core.io.FileUtil.copy(srcPath, targetPath, true);
+//            }
+//        });
+//    }
 
     private Map<String, String> getUploadFiles(ScenePlus scenePlus,String path,Integer cameraType,JSONObject fdageData) throws Exception {
         if (ObjectUtils.isEmpty(scenePlus)) {
@@ -437,14 +468,37 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             }
         }
 
+        //exportMeshObj这个是字段由app写入的
+        boolean genModel = true;//是否生成模型 默认生成,深时场景要根据 exportMeshObj判断是否生成
+        if(!ObjectUtils.isEmpty(cameraType)
+                && cameraType == 14
+                && (!fdageData.containsKey("exportMeshObj") || fdageData.getIntValue("exportMeshObj") != 1)){
+            genModel = false;
+        }
+        boolean gen3dTiles = true;//是否生成3dtiles模型 默认生成
+        if(!ModelKind.THREE_D_TILE.code().equals(modelKind)
+                || CollUtil.isEmpty(sdTilesSceneSourceList)
+                || !sdTilesSceneSourceList.contains(scenePlus.getSceneSource())){
+            gen3dTiles = false;
+        }
 
-        if ((fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1)
-                || (!ObjectUtils.isEmpty(cameraType) && (!cameraType.equals(14)))) {
-            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");
+        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");
+            }else{
+                List<String> list = FileUtils.list(new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
+                if(CollUtil.isEmpty(list)){
+                    log.error("3dtiles目录异常,3dtiles地址:{}", new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
+                    throw new Exception("3dtiles目录异常");
+                }
+                list.stream().forEach(str->{
+                    map.put(str, str.replace(path + File.separator + "results" + File.separator, imagesPath));
+                });
+            }
         }
 
         CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision.txt", resultsPath + "vision.modeldata");
@@ -455,7 +509,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         if(!new File("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum).exists()){
             FileUtil.mkdir("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum);
         }
-        map.put(resultsPath + "floorplan.json", dataViewPath + "floor.json");
+//        map.put(resultsPath + "floorplan.json", dataViewPath + "floor.json");
         map.put(resultsPath + "floorplan_cad.json", dataViewPath + "floorplan_cad.json");
         map.put(path + File.separator + "capture/stitch_params.txt", dataViewPath + "stitch_params.txt");
         map.put(path + File.separator + "capture/Up.xml", dataViewPath + "Up.xml");
@@ -480,8 +534,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private void uploadFloorCad(String path, String num, Map<String, String> uploadFiles){
 
         //户型图上传
-        String  userEditPath = UploadFilePath.USER_EDIT_PATH + "floor-cad-%s.%s";
-        String  userViewPath = UploadFilePath.USER_VIEW_PATH + "floor-cad-%s.%s";
+        String  dataViewPath = UploadFilePath.DATA_VIEW_PATH + "floor-cad-%s.%s";
         String floorCadPath = path + "/results/floorplan_cad";
         List<String> floorCadList = FileUtils.getFileList(floorCadPath);
         if(CollUtil.isNotEmpty(floorCadList)){
@@ -489,8 +542,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 String substring = str.substring(str.lastIndexOf(File.separator) + 1);
                 String[] arr = substring.split("floor");
                 String[] arr2 = arr[1].split("\\.");
-                uploadFiles.put(str, String.format(userEditPath, num, arr2[0], arr2[1]));
-                uploadFiles.put(str, String.format(userViewPath, num, arr2[0], arr2[1]));
+                uploadFiles.put(str, String.format(dataViewPath, num, arr2[0], arr2[1]));
             });
         }
 
@@ -512,6 +564,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         sceneJson.setImgVersion(sceneEditInfo.getImgVersion());
         sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
         sceneJson.setSceneKind(scenePlusExt.getSceneKind());
+        sceneJson.setModelKind(scenePlusExt.getModelKind());
         sceneJson.setVideos(JSON.toJSONString(videosJson));
         sceneJson.setPayStatus(scenePlus.getPayStatus());
 
@@ -582,6 +635,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +".png";
         String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +"_en.png";
         QrConfig qrConfig = QrConfig.create();
+        qrConfig.setWidth(512);
+        qrConfig.setHeight(512);
         if(!ObjectUtils.isEmpty(localLogoPath)){
             qrConfig.setImg(localLogoPath);
         }
@@ -746,42 +801,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         return uploadFile.keySet().stream().map(File::new).filter(File::exists).mapToLong(File::length).sum();
     }
 
-    private void sealScene(Long scenePlusId){
-        scenePlusService.update(
-            new LambdaUpdateWrapper<ScenePlus>()
-                .set(ScenePlus::getPayStatus, PayStatus.NO_CAPACITY.code())
-                .eq(ScenePlus::getId, scenePlusId));
-    }
-
-    /**
-     * <p>
-     双目场景更新数据库
-     * </p>
-     * @author dengsixing
-     * @date 2022/3/21
-     * @param num
-     * @param space
-     **/
-    private void updateDb4Sm(String num, long space){
-        List<ScenePlus> ScenePlusList = scenePlusService.list(
-            new LambdaQueryWrapper<ScenePlus>().select(ScenePlus::getId).eq(ScenePlus::getNum, num));
-
-        if(CollUtil.isEmpty(ScenePlusList)){
-            return ;
-        }
-
-        List<Long> sceneIds = ScenePlusList.stream().map(ScenePlus::getId).collect(Collectors.toList());
-
-        //更新场景创建时间
-        scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>().in(ScenePlus::getId, sceneIds)
-            .set(ScenePlus::getSceneStatus, SceneStatus.NO_DISPLAY.code()));
-
-        //更新使用容量
-        scenePlusExtService.update(new LambdaUpdateWrapper<ScenePlusExt>().in(ScenePlusExt::getPlusId, sceneIds)
-                .set(ScenePlusExt::getSpace, space)
-                .set(ScenePlusExt::getAlgorithmTime, Calendar.getInstance().getTime()));
-    }
-
     private void updateDbPlus(int sceneSource,Long space,String videosJson, Long computeTime,boolean isObj,ScenePlusExt scenePlusExt){
 
         scenePlusExt.setSpace(space);
@@ -815,6 +834,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
         String sceneKind = scenePlusExt.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
         scenePlusExt.setSceneKind(sceneKind);
+//        scenePlusExt.setModelKind(modelKind);
 
         scenePlusExtService.updateById(scenePlusExt);
     }
@@ -850,12 +870,36 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             sceneEditInfo.setDescription(scenePlus.getDescription());
             sceneEditInfo.setTitle(scenePlus.getTitle());
             sceneEditInfoService.save(sceneEditInfo);
-
         }else{
+
+            int version = 0;
+            int imgVersion = 0;
+            int linkVersion = 0;
+            //获取展示页的版本号
+            String sceneJsonStr = fYunFileService.getFileContent(String.format(UploadFilePath.DATA_VIEW_PATH, scenePlus.getNum()) + "scene.json");
+            if(StrUtil.isNotEmpty(sceneJsonStr)){
+                JSONObject sceneJson = JSON.parseObject(sceneJsonStr);
+                version = sceneJson.getIntValue("version");
+                imgVersion = sceneJson.getIntValue("imgVersion");
+                linkVersion =  sceneJson.getIntValue("linkVersion");
+            }
+
+            if(version < sceneEditInfo.getVersion()){
+                version = sceneEditInfo.getVersion();
+            }
+            if(imgVersion < sceneEditInfo.getImgVersion()){
+                imgVersion = sceneEditInfo.getImgVersion();
+            }
+            if(linkVersion < sceneEditInfo.getLinkVersion()){
+                linkVersion = sceneEditInfo.getLinkVersion();
+            }
+
             sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
             sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
-            sceneEditInfo.setVersion(sceneEditInfo.getVersion() + 1);
-            sceneEditInfo.setImgVersion(sceneEditInfo.getImgVersion() + 1);
+            sceneEditInfo.setVersion(version + 1);
+            sceneEditInfo.setImgVersion(imgVersion + 1);
+            sceneEditInfo.setLinkVersion(linkVersion + 1);
+            sceneEditInfo.setIsUploadObj(CommonStatus.NO.code());
             sceneEditInfoService.updateById(sceneEditInfo);
         }
         if(sceneEditControls == null){
@@ -872,15 +916,21 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         return new Object[]{sceneEditInfo, sceneEditInfoExt, sceneEditControls};
     }
 
-    public void uploadHouseTypeJson(String num, String floorPlanCardFilePath) {
+    public boolean uploadHouseTypeJson(String num, String dataSource) {
+        String floorPlanCardFilePath = dataSource + File.separator + "results/floorplan_cad.json";
         if (!new File(floorPlanCardFilePath).exists()) {
-            log.error("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
-            return;
+            log.warn("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
+            return false;
         }
         JSONObject json = CreateHouseJsonUtil.createHouseTypeJsonByCad(floorPlanCardFilePath);
-        String hourseTypeJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "houseType.json";
+        if(Objects.isNull(json)){
+            return false;
+        }
+        String hourseTypeJsonPath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "houseType.json";
         fYunFileService.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
-        hourseTypeJsonPath = String.format(UploadFilePath.DATA_EDIT_PATH, num) + "houseType.json";
+        hourseTypeJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "houseType.json";
         fYunFileService.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
+
+        return true;
     }
 }

+ 68 - 58
src/main/java/com/fdkankan/contro/mq/service/impl/BuildV3SceneServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fdkankan.contro.mq.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.file.FileNameUtil;
 import cn.hutool.core.util.StrUtil;
@@ -10,12 +11,15 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.common.constant.CommonOperStatus;
 import com.fdkankan.common.constant.ExpiredStatus;
+import com.fdkankan.common.constant.ModelKind;
 import com.fdkankan.common.constant.PayStatus;
 import com.fdkankan.common.constant.SceneStatus;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.mq.service.ICommonService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.service.impl.FdkkV4Service;
 import com.fdkankan.fyun.config.FYunFileConfig;
@@ -23,6 +27,7 @@ import com.fdkankan.fyun.constant.FYunTypeEnum;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.constants.ConstantFileName;
 import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.constants.SceneBuildProcessType;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.model.utils.CreateHouseJsonUtil;
 import com.fdkankan.model.utils.CreateObjUtil;
@@ -66,6 +71,15 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
     @Value("${model.type:#{null}}")
     private String modelSceneKind;
 
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
+    @Value("${env:gn}")
+    private String env;
+
+    @Autowired
+    private ICommonService commonService;
+
     @Autowired
     private RabbitMqProducer mqProducer;
 
@@ -101,7 +115,14 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
     @Override
     public void buildScenePre(BuildSceneCallMessage message) {
         boolean success = false;
+        String num = message.getSceneNum();
         try {
+
+            //重新计算时需要删除文件夹,否知使用缓存
+            if(new File(message.getPath() + File.separator + "results").exists()){
+                FileUtils.deleteDirectory(message.getPath() + File.separator + "results");
+            }
+
             //根据相机类型,组装资源路径
             //下载资源到本地
             this.downLoadSource(message, message.getPath());
@@ -139,13 +160,9 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
             log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
 
         }catch (Exception e){
-            log.error("场景计算前置处理出错", e);
-        }finally {
-            //如果前置处理失败,发送钉钉消息
-            if(!success){
-                buildSceneDTService.handBaseFail("场景计算资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
-            }
-
+            log.error("场景计算前置处理出错,num="+num, e);
+            buildSceneDTService.handBaseFail("场景计算资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
+            throw e;
         }
     }
 
@@ -168,16 +185,17 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
 
     @Override
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
-        Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
         String sceneCode = message.getBuildContext().get("sceneNum").toString();
-        Long computeTime = message.getComputeTime();
+        try {
 
-        String path = message.getPath();
+            Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
+            Long computeTime = message.getComputeTime();
 
-        Boolean buildSuccess = message.getBuildSuccess();
-        JSONObject fdageData = getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
-        Integer videoVersion = fdageData.getInteger("videoVersion");
-        try {
+            String path = message.getPath();
+
+            Boolean buildSuccess = message.getBuildSuccess();
+            JSONObject fdageData = getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
+            Integer videoVersion = fdageData.getInteger("videoVersion");
             // 上传计算日志
             //如果是重复计算,没有走到计算逻辑,不需要上传日志文件
             log.info("开始上传计算日志");
@@ -197,6 +215,8 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
 
             Map<String, String> uploadFiles = getUploadFiles(sceneCode,path,cameraType,fdageData);
 
+            copyFiles(path,sceneCode);
+
             //建模成功走以下逻辑
             log.info("cameraType:{}",cameraType);
 
@@ -226,18 +246,17 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
             Map<String,String> damFileHeaders = new HashMap<>();
             damFileHeaders.put("Content-Encoding","gzip");
 
-            if (!fYunFileService.getFyunType().equals(FYunTypeEnum.LOCAL.code())) {
-                // dam 文件设置请求头
-                uploadFiles.entrySet().stream().filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
-                        .filter(entry -> new File(entry.getKey()).exists())
-                        .forEach(entry -> {
-                            // 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);
-                        });
-            }
+            // dam 文件设置请求头
+            uploadFiles.entrySet().stream()
+                .filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
+                .filter(entry -> new File(entry.getKey()).exists())
+                .forEach(entry -> {
+                    // 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);
+                });
 
             //生成houseTypejson并上传
             uploadFiles.entrySet().stream().filter(entry-> FileNameUtil.getName(entry.getKey()).equals("floorplan_cad.json"))
@@ -259,6 +278,8 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
                 //计算成功  激光转台相机 同步 请求
                 fdkkLaserService.syncBuildResult(scenePro.getNum(), scenePro.getDataSource(),scenePro.getCreateTime());
                 sceneProEdit.setMapVisi(0);
+            }else if (new File(path + "/results/laserData/vision_edit.txt").exists()) {
+                fdkkLaserService.cloudPointBuild(sceneCode,path);
             }
             sceneProEditService.updateById(sceneProEdit);
 
@@ -269,13 +290,29 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
             CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
             // 判断是否升级V4
-            if(fdageData.containsKey("updateV4") && fdageData.getIntValue("updateV4") == 1){
-                fdkkV4Service.upgradeToV4(sceneCode);
+//            if(fdageData.containsKey("updateV4") && fdageData.getIntValue("updateV4") == 1){
+//                fdkkV4Service.upgradeToV4(sceneCode);
+//            }
+
+            //国际环境需要发邮件通知
+            if("eur".equals(env)){
+                commonService.sendEmail(sceneCode);
             }
 
         }catch (Exception e){
-            log.error("场景计算结果处理出错!", e);
+            log.error("场景计算结果处理出错,num"+sceneCode, e);
             buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
+            throw e;
+        }
+    }
+
+    private void copyFiles(String path, String num) {
+        if (new File(path + File.separator + "results" + File.separator + "floor.json").exists()) {
+            FileUtils.copyFile(path + File.separator + "results" + File.separator + "floor.json", ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + num + File.separator + "floor.json", true);
+        }
+        if (new File(path + File.separator + "results" + File.separator + "floorplan.json").exists()) {
+            FileUtils.copyFile(path + File.separator + "results" + File.separator + "floorplan.json", ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + num + File.separator + "floor.json", true);
+            FileUtils.copyFile(path + File.separator + "results" + File.separator + "floorplan.json", ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + num + File.separator + "floorplan.json", true);
         }
     }
 
@@ -341,7 +378,7 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
 
 
         if ((fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1)
-                || (!ObjectUtils.isEmpty(cameraType) && (!cameraType.equals(14)))) {
+                || (!ObjectUtils.isEmpty(cameraType) && cameraType != 14)) {
             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");
@@ -356,7 +393,7 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
         log.info("数据转换完成:" + projectNum);
 
         FileUtil.touch("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum);
-        map.put(resultsPath + "floorplan.json", dataViewPath + "floor.json");
+//        map.put(resultsPath + "floorplan.json", dataViewPath + "floor.json");
         map.put(resultsPath + "floorplan_cad.json", dataViewPath + "floorplan_cad.json");
         map.put(path + File.separator + "capture/stitch_params.txt", dataViewPath + "stitch_params.txt");
         map.put(path + File.separator + "capture/Up.xml", dataViewPath + "Up.xml");
@@ -541,33 +578,6 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
         return uploadFile.keySet().stream().map(File::new).filter(File::exists).mapToLong(File::length).sum();
     }
 
-    /**
-     * <p>
-     双目场景更新数据库
-     * </p>
-     * @author dengsixing
-     * @date 2022/3/21
-     * @param num
-     * @param space
-     **/
-    private void updateDb4Sm(String num, long space){
-        List<ScenePro> ScenePlusList = sceneProService.list(
-            new LambdaQueryWrapper<ScenePro>().select(ScenePro::getId).eq(ScenePro::getNum, num));
-
-        if(CollUtil.isEmpty(ScenePlusList)){
-            return ;
-        }
-
-        List<Long> sceneIds = ScenePlusList.stream().map(ScenePro::getId).collect(Collectors.toList());
-
-        //更新场景创建时间
-        sceneProService.update(new LambdaUpdateWrapper<ScenePro>().in(ScenePro::getId, sceneIds)
-            .set(ScenePro::getStatus, SceneStatus.NO_DISPLAY.code())
-                .set(ScenePro::getSpace,space)
-                .set(ScenePro::getCreateTime,new Date())
-        );
-    }
-
     private ScenePro updateDbPlus(String num, Long space, String videosJson, Long computeTime,boolean isObj){
         sceneProService.update(new LambdaUpdateWrapper<ScenePro>()
                 .eq(ScenePro::getNum, num)

+ 228 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/CommonServiceImpl.java

@@ -0,0 +1,228 @@
+package com.fdkankan.contro.mq.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.contro.entity.*;
+import com.fdkankan.contro.factory.UserEditData.UserEditDataHandler;
+import com.fdkankan.contro.factory.UserEditData.UserEditDataHandlerFactory;
+import com.fdkankan.contro.mq.service.ICommonService;
+import com.fdkankan.contro.service.*;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.UploadFilePath;
+import com.fdkankan.model.utils.FloorPlanUserUtil;
+import com.fdkankan.sms.SendMailAcceUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.*;
+
+@Slf4j
+@Service
+@RefreshScope
+public class CommonServiceImpl implements ICommonService {
+
+    @Value("${main.url}")
+    private String mainUrl;
+
+    @Value("${env:gn}")
+    private String env;
+
+    @Value("${helpLink.zh-cn:https://docs.4dkankan.com/#/product/4dkk/zh-cn/README}")
+    private String helpLinkZh;
+
+    @Value("${helpLink.en-us:https://docs.4dkankan.com/#/product/4dkk/en-us/README}")
+    private String helpLinkEn;
+
+
+    @Autowired
+    private FYunFileServiceInterface fYunFileServiceInterface;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Autowired
+    private IMailTemplateService mailTemplateService;
+    @Autowired
+    private IUserService userService;
+    @Autowired
+    private ISceneProService sceneProService;
+
+
+    @Override
+    public void uploadBuildResultData(String num, String dataSource, String version) {
+
+        Map<String, String> uploadMap = new HashMap<>();
+
+        String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
+
+        //删除旧的文件目录
+        fYunFileServiceInterface.deleteFolder(ossResultPath);
+
+        //上传caches/images
+        String localCachesImagePath = dataSource + "/caches/images/";
+        String ossCachesImagePath = ossResultPath + "caches/images/";
+        //先清除旧的全景图
+        if(FileUtil.exist(localCachesImagePath)){
+            fYunFileServiceInterface.uploadFileByCommand(localCachesImagePath, ossCachesImagePath);
+        }
+
+        //上传project.json
+        String localProjectJsonPath = dataSource + "/project.json";
+        String ossProjectJsonPath = ossResultPath + "project.json";
+        if(FileUtil.exist(localProjectJsonPath)){
+            uploadMap.put(localProjectJsonPath, ossProjectJsonPath);
+        }
+
+        //上传data.json
+        String localDataJsonPath = dataSource + "/data.json";
+        String ossDataJsonPath = ossResultPath + "data.json";
+        if(FileUtil.exist(localDataJsonPath)){
+            uploadMap.put(localDataJsonPath, ossDataJsonPath);
+        }
+
+        //户型图上传
+        String floorplanCadPath = ossResultPath + "floorplan_cad";
+        String cadPicPathFormat = floorplanCadPath + "/floor-cad-%s.%s";
+        String floorCadPath = dataSource + "/results/floorplan_cad";
+        //清除原有旧的cad图
+        fYunFileServiceInterface.deleteFolder(floorplanCadPath);
+        List<String> floorCadList = FileUtils.getFileList(floorCadPath);
+        if(CollUtil.isNotEmpty(floorCadList)){
+            floorCadList.stream().forEach(str->{
+                String substring = str.substring(str.lastIndexOf(File.separator) + 1);
+                String[] arr = substring.split("floor");
+                String[] arr2 = arr[1].split("\\.");
+                //上传到用户编辑目录
+                uploadMap.put(str, String.format(cadPicPathFormat, arr2[0], arr2[1]));
+            });
+        }
+
+        //上传深时场景生成obj需要的文件
+        String localReconstruction = dataSource + "/caches/reconstruction/";
+        String ossReconstruction = ossResultPath + "caches/reconstruction/";
+        if(FileUtil.exist(localReconstruction)){
+            fYunFileServiceInterface.uploadFileByCommand(localReconstruction, ossReconstruction);
+        }
+        String localDepthmap = dataSource + "/caches/depthmap/";
+        String ossDepthmap = ossResultPath + "caches/depthmap/";
+        if(FileUtil.exist(localDepthmap)){
+            fYunFileServiceInterface.uploadFileByCommand(localDepthmap, ossDepthmap);
+        }
+        String localDepthmapAsc = dataSource + "/caches/depthmap_csc/";
+        String ossDepthmapAsc = ossResultPath + "caches/depthmap_csc/";
+        if(FileUtil.exist(localDepthmapAsc)){
+            fYunFileServiceInterface.uploadFileByCommand(localDepthmapAsc, ossDepthmapAsc);
+        }
+        String localPanoramaJson =  dataSource + "/caches/panorama.json";
+        String ossPanoramaJson =  ossResultPath + "caches/panorama.json";
+        if(FileUtil.exist(localPanoramaJson)){
+            fYunFileServiceInterface.uploadFile(localPanoramaJson, ossPanoramaJson);
+        }
+        String localLaserPly = dataSource + "/results/laserData/laser.ply";
+        String ossLaserPly =  ossResultPath + "results/laserData/laser.ply";
+        if(FileUtil.exist(localLaserPly)){
+            fYunFileServiceInterface.uploadFile(localLaserPly, ossLaserPly);
+        }
+        String localFloorGroupFixJson = dataSource + "/caches/floor_group_fix.json";
+        String ossFloorGroupFixJson = ossResultPath + "caches/floor_group_fix.json";
+        if(FileUtil.exist(localFloorGroupFixJson)){
+            fYunFileServiceInterface.uploadFile(localFloorGroupFixJson, ossFloorGroupFixJson);
+        }
+
+        String localDepthmapVis = dataSource + "/caches/depthmap_vis";
+        String ossDepthmapVis = ossResultPath + "caches/depthmap_vis";
+        if(FileUtil.exist(localDepthmapVis)){
+            fYunFileServiceInterface.uploadFileByCommand(localDepthmapVis, ossDepthmapVis);
+        }
+
+        String localIntensity = dataSource + "/caches/intensity";
+        String ossIntensity = ossResultPath + "caches/intensity";
+        if(FileUtil.exist(localIntensity)){
+            fYunFileServiceInterface.uploadFileByCommand(localIntensity, ossIntensity);
+        }
+
+        //开始上传
+        fYunFileServiceInterface.uploadMulFiles(uploadMap);
+    }
+
+    @Override
+    public void initUserEditData(String num, Set<String> bizs, Map<String, Map<String ,Object>> params) {
+        if(StrUtil.isEmpty(num) || CollUtil.isEmpty(bizs)){
+            return;
+        }
+        for (String biz : bizs) {
+            UserEditDataHandler handler = UserEditDataHandlerFactory.getHandler(biz);
+            handler.init(num, CollUtil.isEmpty(params) ? null : params.get(biz));
+        }
+    }
+
+    @Override
+    public void uploadFloorplanJson(String num, String dataSource) throws Exception{
+        String floorPlanCardFilePath = dataSource + File.separator + "results/floorplan_cad.json";
+        if (!new File(floorPlanCardFilePath).exists()) {
+            log.warn("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
+            return;
+        }
+        JSONObject json = FloorPlanUserUtil.createFloorPlanUserJson(floorPlanCardFilePath);
+        if(Objects.isNull(json)){
+            log.error("生成floorplan.json失败,cadPath:", floorPlanCardFilePath);
+            throw new Exception("生成floorplan.json失败,cadPath:" + floorPlanCardFilePath);
+        }
+        String hourseTypeJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan.json";
+        fYunFileServiceInterface.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
+    }
+
+    @Override
+    public void sendEmail(String num) {
+        try {
+            Long userId = null;
+            String websize = "";
+            String title = "";
+            ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+            if(Objects.isNull(scenePlus)){
+                ScenePro scenePro = sceneProService.getByNum(num);
+                if(Objects.isNull(scenePro)){
+                    return;
+                }
+                userId = scenePro.getUserId();
+                websize = scenePro.getWebSite();
+                title = scenePro.getSceneName();
+            }else{
+                userId = scenePlus.getUserId();
+                ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+                websize = scenePlusExt.getWebSite();
+                title = scenePlus.getTitle();
+            }
+
+            if(Objects.isNull(userId)){
+                return;
+            }
+            User user = userService.getById(userId);
+            if(Objects.isNull(user) || StrUtil.isEmpty(user.getUserName())){
+                return;
+            }
+            String toEmail = user.getUserName();
+            String helpLink = helpLinkEn;
+            String lang = "en";
+            if("gn".equals(env)){
+                lang = "zh";
+                helpLink = helpLinkZh;
+            }
+            websize += "&lang=" + lang;
+
+            MailTemplate mailTemplate = mailTemplateService.getOne(new LambdaQueryWrapper<MailTemplate>().eq(MailTemplate::getRemark, "计算完成").eq(MailTemplate::getLang, lang));
+            String content = mailTemplate.getMsg().replaceAll("scene_name", title).replaceAll("scene_link", websize).replaceAll("help_link", helpLink);
+            SendMailAcceUtils.sendMail(mailTemplate.getSendMail(), mailTemplate.getSendPassword(), mailTemplate.getSendHost(), toEmail, mailTemplate.getSubject(), content, null);
+        }catch (Exception e){
+            log.error("发送邮件失败,num:" + num, e);
+        }
+    }
+}

+ 11 - 0
src/main/java/com/fdkankan/contro/schedule/ScheduleJob.java

@@ -1,5 +1,6 @@
 package com.fdkankan.contro.schedule;
 
+import com.fdkankan.contro.service.IScene3dNumService;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.rubbersheeting.ScalingService;
 import lombok.extern.log4j.Log4j2;
@@ -23,6 +24,8 @@ public class ScheduleJob {
 
     @Value("${queue.modeling.modeling-call}")
     private String queueModelingCall;
+    @Autowired
+    private IScene3dNumService scene3dNumService;
 
 
     @Scheduled(cron = "${rocketmq.autoScaling.corn:0 0/5 8-21 * * ?}")
@@ -40,4 +43,12 @@ public class ScheduleJob {
             log.error(e.getMessage());
         }
     }
+
+    /**
+     * 定时生成场景码,间隔1小时执行一次,项目启动一秒后执行一次
+     */
+    @Scheduled(fixedDelay = 60*60*1000, initialDelay = 1000)
+    public void generateSceneNum() {
+        scene3dNumService.generateSceneNumHandler();
+    }
 }

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

@@ -18,9 +18,11 @@ import java.util.Date;
 public interface IFdkkLaserService {
     void syncBuildResult(String sceneNum, String dataSource, Date createTime);
 
-    void pushBuildStatusToLaserSystem(String projectNum, String laserObjFilePath);
+    void pushBuildStatusToLaserSystem(String projectNum, String laserObjFilePath, Integer buildObjStatus);
 
     void saveScene(ScenePlus scenePlus, String scenePassword, Camera cameraEntity, String userName, boolean b);
 
     void saveScene(ScenePro scenePro, String scenePassword, Camera cameraEntity, String phone, boolean rebuild);
+
+    void cloudPointBuild(String sceneCode, String visionEditFilePath);
 }

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

@@ -0,0 +1,16 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.MailTemplate;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-01
+ */
+public interface IMailTemplateService extends IService<MailTemplate> {
+
+}

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

@@ -23,7 +23,9 @@ public interface IScene3dNumService extends IService<Scene3dNum> {
      * 从码池中取出一个场景码
      * @return
      */
-    String generateSceneNum(Integer cameraType);
+    String generateSceneNum(Integer cameraType) throws Exception;
+
+    void generateSceneNumHandler();
 
     /**
      * 批量生成场景码并放入码池

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

@@ -0,0 +1,20 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.SceneBuildProcessLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 场景计算流程状态表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-01-28
+ */
+public interface ISceneBuildProcessLogService extends IService<SceneBuildProcessLog> {
+
+    public void clearSceneBuildProcessLog(String num, String process, String queueName);
+
+    public void saveSceneBuildProcessLog(String num, String process, String queueName, int status, String reason);
+
+}

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

@@ -0,0 +1,16 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.SceneCopyDistinctEnv;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-21
+ */
+public interface ISceneCopyDistinctEnvService extends IService<SceneCopyDistinctEnv> {
+
+}

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

@@ -38,11 +38,6 @@ public class FdkkV4Service {
     public void upgradeToV4(String num){
         // 如果场景在旧表中存在,则需要升级,否则不需要升级
         ScenePro scenePro = sceneProService.getByNum(num);
-        if(ObjectUtils.isEmpty(scenePro)){
-            log.error("scene_pro 表中不存在该记录,退出升级!");
-            return;
-        }
-
         String url = mainUrl + String.format(UPGRADE_TO_V4,num);
         log.info("v3场景升级v4,url:{}",url);
         ResponseEntity<Result> responseEntity = restTemplate.getForEntity(url, Result.class);

+ 38 - 2
src/main/java/com/fdkankan/contro/service/impl/IFdkkLaserServiceImpl.java

@@ -9,6 +9,7 @@ import com.fdkankan.contro.entity.ScenePro;
 import com.fdkankan.contro.service.IFdkkLaserService;
 import com.fdkankan.contro.service.IScenePlusService;
 import com.fdkankan.contro.service.ISceneProService;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +18,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -40,6 +42,18 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
     @Value("${queue.application.laser.update-build-status}")
     private String updateBuildStatus;
 
+    @Value("${queue.application.laser.cloud-point-build}")
+    private String cloudPointBuild;
+
+    @Value("${4dkk.laserService.bucket}")
+    private String bucket;
+
+    @Value("${4dkk.laserService.cloud-point-fyun-path}")
+    private String cloudPointFyunPath;
+
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
+
 
     public void updateSceneStatus(String sceneCode, int sceneStatus, String path, Date createTime) {
         Map<String, Object> params = new HashMap<>();
@@ -88,10 +102,11 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
     }
 
     @Override
-    public void pushBuildStatusToLaserSystem(String projectNum, String laserObjFilePath) {
-        Map<String, String> params = new HashMap<>();
+    public void pushBuildStatusToLaserSystem(String projectNum, String laserObjFilePath, Integer buildObjStatus) {
+        Map<String, Object> params = new HashMap<>();
         params.put("sceneCode", projectNum);
         params.put("objPath", laserObjFilePath);
+        params.put("buildObjStatus", buildObjStatus);
         rabbitMqProducer.sendByWorkQueue(updateBuildStatus, params);
     }
 
@@ -149,4 +164,25 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
         return version;
     }
 
+    @Override
+    public void cloudPointBuild(String sceneCode, String path) {
+        log.info("开始同步点云编辑文件");
+        // 删除旧的文件及目录
+        try {
+            fYunFileService.deleteFile(cloudPointFyunPath + "vision_edit.txt");
+            fYunFileService.deleteFolder(cloudPointFyunPath + "uuidcloud");
+        } catch (IOException e) {
+            log.error("删除文件失败", e);
+            e.printStackTrace();
+        }
+
+        // 上传点云编辑文件,并通知激光系统
+        fYunFileService.uploadFile(bucket,path + "/results/laserData/vision_edit.txt", String.format(cloudPointFyunPath,sceneCode,sceneCode) + "vision_edit.txt");
+        fYunFileService.uploadFileByCommand(bucket,path + "/results/laserData/uuidcloud", String.format(cloudPointFyunPath,sceneCode,sceneCode) + "uuidcloud");
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("sceneNum", sceneCode);
+        params.put("businessType", 0);
+        rabbitMqProducer.sendByWorkQueue(cloudPointBuild, params);
+    }
 }

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

@@ -0,0 +1,20 @@
+package com.fdkankan.contro.service.impl;
+
+import com.fdkankan.contro.entity.MailTemplate;
+import com.fdkankan.contro.mapper.IMailTemplateMapper;
+import com.fdkankan.contro.service.IMailTemplateService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-01
+ */
+@Service
+public class MailTemplateServiceImpl extends ServiceImpl<IMailTemplateMapper, MailTemplate> implements IMailTemplateService {
+
+}

+ 76 - 58
src/main/java/com/fdkankan/contro/service/impl/Scene3dNumServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fdkankan.contro.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -11,6 +12,7 @@ import com.fdkankan.contro.entity.Scene3dNum;
 import com.fdkankan.contro.enums.CameraTypeEnum;
 import com.fdkankan.contro.mapper.IScene3dNumMapper;
 import com.fdkankan.contro.service.IScene3dNumService;
+import com.fdkankan.dingtalk.DingTalkSendUtils;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.constant.RedisLockKey;
 import com.fdkankan.redis.util.RedisLockUtil;
@@ -18,6 +20,7 @@ import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -36,10 +39,16 @@ import java.util.stream.Collectors;
  * @author dengsixing
  * @since 2021-12-23
  */
+@RefreshScope
 @Slf4j
 @Service
 public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3dNum> implements IScene3dNumService {
 
+    public static final String DINGTALK_MSG_PATTERN =
+        "**环境**: %s\n\n" +
+        "**标题**: %s\n\n" +
+        "**告警信息**: %s\n\n";
+
     @Autowired
     private RedisUtil redisUtil;
     @Autowired
@@ -47,54 +56,71 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
 
     @Value("${scene.num.cachePageSize:500}")
     private int cachePageSize;
-    @Value("${scene.num.threshold:10000}")
+    @Value("${scene.num.threshold:1000}")
     private int threshold;
-    @Value("${scene.num.prefix:V4-}")
+    @Value("${scene.num.prefix}")
     private String numPrefix;
     @Value("${scene.num.batchSize:100}")
     private int batchSize;
+    @Value("${main.url}")
+    private String mainUrl;
+
+    @Autowired
+    private DingTalkSendUtils dingTalkSendUtils;
 
     @Override
-    public String generateSceneNum(Integer cameraType){
+    public String generateSceneNum(Integer cameraType) throws Exception {
         // 从缓存中获取
         String sceneNum = redisUtil.lLeftPop(RedisKey.FDKANKAN_SCENE_NUMS);
         if(Objects.nonNull(sceneNum)){
             return addPrefix(sceneNum,cameraType);
         }
+        //为了防止场景量暴增导致定时任务来还不急处理,如果上面redis获取不到,需要调用一下生成场景码方法
+        log.warn("定时任务没有生成足够的场景码,此处实时调用批量生成场景码程序");
+        this.generateSceneNumHandler();
+        Thread.sleep(5000L);
+        // 从缓存中获取
+        sceneNum = redisUtil.lLeftPop(RedisKey.FDKANKAN_SCENE_NUMS);
+        if(Objects.isNull(sceneNum)){
+            String content = String.format(this.DINGTALK_MSG_PATTERN, mainUrl, "场景码穷尽告警", "场景计算获取场景码失败");
+            dingTalkSendUtils.sendActioncardMsgToDingRobot(content, "场景码穷尽告警");
+            throw new Exception("场景计算获取场景码失败");
+        }
+        return addPrefix(sceneNum,cameraType);
+    }
+
+    @Override
+    public void generateSceneNumHandler() {
+        boolean lock =  redisLockUtil.lock(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS, RedisKey.EXPIRE_TIME_30_MINUTE);
+        if(!lock){
+            return;
+        }
         // 分布式加锁
-        boolean lock =  redisLockUtil.lock(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS, RedisKey.EXPIRE_TIME_10_MINUTE);
-        if (lock) {
-            try {
-                log.info("开始加载场景码缓存");
-                List<String> nums = this.findSceneNum(cachePageSize);
-                if(CollectionUtils.isEmpty(nums)){
-                    batchCreateSceneNum(true);
-                    nums = this.findSceneNum(cachePageSize);
-                }else{
-                    CompletableFuture.runAsync(() -> batchCreateSceneNum(false));
-                }
+        try {
+            //检查mysql码池中是否有足够的未使用场景,不够时,需要创建一批
+            batchCreateSceneNum(false);
+
+            //检查redis中场景码是否少于指定缓存数量,少于时,需要从码池中获取
+            long redisCnt = redisUtil.lGetSize(RedisKey.FDKANKAN_SCENE_NUMS);
+            if(redisCnt >= cachePageSize){
+                return;
+            }
+            log.info("开始加载场景码缓存");
+            List<String> nums = this.findSceneNum(cachePageSize);
+            if(CollUtil.isEmpty(nums) || nums.size() < cachePageSize){
+                String content = String.format(this.DINGTALK_MSG_PATTERN, mainUrl, "场景码穷尽告警", "场景码表中未使用状态少于" + cachePageSize);
+                dingTalkSendUtils.sendActioncardMsgToDingRobot(content, "场景码穷尽告警");
+            }
+            if(CollUtil.isNotEmpty(nums)){
                 redisUtil.lRightPushAll(RedisKey.FDKANKAN_SCENE_NUMS, nums);
                 this.updateUsedStatus(nums);
-                log.info("场景码加载缓存完成");
-            } catch (Exception e) {
-                log.error("场景码加载缓存失败", e);
-            } finally {
-                redisLockUtil.unlockLua(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS);
             }
-        }else{
-            // 等待2秒加载缓存
-            try {
-                Thread.sleep(2000);
-            } catch (InterruptedException e) {
-                log.error("场景码加载缓存失败", e);
-            }
-        }
-        sceneNum = redisUtil.lLeftPop(RedisKey.FDKANKAN_SCENE_NUMS);
-        if(StrUtil.isEmpty(sceneNum)){
-            log.error("场景码加载失败");
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5053);
+            log.info("场景码加载缓存完成");
+        } catch (Exception e) {
+            log.error("场景码加载缓存失败", e);
+        } finally {
+            redisLockUtil.unlockLua(RedisLockKey.LOCK_FDKANKAN_SCENE_NUMS);
         }
-        return addPrefix(sceneNum,cameraType);
     }
 
     private  static  String addPrefix( String num,Integer cameraType){
@@ -106,34 +132,26 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
 
     @Override
     public void batchCreateSceneNum(boolean force) {
-        String lockKey = String.format(RedisLockKey.LOCK_BATCH_CREATE_NUM);
-        boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
-        if(!lock){
-            return;
-        }
-        try {
-            if (!force) {
-                long count = this.count(new LambdaQueryWrapper<Scene3dNum>().eq(Scene3dNum::getUsed, CommonStatus.NO.code()));
-                if (count > threshold) {
-                    return;
-                }
+        if (!force) {
+            long count = this.count(new LambdaQueryWrapper<Scene3dNum>().eq(Scene3dNum::getUsed, CommonStatus.NO.code()));
+            if (count > threshold) {
+                return;
             }
-            int batchCnt = threshold / batchSize + (threshold % batchSize > 0 ? 1 : 0);
-            for (int i = 0; i < batchCnt; i++){
-                Set<String> numSet = this.turnCreateSceneNum(batchSize);
-                List<Scene3dNum> scene3dNumList = numSet.parallelStream().map(num -> {
-                    Scene3dNum scene3dNum = new Scene3dNum();
-                    scene3dNum.setNum(num);
-                    return scene3dNum;
-                }).collect(Collectors.toList());
-                try{
-                    this.saveBatch(scene3dNumList);
-                }catch (Exception e){
-                    log.error("场景码插入异常!",e);
-                }
+        }
+        int batchCnt = threshold / batchSize + (threshold % batchSize > 0 ? 1 : 0);//批次数
+        for (int i = 0; i < batchCnt; i++){//分批生成,每批次batchSize个
+            Set<String> numSet = this.turnCreateSceneNum(batchSize);
+            List<Scene3dNum> scene3dNumList = numSet.parallelStream().map(num -> {
+                Scene3dNum scene3dNum = new Scene3dNum();
+                scene3dNum.setCode(num);
+                return scene3dNum;
+            }).collect(Collectors.toList());
+            try{
+                this.saveBatch(scene3dNumList);
+            }catch (Exception e){
+                log.error("场景码插入异常!");
+                e.printStackTrace();
             }
-        }finally {
-            redisLockUtil.unlockLua(lockKey);
         }
     }
 

+ 50 - 0
src/main/java/com/fdkankan/contro/service/impl/SceneBuildProcessLogServiceImpl.java

@@ -0,0 +1,50 @@
+package com.fdkankan.contro.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.contro.entity.SceneBuildProcessLog;
+import com.fdkankan.contro.mapper.ISceneBuildProcessLogMapper;
+import com.fdkankan.contro.service.ISceneBuildProcessLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.Objects;
+
+/**
+ * <p>
+ * 场景计算流程状态表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-01-28
+ */
+@Service
+public class SceneBuildProcessLogServiceImpl extends ServiceImpl<ISceneBuildProcessLogMapper, SceneBuildProcessLog> implements ISceneBuildProcessLogService {
+
+
+    @Override
+    public void clearSceneBuildProcessLog(String num, String process, String queueName) {
+        this.remove(new LambdaQueryWrapper<SceneBuildProcessLog>()
+                .eq(SceneBuildProcessLog::getNum, num)
+                .eq(SceneBuildProcessLog::getProcess, process)
+                .eq(SceneBuildProcessLog::getQueueName, queueName));
+    }
+
+    @Override
+    public void saveSceneBuildProcessLog(String num, String process, String queueName, int status, String reason) {
+
+        SceneBuildProcessLog log = this.getOne(new LambdaQueryWrapper<SceneBuildProcessLog>()
+                .eq(SceneBuildProcessLog::getNum, num)
+                .eq(SceneBuildProcessLog::getProcess,process)
+                .eq(SceneBuildProcessLog::getQueueName, queueName));
+        if(Objects.isNull(log)){
+            log = new SceneBuildProcessLog();
+        }
+        log.setNum(num);
+        log.setProcess(process);
+        log.setProcess(process);
+        log.setQueueName(queueName);
+        log.setState(status);
+        log.setReason(reason);
+        this.saveOrUpdate(log);
+    }
+}

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

@@ -0,0 +1,20 @@
+package com.fdkankan.contro.service.impl;
+
+import com.fdkankan.contro.entity.SceneCopyDistinctEnv;
+import com.fdkankan.contro.mapper.ISceneCopyDistinctEnvMapper;
+import com.fdkankan.contro.service.ISceneCopyDistinctEnvService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-21
+ */
+@Service
+public class SceneCopyDistinctEnvServiceImpl extends ServiceImpl<ISceneCopyDistinctEnvMapper, SceneCopyDistinctEnv> implements ISceneCopyDistinctEnvService {
+
+}

+ 189 - 83
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -4,10 +4,12 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
 import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -31,6 +33,7 @@ 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.constant.RedisKey;
 import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.web.response.Result;
@@ -54,6 +57,9 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -85,6 +91,12 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Value("${v3.controlUrl:#{null}}")
     private String v3controlUrl;
 
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
+    @Value("#{'${model.3dtiles.sceneSource:}'.split(',')}")
+    private List<Integer> sdTilesSceneSourceList;
+
     @Value("${build.notSupport.beforeTime:202203}")
     private String jgNotSupportBuildTime;
 
@@ -92,6 +104,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     private RedisUtil redisUtil;
 
 
+
     @Autowired
     private IScenePlusExtService scenePlusExtService;
 
@@ -149,6 +162,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
     private RestTemplate restTemplate = new RestTemplate();
 
+    @Autowired
+    private ISceneCopyDistinctEnvService sceneCopyDistinctEnvService;
+
     @Override
     public SceneFileBuild findByFileId(String fileId) {
 
@@ -513,6 +529,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +".png";
         String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +"_en.png";
         QrConfig qrConfig = QrConfig.create();
+        qrConfig.setWidth(512);
+        qrConfig.setHeight(512);
         if(!org.apache.commons.lang3.ObjectUtils.isEmpty(localLogoPath)){
             qrConfig.setImg(localLogoPath);
         }
@@ -581,12 +599,14 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             }
         }
 
-        ResultData ok = callV3(preParams, fdageJson,"api/scene/file/uploadSuccessBuild");
-        if (ok != null) return ok;
-
         // 判断是否是V3的场景
         ScenePro scenePro = sceneProService.getOne(
-                new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+            new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+
+        boolean callV3 = callV3(scenePro, preParams, fdageJson, "api/scene/file/uploadSuccessBuild");
+        if(callV3) return ResultData.ok();
+
+
         if (ObjectUtils.isEmpty(scenePro) || (!ObjectUtils.isEmpty(scenePro.getIsUpgrade()) && scenePro.getIsUpgrade() == 1)) {
             buildScene(fileId, prefixBuffer.toString(),fdageJson,buildType,cameraType);
         }else{
@@ -595,7 +615,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return ResultData.ok();
     }
 
-    private ResultData callV3(String preParams, JSONObject fdageJson,String api) {
+    private boolean callV3(ScenePro scenePro, String preParams, JSONObject fdageJson,String api) throws Exception {
         String cameraName = fdageJson.getJSONObject("cam").getString("uuid");
 
         Camera camera = cameraService.getByChildName(cameraName);
@@ -609,7 +629,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             log.error("该相机详情不存在:" + cameraName);
             throw new BusinessException(CameraConstant.FAILURE_6003);
         }
-        // 判断是否是正顺的场景,如果是正顺的场景,则发送到原来的系统进行计算
+        // 判断是否是正顺|火调|普通v3的场景,如果是正顺|火调|普通v3的场景,则发送到原来的系统进行计算
         if (!ObjectUtils.isEmpty(cameraDetail.getCompanyId())) {
             Company company = companyService.getById(cameraDetail.getCompanyId());
             if(ObjectUtils.isEmpty(company)){
@@ -617,18 +637,25 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                 throw new BusinessException(CameraConstant.FAILURE_6003);
             }
             if (!ObjectUtils.isEmpty(company.getSceneVersion()) && company.getSceneVersion().equals("V3")) {
-                callV3Service(preParams,api);
-                return ResultData.ok();
+                callV3Service(preParams, api);
+                return Boolean.TRUE;
             }
         }
-        return null;
+        // TODO: 2023/1/12 3dtiles临时上激光场景
+//        else if (Objects.nonNull(scenePro) &&
+//            scenePro.getSceneSource() != SceneSource.JG.code() &&
+//            scenePro.getIsUpgrade() == CommonStatus.NO.code().intValue()){
+//            callV3Service(preParams,api);
+//            return Boolean.TRUE;
+//        }
+        return Boolean.FALSE;
     }
 
-    public void callV3Service(String params,String api){
+    public void callV3Service(String params,String api) throws Exception {
         log.info("params:{}", params);
         if(ObjectUtils.isEmpty(v3controlUrl)){
             log.error("未配置V3服务器!");
-            return;
+            throw new Exception("未配置V3服务器!");
         }
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.MULTIPART_FORM_DATA);
@@ -636,9 +663,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         paramMap.add("params",params);
         HttpEntity<Object> formEntity = new HttpEntity<>(paramMap,headers);
         ResponseEntity<Result> responseEntity = restTemplate.postForEntity(v3controlUrl+api, formEntity, Result.class);
-        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
-            log.error("正顺场景请求V3服务器失败!");
-            return;
+        if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || responseEntity.getBody().getCode() != ServerCode.SUCCESS.code()) {
+            log.error("正顺场景请求V3服务器失败, params:{}, result:{}",params, JSON.toJSONString(responseEntity));
+            throw new BusinessException(ErrorCode.SYSTEM_BUSY);
         }
         log.info("正顺场景请求V3服务器成功!");
     }
@@ -699,19 +726,18 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             cameraType = 14L;
         }
 
-        ResultData ok = callV3(preParams, fdageJson,"api/scene/file/turntableUploadSuccess");
-        if (ok != null) return ok;
-
-
-        ScenePlusVO scenePlusVO = null;
-
         // 判断是否是V3的场景
         ScenePro scenePro = sceneProService.getOne(
-                new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+            new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+
+        boolean callV3 = callV3(scenePro, preParams, fdageJson, "api/scene/file/turntableUploadSuccess");
+        if (callV3) return ResultData.ok();
 
         //激光场景校验是否能够计算
         this.checkJgCanBuild(scenePro);
 
+        ScenePlusVO scenePlusVO = null;
+
         if (ObjectUtils.isEmpty(scenePro) || (!ObjectUtils.isEmpty(scenePro.getIsUpgrade()) && scenePro.getIsUpgrade() == 1)) {
             scenePlusVO = buildScene(fileId, prefixBuffer.toString(), fdageJson, buildType, cameraType);
         } else {
@@ -776,6 +802,12 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             scenePlusExt.setSceneScheme(10);
         }
 
+        if(ModelKind.THREE_D_TILE.code().equals(modelKind)
+                && CollUtil.isNotEmpty(sdTilesSceneSourceList)
+                && sdTilesSceneSourceList.contains(scenePlus.getSceneSource())){
+            scenePlusExt.setModelKind(modelKind);
+        }
+
         if (pic != null && pic.length() > 5) {
             scenePlusExt.setThumb(pic);
         } else {
@@ -831,8 +863,12 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                 sceneEditInfo.setScenePassword(sceneKey);
                 sceneEditControls.setShowLock((int) CommonStatus.YES.code());
             }
-
             sceneEditInfoService.save(sceneEditInfo);
+
+            sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
+            sceneEditInfoExt.setScenePlusId(scenePlus.getId());
+            sceneEditInfoExtService.save(sceneEditInfoExt);
+
             sceneEditControls.setEditInfoId(sceneEditInfo.getId());
             sceneEditControlsService.save(sceneEditControls);
 
@@ -889,11 +925,12 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             sceneEditInfo.setVersion(oldSceneEditInfo.getVersion() + 1);
             sceneEditInfoService.updateById(sceneEditInfo);
 
-            sceneEditInfoExt.setId(oldSceneEditeIinfoExt.getId());
+            if(Objects.nonNull(oldSceneEditeIinfoExt)){
+                sceneEditInfoExt.setId(oldSceneEditeIinfoExt.getId());
+            }
             sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
             sceneEditInfoExt.setScenePlusId(scenePlus.getId());
-            sceneEditInfoExtService.updateById(sceneEditInfoExt);
-
+            sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
         }
 
         BeanUtil.copyProperties(scenePlusExt, scenePlusVO);
@@ -1066,12 +1103,23 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
         ScenePro scenePro = sceneProService.getByNum(num);
 
+        // TODO: 2023/1/12 3dtiles临时上激光场景
+//        if(Objects.nonNull(scenePro) && (Objects.isNull(scenePro.getIsUpgrade())
+//            || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
+//            if(scenePro.getSceneSource() == SceneSource.JG.code().intValue()){
+//                return rebuildV3Scene(scenePro,num,force);
+//            }else{
+//                return rebuildV3SceneToMini(scenePro);
+//            }
+//        }
+
+
         //激光场景校验是否能够计算
         this.checkJgCanBuild(scenePro);
 
         //如果是v3场景,不允许重算,需要升级v4后再调此接口进行重算
         if(Objects.nonNull(scenePro) && (Objects.isNull(scenePro.getIsUpgrade())
-            || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
+                || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
             return rebuildV3Scene(scenePro,num,force);
         }
 
@@ -1139,11 +1187,21 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         if(deleteExtras){
             message.getExt().put("deleteExtras",deleteExtras);
         }
+        if (force) {
+            message.setRebuild("1");
+        }
         rabbitMqProducer.sendByWorkQueue(queueModelingPre, message);
         scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
             .set(ScenePlus::getSceneStatus, SceneStatus.wait.code())
             .eq(ScenePlus::getNum, num));
 
+        if(ModelKind.THREE_D_TILE.code().equals(modelKind)
+                && CollUtil.isNotEmpty(sdTilesSceneSourceList)
+                && sdTilesSceneSourceList.contains(scenePlus.getSceneSource())){
+            scenePlusExt.setModelKind(modelKind);
+        }
+        scenePlusExtService.updateById(scenePlusExt);
+
         return ResultData.ok();
     }
 
@@ -1191,9 +1249,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String buildType = scenePro.getBuildType();
         Integer sceneScheme = scenePro.getSceneScheme();
 
-        //重新计算时需要删除文件夹,否知使用缓存
-        FileUtils.delAllFile(path + File.separator + "results");
-
         String dataFdageOssPath = ConstantFilePath.OSS_PREFIX+ path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
                 .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage";
 
@@ -1247,16 +1302,17 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     }
 
     @Override
-    public ResultData copyDataAndBuild(String sourceBucet,String dataSource,String sceneVer) throws Exception {
-        if(!StringUtils.equals(sceneVer,"V3") && ! StringUtils.equals(sceneVer,"V4")){
+    public ResultData copyDataAndBuild(String sourceBucet,String dataSource, String sceneVer) throws Exception {
+        if(!SceneVersionType.V3.code().equals(sceneVer)
+                && !SceneVersionType.V4.code().equals(sceneVer)){
             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);
-        }
+//        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)){
@@ -1273,66 +1329,105 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             throw new BusinessException(ErrorCode.FAILURE_CODE_6003);
         }
 
-        Long cameraType = 11L;
-        //判断是否转台相机
-        if (detailEntity.getType() == 9) {
-            cameraType = 13L;
-        }
+        // 拷贝资源至新的资源路径
+        String[] newDataPath = dataSource.split("/");
+        newDataPath[4] = newDataPath[4] + "_" + System.currentTimeMillis();
+        String time = DateExtUtil.format(Calendar.getInstance().getTime(), DateExtUtil.dateStyle11);
+        newDataPath[5] = newDataPath[5].split("_")[0] + "_" + time;
+        String newDataSource = Arrays.stream(newDataPath).collect(Collectors.joining("/"));
 
-        if (detailEntity.getType() == 10) {
-            cameraType = 14L;
+        String newFYunPath = ConstantFilePath.OSS_PREFIX + newDataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+
+        List<ScenePro> pros = sceneProService.list(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getDataSource, newDataSource));
+        if (CollUtil.isNotEmpty(pros)) {
+            return ResultData.error(ErrorCode.PARAM_ERROR.code(),newDataSource + "已存在,请勿重复添加!");
+        }
+        List<ScenePlusExt> plusExts = scenePlusExtService.list(new LambdaQueryWrapper<ScenePlusExt>().eq(ScenePlusExt::getDataSource, newDataSource));
+        if (CollUtil.isNotEmpty(plusExts)) {
+            return ResultData.error(ErrorCode.PARAM_ERROR.code(),newDataSource + "已存在,请勿重复添加!");
+        }
+        List<String> newFyunFileList = fYunFileService.listRemoteFiles(newFYunPath);
+        if(CollUtil.isNotEmpty(newFyunFileList)){
+            return ResultData.error(ErrorCode.PARAM_ERROR.code(),newFYunPath + "已存在,请勿重复添加!");
         }
+
         String sceneNum = scene3dNumService.generateSceneNum(detailEntity.getType());
 
-        String icon = null;
-        String imgViewPath = null;
-        switch (sceneVer) {
-            case "V3":
-                List<ScenePro> pros = sceneProService.list(new LambdaQueryWrapper<ScenePro>()
-                        .like(ScenePro::getDataSource, dataSource));
-                if (pros.size() > 0) {
-                    return ResultData.error(ErrorCode.PARAM_ERROR.code(),"该场景资源已存在,请勿重复添加!");
-                }
+        //写入日志表
+        SceneCopyDistinctEnv sceneCopyDistinctEnv = new SceneCopyDistinctEnv();
+        sceneCopyDistinctEnv.setNum(sceneNum);
+        sceneCopyDistinctEnv.setSrcDataSource(dataSource);
+        sceneCopyDistinctEnv.setTargetDataSource(newDataSource);
+        sceneCopyDistinctEnvService.save(sceneCopyDistinctEnv);
+
+        ExecutorService executor = ThreadUtil.newSingleExecutor();
+        try {
+            CompletableFuture.runAsync(() -> {
+                try {
+                    fYunFileService.copyFileBetweenBucket(sourceBucet, fYunPath, fYunFileConfig.getBucket(), newFYunPath);
+
+                    fdageData.put("uuidtime",time);
+                    fYunFileService.uploadFile(fdageData.toJSONString().getBytes(),newFYunPath+"/data.fdage");
+
+                    Long cameraType = 11L;
+                    //判断是否转台相机
+                    if (detailEntity.getType() == 9) {
+                        cameraType = 13L;
+                    }
 
-                imgViewPath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, 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成功....");
-                }
-                buildV3Scene2(dataSource,fdageData,cameraType,sceneNum,cameraEntity,detailEntity,icon);
-                break;
-            case "V4":
-                List<ScenePlusExt> plusExts = scenePlusExtService.list(new LambdaQueryWrapper<ScenePlusExt>()
-                        .like(ScenePlusExt::getDataSource, dataSource));
-                if (plusExts.size() > 0) {
-                    return ResultData.error(ErrorCode.PARAM_ERROR.code(),"该场景资源已存在,请勿重复添加!");
-                }
+                    if (detailEntity.getType() == 10) {
+                        cameraType = 14L;
+                    }
 
-                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, detailEntity, 0, icon);
-                if (cameraType == 14) {
-                    // 通知激光系统
-                    ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
-                    String userName = null;
-                    if (!ObjectUtils.isEmpty(detailEntity.getUserId())) {
-                        userName = userService.getSSOUserByUserId(detailEntity.getUserId()).getUserName();
+                    String icon = null;
+                    String imgViewPath = null;
+                    switch (sceneVer) {
+                        case "V3":
+                            imgViewPath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, sceneNum);
+                            if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
+                                String ossPath = ConstantFilePath.OSS_PREFIX + newDataSource.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");
+                            }
+                            buildV3Scene2(newDataSource,fdageData,cameraType,sceneNum,cameraEntity,detailEntity,icon);
+                            break;
+                        case "V4":
+                            imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
+                            if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
+                                String ossPath = ConstantFilePath.OSS_PREFIX + newDataSource.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");
+                            }
+                            buildScenePost(newDataSource, fdageData, "V3", cameraType, sceneNum, detailEntity, 0, icon);
+                            if (cameraType == 14) {
+                                // 通知激光系统
+                                ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
+                                String userName = null;
+                                if (!ObjectUtils.isEmpty(detailEntity.getUserId())) {
+                                    userName = userService.getSSOUserByUserId(detailEntity.getUserId()).getUserName();
+                                }
+                                fdkkLaserService.saveScene(scenePlus, fdageData.getString("pwd"), cameraEntity, userName, false);
+                            }
+                            break;
                     }
-                    fdkkLaserService.saveScene(scenePlus, fdageData.getString("pwd"), cameraEntity, userName, false);
+
+                }catch (Exception e){
+                    log.error("复制场景异常", e);
                 }
-                break;
+            }, executor).whenComplete((reslut, e) -> {
+                log.info("复制场景souceDataSource:{},newDataSource:{}结束-{}",dataSource,newDataSource, new Date());
+            });
+        }catch (Exception e){
+            log.error("线程错误:{}",e);
+        }finally {
+            executor.shutdown();
         }
         Map<String,Object> result = new HashMap<>();
         result.put("code",sceneNum);
+        result.put("newDataSource",newDataSource);
         return ResultData.ok(result);
     }
 
@@ -1606,4 +1701,15 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return scene;
     }
 
+    private ResultData rebuildV3SceneToMini(ScenePro scenePro){
+        log.info("v3场景重算,请求v3服务器,url:{}",v3controlUrl+"api/scene/rebuildScene?num=" + scenePro.getNum());
+        ResponseEntity<Result> responseEntity = restTemplate.getForEntity(v3controlUrl+"api/scene/rebuildScene?num=" + scenePro.getNum(), Result.class);
+        if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || responseEntity.getBody().getCode() != ServerCode.SUCCESS.code()) {
+            log.error("请求V3服务器重算场景失败, num:{}, result:{}",scenePro.getNum(), JSON.toJSONString(responseEntity));
+            throw new BusinessException(ErrorCode.SYSTEM_BUSY);
+        }
+        log.info("v3场景重算,请求v3服务器,url:{}, result",v3controlUrl+"api/scene/rebuildScene?num=" + scenePro.getNum(), JSON.toJSONString(responseEntity));
+        return ResultData.ok();
+    }
+
 }

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

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

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