|
@@ -203,26 +203,27 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
//计算场景消耗磁盘空间
|
|
|
long space = this.calUseSpace(uploadFiles);
|
|
|
|
|
|
- if(cameraType < 3){
|
|
|
- this.updateDb4Sm(sceneCode, space);
|
|
|
- fYunFileService.uploadMulFiles(uploadFiles);
|
|
|
- return;
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneCode);
|
|
|
+
|
|
|
+ int payStatus = PayStatus.PAY.code();
|
|
|
+ //如果相机容量不足,需要把场景的paystatus改为容量不足状态
|
|
|
+ if (cameraType != 14) {
|
|
|
+ payStatus = this.getPayStatus(scenePlus.getCameraId(), space);
|
|
|
}
|
|
|
|
|
|
//读取计算结果文件生成videosJson
|
|
|
JSONObject videosJson = this.getVideosJson(path, videoVersion, sceneCode, cameraType);
|
|
|
|
|
|
- //写入数据库
|
|
|
- ScenePlus scenePlus = this.updateDbPlus(sceneCode, space, videosJson.toJSONString(), computeTime,fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1);
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
|
|
- //变更容量,arrearCap为true时,代表容量不足
|
|
|
- boolean arrearCap = this.updateSpace(scenePlus.getCameraId(), space);
|
|
|
+ scenePlus.setPayStatus(payStatus);
|
|
|
+ scenePlus.setUpdateTime(new Date());
|
|
|
+ scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
|
|
|
+ scenePlusService.updateById(scenePlus);
|
|
|
|
|
|
- //如果相机容量不足,需要把场景的paystatus改为容量不足状态
|
|
|
- if (arrearCap && cameraType != 14) {
|
|
|
- this.sealScene(arrearCap, scenePlus.getId(), scenePlus.getId());
|
|
|
- }
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+ boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
|
|
|
+ //写入数据库
|
|
|
+ this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), computeTime,isObj,scenePlusExt);
|
|
|
|
|
|
Object[] editInfoArr = this.updateEditInfo(scenePlus);
|
|
|
SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
|
|
@@ -232,7 +233,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
//上传全景图俯视图
|
|
|
this.uploadFloorCad(path, sceneCode, uploadFiles);
|
|
|
|
|
|
-
|
|
|
//上传文件
|
|
|
log.info("开始上传场景计算结果数据,num:{}", sceneCode);
|
|
|
fYunFileService.uploadMulFiles(uploadFiles);
|
|
@@ -262,8 +262,12 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
|
|
|
//写scene.json
|
|
|
log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
|
|
|
- this.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,
|
|
|
- scenePlusExt, arrearCap);
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
|
|
|
+ Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
|
|
|
+
|
|
|
+ this.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
|
|
|
+
|
|
|
+ createQrCode(sceneCode, scenePlusExt, company.getQrLogo());
|
|
|
|
|
|
//计算成功,通知APP
|
|
|
Integer pushChannel = fdageData.getInteger("pushChannel");
|
|
@@ -423,7 +427,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
}
|
|
|
|
|
|
private void writeSceneJson(String num, JSONObject videosJson, SceneEditInfo sceneEditInfo, SceneEditInfoExt sceneEditInfoExt,
|
|
|
- SceneEditControls sceneEditControls, ScenePlus scenePlus, ScenePlusExt scenePlusExt, boolean arrearCap) throws Exception{
|
|
|
+ SceneEditControls sceneEditControls, ScenePlus scenePlus, ScenePlusExt scenePlusExt,Company company){
|
|
|
String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
|
|
|
SceneJsonBean sceneJson = new SceneJsonBean();
|
|
@@ -436,15 +440,10 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
|
sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
|
|
|
sceneJson.setVideos(JSON.toJSONString(videosJson));
|
|
|
- if(arrearCap) {
|
|
|
- sceneJson.setPayStatus(PayStatus.NO_CAPACITY.code());
|
|
|
- }
|
|
|
- String qrLogo = null;
|
|
|
- // 获取企业logo
|
|
|
- CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
|
|
|
- if(!ObjectUtils.isEmpty(cameraDetail.getCompanyId())){
|
|
|
+ sceneJson.setPayStatus(scenePlus.getPayStatus());
|
|
|
+
|
|
|
+ if(!ObjectUtils.isEmpty(company)){
|
|
|
String userViewPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
|
- Company company = companyService.getById(cameraDetail.getCompanyId());
|
|
|
if (StrUtil.isNotEmpty(company.getTopLogo())) {
|
|
|
fYunFileService.copyFileInBucket(company.getTopLogo(),userViewPath + "loadingLogo-user.png");
|
|
|
sceneJson.setLoadingLogo("user");
|
|
@@ -455,12 +454,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
sceneJson.setFloorLogo("user");
|
|
|
sceneJson.setFloorLogoFile("floorLogo-user.png");
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(company.getQrLogo())) {
|
|
|
- if (!new File(ConstantFilePath.AGENT_PATH + company.getQrLogo()).exists()) {
|
|
|
- fYunFileService.downloadFile(company.getQrLogo(), ConstantFilePath.AGENT_PATH + company.getQrLogo());
|
|
|
- }
|
|
|
- qrLogo = ConstantFilePath.AGENT_PATH + company.getQrLogo();
|
|
|
- }
|
|
|
}
|
|
|
String sceneJsonStr = JSON.toJSONString(sceneJson);
|
|
|
//上传sceneJson文件
|
|
@@ -482,9 +475,19 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
fYunFileService.uploadFile(ConstantFilePath.SCENE_PATH + "data/data" + num + File.separator + "status.json",
|
|
|
dataViewPath + "status.json");
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createQrCode(String num, ScenePlusExt scenePlusExt, String qrLogo) {
|
|
|
+ if (!ObjectUtils.isEmpty(qrLogo)) {
|
|
|
+ if (!new File(ConstantFilePath.AGENT_PATH + qrLogo).exists()) {
|
|
|
+ fYunFileService.downloadFile(qrLogo, ConstantFilePath.AGENT_PATH + qrLogo);
|
|
|
+ }
|
|
|
+ qrLogo = ConstantFilePath.AGENT_PATH + qrLogo;
|
|
|
+ }
|
|
|
+
|
|
|
//生成二维码
|
|
|
- String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+num+".png";
|
|
|
- String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+num+"_en.png";
|
|
|
+ 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();
|
|
|
if(!ObjectUtils.isEmpty(qrLogo)){
|
|
|
qrConfig.setImg(qrLogo);
|
|
@@ -494,7 +497,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
//上传二维码
|
|
|
fYunFileService.uploadFile(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + ".png");
|
|
|
fYunFileService.uploadFile(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, num) + num + "_en.png");
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void pushMsgToApp(Integer pushChannel, String pushToken, int cameraType, String sceneName, String webSite){
|
|
@@ -647,7 +649,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
return uploadFile.keySet().stream().map(File::new).filter(File::exists).mapToLong(File::length).sum();
|
|
|
}
|
|
|
|
|
|
- private void sealScene(boolean arrearCap, Long scenePlusId, Long sceneProId){
|
|
|
+ private void sealScene(Long scenePlusId){
|
|
|
scenePlusService.update(
|
|
|
new LambdaUpdateWrapper<ScenePlus>()
|
|
|
.set(ScenePlus::getPayStatus, PayStatus.NO_CAPACITY.code())
|
|
@@ -683,23 +685,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
.set(ScenePlusExt::getAlgorithmTime, Calendar.getInstance().getTime()));
|
|
|
}
|
|
|
|
|
|
- private ScenePlus updateDbPlus(String num, Long space, String videosJson, Long computeTime,boolean isObj){
|
|
|
- ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
- List<ScenePlus> list = scenePlusService.list(new LambdaQueryWrapper<ScenePlus>()
|
|
|
- .select(ScenePlus::getId).eq(ScenePlus::getNum, num));
|
|
|
- if (CollUtil.isEmpty(list)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- //修改场景状态 空间 支付状态 计算时间
|
|
|
- List<Long> scenePlusIds = list.stream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
|
-
|
|
|
- scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
|
|
|
- .in(ScenePlus::getId, scenePlusIds)
|
|
|
- .set(ScenePlus::getSceneStatus, SceneStatus.NO_DISPLAY.code())
|
|
|
- .set(ScenePlus::getUpdateTime, new Date())
|
|
|
- .set(ScenePlus::getPayStatus, PayStatus.PAY.code()));
|
|
|
+ private void updateDbPlus(int sceneSource,Long space,String videosJson, Long computeTime,boolean isObj,ScenePlusExt scenePlusExt){
|
|
|
|
|
|
scenePlusExt.setSpace(space);
|
|
|
scenePlusExt.setComputeTime(computeTime.toString());
|
|
@@ -711,8 +697,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
scenePlusExt.setSceneScheme(3);
|
|
|
}
|
|
|
|
|
|
- SceneSource sceneSource = SceneSource.get(scenePlus.getSceneSource());
|
|
|
- switch (sceneSource){
|
|
|
+ switch (SceneSource.get(sceneSource)){
|
|
|
case BM:
|
|
|
scenePlusExt.setSceneResolution(SceneResolution.two_K.code());
|
|
|
scenePlusExt.setSceneFrom(SceneFrom.PRO.code());
|
|
@@ -735,24 +720,25 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
scenePlusExt.setSceneKind(sceneKind);
|
|
|
|
|
|
scenePlusExtService.updateById(scenePlusExt);
|
|
|
-
|
|
|
-
|
|
|
- return scenePlus;
|
|
|
}
|
|
|
|
|
|
- private boolean updateSpace(Long cameraId, Long space) throws Exception{
|
|
|
+ private int getPayStatus(Long cameraId, Long space){
|
|
|
//更新相机使用用量
|
|
|
CameraDetail cameraDetail = cameraDetailService.updateCameraDetailByCameraIdAndSpace(cameraId, space);
|
|
|
- UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
+ Long totalSpace = cameraDetail.getTotalSpace();
|
|
|
|
|
|
- if(!ObjectUtils.isEmpty(userIncrement)){
|
|
|
+ UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
+ if(!ObjectUtils.isEmpty(userIncrement) && userIncrement.getIsExpired().equals(ExpiredStatus.NOT_EXPIRED.code())){
|
|
|
IncrementType type = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
- if(type.getType().equals("cn") && userIncrement.getIsExpired().equals(ExpiredStatus.NOT_EXPIRED.code())){
|
|
|
- return false;
|
|
|
+ if (type.getType().equals("cn")) {
|
|
|
+ return PayStatus.PAY.code();
|
|
|
+ }
|
|
|
+ if (type.getType().equals("eur")){
|
|
|
+ totalSpace = type.getCameraCapacity()* 1024 * 1024L;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return cameraDetail.getTotalSpace().compareTo(cameraDetail.getUsedSpace()) == -1;
|
|
|
+ return totalSpace.compareTo(cameraDetail.getUsedSpace()) == -1 ? PayStatus.NO_CAPACITY.code() : PayStatus.PAY.code();
|
|
|
}
|
|
|
|
|
|
private Object[] updateEditInfo(ScenePlus scenePlus){
|