Parcourir la source

增加漫游点查询接口

xiewenjie il y a 3 ans
Parent
commit
f0facb0dcb

+ 55 - 26
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/ImportDataController.java

@@ -1,5 +1,6 @@
 package com.fdkk.sxz.webApi.controller;
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -12,6 +13,7 @@ import com.fdkk.sxz.annotation.log.AroundLog;
 import com.fdkk.sxz.base.BaseController;
 import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.constant.CodeConstant;
+import com.fdkk.sxz.entity.SceneEntity;
 import com.fdkk.sxz.entity.SceneLightEntity;
 import com.fdkk.sxz.entity.SceneStyleEntity;
 import com.fdkk.sxz.other.mq.TopicRabbitConfig;
@@ -59,7 +61,8 @@ public class ImportDataController extends BaseController {
 
     @Autowired
     private ISceneStyleService sceneStyleService;
-
+    @Autowired
+    private ISceneService sceneService;
     @Autowired
     private ISceneLightService sceneLightService;
 
@@ -133,8 +136,11 @@ public class ImportDataController extends BaseController {
             } else {
                 ImportDataController.log.info("roamingPoint,不存在");
             }
-
-
+            SceneEntity sceneEntity = sceneService.findBySceneNum(sceneNum);
+            if (ObjectUtil.isNotNull(sceneEntity) && StrUtil.isNotEmpty(roamingPointUrl)) {
+                sceneEntity.setRoamingPointUrl(roamingPointUrl);
+                sceneService.updateById(sceneEntity);
+            }
             if (StringUtils.isEmpty(styleNum)) {
                 Integer num = sceneStyleService.findLastNum(sceneNum);
                 if (num == null) {
@@ -149,7 +155,6 @@ public class ImportDataController extends BaseController {
                 sceneStyleEntity.setSceneNum(sceneNum);
                 sceneStyleEntity.setStyleName(styleName);
                 sceneStyleEntity.setStyleNum(vrNum);
-                sceneStyleEntity.setRoamingPointUrl(roamingPointUrl);
                 //新生成的换装风格,未渲染
                 sceneStyleEntity.setStatus(2);
                 sceneStyleService.save(sceneStyleEntity);
@@ -161,7 +166,6 @@ public class ImportDataController extends BaseController {
                 if (list != null && list.size() > 0) {
                     SceneStyleEntity sceneStyleEntity = list.get(0);
                     sceneStyleEntity.setStyleName(styleName);
-                    sceneStyleEntity.setRoamingPointUrl(roamingPointUrl);
                     sceneStyleService.updateById(sceneStyleEntity);
                 }
             }
@@ -469,10 +473,6 @@ public class ImportDataController extends BaseController {
     @NoAuthentication
     @AroundLog(name = "测试运行命令")
     public String fbxToObj(String fbxPath, String objPath) throws Exception {
-//        String command = "D:/OneKeyDecorate/StartDecorate.exe -s " + vrNum;
-//        log.info("开始建模:" + command);
-//        RunCmdUtil.callshell(command);
-//        log.info("计算完毕:" + command);
         String filePth = fbxPath.substring(0, fbxPath.lastIndexOf(File.pathSeparator) + 1);
         String fbxName = fbxPath.substring(fbxPath.lastIndexOf(File.pathSeparator) + 1);
         CreateObjUtil.fbxToObj(filePth, fbxName, objPath);
@@ -480,6 +480,22 @@ public class ImportDataController extends BaseController {
     }
 
     /**
+     * 根据场景编码获取处理后的漫游点数据
+     *
+     * @return
+     */
+    @ApiOperation("根据场景编码获取处理后的漫游点数据")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "num", value = "场景码", dataType = "String")})
+    @RequestMapping(value = "/getRoamingPointByNum", method = RequestMethod.POST)
+    @NoAuthentication
+    @AroundLog(name = "根据场景编码获取处理后的漫游点数据")
+    public Result getRoamingPointByNum(String num) {
+        SceneEntity sceneEntity = sceneService.findBySceneNum(num);
+        return Result.success(sceneEntity);
+    }
+
+    /**
      * 生成房型数据
      *
      * @param num
@@ -534,24 +550,37 @@ public class ImportDataController extends BaseController {
                     if (sweepArray != null && sweepArray.size() > 0) {
                         entryJson.put("noSetting", sweepArray.getJSONObject(0));
                         //处理漫游点供前端使用
-                        List<JSONObject> roamingPoint = new ArrayList();
-                        for (int i = 0; i < sweepArray.size(); i++) {
-                            JSONObject objectJson = sweepArray.getJSONObject(i);
-                            JSONObject newJson = new JSONObject();
-                            newJson.put("uuid", objectJson.getString("uuid"));
-                            JSONObject puck = objectJson.getJSONObject("puck");
-                            puck.put("y", puck.getDoubleValue("y") * -1);
-                            puck.remove("z");
-                            newJson.put("puck", puck);
-                            newJson.put("subgroup", objectJson.getInteger("subgroup"));
-                            roamingPoint.add(newJson);
+                        SceneEntity sceneEntity = sceneService.findBySceneNum(num);
+                        if (ObjectUtil.isNotNull(sceneEntity)) {
+                            List<JSONObject> roamingPoint = new ArrayList();
+                            for (int i = 0; i < sweepArray.size(); i++) {
+                                JSONObject objectJson = sweepArray.getJSONObject(i);
+                                JSONObject newJson = new JSONObject();
+                                newJson.put("uuid", objectJson.getString("uuid"));
+                                JSONObject puck = objectJson.getJSONObject("puck");
+                                puck.put("y", puck.getDoubleValue("y") * -1);
+                                puck.remove("z");
+                                newJson.put("puck", puck);
+                                newJson.put("subgroup", objectJson.getInteger("subgroup"));
+                                roamingPoint.add(newJson);
+                            }
+                            Map<Integer, List<JSONObject>> subgroup = roamingPoint.stream().collect(
+                                    Collectors.groupingBy(x -> x.getInteger("subgroup")));
+                            FileUtils.writeFile(basePath + File.separator + "roamingPoint.json", JSON.toJSONString(subgroup));
+                            //数据上传oss,让计算服务器下载资源
+                            uploadToOssUtil.upload(basePath + File.separator + "roamingPoint.json",
+                                    "data/data" + num + "/roamingPoint.json");
+                            sceneEntity.setSceneNum(num);
+                            String roamingPointUrl = "";
+                            Boolean existRoamingPoint = uploadToOssUtil.existFileToOSS("data/data" + num + "/roamingPoint.json", "4dkankan");
+                            if (existRoamingPoint) {
+                                roamingPointUrl = "https://4dkk.4dage.com/data/data" + num + "/roamingPoint.json";
+                            } else {
+                                ImportDataController.log.info("roamingPoint,不存在");
+                            }
+                            sceneEntity.setRoamingPointUrl(roamingPointUrl);
+                            sceneService.save(sceneEntity);
                         }
-                        Map<Integer, List<JSONObject>> subgroup = roamingPoint.stream().collect(
-                                Collectors.groupingBy(x -> x.getInteger("subgroup")));
-                        FileUtils.writeFile(basePath + File.separator + "roamingPoint.json", JSON.toJSONString(subgroup));
-                        //数据上传oss,让计算服务器下载资源
-                        uploadToOssUtil.upload(basePath + File.separator + "roamingPoint.json",
-                                "data/data" + num + "/roamingPoint.json");
                     }
                 }
             } else {

+ 15 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/mapper/ISceneMapper.java

@@ -0,0 +1,15 @@
+package com.fdkk.sxz.webApi.mapper;
+
+import com.fdkk.sxz.base.IBaseMapper;
+import com.fdkk.sxz.entity.SceneEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by Hb_zzZ on 2020/7/14.
+ */
+@Mapper
+@Component("ISceneMapper")
+public interface ISceneMapper extends IBaseMapper<SceneEntity> {
+
+}

+ 11 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/ISceneService.java

@@ -0,0 +1,11 @@
+package com.fdkk.sxz.webApi.service;
+
+import com.fdkk.sxz.base.IBaseService;
+import com.fdkk.sxz.entity.SceneEntity;
+
+/**
+ * Created by Hb_zzZ on 2020/7/14.
+ */
+public interface ISceneService extends IBaseService<SceneEntity> {
+    SceneEntity findBySceneNum(String sceneNum);
+}

+ 16 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/SceneServiceImpl.java

@@ -0,0 +1,16 @@
+package com.fdkk.sxz.webApi.service.impl;
+
+import com.fdkk.sxz.base.impl.BaseServiceImpl;
+import com.fdkk.sxz.entity.SceneEntity;
+import com.fdkk.sxz.webApi.mapper.ISceneMapper;
+import com.fdkk.sxz.webApi.service.ISceneService;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by Hb_zzZ on 2020/7/14.
+ */
+@Service
+public class SceneServiceImpl extends BaseServiceImpl<ISceneMapper, SceneEntity> implements ISceneService {
+
+
+}

+ 20 - 0
sxz-modules/src/main/java/com/fdkk/sxz/entity/SceneEntity.java

@@ -0,0 +1,20 @@
+package com.fdkk.sxz.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+
+/**
+ * Created by Hb_zzZ on 2020/7/14.
+ */
+@Data
+@TableName("tb_scene")
+public class SceneEntity extends BaseEntity {
+
+    @TableField("scene_num")
+    private String sceneNum;
+
+    @TableField("roaming_point_url")
+    private String roamingPointUrl;
+}

+ 0 - 2
sxz-modules/src/main/java/com/fdkk/sxz/entity/SceneStyleEntity.java

@@ -48,6 +48,4 @@ public class SceneStyleEntity extends BaseEntity {
     @TableField("is_decoration")
     private Integer isDecoration;
 
-    @TableField("roaming_point_url")
-    private String roamingPointUrl;
 }