Преглед изворни кода

Merge branch 'feature-理光格式压缩包计算-2024-0924' into release

dengsixing пре 10 месеци
родитељ
комит
bf07256cf1

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

@@ -151,4 +151,13 @@ public class SceneFileController{
         return ResultData.ok();
     }
 
+    /**
+     * 计算理光相机格式场景
+     * @return
+     */
+    @PostMapping("uploadLiguang")
+    public ResultData uploadLiguang(String num, String snCode, String ossPath) throws Exception {
+        return sceneFileBuildService.uploadLiguang(num, snCode, ossPath);
+    }
+
 }

+ 54 - 0
src/main/java/com/fdkankan/contro/mq/listener/BuildLiguangListener.java

@@ -0,0 +1,54 @@
+package com.fdkankan.contro.mq.listener;
+
+import com.fdkankan.contro.mq.service.impl.BuildLiguangServiceImpl;
+import com.fdkankan.contro.mq.service.impl.BuildSceneServiceImpl;
+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;
+
+@Slf4j
+@Component
+public class BuildLiguangListener extends AbstrackBuildSceneListener {
+
+    @Value("${queue.modeling.liguang.modeling-pre:liguang-modeling-pre}")
+    private String queueModelingPre;
+    @Value("${queue.modeling.liguang.modeling-post:liguang-modeling-post}")
+    private String queueModelingPost;
+
+    @Autowired
+    private BuildLiguangServiceImpl buildSceneService;
+
+    /**
+     * 场景计算前置资源准备处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.liguang.modeling-pre:liguang-modeling-pre}"),
+            concurrency = "${maxThread.modeling.modeling-pre}"
+    )
+    public void buildScenePreHandler(Channel channel, Message message) throws Exception {
+        preHandle(channel,queueModelingPre,message,buildSceneService, "standard");
+    }
+
+    /**
+     * 场景计算后置结果处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.liguang.modeling-post:liguang-modeling-post}"),
+            concurrency = "${maxThread.modeling.modeling-post}"
+    )
+    public void buildScenePostHandler(Channel channel, Message message) throws Exception {
+        postHandle(channel,queueModelingPost,message,buildSceneService, "standard");
+
+    }
+}

+ 591 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/BuildLiguangServiceImpl.java

@@ -0,0 +1,591 @@
+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 cn.hutool.core.util.ZipUtil;
+import cn.hutool.extra.qrcode.QrCodeUtil;
+import cn.hutool.extra.qrcode.QrConfig;
+import cn.hutool.http.ContentType;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+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.bean.SyncLaserResultBean;
+import com.fdkankan.contro.constant.UserEditDataType;
+import com.fdkankan.contro.entity.*;
+import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.service.*;
+import com.fdkankan.fyun.config.FYunFileConfig;
+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.UploadFilePath;
+import com.fdkankan.model.enums.ModelTypeEnums;
+import com.fdkankan.model.utils.CreateHouseJsonUtil;
+import com.fdkankan.model.utils.CreateObjUtil;
+import com.fdkankan.model.utils.SceneUtil;
+import com.fdkankan.push.config.PushMessageConfig;
+import com.fdkankan.push.utils.PushMsgUtil;
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import com.fdkankan.redis.util.RedisUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.http.HttpHeaders;
+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 javax.annotation.Resource;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/20
+ **/
+@Slf4j
+@Service
+@RefreshScope
+public class BuildLiguangServiceImpl implements IBuildSceneService {
+
+    @Value("${queue.modeling.modeling-call}")
+    private String queueModelingCall;
+
+    @Value("${queue.modeling.single.modeling-call}")
+    private String singleModelingCall;
+
+    @Value("${model.type:#{null}}")
+    private String modelType;
+
+    @Value("${env:gn}")
+    private String env;
+
+    @Value("#{'${build.scene.post.not-delete-nas-nums:}'.split(',')}")
+    private List<String> notDeleteNasNumList;
+
+    @Value("4dkk.laserService.bucket")
+    private String laserBucket;
+
+    @Autowired
+    private RabbitMqProducer mqProducer;
+
+    @Resource
+    private FYunFileServiceInterface fYunFileService;
+    @Autowired
+    private ICameraDetailService cameraDetailService;
+    @Autowired
+    private ISceneEditInfoService sceneEditInfoService;
+    @Autowired
+    private ISceneEditControlsService sceneEditControlsService;
+
+    @Autowired
+    private FYunFileConfig fYunFileConfig;
+
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Autowired
+    private ISceneEditInfoExtService sceneEditInfoExtService;
+
+    @Autowired
+    private IUserIncrementService userIncrementService;
+
+    @Autowired
+    private IFdkkLaserService fdkkLaserService;
+
+
+    @Autowired
+    private IBuildSceneDTService buildSceneDTService;
+
+
+    @Autowired
+    private IIncrementTypeService incrementTypeService;
+
+    @Autowired
+    private ICompanyService companyService;
+    @Autowired
+    private ISceneAsynOperLogService sceneAsynOperLogService;
+    @Autowired
+    private ICommonService commonService;
+    @Autowired
+    private ISceneBuildProcessLogService sceneBuildProcessLogService;
+    @Autowired
+    private ISceneColdStorageService sceneColdStorageService;
+
+
+    @Override
+    public void buildScenePre(BuildSceneCallMessage message) throws Exception{
+        String num = message.getSceneNum();
+        try {
+            //重新计算时需要删除文件夹,否知使用缓存
+            if(new File(message.getPath() + File.separator + "results").exists()){
+                FileUtils.deleteDirectory(message.getPath() + File.separator + "results");
+            }
+            //由于刘强说caches会影响计算结果,所以这里删除caches
+            if(new File(message.getPath() + File.separator + "caches").exists()){
+                FileUtils.deleteDirectory(message.getPath() + File.separator + "caches");
+            }
+
+            //删除点位校准数据
+            if (Objects.nonNull(message.getExt())
+                    && message.getExt().containsKey("deleteExtras")
+                    && (Boolean) message.getExt().get("deleteExtras")) {
+                String extras = String.format(UploadFilePath.scene_result_data_path, num).concat("extras");
+                if(CollUtil.isNotEmpty(fYunFileService.listRemoteFiles(extras))){
+                    fYunFileService.deleteFolder(extras);
+                }
+            }
+
+            //根据相机类型,组装资源路径
+            //下载资源到本地
+            this.downLoadSource(message, message.getPath());
+
+
+            message.getBuildContext().put("cameraType",message.getCameraType());
+
+            message.setBizType("standard");
+
+            log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
+
+        }catch (Exception e){
+            log.error("场景计算前置处理出错,num"+num, e);
+            buildSceneDTService.handBaseFail("场景计算资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
+            throw e;
+        }
+    }
+
+    private String getOssPath(String path) {
+        String ossPath = ConstantFilePath.OSS_PREFIX
+                + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+        if (!ossPath.endsWith("/")) {
+            ossPath = ossPath.concat("/");
+        }
+        return ossPath;
+    }
+
+    @Override
+    public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
+        String ossPath = (String) buildSceneMqMessage.getExt().get("ossPath");
+        fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
+    }
+
+    @Override
+    public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
+        String sceneCode = message.getBuildContext().get("sceneNum").toString();
+        String path = message.getPath();
+        try {
+            // 上传计算日志
+            //如果是重复计算,没有走到计算逻辑,不需要上传日志文件
+            log.info("开始上传计算日志");
+            String buildLogPath = String.format(UploadFilePath.BUILD_LOG_PATH, sceneCode);
+            fYunFileService.uploadFile(path + File.separator + "console.log", buildLogPath + "console.log");
+            log.info("计算日志上传完成");
+
+            if (!message.getBuildSuccess()) {
+                log.error("建模失败,修改状态为失败状态");
+                scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
+                        .set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
+                        .eq(ScenePlus::getNum, sceneCode));
+
+                // 发送钉钉消息,计算失败
+                buildSceneDTService.handModelFail("计算失败", message.getPath(), sceneCode, message.getHostName());
+                return;
+            }
+            JSONObject fdageData = commonService.getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
+
+            ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneCode);
+
+            Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
+            Map<String, String> uploadFiles = commonService.getUploadFiles(scenePlus,path,cameraType,fdageData);
+
+            scenePlus.setPayStatus(PayStatus.PAY.code());
+            scenePlus.setUpdateTime(new Date());
+            scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
+
+            Integer videoVersion = fdageData.getInteger("videoVersion");
+            //读取计算结果文件生成videosJson
+            JSONObject videosJson = commonService.getVideosJson(path, videoVersion, sceneCode, cameraType);
+
+            ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+            boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
+
+            //上传全景图俯视图
+            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.deleteFolder(String.format(UploadFilePath.IMG_VIEW_PATH,  sceneCode) + ModelKind.THREE_D_TILE.code());
+            //上传文件
+            fYunFileService.uploadMulFiles(uploadFiles);
+
+            //修改oss上dam的内容编码
+            Map<String,String> damFileHeaders = new HashMap<>();
+            damFileHeaders.put("Content-Encoding","gzip");
+            String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
+            fYunFileService.uploadFile(damPath,  String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + ConstantFileName.modelUUID + "_50k.dam", damFileHeaders);
+
+            //拷贝部分文件到编辑目录,用于用户编辑
+            this.copyToEditDir(sceneCode);
+
+            //计算完毕后,同步全景图到缓存目录
+//            this.cachePanorama(path, sceneCode);
+
+            //生成houseTypejson并上传
+            boolean existHouseType = this.uploadHouseTypeJson(sceneCode, path);
+            scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
+
+            //生成floorpan.json
+            commonService.uploadFloorplanJson(sceneCode, path);
+
+            //重置异步操作记录
+            commonService.removeSceneAsynOperLog(sceneCode);
+
+            //清除用户编辑业务数据
+            Set<String> bizs = new HashSet<>();
+            bizs.add(UserEditDataType.BOX_MODEL.message());
+            bizs.add(UserEditDataType.FLOORPLAN.message());
+            bizs.add(UserEditDataType.FILTERS.message());
+            commonService.initUserEditData(sceneCode, bizs, null);
+
+            //上传计算结果文件
+            commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
+
+            //容量统计
+            Long space = commonService.getSpace(sceneCode);
+
+            //写入数据库
+            this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
+
+            Object[] editInfoArr = commonService.updateEditInfo(scenePlus);
+            SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
+            SceneEditInfoExt sceneEditInfoExt = (SceneEditInfoExt)editInfoArr[1];
+            SceneEditControls sceneEditControls = (SceneEditControls)editInfoArr[2];
+
+            //更新场景主表
+            //如果相机容量不足,需要把场景的paystatus改为容量不足状态
+            scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space));
+            //统计原始资源大小
+            scenePlusExt.setOrigSpace(FileUtil.size(new File(path.concat(File.separator).concat("capture"))));
+
+            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
+            commonService.writeSceneJson(sceneCode,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
+
+            String qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
+
+            qrLogo = ObjectUtils.isEmpty(qrLogo) && !ObjectUtils.isEmpty(sceneEditInfoExt.getShareLogoImg()) ? fYunFileConfig.getHost().concat(sceneEditInfoExt.getShareLogoImg()) : null;
+
+            createQrCode(sceneCode, scenePlusExt, qrLogo);
+
+//            //删除计算目录
+            if(CollUtil.isEmpty(notDeleteNasNumList) || !notDeleteNasNumList.contains(sceneCode)){
+                CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
+            }
+
+            this.uploadStatusJson(scenePlus, scenePlusExt);
+
+            scenePlusService.updateById(scenePlus);
+            scenePlusExtService.updateById(scenePlusExt);
+
+            log.info("场景计算结果处理结束,场景码:{}", sceneCode);
+
+        }catch (Exception e){
+            log.error("场景计算结果处理出错,num"+sceneCode, e);
+            buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
+            throw e;
+        }
+    }
+
+//    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 uploadFloorCad(String path, String num, Map<String, String> uploadFiles){
+
+        //户型图上传
+        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)){
+            floorCadList.stream().forEach(str->{
+                String substring = str.substring(str.lastIndexOf(File.separator) + 1);
+                String[] arr = substring.split("floor");
+                String[] arr2 = arr[1].split("\\.");
+                uploadFiles.put(str, String.format(dataViewPath, num, arr2[0], arr2[1]));
+            });
+        }
+
+    }
+
+    private void uploadStatusJson(ScenePlus scenePlus, ScenePlusExt scenePlusExt){
+        String num = scenePlus.getNum();
+        String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
+
+        Integer status = 1;
+        if(scenePlus.getSceneSource() == 4 || scenePlus.getSceneSource() == 5){//如果是激光场景,需要激光系统那边完全处理好之后再发mq通知更新状态
+            status = 0;
+        }
+
+        // 上传status JSON.
+        JSONObject statusJson = new JSONObject();
+        //临时将-2改成1,app还没完全更新
+        statusJson.put("status", status);
+        statusJson.put("webSite", scenePlusExt.getWebSite());
+        statusJson.put("sceneNum", num);
+        statusJson.put("thumb", scenePlusExt.getThumb());
+        statusJson.put("payStatus", scenePlus.getPayStatus());
+        statusJson.put("sceneScheme", scenePlusExt.getSceneScheme());
+        FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json", statusJson.toString());
+
+        Map<String,String> headers = new HashMap<>();
+        headers.put(HttpHeaders.CONTENT_TYPE, ContentType.JSON.getValue());
+        fYunFileService.uploadFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json", dataViewPath + "status.json", headers);
+    }
+
+    private void createQrCode(String num, ScenePlusExt scenePlusExt, String qrLogo) {
+        String localLogoPath = null;
+        if (!ObjectUtils.isEmpty(qrLogo)) {
+            try {
+                localLogoPath = ConstantFilePath.AGENT_PATH + qrLogo.substring(qrLogo.lastIndexOf("//") + 1);
+                HttpUtil.downloadFile(qrLogo, localLogoPath);
+            } catch (Exception e) {
+                log.error("公司logo下载失败:{}", qrLogo);
+                localLogoPath = null;
+            }
+        }
+        //生成二维码
+        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(1024);
+        qrConfig.setHeight(1024);
+        if(StrUtil.isNotEmpty(localLogoPath)){
+            qrConfig.setImg(localLogoPath);
+        }
+        QrCodeUtil.generate(scenePlusExt.getWebSite(), qrConfig, FileUtil.file(outPathZh));
+        QrCodeUtil.generate(scenePlusExt.getWebSite() + "&lang=en", qrConfig, FileUtil.file(outPathEn));
+        //上传二维码
+        fYunFileService.uploadFile(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + ".png");
+        fYunFileService.uploadFile(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + "_en.png");
+
+        if(!ObjectUtils.isEmpty(localLogoPath)){
+            FileUtils.deleteFile(localLogoPath);
+        }
+    }
+
+    private void pushMsgToApp(Integer pushChannel, String pushToken, int cameraType, String sceneName, String webSite){
+        log.info("推送消息,渠道是 {}, 手机token是 {}", pushChannel, pushToken);
+        if(Objects.isNull(pushChannel) || StrUtil.isBlank(pushToken)){
+            return;
+        }
+
+        String title = sceneName + "计算完成";
+        String body = "您上传的" + sceneName + "计算完成,点击查看";
+
+        try{
+            if(FYunTypeEnum.AWS.code().equals(fYunFileService.getFyunType())){
+                PushMsgUtil.googlePushMsg(ConstantFilePath.BASE_PATH + "/refreshToken.json", pushToken,
+                        title, body , webSite);
+                return;
+            }
+
+            PushMessageConfig pushConfig = null;
+            if(pushChannel == 0){
+                if(cameraType == 10 || cameraType == 13){
+                    //ios
+                    pushConfig = new PushMessageConfig(PushMessageConfig.IOS_KEY_Z, PushMessageConfig.IOS_SECRET_Z);
+                    pushConfig.sendIOSUnicast(pushToken,  "四维看看Minion",title, body, webSite);
+                }else {
+                    //ios
+                    pushConfig = new PushMessageConfig(PushMessageConfig.IOS_KEY, PushMessageConfig.IOS_SECRET);
+                    pushConfig.sendIOSUnicast(pushToken, "四维看看Pro",title, body, webSite);
+                }
+            }else {
+                if(cameraType == 10 || cameraType == 13){
+                    //ios
+                    //安卓
+                    pushConfig = new PushMessageConfig(PushMessageConfig.ANDROID_KEY_Z, PushMessageConfig.ANDROID_SECRET_Z);
+                    pushConfig.sendAndroidUnicast2(pushToken, "四维看看Minion",title, body, webSite);
+                }else {
+                    //安卓
+                    pushConfig = new PushMessageConfig(PushMessageConfig.ANDROID_KEY, PushMessageConfig.ANDROID_SECRET);
+                    pushConfig.sendAndroidUnicast(pushToken, "四维看看Pro",title, body, webSite);
+                }
+            }
+            log.info("消息推送结束!");
+        }catch (Exception e){
+            log.error("推送消息失败:", e);
+        }
+    }
+
+    private void copyToEditDir(String num) throws IOException {
+
+        String editImagesPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
+        String viewImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
+
+        String editDataPath = String.format(UploadFilePath.DATA_EDIT_PATH, num);
+        String viewDataPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
+
+        Map<String, String> map = new HashMap<>();
+        map.put(editImagesPath + "vision.modeldata", viewImagesPath + "vision.modeldata");
+        map.put(editImagesPath + "vision2.modeldata", viewImagesPath + "vision2.modeldata");
+        map.put(editDataPath + "floorplan_cad.json", viewDataPath + "floorplan_cad.json");
+
+        for (Entry<String, String> entry : map.entrySet()) {
+                fYunFileService.copyFileInBucket(entry.getValue(), entry.getKey());
+        }
+    }
+
+    private void updateDbPlus(int sceneSource,Long space,String videosJson, Long computeTime,boolean isObj,ScenePlusExt scenePlusExt){
+
+        scenePlusExt.setSpace(space);
+        scenePlusExt.setComputeTime(computeTime.toString());
+        scenePlusExt.setAlgorithmTime(new Date());
+        scenePlusExt.setVideos(videosJson);
+        scenePlusExt.setIsObj(isObj ? 1 : 0);
+
+        if(ModelTypeEnums.TILE_CODE.equals(modelType)){
+            scenePlusExt.setSceneScheme(3);
+        }
+
+        switch (SceneSource.get(sceneSource)){
+            case BM:
+                scenePlusExt.setSceneResolution(SceneResolution.two_K.code());
+                scenePlusExt.setSceneFrom(SceneFrom.PRO.code());
+                break;
+            case SM:
+                scenePlusExt.setSceneResolution(SceneResolution.one_k.code());
+                scenePlusExt.setSceneFrom(SceneFrom.LITE.code());
+                break;
+            case ZT:
+                scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
+                scenePlusExt.setSceneFrom(SceneFrom.MINION.code());
+                break;
+            case JG:
+                scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
+                scenePlusExt.setSceneFrom(SceneFrom.LASER.code());
+                break;
+            case SG:
+                scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
+                scenePlusExt.setSceneFrom(SceneFrom.LASER.code());
+                break;
+        }
+
+        String sceneKind = scenePlusExt.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
+        scenePlusExt.setSceneKind(sceneKind);
+//        scenePlusExt.setModelKind(modelKind);
+
+        //统计点位数量
+        Map<String, Integer> result = this.getShootCount(scenePlusExt);
+        Integer shootCount = result.get("shootCount");
+        Integer mixture = result.get("mixture");
+        scenePlusExt.setShootCount(shootCount);
+        scenePlusExt.setMixture(mixture);
+
+        scenePlusExtService.updateById(scenePlusExt);
+    }
+
+    private Map<String, Integer> getShootCount(ScenePlusExt scenePlusExt){
+
+        Map<String, Integer> result = new HashMap<>();
+
+        Integer shootCount = 0;
+        Integer mixture = Objects.isNull(scenePlusExt.getMixture()) ? 0 : scenePlusExt.getMixture();
+        String homePath = SceneUtil.getHomePath(scenePlusExt.getDataSource());
+        JSONObject dataFdageObj = JSON.parseObject(fYunFileService.getFileContent(homePath.concat("data.fdage")));
+        if(Objects.nonNull(dataFdageObj)){
+            JSONArray points = dataFdageObj.getJSONArray("points");
+            if(CollUtil.isNotEmpty(points)){
+                shootCount = points.size();
+            }
+        }
+        if(Objects.nonNull(shootCount) && shootCount > 0){
+            if(Objects.nonNull(scenePlusExt.getLocation()) && scenePlusExt.getLocation() == 6){
+                mixture = CommonStatus.YES.code().intValue();
+            }
+        }else{
+            String slamDataStr = fYunFileService.getFileContent(homePath.concat("slam_data.json"));
+            JSONObject slamDataObj = JSON.parseObject(slamDataStr);
+            if(Objects.nonNull(slamDataObj)){
+                JSONArray viewsInfo = slamDataObj.getJSONArray("views_info");
+                if(CollUtil.isNotEmpty(viewsInfo)){
+                    shootCount = viewsInfo.stream().mapToInt(info -> {
+                        return  ((JSONObject) info).getJSONArray("list_pose").size();
+                    }).sum();
+                }
+            }
+            mixture = CommonStatus.NO.code().intValue();
+        }
+
+        result.put("shootCount", shootCount);
+        result.put("mixture", mixture);
+
+        return result;
+    }
+
+    public static void main(String[] args) {
+        JSONObject dataFdageObj = JSON.parseObject(null);
+        System.out.println(dataFdageObj);
+    }
+
+
+    public boolean uploadHouseTypeJson(String num, String dataSource) {
+        String floorPlanCardFilePath = dataSource + File.separator + "results/floorplan_cad.json";
+        if (!new File(floorPlanCardFilePath).exists()) {
+            log.warn("floorplan_cad.json 文件不存在,文件路径:{}", floorPlanCardFilePath);
+            return false;
+        }
+        JSONObject json = CreateHouseJsonUtil.createHouseTypeJsonByCad(floorPlanCardFilePath);
+        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.USER_EDIT_PATH, num) + "houseType.json";
+        fYunFileService.uploadFile(json.toJSONString().getBytes(), hourseTypeJsonPath);
+
+        return true;
+    }
+}

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

@@ -28,4 +28,6 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
     ResultData rebuildScene(String num,Boolean force,Boolean deleteExtras, String from) throws IOException;
 
     ResultData copyDataAndBuild(String sourceBucet,String dataSource,String sceneVer) throws Exception;
+
+    ResultData uploadLiguang(String num, String snCode, String ossPath) throws Exception;
 }

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

@@ -45,6 +45,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
+import java.security.GeneralSecurityException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -303,6 +304,22 @@ public class CommonServiceImpl implements ICommonService {
         }
     }
 
+    public static void main(String[] args) throws GeneralSecurityException {
+        String content  = "<p>Dear Valued Customer,&nbsp;</p>\n" +
+                "<p>&nbsp;</p>\n" +
+                "<p>The scene \"scene_name\" has been successfully calculated, please review the following:&nbsp;<a href=\"scene_link\" target=\"_blank\" rel=\"noopener\">scene_link</a>&nbsp;</p>\n" +
+                "<p>&nbsp;</p>\n" +
+                "<p>If you need to edit the scene, the User Manual can provide instructions: <a href=\"help_link\" target=\"_blank\" rel=\"noopener\">help_link</a>&nbsp;</p>\n" +
+                "<p>&nbsp;</p>\n" +
+                "<p>Sincerely,&nbsp;</p>\n" +
+                "<p>4Dage Support Team</p>\n" +
+                "<p>&nbsp;</p>\n" +
+                "<p>------------------</p>\n" +
+                "<p><img src=\"http://4dkk.4dage.com/ucenter/image/4dkankan_en.png\" /></p>\n" +
+                "<p><br /><strong><em>Web:</em></strong><a href=\"http://eur.4dkankan.com/\" target=\"_blank\" rel=\"noopener\">eur.4dkankan.com</a></p>";
+        SendMailAcceUtils.sendMail("4Dkankan@4dage.com", "6996790AAaa", "smtp.exmail.qq.com", "qinyongcheng@cgaii.com", "The Scene Calculation is Now Complete.", content, null);
+    }
+
     public String getOssOrignPath(String path) {
         String ossPath = ConstantFilePath.OSS_PREFIX
                 + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")

+ 161 - 6
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -98,6 +98,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Value("${queue.modeling.intermit.modeling-pre}")
     private String queueIntermitModelingPre;
 
+    @Value("${queue.modeling.liguang.modeling-pre:liguang-modeling-pre}")
+    private String queueLiguangModelingPre;
+
     @Value("${v3.controlUrl:#{null}}")
     private String v3controlUrl;
 
@@ -1305,13 +1308,28 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             message.setRebuild("1");
         }
 
-        if(Objects.nonNull(scenePlusExt.getLocation()) && scenePlusExt.getLocation() == 7){
-            //发送到全景看看进行初始化
-            JSONObject jsonObject = JSONObject.parseObject(fYunFileService.getFileContent(SceneUtil.getHomePath(scenePlusExt.getDataSource()) + "data.fdage"));
-            intermitSceneService.sendMq(num, jsonObject, CommonSuccessStatus.WAITING.code());
-            rabbitMqProducer.sendByWorkQueue(queueIntermitModelingPre, message);
+        String ossOrignPath = commonService.getOssOrignPath(path);
+        String ossPath = fYunFileService.getFileContent(ossOrignPath + "custom.txt");
+        if(StrUtil.isNotEmpty(ossPath) && ossPath.contains("MKT862")){
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("location", 4);
+            BuildSceneCallMessage mqMessage = getBuildSceneMqMessage(num, 13L, null, jsonObject, "V3",
+                    path);
+            mqMessage.getExt().put("deleteExtras", deleteExtras);
+            mqMessage.getExt().put("ossPath", ossPath);
+            //故宫博物馆需求,特殊算法参数
+            mqMessage.getExt().put("splitType", "SPLIT_V3");
+            mqMessage.getExt().put("skyboxType", "SKYBOX_V6");
+            rabbitMqProducer.sendByWorkQueue(queueLiguangModelingPre, mqMessage);
         }else{
-            rabbitMqProducer.sendByWorkQueue(queueModelingPre, message);
+            if(Objects.nonNull(scenePlusExt.getLocation()) && scenePlusExt.getLocation() == 7){
+                //发送到全景看看进行初始化
+                JSONObject jsonObject = JSONObject.parseObject(fYunFileService.getFileContent(SceneUtil.getHomePath(scenePlusExt.getDataSource()) + "data.fdage"));
+                intermitSceneService.sendMq(num, jsonObject, CommonSuccessStatus.WAITING.code());
+                rabbitMqProducer.sendByWorkQueue(queueIntermitModelingPre, message);
+            }else{
+                rabbitMqProducer.sendByWorkQueue(queueModelingPre, message);
+            }
         }
 
         scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
@@ -1841,4 +1859,141 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return ResultData.ok();
     }
 
+    @Override
+    public ResultData uploadLiguang(String num, String snCode, String ossPath) throws Exception {
+
+        if(StrUtil.isEmpty(ossPath)){
+            return ResultData.error(-1, "资源路径不能为空");
+        }
+        if(!StrUtil.endWith(ossPath, "/")){
+            ossPath = ossPath + "/";
+        }
+
+        if(StrUtil.isEmpty(num) && StrUtil.isEmpty(snCode)){
+            return ResultData.error(-1, "场景码或者相机码不能同时为空");
+        }
+
+        String fileId = null, unicode = null;
+        String dataSource = null;
+        String[] arr = null;
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+        ScenePlusExt scenePlusExt = null;
+        SceneEditInfo sceneEditInfo = null;
+        SceneEditInfoExt sceneEditInfoExt = null;
+        SceneEditControls sceneEditControls = null;
+        if(Objects.nonNull(scenePlus)){
+            scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+            sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+            sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
+            sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
+            dataSource = scenePlusExt.getDataSource();
+            arr = dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "").split("/");
+            fileId = arr[1];
+            unicode = arr[2];
+            snCode = arr[0];
+        }else{
+            //生成场景码
+            num = scene3dNumService.generateSceneNum(CameraTypeEnum.DOUBLE_EYE_TURN.getType());
+        }
+
+        Camera camera = cameraService.getBySnCode(snCode);
+        CameraDetail cameraDetail = cameraDetailService.getByCameraId(camera.getId());
+
+        //生成unicode
+        if(StrUtil.isEmpty(unicode)){
+            unicode = snCode + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss");
+        }
+
+        //生成fileid
+        if (StrUtil.isEmpty(fileId)) {
+            fileId = new SnowflakeIdGenerator(0, 0).nextId() + "";
+            SceneFileBuild sceneFileBuild = new SceneFileBuild();
+            sceneFileBuild.setChildName(snCode);
+            sceneFileBuild.setFileId(fileId);
+            sceneFileBuild.setUnicode(unicode);
+            sceneFileBuild.setTotalPicNum(0);
+            sceneFileBuild.setChunks(0);
+            sceneFileBuild.setCreateTime(new Date());
+            this.save(sceneFileBuild);
+        }
+
+        dataSource = ConstantFilePath.BUILD_MODEL_PATH + snCode + "/" + fileId + "/" + unicode;
+
+        String dataFdageStr = fYunFileService.getFileContent(ossPath + "data.fdage");
+        JSONObject dataFdage = JSON.parseObject(dataFdageStr);
+        String name = dataFdage.getString("name");
+
+        //生成主表
+        if(Objects.isNull(scenePlus)){
+            scenePlus = new ScenePlus();
+            scenePlus.setNum(num);
+            scenePlus.setDescription("<p>四维看看 让空间讲故事</p>");
+            scenePlus.setUserId(cameraDetail.getUserId());
+            scenePlus.setPhoneId(snCode);
+            scenePlus.setTitle(name);
+            scenePlus.setSceneStatus(SceneStatus.wait.code());
+            scenePlus.setSceneSource(SceneSource.ZT.code());
+            scenePlus.setPayStatus(PayStatus.PAY.code());
+            scenePlus.setSceneType(SceneType.OTHER.code());
+            scenePlus.setCameraId(camera.getId());
+        }
+        scenePlusService.saveOrUpdate(scenePlus);
+        if(Objects.isNull(scenePlusExt)){
+            scenePlusExt = new ScenePlusExt();
+            scenePlusExt.setPlusId(scenePlus.getId());
+            scenePlusExt.setDataSource(dataSource);
+            scenePlusExt.setWebSite(mainUrl + "/smg.html?m=" + num);
+            scenePlusExt.setThumb(ConstantUrl.DEFAULT_SCENE_PIC);
+            scenePlusExt.setSceneScheme(SceneScheme.FOUR_K.code());
+            scenePlusExt.setSceneResolution(SceneResolution.four_K.code());
+            scenePlusExt.setSceneFrom(SceneFrom.MINION.code());
+            scenePlusExt.setSceneKind(SceneKind.TILES.code());
+            scenePlusExt.setModelKind(ModelKind.DAM.code());
+            scenePlusExt.setYunFileBucket(fYunFileConfig.getBucket());
+            scenePlusExt.setLocation(4);
+            scenePlusExt.setBuildType("V3");
+        }
+        scenePlusExtService.saveOrUpdate(scenePlusExt);
+
+        //生成编辑表
+        if(Objects.isNull(sceneEditInfo)){
+            sceneEditInfo = new SceneEditInfo();
+            sceneEditInfo.setScenePlusId(scenePlus.getId());
+            sceneEditInfo.setTitle(name);
+            sceneEditInfo.setDescription(scenePlus.getDescription());
+        }
+        sceneEditInfoService.saveOrUpdate(sceneEditInfo);
+        if(Objects.isNull(sceneEditInfoExt)){
+            sceneEditInfoExt = new SceneEditInfoExt();
+            sceneEditInfoExt.setScenePlusId(scenePlus.getId());
+            sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
+        }
+        sceneEditInfoExtService.saveOrUpdate(sceneEditInfoExt);
+
+        //生成控制表
+        if(Objects.isNull(sceneEditControls)){
+            sceneEditControls = new SceneEditControls();
+            sceneEditControls.setEditInfoId(sceneEditInfo.getId());
+        }
+        sceneEditControlsService.saveOrUpdate(sceneEditControls);
+
+        //上传data.fdage和custom.txt到home目录
+        String homePath = dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, ConstantFilePath.OSS_PREFIX);
+        fYunFileService.uploadFile(dataFdageStr.getBytes(StandardCharsets.UTF_8), homePath + "data.fdage");
+        fYunFileService.uploadFile(ossPath.getBytes(StandardCharsets.UTF_8), homePath + "custom.txt");
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("location", 4);
+        BuildSceneCallMessage mqMessage = getBuildSceneMqMessage(num, 13L, null, jsonObject, "V3",
+                dataSource);
+        mqMessage.getExt().put("deleteExtras", true);
+        mqMessage.getExt().put("ossPath", ossPath);
+        //故宫博物馆需求,特殊算法参数
+        mqMessage.getExt().put("splitType", "SPLIT_V3");
+        mqMessage.getExt().put("skyboxType", "SKYBOX_V6");
+        rabbitMqProducer.sendByWorkQueue(queueLiguangModelingPre, mqMessage);
+
+        //推送mq到前置计算
+        return ResultData.ok(num);
+    }
 }