|
@@ -3,19 +3,20 @@ package com.gis.service.impl;
|
|
|
import cn.hutool.core.io.FileTypeUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.gis.common.constant.ConfigConstant;
|
|
|
import com.gis.common.constant.RabbitConfig;
|
|
|
import com.gis.common.task.AsyncTask;
|
|
|
import com.gis.common.util.*;
|
|
|
import com.gis.domain.dto.*;
|
|
|
import com.gis.domain.entity.SceneEntity;
|
|
|
+import com.gis.domain.entity.SceneInitEntity;
|
|
|
import com.gis.feign.HouseFeign;
|
|
|
import com.gis.feign.SceneProFeign;
|
|
|
import com.gis.mapper.IBaseMapper;
|
|
|
+import com.gis.mapper.SceneInitMapper;
|
|
|
import com.gis.mapper.SceneMapper;
|
|
|
+import com.gis.service.SceneInitService;
|
|
|
import com.gis.service.SceneService;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -46,6 +47,12 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
private SceneMapper entityMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ SceneInitMapper sceneInitMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SceneInitService sceneInitService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
@Autowired
|
|
@@ -150,7 +157,10 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
|
|
|
// 缩略图,使用切图那个thumb.jpg
|
|
|
// 压缩图片并上传oss
|
|
|
- String iconPath = fileUtils.compressImgAndUploadOss2(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
|
|
|
+// String iconPath = fileUtils.compressImgAndUploadOss2(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
|
|
|
+ // 全景图缩略图统一命名规则: http:// oss/cms_pano_fcb/image/thumb_sceneCode.jpg
|
|
|
+ String iconPath = fileUtils.compressImgAndUploadOss2(
|
|
|
+ panoPath, configConstant.filePath, configConstant.ossBasePath, configConstant.ossDomain, 600, 300, "image/thumb_"+sceneCode+".jpg");
|
|
|
// String iconPath = fileUtils.compressImgAndUploadOss(panoPath, configConstant.ossBasePath, configConstant.ossDomain);
|
|
|
log.info("iconPath:" + iconPath);
|
|
|
entity.setIcon(iconPath);
|
|
@@ -173,7 +183,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
// SceneEntity index = entityMapper.getIndex(houseId);
|
|
|
List<SceneEntity> index = entityMapper.getIndex(houseId);
|
|
|
if (index.size() == 0) {
|
|
|
- log.info("需要设置更新场景码到VR项目");
|
|
|
+ log.info("更新hengdaId到管理后台");
|
|
|
entity.setIsIndex(1);
|
|
|
|
|
|
// 更新到VR项目
|
|
@@ -352,7 +362,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
return resStatus;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
SceneEntity entity = null;
|
|
|
|
|
|
List<SceneEntity> index = entityMapper.getIndex(param.getHouseId());
|
|
@@ -415,6 +424,27 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Result uploadFixedName(MultipartFile file, String sceneCode) {
|
|
|
+
|
|
|
+ // 检查非法文件上传
|
|
|
+ boolean checkFile = FileUtils.checkFile(file);
|
|
|
+ if (!checkFile) {
|
|
|
+ return Result.failure("上传文件格式有误, 请重新上传");
|
|
|
+ }
|
|
|
+
|
|
|
+ String ossPath = configConstant.ossBasePath + "image/thumb_"+sceneCode+".jpg";
|
|
|
+ try {
|
|
|
+ aliyunOssUtil.upload(file.getBytes(), ossPath);
|
|
|
+ Object ossUrl = configConstant.ossDomain + ossPath;
|
|
|
+ log.info("ossUrl: {}", ossUrl);
|
|
|
+ return Result.success(ossUrl);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Result.failure("上传失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Result saveUseHots(UseHotsDto param) {
|
|
|
String id = param.getId();
|
|
|
SceneEntity entity = this.findById(id);
|
|
@@ -602,6 +632,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
@Override
|
|
|
public Result houseRemove(String houseId) {
|
|
|
entityMapper.houseRemove(houseId);
|
|
|
+ sceneInitMapper.removeByHouseId(houseId);
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
@@ -814,6 +845,10 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
entity.setStatus(3);
|
|
|
entity.setWebSite(webSite);
|
|
|
this.save(entity);
|
|
|
+
|
|
|
+ // 该VR项目下如果没有设置任何初始场景,把户型设置为默认初始场景
|
|
|
+ checkSceneInit(houseId, sceneCode);
|
|
|
+
|
|
|
log.info("保存VR模型完成");
|
|
|
} else {
|
|
|
entity = this.findById(id);
|
|
@@ -826,43 +861,21 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result uploadMedia(MultipartFile file, String sceneCode) {
|
|
|
- if (file == null) {
|
|
|
- log.error("文件不能为空");
|
|
|
- return Result.failure("文件不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- SceneEntity entity = this.findById(sceneCode);
|
|
|
- if (entity == null) {
|
|
|
- log.error("场景不存在: {}", sceneCode);
|
|
|
- return Result.failure("场景不存在");
|
|
|
+ // 该VR项目下如果没有设置任何初始场景,把户型设置为默认初始场景
|
|
|
+ private void checkSceneInit(String houseId, String sceneCode){
|
|
|
+ List<SceneInitEntity> list = sceneInitService.findByHouseId(houseId);
|
|
|
+ if (list.size() == 0){
|
|
|
+ SceneInitEntity entity = new SceneInitEntity();
|
|
|
+ entity.setId(RandomUtils.getUuid("init"));
|
|
|
+ entity.setHouseId(houseId);
|
|
|
+ entity.setSceneCode(sceneCode);
|
|
|
+ sceneInitService.save(entity);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- String basePath = entity.getPath() ;
|
|
|
- basePath = StringUtils.substringBeforeLast(basePath, "/") + "/media/" ;
|
|
|
-
|
|
|
-
|
|
|
- String originalFilename = file.getOriginalFilename();
|
|
|
-
|
|
|
- String filePath = basePath + originalFilename;
|
|
|
- try {
|
|
|
- file.transferTo(new File(filePath));
|
|
|
- log.info("文件写入成功: {}", filePath);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
|
|
|
- // 上传到oss
|
|
|
- String ossUploadPath = configConstant.ossBasePath + sceneCode + "/media/" + originalFilename;
|
|
|
- String ossPath = configConstant.ossDomain + ossUploadPath;
|
|
|
|
|
|
- asyncTask.uploadOss(filePath, ossUploadPath);
|
|
|
|
|
|
- log.info("文件上传到oss完成: {}", ossPath);
|
|
|
- return Result.success(ossPath);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public Result upload(MultipartFile file) {
|
|
@@ -875,9 +888,68 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
return Result.success(fileUtils.renameUploadOss(file, configConstant.filePath, configConstant.ossBasePath, configConstant.ossDomain));
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// public Result editXml(XmlDataDto param) {
|
|
|
+// long start = System.currentTimeMillis();
|
|
|
+// String id = param.getId();
|
|
|
+//// SceneEntity entity = findById(id);
|
|
|
+// SceneEntity entity = entityMapper.findByIdForUpdate(id);
|
|
|
+// if (entity == null) {
|
|
|
+// log.error("对象不存在,id : " + id);
|
|
|
+// return Result.failure("场景码不存在");
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// // 检查VR项目状态
|
|
|
+// String houseId = entity.getHouseId();
|
|
|
+// Result resStatus = getHouseStatus(houseId);
|
|
|
+// if (resStatus != null) {
|
|
|
+// return resStatus;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// // 注意网络下载会有缓存,必须加时间戳
|
|
|
+// // http://ossxiaoan.4dage.com/cms_pano_fcb/p19/fcb_px2rJW96F/vtour/tour.xml
|
|
|
+// String tourOssUrl = entity.getOssPath() + "/vtour/tour.xml?m=" + System.currentTimeMillis();
|
|
|
+// log.info("网络下载文件地址: {}", tourOssUrl);
|
|
|
+// String fileName = "tour2.xml";
|
|
|
+// String filePath = entity.getPath();
|
|
|
+// String localBasePath = StringUtils.substringBeforeLast(filePath, "/");
|
|
|
+// FileUtils.downLoadFromUrl(tourOssUrl, fileName, localBasePath);
|
|
|
+// log.info("网络下载成功: {}", localBasePath+ "/tour2.xml");
|
|
|
+//
|
|
|
+// // 编辑xml, 修改初始角度
|
|
|
+// String inPath = localBasePath + "/tour2.xml";
|
|
|
+// String outPath = localBasePath + "/tour.xml";
|
|
|
+// String hlookat = param.getHlookat();
|
|
|
+// String vlookat = param.getVlookat();
|
|
|
+// streamEditFile(inPath, outPath, hlookat, vlookat);
|
|
|
+// log.info("编辑xml, 修改初始角度完毕");
|
|
|
+//
|
|
|
+// String tourOssSavePath = configConstant.ossBasePath + entity.getHouseId() + "/" + entity.getSceneCode() + "/vtour/tour.xml";
|
|
|
+// log.info("osspath: " + tourOssSavePath);
|
|
|
+// aliyunOssUtil.upload(outPath, tourOssSavePath);
|
|
|
+//// asyncTask.uploadOss(outPath, tourOssSavePath);
|
|
|
+// long end = System.currentTimeMillis();
|
|
|
+// log.info("tour.xml 上传oss完成, 共耗时: " + (end-start)/1000 + " s");
|
|
|
+//
|
|
|
+// // 保存初始视觉
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("hlookat", hlookat);
|
|
|
+// jsonObject.put("vlookat", vlookat);
|
|
|
+// entity.setInitVisual(jsonObject.toJSONString());
|
|
|
+//
|
|
|
+// this.update(entity);
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// return Result.success(entity.getOssPath());
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Result editXml(XmlDataDto param) {
|
|
|
- long start = System.currentTimeMillis();
|
|
|
+// long start = System.currentTimeMillis();
|
|
|
String id = param.getId();
|
|
|
// SceneEntity entity = findById(id);
|
|
|
SceneEntity entity = entityMapper.findByIdForUpdate(id);
|
|
@@ -897,39 +969,37 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
|
|
|
// 注意网络下载会有缓存,必须加时间戳
|
|
|
// http://ossxiaoan.4dage.com/cms_pano_fcb/p19/fcb_px2rJW96F/vtour/tour.xml
|
|
|
- String tourOssUrl = entity.getOssPath() + "/vtour/tour.xml?m=" + System.currentTimeMillis();
|
|
|
- log.info("网络下载文件地址: {}", tourOssUrl);
|
|
|
- String fileName = "tour2.xml";
|
|
|
- String filePath = entity.getPath();
|
|
|
- String localBasePath = StringUtils.substringBeforeLast(filePath, "/");
|
|
|
- FileUtils.downLoadFromUrl(tourOssUrl, fileName, localBasePath);
|
|
|
- log.info("网络下载成功: {}", localBasePath+ "/tour2.xml");
|
|
|
+// String tourOssUrl = entity.getOssPath() + "/vtour/tour.xml?m=" + System.currentTimeMillis();
|
|
|
+// log.info("网络下载文件地址: {}", tourOssUrl);
|
|
|
+// String fileName = "tour2.xml";
|
|
|
+// String filePath = entity.getPath();
|
|
|
+// String localBasePath = StringUtils.substringBeforeLast(filePath, "/");
|
|
|
+// FileUtils.downLoadFromUrl(tourOssUrl, fileName, localBasePath);
|
|
|
+// log.info("网络下载成功: {}", localBasePath+ "/tour2.xml");
|
|
|
|
|
|
// 编辑xml, 修改初始角度
|
|
|
- String inPath = localBasePath + "/tour2.xml";
|
|
|
- String outPath = localBasePath + "/tour.xml";
|
|
|
- String hlookat = param.getHlookat();
|
|
|
- String vlookat = param.getVlookat();
|
|
|
- streamEditFile(inPath, outPath, hlookat, vlookat);
|
|
|
- log.info("编辑xml, 修改初始角度完毕");
|
|
|
-
|
|
|
- String tourOssSavePath = configConstant.ossBasePath + entity.getHouseId() + "/" + entity.getSceneCode() + "/vtour/tour.xml";
|
|
|
- log.info("osspath: " + tourOssSavePath);
|
|
|
- aliyunOssUtil.upload(outPath, tourOssSavePath);
|
|
|
-// asyncTask.uploadOss(outPath, tourOssSavePath);
|
|
|
- long end = System.currentTimeMillis();
|
|
|
- log.info("tour.xml 上传oss完成, 共耗时: " + (end-start)/1000 + " s");
|
|
|
+// String inPath = localBasePath + "/tour2.xml";
|
|
|
+// String outPath = localBasePath + "/tour.xml";
|
|
|
+// String hlookat = param.getHlookat();
|
|
|
+// String vlookat = param.getVlookat();
|
|
|
+// streamEditFile(inPath, outPath, hlookat, vlookat);
|
|
|
+// log.info("编辑xml, 修改初始角度完毕");
|
|
|
+//
|
|
|
+// String tourOssSavePath = configConstant.ossBasePath + entity.getHouseId() + "/" + entity.getSceneCode() + "/vtour/tour.xml";
|
|
|
+// log.info("osspath: " + tourOssSavePath);
|
|
|
+// aliyunOssUtil.upload(outPath, tourOssSavePath);
|
|
|
+//// asyncTask.uploadOss(outPath, tourOssSavePath);
|
|
|
+// long end = System.currentTimeMillis();
|
|
|
+// log.info("tour.xml 上传oss完成, 共耗时: " + (end-start)/1000 + " s");
|
|
|
|
|
|
// 保存初始视觉
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("hlookat", hlookat);
|
|
|
- jsonObject.put("vlookat", vlookat);
|
|
|
+ jsonObject.put("hlookat", param.getHlookat());
|
|
|
+ jsonObject.put("vlookat", param.getVlookat());
|
|
|
entity.setInitVisual(jsonObject.toJSONString());
|
|
|
|
|
|
this.update(entity);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
return Result.success(entity.getOssPath());
|
|
|
}
|
|
|
|
|
@@ -992,66 +1062,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 流处理数据
|
|
|
- * 这方法写出的结果第一行会少结果
|
|
|
- * @param inPath
|
|
|
- * @param outPath
|
|
|
- */
|
|
|
- public static void streamEditFile2(String inPath, String outPath, String hlookat, String vlookat) {
|
|
|
- // 4*4矩阵
|
|
|
-
|
|
|
- BufferedReader reader = null;
|
|
|
- try {
|
|
|
- InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(inPath), "UTF-8");
|
|
|
- reader = new BufferedReader(inputStreamReader);
|
|
|
-
|
|
|
-
|
|
|
- // 输出缓冲流
|
|
|
- BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(outPath));
|
|
|
-
|
|
|
- String tempString = null;
|
|
|
-
|
|
|
- // 转数组
|
|
|
- while ((tempString = reader.readLine()) != null) {
|
|
|
-// log.info("line: " + tempString);
|
|
|
- tempString = tempString.replace("\t", "");
|
|
|
-
|
|
|
- if (tempString.contains("<view hlookat=")) {
|
|
|
-
|
|
|
- String start = StringUtils.substring(tempString, 0, 5);
|
|
|
- String end = StringUtils.substringAfter(tempString, "fovtype");
|
|
|
-
|
|
|
- StringBuffer buffer = new StringBuffer();
|
|
|
- buffer.append(start);
|
|
|
- buffer.append(" hlookat=").append("\"").append(hlookat).append("\"");
|
|
|
- buffer.append(" vlookat=").append("\"").append(vlookat).append("\"");
|
|
|
- buffer.append(" fovtype");
|
|
|
- buffer.append(end);
|
|
|
- // 写文件
|
|
|
- tempString = buffer.toString();
|
|
|
- log.info("temp: " + tempString);
|
|
|
- }
|
|
|
- log.warn("write: " + tempString);
|
|
|
- stream.write(tempString.getBytes(), 0, tempString.length() );
|
|
|
- // 换行写入
|
|
|
- stream.write("\r\n".getBytes());
|
|
|
- }
|
|
|
- stream.flush();
|
|
|
- reader.close();
|
|
|
- stream.close();
|
|
|
- } catch (IOException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- } finally {
|
|
|
- if (reader != null) {
|
|
|
- try {
|
|
|
- reader.close();
|
|
|
- } catch (IOException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
|
|
|
@Test
|