|
@@ -1,14 +1,13 @@
|
|
|
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.thread.ThreadUtil;
|
|
|
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;
|
|
@@ -17,42 +16,40 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
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.bean.SyncLaserResultBean;
|
|
|
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;
|
|
|
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;
|
|
|
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 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;
|
|
|
+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.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -68,6 +65,7 @@ import java.util.stream.Collectors;
|
|
|
**/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
+@RefreshScope
|
|
|
public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
|
|
|
@Value("${queue.modeling.modeling-call}")
|
|
@@ -79,19 +77,19 @@ 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;
|
|
|
|
|
|
+ @Value("#{'${build.scene.post.not-delete-nas-nums:}'.split(',')}")
|
|
|
+ private List<String> notDeleteNasNumList;
|
|
|
+
|
|
|
+ @Value("4dkk.laserService.bucket")
|
|
|
+ private String laserBucket;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RabbitMqProducer mqProducer;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private FYunFileServiceInterface fYunFileService;
|
|
|
@Autowired
|
|
|
private ICameraDetailService cameraDetailService;
|
|
@@ -134,16 +132,41 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
private ICommonService commonService;
|
|
|
@Autowired
|
|
|
private ISceneBuildProcessLogService sceneBuildProcessLogService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneColdStorageService sceneColdStorageService;
|
|
|
+ @Autowired
|
|
|
+ private IWbService wbService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void buildScenePre(BuildSceneCallMessage message) throws Exception{
|
|
|
- boolean success = false;
|
|
|
String num = message.getSceneNum();
|
|
|
try {
|
|
|
+ Map<String, Object> sceneStatusParam = new HashMap<>();
|
|
|
+ sceneStatusParam.put("num", num);
|
|
|
+ sceneStatusParam.put("status", 0);
|
|
|
+ commonService.sendUpdateSceneStatusMqToQueues(sceneStatusParam);
|
|
|
//重新计算时需要删除文件夹,否知使用缓存
|
|
|
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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户相机重新全量上传,需要解冻结
|
|
|
+ sceneColdStorageService.unfreeze(num, "用户相机重新全量上传", message.getPath());
|
|
|
|
|
|
//根据相机类型,组装资源路径
|
|
|
//下载资源到本地
|
|
@@ -174,16 +197,18 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
|
|
|
message.getBuildContext().put("cameraType",message.getCameraType());
|
|
|
|
|
|
- // 判断企业是否配置了弹性伸缩
|
|
|
- if (message.getFlexibility() == 0) {
|
|
|
- //发送mq,就进行计算
|
|
|
- mqProducer.sendByWorkQueue(queueModelingCall, message);
|
|
|
- } else {
|
|
|
- //发送mq,就进行计算
|
|
|
- mqProducer.sendByWorkQueue(singleModelingCall, message);
|
|
|
+ //查询是否超过比例50%,如果超过,则启动128G服务器弹性伸缩
|
|
|
+ Float maxRate = fdageJson.getFloat("maxRate");
|
|
|
+ if(env.equals("gn") && Objects.nonNull(maxRate) && maxRate > 50){
|
|
|
+ Map<String, Object> ext = message.getExt();
|
|
|
+ if(Objects.isNull(ext)){
|
|
|
+ ext = new HashMap<>();
|
|
|
+ message.setExt(ext);
|
|
|
+ }
|
|
|
+ ext.put("128G", 1);
|
|
|
}
|
|
|
|
|
|
- success = true;
|
|
|
+ message.setBizType("standard");
|
|
|
|
|
|
log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
|
|
|
|
|
@@ -210,7 +235,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
|
|
|
String sceneCode = message.getBuildContext().get("sceneNum").toString();
|
|
@@ -229,37 +253,29 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
.set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
|
|
|
.eq(ScenePlus::getNum, sceneCode));
|
|
|
|
|
|
+ wbService.sendMq(sceneCode, CommonSuccessStatus.FAIL.code());
|
|
|
+
|
|
|
// 发送钉钉消息,计算失败
|
|
|
buildSceneDTService.handModelFail("计算失败", message.getPath(), sceneCode, message.getHostName());
|
|
|
return;
|
|
|
}
|
|
|
- JSONObject fdageData = getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
|
|
|
+ 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 = getUploadFiles(scenePlus,path,cameraType,fdageData);
|
|
|
-
|
|
|
- //计算场景消耗磁盘空间
|
|
|
- long space = this.calUseSpace(uploadFiles);
|
|
|
-
|
|
|
+ Map<String, String> uploadFiles = commonService.getUploadFiles(scenePlus,path,cameraType,fdageData);
|
|
|
|
|
|
scenePlus.setPayStatus(PayStatus.PAY.code());
|
|
|
- //如果相机容量不足,需要把场景的paystatus改为容量不足状态
|
|
|
- if (cameraType != 14) {
|
|
|
- scenePlus.setPayStatus(this.getPayStatus(scenePlus.getCameraId(), space));
|
|
|
- }
|
|
|
scenePlus.setUpdateTime(new Date());
|
|
|
scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
|
|
|
|
|
|
Integer videoVersion = fdageData.getInteger("videoVersion");
|
|
|
//读取计算结果文件生成videosJson
|
|
|
- JSONObject videosJson = this.getVideosJson(path, videoVersion, sceneCode, cameraType);
|
|
|
+ JSONObject videosJson = commonService.getVideosJson(path, videoVersion, sceneCode, cameraType);
|
|
|
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
|
|
|
- //写入数据库
|
|
|
- this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
|
|
|
|
|
|
//上传全景图俯视图
|
|
|
this.uploadFloorCad(path, sceneCode, uploadFiles);
|
|
@@ -267,24 +283,15 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
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");
|
|
|
- // 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);
|
|
|
- });
|
|
|
+ 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);
|
|
@@ -293,31 +300,53 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
// this.cachePanorama(path, sceneCode);
|
|
|
|
|
|
//生成houseTypejson并上传
|
|
|
- boolean existHouseType = this.uploadHouseTypeJson(sceneCode, scenePlusExt.getDataSource());
|
|
|
+ boolean existHouseType = this.uploadHouseTypeJson(sceneCode, path);
|
|
|
scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
|
|
|
|
|
|
//生成floorpan.json
|
|
|
- commonService.uploadFloorplanJson(sceneCode, scenePlusExt.getDataSource());
|
|
|
+ commonService.uploadFloorplanJson(sceneCode, path);
|
|
|
|
|
|
//重置异步操作记录
|
|
|
- this.removeSceneAsynOperLog(sceneCode);
|
|
|
+ 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());
|
|
|
|
|
|
- Object[] editInfoArr = this.updateEditInfo(scenePlus);
|
|
|
+ //容量统计
|
|
|
+ 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 (cameraType == 14) {
|
|
|
//计算成功 激光转台相机 同步 请求
|
|
|
- fdkkLaserService.syncBuildResult(scenePlus.getNum(), scenePlusExt.getDataSource(),scenePlus.getCreateTime());
|
|
|
+ fdkkLaserService.syncBuildResult(
|
|
|
+ SyncLaserResultBean.builder()
|
|
|
+ .num(sceneCode).dataSource(path)
|
|
|
+ .sceneStatus(2)
|
|
|
+ .createTime(scenePlus.getCreateTime())
|
|
|
+ .shootCount(scenePlusExt.getShootCount())
|
|
|
+ .payStatus(scenePlus.getPayStatus())
|
|
|
+ .mixture(scenePlusExt.getMixture())
|
|
|
+ .version(SceneVersionType.V4.code()).build());
|
|
|
sceneEditControlsService.update(new LambdaUpdateWrapper<SceneEditControls>().set(SceneEditControls::getShowMap,0)
|
|
|
.eq(SceneEditControls::getEditInfoId,sceneEditInfo.getId()));
|
|
|
sceneEditControls.setShowMap(0);
|
|
@@ -325,11 +354,12 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
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);
|
|
|
+ commonService.writeSceneJson(sceneCode,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
|
|
|
|
|
|
String qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
|
|
|
|
|
@@ -342,46 +372,40 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
String pushToken = fdageData.getString("pushToken");
|
|
|
this.pushMsgToApp(pushChannel,pushToken, cameraType, scenePlus.getTitle(), scenePlusExt.getWebSite());
|
|
|
|
|
|
- //更新场景主表
|
|
|
- scenePlusService.updateById(scenePlus);
|
|
|
+// //删除计算目录
|
|
|
+ if(CollUtil.isEmpty(notDeleteNasNumList) || !notDeleteNasNumList.contains(sceneCode)){
|
|
|
+ CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- //删除计算目录
|
|
|
- CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
|
|
|
+ this.uploadStatusJson(scenePlus, scenePlusExt);
|
|
|
+
|
|
|
+ scenePlusService.updateById(scenePlus);
|
|
|
+ scenePlusExtService.updateById(scenePlusExt);
|
|
|
|
|
|
//国际环境需要发邮件通知
|
|
|
- if("eur".equals(env)){
|
|
|
- commonService.sendEmail(sceneCode);
|
|
|
+ if("eur".equals(env) &&
|
|
|
+ !scenePlus.getSceneSource().equals(SceneSource.JG.code()) &&
|
|
|
+ !scenePlus.getSceneSource().equals(SceneSource.SG.code())){
|
|
|
+ commonService.sendEmail(sceneCode, "standar");
|
|
|
}
|
|
|
|
|
|
+ wbService.sendMq(sceneCode, CommonSuccessStatus.SUCCESS.code());
|
|
|
+
|
|
|
log.info("场景计算结果处理结束,场景码:{}", sceneCode);
|
|
|
|
|
|
}catch (Exception e){
|
|
|
log.error("场景计算结果处理出错,num"+sceneCode, e);
|
|
|
buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
|
|
|
throw e;
|
|
|
+ } finally {
|
|
|
+ Map<String, Object> sceneStatusParam = new HashMap<>();
|
|
|
+ sceneStatusParam.put("num", sceneCode);
|
|
|
+ sceneStatusParam.put("status", message.getBuildSuccess() ? 1 : -1);
|
|
|
+ commonService.sendUpdateSceneStatusMqToQueues(sceneStatusParam);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void removeSceneAsynOperLog(String num){
|
|
|
- List<SceneAsynOperLog> list = sceneAsynOperLogService.list(new LambdaQueryWrapper<SceneAsynOperLog>().eq(SceneAsynOperLog::getNum, num));
|
|
|
- if(CollUtil.isEmpty(list)){
|
|
|
- return;
|
|
|
- }
|
|
|
- //删除数据库记录
|
|
|
- List<Long> deleteIdList = list.parallelStream().map(item -> item.getId()).collect(Collectors.toList());
|
|
|
- sceneAsynOperLogService.removeByIds(deleteIdList);
|
|
|
-
|
|
|
- list.parallelStream().forEach(item -> {
|
|
|
- if(StrUtil.isNotEmpty(item.getUrl())){
|
|
|
- try {
|
|
|
- fYunFileService.deleteFile(item.getUrl());
|
|
|
- } catch (IOException e) {
|
|
|
- log.warn("删除oss全景图下载压缩包失败,key:{}", item.getUrl());
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
// private void cachePanorama(String dataSource, String num){
|
|
|
// String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
|
|
|
// //将全景图缓存到缓存目录
|
|
@@ -400,136 +424,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
- private Map<String, String> getUploadFiles(ScenePlus scenePlus,String path,Integer cameraType,JSONObject fdageData) throws Exception {
|
|
|
- if (ObjectUtils.isEmpty(scenePlus)) {
|
|
|
- throw new Exception("未找到场景信息:" + path);
|
|
|
- }
|
|
|
-
|
|
|
- String projectNum = scenePlus.getNum();
|
|
|
-
|
|
|
- String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, projectNum);
|
|
|
- String imagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, projectNum);
|
|
|
- String videoPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, projectNum);
|
|
|
- String resultsPath = path + File.separator + "results" + File.separator;
|
|
|
-
|
|
|
- String uploadData = FileUtils.readFile(resultsPath + "upload.json");
|
|
|
- JSONArray array = JSONObject.parseObject(uploadData).getJSONArray("upload");
|
|
|
-
|
|
|
- JSONObject fileJson = null;
|
|
|
- String fileName = "";
|
|
|
-
|
|
|
- Map<String, String> map = new HashMap();
|
|
|
-
|
|
|
- for (int i = 0; i < array.size(); ++i) {
|
|
|
- fileJson = array.getJSONObject(i);
|
|
|
- fileName = fileJson.getString("file");
|
|
|
- String filePath = resultsPath + fileName;
|
|
|
-
|
|
|
- if (!(new File(filePath)).exists()) {
|
|
|
- throw new Exception(filePath + "文件不存在");
|
|
|
- }
|
|
|
-
|
|
|
- if ("vision2.txt".equals(fileName)) {
|
|
|
- CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision2.txt", resultsPath + "vision2.modeldata");
|
|
|
- map.put(resultsPath + "vision2.modeldata", imagesPath + "vision2.modeldata");
|
|
|
- map.put(resultsPath + "vision2.txt", imagesPath + "vision2.txt");
|
|
|
- }
|
|
|
-
|
|
|
- if (fileJson.getIntValue("clazz") == 2) {
|
|
|
- map.put(filePath, imagesPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
|
|
|
- } else if (fileJson.getIntValue("clazz") == 3) {
|
|
|
- map.put(filePath, imagesPath + "pan/high/" + fileName.replace("high/", ""));
|
|
|
- } else if (fileJson.getIntValue("clazz") == 4) {
|
|
|
- map.put(filePath, imagesPath + "pan/low/" + fileName.replace("low/", ""));
|
|
|
- } else if (fileJson.getIntValue("clazz") == 5) {
|
|
|
- map.put(filePath, imagesPath + fileName);
|
|
|
- } else if (fileJson.getIntValue("clazz") == 7) {
|
|
|
- map.put(filePath, imagesPath + fileName);
|
|
|
- } else if (fileJson.getIntValue("clazz") == 10) {
|
|
|
- String updown = FileUtils.readFile(filePath);
|
|
|
- JSONObject updownJson = JSONObject.parseObject(updown);
|
|
|
- String mappingOssPath = String.format("scene_edit_data/%s/data/", projectNum) + fileName.replace("updown", "mapping");
|
|
|
- map.put(filePath, mappingOssPath);
|
|
|
- } else {
|
|
|
- if (fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("clazz") == 12) {
|
|
|
- map.put(filePath, videoPath + fileName.replace("videos/", ""));
|
|
|
- if (fileName.contains(".mp4")) {
|
|
|
- map.put(resultsPath + fileName.replace("mp4", "flv"), videoPath + fileName.replace("videos/", "").replace("mp4", "flv"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (fileJson.getIntValue("clazz") == 16) {
|
|
|
- map.put(filePath, dataViewPath + fileName);
|
|
|
- }
|
|
|
-
|
|
|
- if (fileJson.getIntValue("clazz") == 18) {
|
|
|
- map.put(filePath, imagesPath + fileName);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //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(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");
|
|
|
- map.put(resultsPath + "vision.txt", imagesPath + "vision.txt");
|
|
|
- map.put(resultsPath + "vision.modeldata", imagesPath + "vision.modeldata");
|
|
|
-
|
|
|
- log.info("数据转换完成:" + projectNum);
|
|
|
- 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_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");
|
|
|
- map.put(path + File.separator + "capture/Up2.xml", dataViewPath + "Up2.xml");
|
|
|
- map.put(path + File.separator + "capture/Up.txt", dataViewPath + "Up.txt");
|
|
|
- map.put(path + File.separator + "capture/Up2.txt", dataViewPath + "Up2.txt");
|
|
|
- return map;
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- private JSONObject getFdageData(String dataFdagePath) {
|
|
|
- log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
|
|
|
- String data = FileUtils.readFile(dataFdagePath);
|
|
|
- //获取data.fdage的内容
|
|
|
- JSONObject dataJson = new JSONObject();
|
|
|
- if(data!=null){
|
|
|
- dataJson = JSONObject.parseObject(data);
|
|
|
- }
|
|
|
- return dataJson;
|
|
|
- }
|
|
|
|
|
|
private void uploadFloorCad(String path, String num, Map<String, String> uploadFiles){
|
|
|
|
|
@@ -548,66 +443,19 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void writeSceneJson(String num, JSONObject videosJson, SceneEditInfo sceneEditInfo, SceneEditInfoExt sceneEditInfoExt,
|
|
|
- SceneEditControls sceneEditControls, ScenePlus scenePlus, ScenePlusExt scenePlusExt,Company company){
|
|
|
+ private void uploadStatusJson(ScenePlus scenePlus, ScenePlusExt scenePlusExt){
|
|
|
+ String num = scenePlus.getNum();
|
|
|
String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
|
|
|
- SceneJsonBean sceneJson = new SceneJsonBean();
|
|
|
- BeanUtil.copyProperties(sceneEditInfoExt, sceneJson);
|
|
|
- BeanUtil.copyProperties(sceneEditInfo, sceneJson);
|
|
|
- SceneEditControlsVO sceneEditControlsVO = BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class);
|
|
|
- sceneJson.setControls(sceneEditControlsVO);
|
|
|
- sceneJson.setNum(num);
|
|
|
- sceneJson.setCreateTime(scenePlus.getCreateTime());
|
|
|
- sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
|
- sceneJson.setVersion(sceneEditInfo.getVersion());
|
|
|
- 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());
|
|
|
-
|
|
|
- if(!ObjectUtils.isEmpty(company)){
|
|
|
- String userViewPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
|
- String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
|
- String localLogoPath = null;
|
|
|
- if (StrUtil.isNotEmpty(company.getTopLogo())) {
|
|
|
- localLogoPath = ConstantFilePath.AGENT_PATH + company.getTopLogo().substring(company.getTopLogo().lastIndexOf("//") + 1);
|
|
|
- HttpUtil.downloadFile(company.getTopLogo(), localLogoPath);
|
|
|
- fYunFileService.uploadFile(localLogoPath, userViewPath + "loadingLogo-user.png");
|
|
|
- fYunFileService.uploadFile(localLogoPath, userEditPath + "loadingLogo-user.png");
|
|
|
- sceneJson.setLoadingLogo("user");
|
|
|
- sceneJson.setLoadingLogoFile("loadingLogo-user.png");
|
|
|
- sceneEditInfo.setLoadingLogo("user");
|
|
|
- sceneEditInfo.setLoadingLogoFile("loadingLogo-user.png");
|
|
|
- }
|
|
|
- if (StrUtil.isNotEmpty(company.getFloorLogo())) {
|
|
|
- localLogoPath = ConstantFilePath.AGENT_PATH + company.getFloorLogo().substring(company.getFloorLogo().lastIndexOf("//") + 1);
|
|
|
- HttpUtil.downloadFile(company.getFloorLogo(), localLogoPath);
|
|
|
- fYunFileService.uploadFile(localLogoPath, userViewPath + "floorLogo-user.png");
|
|
|
- fYunFileService.uploadFile(localLogoPath, userEditPath + "floorLogo-user.png");
|
|
|
- sceneJson.setFloorLogo("user");
|
|
|
- sceneJson.setFloorLogoFile("floorLogo-user.png");
|
|
|
-
|
|
|
- sceneEditInfo.setFloorLogo("user");
|
|
|
- sceneEditInfo.setFloorLogoFile("floorLogo-user.png");
|
|
|
- }
|
|
|
- if(!ObjectUtils.isEmpty(localLogoPath)){
|
|
|
- sceneEditInfoService.updateById(sceneEditInfo);
|
|
|
- FileUtils.deleteFile(localLogoPath);
|
|
|
- }
|
|
|
+ Integer status = 1;
|
|
|
+ if(scenePlus.getSceneSource() == 4 || scenePlus.getSceneSource() == 5){//如果是激光场景,需要激光系统那边完全处理好之后再发mq通知更新状态
|
|
|
+ status = 0;
|
|
|
}
|
|
|
- String sceneJsonStr = JSON.toJSONString(sceneJson);
|
|
|
- //上传sceneJson文件
|
|
|
- fYunFileService.uploadFile(sceneJsonStr.getBytes(), dataViewPath + "scene.json");
|
|
|
- //scenejson写入缓存
|
|
|
- redisUtil.set(String.format(RedisKey.SCENE_JSON, num), sceneJsonStr);
|
|
|
|
|
|
// 上传status JSON.
|
|
|
JSONObject statusJson = new JSONObject();
|
|
|
//临时将-2改成1,app还没完全更新
|
|
|
- statusJson.put("status", 1);
|
|
|
+ statusJson.put("status", status);
|
|
|
statusJson.put("webSite", scenePlusExt.getWebSite());
|
|
|
statusJson.put("sceneNum", num);
|
|
|
statusJson.put("thumb", scenePlusExt.getThumb());
|
|
@@ -615,9 +463,9 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
statusJson.put("sceneScheme", scenePlusExt.getSceneScheme());
|
|
|
FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json", statusJson.toString());
|
|
|
|
|
|
- fYunFileService.uploadFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json",
|
|
|
- dataViewPath + "status.json");
|
|
|
-
|
|
|
+ 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) {
|
|
@@ -635,9 +483,9 @@ 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.setWidth(1024);
|
|
|
+ qrConfig.setHeight(1024);
|
|
|
+ if(StrUtil.isNotEmpty(localLogoPath)){
|
|
|
qrConfig.setImg(localLogoPath);
|
|
|
}
|
|
|
QrCodeUtil.generate(scenePlusExt.getWebSite(), qrConfig, FileUtil.file(outPathZh));
|
|
@@ -653,7 +501,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
|
|
|
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)){
|
|
|
+ if(Objects.isNull(pushChannel) || StrUtil.isBlank(pushToken)){
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -714,93 +562,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private JSONObject getVideosJson(String path, Integer videoVersion, String projectNum, int cameraType) throws Exception {
|
|
|
- //读取videos_hdr_param.json, 保存点位视频的value
|
|
|
- Map<String, Object> videoMap = new HashMap<>();
|
|
|
- String videosHdr = FileUtils.readFile(path + File.separator + "results/videos/videos_hdr_param.json");
|
|
|
- JSONArray videoArray = null;
|
|
|
- if(StringUtils.isNotEmpty(videosHdr)){
|
|
|
- videoArray = JSONObject.parseObject(videosHdr).getJSONArray("hdr_param");
|
|
|
- }
|
|
|
- if(videoArray != null){
|
|
|
- for(int i = 0, len = videoArray.size(); i < len; i++) {
|
|
|
- videoMap.put(videoArray.getJSONObject(i).getString("name"), videoArray.getJSONObject(i).getString("value"));
|
|
|
- if(videoArray.getJSONObject(i).containsKey("fov")){
|
|
|
- videoMap.put(videoArray.getJSONObject(i).getString("name") + "_fov", videoArray.getJSONObject(i).getString("fov"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //获取upload中的video视频名称
|
|
|
- String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
|
|
|
- JSONObject uploadJson = null;
|
|
|
- JSONArray array = null;
|
|
|
- if(uploadData!=null) {
|
|
|
- uploadJson = JSONObject.parseObject(uploadData);
|
|
|
- array = uploadJson.getJSONArray("upload");
|
|
|
- }
|
|
|
- JSONObject fileJson = null;
|
|
|
- String fileName = "";
|
|
|
-
|
|
|
- //计算ts文件的大小,并拼接成json格式
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- JSONObject videoJson = null;
|
|
|
- JSONObject videosJson = new JSONObject();
|
|
|
- long videoSize = 0L;
|
|
|
- for(int i = 0, len = array.size(); i < len; i++) {
|
|
|
- fileJson = array.getJSONObject(i);
|
|
|
- fileName = fileJson.getString("file");
|
|
|
- if(fileJson.getIntValue("clazz") == 11 && fileName.contains(".mp4") && !fileName.contains("-ios.mp4")){
|
|
|
- videoJson = new JSONObject();
|
|
|
- videoJson.put("id", fileName.substring(
|
|
|
- 0, fileName.lastIndexOf(".")).replace("videos/", ""));
|
|
|
-
|
|
|
- //如果ts文件存在,就计算ts大小
|
|
|
- if(new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).exists()){
|
|
|
- videoSize = new File(path + File.separator + "results" +File.separator+ fileName.replace(".mp4", ".ts")).length();
|
|
|
- videoJson.put("tsSize", videoSize);
|
|
|
- }
|
|
|
- if(videoMap.containsKey(videoJson.get("id"))){
|
|
|
- videoJson.put("value", videoMap.get(videoJson.get("id")));
|
|
|
- }
|
|
|
- if(videoMap.containsKey(videoJson.get("id") + "_fov")){
|
|
|
- videoJson.put("blend_fov", videoMap.get(videoJson.get("id") + "_fov"));
|
|
|
- }else {
|
|
|
- videoJson.put("blend_fov", 7);
|
|
|
- }
|
|
|
- jsonArray.add(videoJson);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- videosJson.put("data", jsonArray);
|
|
|
- if(Objects.nonNull(videoVersion) && videoVersion >= 4){
|
|
|
- videosJson.put("version", 3);
|
|
|
- videosJson.put("upPath", fYunFileConfig.getHost() + String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "Up.xml");
|
|
|
- if(cameraType == 13){
|
|
|
- //转台相机
|
|
|
- videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
|
|
|
- }
|
|
|
- }else {
|
|
|
- videosJson.put("version", 1);
|
|
|
- videosJson.put("upPath", fYunFileConfig.getHost() + String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "Up2.xml");
|
|
|
- if(cameraType == 13){
|
|
|
- //转台相机
|
|
|
- videosJson.put("upPath", videosJson.getString("upPath").replace(".xml", ".txt"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(cameraType == 5 || cameraType == 6){
|
|
|
- videosJson.put("version", 1);
|
|
|
- videosJson.put("upPath", fYunFileConfig.getHost() + String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "stitch_params.txt");
|
|
|
- }
|
|
|
-
|
|
|
- return videosJson;
|
|
|
- }
|
|
|
-
|
|
|
- private Long calUseSpace(Map<String, String> uploadFile) {
|
|
|
- return uploadFile.keySet().stream().map(File::new).filter(File::exists).mapToLong(File::length).sum();
|
|
|
- }
|
|
|
-
|
|
|
private void updateDbPlus(int sceneSource,Long space,String videosJson, Long computeTime,boolean isObj,ScenePlusExt scenePlusExt){
|
|
|
|
|
|
scenePlusExt.setSpace(space);
|
|
@@ -830,92 +591,70 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
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);
|
|
|
|
|
|
- scenePlusExtService.updateById(scenePlusExt);
|
|
|
- }
|
|
|
-
|
|
|
- private int getPayStatus(Long cameraId, Long space){
|
|
|
- //更新相机使用用量
|
|
|
- CameraDetail cameraDetail = cameraDetailService.updateCameraDetailByCameraIdAndSpace(cameraId, space);
|
|
|
- Long totalSpace = cameraDetail.getTotalSpace();
|
|
|
-
|
|
|
- UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
- if(!ObjectUtils.isEmpty(userIncrement) && userIncrement.getIsExpired().equals(ExpiredStatus.NOT_EXPIRED.code())){
|
|
|
- IncrementType type = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
- if(type != null){
|
|
|
- Integer cameraCapacity = type.getCameraCapacity();
|
|
|
- if(cameraCapacity == -1){ //无限容量权益
|
|
|
- return PayStatus.PAY.code();
|
|
|
- }else {
|
|
|
- totalSpace = cameraCapacity *1024 * 1024 * 1024L; //权益设置容量
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //统计点位数量
|
|
|
+ Map<String, Integer> result = this.getShootCount(scenePlusExt);
|
|
|
+ Integer shootCount = result.get("shootCount");
|
|
|
+ Integer mixture = result.get("mixture");
|
|
|
+ scenePlusExt.setShootCount(shootCount);
|
|
|
+ scenePlusExt.setMixture(mixture);
|
|
|
|
|
|
- return totalSpace.compareTo(cameraDetail.getUsedSpace()) == -1 ? PayStatus.NO_CAPACITY.code() : PayStatus.PAY.code();
|
|
|
+ scenePlusExtService.updateById(scenePlusExt);
|
|
|
}
|
|
|
|
|
|
- private Object[] updateEditInfo(ScenePlus scenePlus){
|
|
|
- SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
- SceneEditControls sceneEditControls = null;
|
|
|
- SceneEditInfoExt sceneEditInfoExt = null;
|
|
|
- if(sceneEditInfo == null){
|
|
|
- sceneEditInfo = new SceneEditInfo();
|
|
|
- sceneEditInfo.setScenePlusId(scenePlus.getId());
|
|
|
- sceneEditInfo.setDescription(scenePlus.getDescription());
|
|
|
- sceneEditInfo.setTitle(scenePlus.getTitle());
|
|
|
- sceneEditInfoService.save(sceneEditInfo);
|
|
|
- }else{
|
|
|
+ private Map<String, Integer> getShootCount(ScenePlusExt scenePlusExt){
|
|
|
|
|
|
- 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");
|
|
|
- }
|
|
|
+ Map<String, Integer> result = new HashMap<>();
|
|
|
|
|
|
- if(version < sceneEditInfo.getVersion()){
|
|
|
- version = sceneEditInfo.getVersion();
|
|
|
+ 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(imgVersion < sceneEditInfo.getImgVersion()){
|
|
|
- imgVersion = sceneEditInfo.getImgVersion();
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(shootCount) && shootCount > 0){
|
|
|
+ if(Objects.nonNull(scenePlusExt.getLocation()) && scenePlusExt.getLocation() == 6){
|
|
|
+ mixture = CommonStatus.YES.code().intValue();
|
|
|
}
|
|
|
- if(linkVersion < sceneEditInfo.getLinkVersion()){
|
|
|
- linkVersion = sceneEditInfo.getLinkVersion();
|
|
|
+ }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();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
|
|
|
- sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
|
|
|
- sceneEditInfo.setVersion(version + 1);
|
|
|
- sceneEditInfo.setImgVersion(imgVersion + 1);
|
|
|
- sceneEditInfo.setLinkVersion(linkVersion + 1);
|
|
|
- sceneEditInfo.setIsUploadObj(CommonStatus.NO.code());
|
|
|
- sceneEditInfoService.updateById(sceneEditInfo);
|
|
|
- }
|
|
|
- if(sceneEditControls == null){
|
|
|
- sceneEditControls = new SceneEditControls();
|
|
|
- sceneEditControls.setEditInfoId(sceneEditInfo.getId());
|
|
|
- sceneEditControlsService.save(sceneEditControls);
|
|
|
+ mixture = CommonStatus.NO.code().intValue();
|
|
|
}
|
|
|
- if(sceneEditInfoExt == null){
|
|
|
- sceneEditInfoExt = new SceneEditInfoExt();
|
|
|
- sceneEditInfoExt.setScenePlusId(scenePlus.getId());
|
|
|
- sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
- sceneEditInfoExtService.save(sceneEditInfoExt);
|
|
|
- }
|
|
|
- return new Object[]{sceneEditInfo, sceneEditInfoExt, sceneEditControls};
|
|
|
+
|
|
|
+ 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()) {
|