dengsixing 2 mesiacov pred
rodič
commit
06af5e838d

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

@@ -2,46 +2,32 @@ package com.fdkankan.contro.controller;
 
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.core.util.ZipUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
-import com.fdkankan.contro.entity.User;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
 import com.fdkankan.contro.service.IAppCameraFailLogService;
 import com.fdkankan.contro.service.ISceneFileBuildService;
 import com.fdkankan.contro.service.ISceneUploadCountService;
 import com.fdkankan.contro.vo.ReportFailLogVO;
 import com.fdkankan.contro.vo.ResponseSceneFile;
-import com.fdkankan.contro.vo.SendCallAlgorithmParam;
-import com.fdkankan.fyun.face.FYunFileServiceInterface;
-import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.contro.vo.SceneUploadCountParamVO;
+import com.fdkankan.contro.vo.SendCallAlgorithmParam;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.web.response.ResultData;
 import lombok.extern.log4j.Log4j2;
-import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.bind.annotation.*;
 
-import java.io.File;
 import javax.validation.Valid;
+import java.io.File;
 import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -165,8 +151,8 @@ public class SceneFileController{
      */
     @PostMapping("upload")
     public ResultData upload(@RequestParam(value = "file",required = false) MultipartFile file,
-                         String params) throws Exception {
-        return sceneFileBuildService.uploadFile(file, params);
+                         String params, String dir) throws Exception {
+        return sceneFileBuildService.uploadFile(file, params,dir);
     }
 
     /**

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

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

+ 16 - 1
src/main/java/com/fdkankan/contro/service/impl/CommonServiceImpl.java

@@ -594,6 +594,7 @@ public class CommonServiceImpl implements ICommonService {
 
         try {
             String aiJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan/ai.json";
+            String aiEntireJsonKey = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan/ai-entire.json";
             //先清空历史数据,因为数据格式改动很多个版本,已经无法按照规律进行过滤删除,所以这里先删除历史数据,而后再根据算法生成去插入数据
             sceneMarkShapeService.remove(new LambdaQueryWrapper<SceneMarkShape>().eq(SceneMarkShape::getNum, num).eq(SceneMarkShape::getType, DetectType.PLAN.getCode()));
             if(fYunFileService.fileExist(aiJsonKey)){
@@ -650,7 +651,21 @@ public class CommonServiceImpl implements ICommonService {
                     }
                 }
             }
-
+            //先上传一份带门窗的,完整的,绘图功能要用
+            fYunFileService.uploadFile(JSON.toJSONString(sceneMarkShapes).getBytes(StandardCharsets.UTF_8), aiEntireJsonKey);
+
+            //上传一份过滤掉门窗的,徐总要求过滤
+            for (SceneMarkShape sceneMarkShape : sceneMarkShapes) {
+                //徐总要求去掉门窗(因为门窗不属于家具)
+                List<JSONObject> shapes = sceneMarkShape.getShapes().stream().filter(v -> {
+                    String category = v.getString("category");
+                    if (StrUtil.isNotEmpty(category) && (category.contains("Door") || category.contains("Window"))) {
+                        return false;
+                    }
+                    return true;
+                }).collect(Collectors.toList());
+                sceneMarkShape.setShapes(shapes);
+            }
             fYunFileService.uploadFile(JSON.toJSONString(sceneMarkShapes).getBytes(StandardCharsets.UTF_8), aiJsonKey);
 
             return hasFloorplanAi;

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

@@ -385,9 +385,42 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         //调用createScene方法生成scene数据和加入算法队列
         String sceneNum = "";
 
+
         String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
         String unicode = jsonObject.getString("creator") + "_" + jsonObject.getString("uuidtime");
 
+        int camType = jsonObject.getJSONObject("cam").getIntValue("type");
+        String cameraInStoreUrl = fdServiceUrl + "/service/manage/inner/cameraInStore";
+        Map<String, Object> cameraInStoreParams = new HashMap<>();
+        cameraInStoreParams.put("cameraType", camType);
+        cameraInStoreParams.put("snCode", jsonObject.getString("creator"));
+        ResultData post = myClient.post(cameraInStoreUrl, cameraInStoreParams);
+        log.info("---------cameraInStore result:{}-----------", post);
+
+        JSONObject configJson = JSONObject.parseObject(fYunFileService.getFileContent(ConstantFilePath.OSS_PREFIX + prefix + "config.fdage"));
+        String folderName = configJson.getString("id");
+        String customUserId = configJson.getString("customUserId");
+        String customUserName = configJson.getString("customUserName");
+        String customUserPwd = configJson.getString("customUserPwd");
+        if(StrUtil.isBlank(folderName) || StrUtil.isBlank(jsonObject.getString("creator"))){
+            throw new RuntimeException("config.json 文件有误!");
+        }
+
+        //调注册用户接口
+        Map<String, Object> params = new HashMap<>();
+        params.put("ryId", customUserId);
+        params.put("ryNo", customUserName);
+//        params.put("nickName", customUserName);//去掉昵称,又燕海的接口进行判断
+        params.put("password", AesUtil.encryptCBC(customUserPwd, userPasswordKey, userPasswordIv, AesUtil.ALMODE_CBC_NOPADDING));
+        String url = fdServiceUrl.concat(URL_ADD_UCENTER_USER);
+        myClient.post(url, params);
+        JyUser jyUser = jyUserService.getByRyId(customUserId);
+        User user = userService.getById(jyUser.getUserId());
+        if(Objects.isNull(jyUser)){
+            throw new RuntimeException("注册用户失败");
+        }
+
+
         Camera camera = cameraService.getByChildName(cameraName);
 
         if (camera == null) {
@@ -493,6 +526,12 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                 jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
                 jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
 
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
+        ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+        boolean isObj = jsonObject.containsKey("exportMeshObj") && jsonObject.getIntValue("exportMeshObj") == 1;
+        scenePlusExt.setIsObj(isObj ? CommonStatus.YES.code() : CommonStatus.NO.code());
+        scenePlusExtService.updateById(scenePlusExt);
+
         //上传app状态文件
         commonService.uploadStatusJson(sceneNum, scenePlusVO.getSceneStatus(),
                 scenePlusVO.getWebSite(),scenePlusVO.getThumb(),PayStatus.NOT_PAY.code(),
@@ -711,8 +750,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         ScenePro scenePro = sceneProService.getOne(
             new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, "/".concat(fileId).concat("/")));
 
-        boolean callV3 = callV3(scenePro, preParams, fdageJson, "api/scene/file/uploadSuccessBuild");
-        if(callV3) return ResultData.ok();
+//        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)) {
@@ -1975,7 +2014,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     }
 
     @Override
-    public ResultData uploadFile(MultipartFile file, String params) throws Exception {
+    public ResultData uploadFile(MultipartFile file, String params, String dir) throws Exception {
 
         log.info("upload-params: "+params);
         if (StringUtils.isEmpty(params)){
@@ -2045,7 +2084,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String filePath = mac.concat(File.separator).concat(fileId).concat(File.separator).concat(folderName);
 
         String yunFilePath = LocalConstants.BASE_PATH.concat(fYunFileConfig.getBucket()).concat(File.separator).concat(ConstantFilePath.OSS_PREFIX)
-        .concat(filePath).concat(File.separator).concat(fileName);
+                .concat(filePath).concat(File.separator).concat(dir).concat(fileName);
         log.info("yunFilePath:{}", yunFilePath);
 
         boolean needUpload = false;
@@ -2092,7 +2131,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         // 5. 如果相等,更新数据记录。如果不相等,返回上传失败结果。
         try {
         if (needUpload){
-        fYunFileService.uploadFile(file.getInputStream(),ConstantFilePath.OSS_PREFIX.concat(filePath).concat(File.separator).concat(fileName));
+            fYunFileService.uploadFile(file.getInputStream(),ConstantFilePath.OSS_PREFIX.concat(filePath).concat(File.separator).concat(dir).concat(fileName));
         File uploadFile = new File(yunFilePath);
         String fileMD5 = FileMd5Util.getFileMD5(uploadFile);