|
@@ -11,6 +11,7 @@ import com.gis.domain.entity.FodderEntity;
|
|
import com.gis.domain.entity.SceneEntity;
|
|
import com.gis.domain.entity.SceneEntity;
|
|
import com.gis.domain.entity.WorkEntity;
|
|
import com.gis.domain.entity.WorkEntity;
|
|
import com.gis.domain.vo.CatalogSceneVo;
|
|
import com.gis.domain.vo.CatalogSceneVo;
|
|
|
|
+import com.gis.domain.vo.CatalogVo;
|
|
import com.gis.domain.vo.ProSceneVo;
|
|
import com.gis.domain.vo.ProSceneVo;
|
|
import com.gis.mapper.CatalogMapper;
|
|
import com.gis.mapper.CatalogMapper;
|
|
import com.gis.mapper.IBaseMapper;
|
|
import com.gis.mapper.IBaseMapper;
|
|
@@ -18,6 +19,8 @@ import com.gis.mapper.SceneMapper;
|
|
import com.gis.service.CatalogService;
|
|
import com.gis.service.CatalogService;
|
|
import com.gis.service.SceneService;
|
|
import com.gis.service.SceneService;
|
|
import com.gis.service.WorkService;
|
|
import com.gis.service.WorkService;
|
|
|
|
+import com.gis.tree.CatalogTree;
|
|
|
|
+import com.gis.tree.CatalogTreeUtil;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -30,6 +33,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
|
|
+import javax.validation.constraints.NotNull;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@@ -57,10 +61,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
@Autowired
|
|
@Autowired
|
|
FileUtils fileUtils;
|
|
FileUtils fileUtils;
|
|
|
|
|
|
-// @Autowired
|
|
|
|
-// AliyunOssUtil aliyunOssUtil;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public IBaseMapper<SceneEntity, Long> getBaseMapper() {
|
|
public IBaseMapper<SceneEntity, Long> getBaseMapper() {
|
|
return this.entityMapper;
|
|
return this.entityMapper;
|
|
@@ -149,42 +149,26 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
|
-// public Result saves(List<SceneDto> params) {
|
|
|
|
-// SceneEntity entity = null;
|
|
|
|
-// for (SceneDto sceneDto : params) {
|
|
|
|
-// Long id = sceneDto.getId();
|
|
|
|
-// if (id == null) {
|
|
|
|
-// entity = new SceneEntity();
|
|
|
|
-// BeanUtils.copyProperties(sceneDto, entity);
|
|
|
|
-// this.save(entity);
|
|
|
|
-// } else {
|
|
|
|
-// entity = findById(id);
|
|
|
|
-// BeanUtils.copyProperties(sceneDto, entity);
|
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
|
-// this.update(entity);
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// return Result.success();
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result saves(List<SceneDto> params) {
|
|
|
|
|
|
+ public Result saves(CatalogSceneDto params) {
|
|
SceneEntity entity = null;
|
|
SceneEntity entity = null;
|
|
- for (SceneDto sceneDto : params) {
|
|
|
|
|
|
+ Long catalogId = params.getCatalogId();
|
|
|
|
+ Long workId = params.getWorkId();
|
|
|
|
+ // 创建分组
|
|
|
|
+ if (catalogId == null) {
|
|
|
|
+ catalogId = createCatalog(params);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<SceneDto> scenes = params.getScenes();
|
|
|
|
+
|
|
|
|
+ for (SceneDto sceneDto : scenes) {
|
|
Long id = sceneDto.getId();
|
|
Long id = sceneDto.getId();
|
|
if (id == null) {
|
|
if (id == null) {
|
|
entity = new SceneEntity();
|
|
entity = new SceneEntity();
|
|
BeanUtils.copyProperties(sceneDto, entity);
|
|
BeanUtils.copyProperties(sceneDto, entity);
|
|
-
|
|
|
|
- // 创建分组
|
|
|
|
- Long catalogId = sceneDto.getCatalogId();
|
|
|
|
- if (catalogId == null) {
|
|
|
|
- entity.setCatalogId(createCatalog(sceneDto));
|
|
|
|
- }
|
|
|
|
|
|
+ entity.setCatalogId(catalogId);
|
|
|
|
+ entity.setWorkId(workId);
|
|
|
|
|
|
this.save(entity);
|
|
this.save(entity);
|
|
} else {
|
|
} else {
|
|
@@ -196,21 +180,52 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return Result.success();
|
|
|
|
|
|
+ // 前端需要分组对象
|
|
|
|
+ CatalogVo catalogVo = catalogService.voFindById(catalogId);
|
|
|
|
+ CatalogTree catalogTree = new CatalogTree();
|
|
|
|
+ catalogTree.setId(catalogVo.getCatalogId());
|
|
|
|
+ catalogTree.setName(catalogVo.getCatalogName());
|
|
|
|
+ Long parentId = catalogVo.getParentId();
|
|
|
|
+ catalogTree.setParentId(parentId);
|
|
|
|
+
|
|
|
|
+ // 结果集
|
|
|
|
+ List<CatalogTree> resultTree = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ // 二层分组 (父子结构)
|
|
|
|
+ if (parentId != null) {
|
|
|
|
+ CatalogTree parentCatalog = new CatalogTree();
|
|
|
|
+ parentCatalog.setId(parentId);
|
|
|
|
+ parentCatalog.setName(catalogVo.getParentName());
|
|
|
|
+ List<CatalogTree> children = new ArrayList<>();
|
|
|
|
+ children.add(catalogTree);
|
|
|
|
+ parentCatalog.setChildren(children);
|
|
|
|
+ resultTree.add(parentCatalog);
|
|
|
|
+ } else {
|
|
|
|
+ // 一层分组
|
|
|
|
+ resultTree.add(catalogTree);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return Result.success(resultTree);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 创建分组
|
|
* 创建分组
|
|
- * @param sceneDto
|
|
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private Long createCatalog(SceneDto sceneDto) {
|
|
|
|
- Long parentId = sceneDto.getParentId();
|
|
|
|
- String parentName = sceneDto.getParentName();
|
|
|
|
- Long workId = sceneDto.getWorkId();
|
|
|
|
|
|
+ private Long createCatalog(CatalogSceneDto params) {
|
|
|
|
+ Long parentId = params.getParentId();
|
|
|
|
+ String parentName = params.getParentName();
|
|
|
|
+ Long workId = params.getWorkId();
|
|
|
|
|
|
CatalogEntity entity = new CatalogEntity();
|
|
CatalogEntity entity = new CatalogEntity();
|
|
- entity.setName(sceneDto.getCatalogName());
|
|
|
|
|
|
+ entity.setName(params.getCatalogName());
|
|
entity.setWorkId(workId);
|
|
entity.setWorkId(workId);
|
|
// 当父id不为空时
|
|
// 当父id不为空时
|
|
if (parentId != null) {
|
|
if (parentId != null) {
|
|
@@ -223,8 +238,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
parentEntity.setWorkId(workId);
|
|
parentEntity.setWorkId(workId);
|
|
parentEntity.setName(parentName);
|
|
parentEntity.setName(parentName);
|
|
catalogService.save(parentEntity);
|
|
catalogService.save(parentEntity);
|
|
-
|
|
|
|
- entity.setParentId(parentEntity.getParentId());
|
|
|
|
|
|
+ entity.setParentId(parentEntity.getId());
|
|
|
|
|
|
}
|
|
}
|
|
// 创建目录
|
|
// 创建目录
|
|
@@ -232,6 +246,8 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
return entity.getId();
|
|
return entity.getId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<String> strFindByWorkId(Long workId, String type) {
|
|
public List<String> strFindByWorkId(Long workId, String type) {
|
|
return entityMapper.strFindByWorkId(workId, type);
|
|
return entityMapper.strFindByWorkId(workId, type);
|
|
@@ -325,7 +341,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result editXml(XmlDataDto param) {
|
|
public Result editXml(XmlDataDto param) {
|
|
-// long start = System.currentTimeMillis();
|
|
|
|
Long id = param.getId();
|
|
Long id = param.getId();
|
|
SceneEntity entity = entityMapper.findByIdForUpdate(id);
|
|
SceneEntity entity = entityMapper.findByIdForUpdate(id);
|
|
if (entity == null) {
|
|
if (entity == null) {
|
|
@@ -333,36 +348,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
return Result.failure("场景码不存在");
|
|
return Result.failure("场景码不存在");
|
|
}
|
|
}
|
|
|
|
|
|
-// String sceneCode = entity.getSceneCode();
|
|
|
|
-// FodderEntity fodderEntity = fodderService.findBySceneCode(sceneCode);
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// // 注意网络下载会有缓存,必须加时间戳
|
|
|
|
-// // http://ossxiaoan.4dage.com/cms_pano_fcb/p19/fcb_px2rJW96F/vtour/tour.xml
|
|
|
|
-// String tourOssUrl = fodderEntity.getOssPath() + "/vtour/tour.xml?m=" + System.currentTimeMillis();
|
|
|
|
-// log.info("网络下载文件地址: {}", tourOssUrl);
|
|
|
|
-// String fileName = "tour2.xml";
|
|
|
|
-// String filePath = fodderEntity.getFilePath();
|
|
|
|
-// 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";
|
|
|
|
-// String tourOssSavePath = configConstant.ossBasePath + 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 jsonObject = new JSONObject();
|
|
jsonObject.put("hlookat", param.getHlookat());
|
|
jsonObject.put("hlookat", param.getHlookat());
|
|
@@ -375,64 +360,6 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
|
- public void tes1() {
|
|
|
|
- String inPath = "C:\\Users\\Administrator\\Desktop\\33\\tour2.xml";
|
|
|
|
- String outPath = "C:\\Users\\Administrator\\Desktop\\33\\tour.xml";
|
|
|
|
- streamEditFile(inPath, outPath, "0.1", "0.2");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public static void streamEditFile(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);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // 输出缓冲流
|
|
|
|
-
|
|
|
|
- String tempString = null;
|
|
|
|
- StringBuffer buffer = new StringBuffer();
|
|
|
|
-
|
|
|
|
- // 转数组
|
|
|
|
- while ((tempString = reader.readLine()) != null) {
|
|
|
|
-
|
|
|
|
- if (tempString.contains("<view hlookat=")) {
|
|
|
|
- tempString = tempString.replace("\t", "");
|
|
|
|
-
|
|
|
|
- String start = StringUtils.substring(tempString, 0, 5);
|
|
|
|
- String end = StringUtils.substringAfter(tempString, "fovtype");
|
|
|
|
-
|
|
|
|
- StringBuffer aa = new StringBuffer();
|
|
|
|
- aa.append(start);
|
|
|
|
- aa.append(" hlookat=").append("\"").append(hlookat).append("\"");
|
|
|
|
- aa.append(" vlookat=").append("\"").append(vlookat).append("\"");
|
|
|
|
- aa.append(" fovtype");
|
|
|
|
- aa.append(end);
|
|
|
|
- // 写文件
|
|
|
|
- tempString = aa.toString();
|
|
|
|
- log.info("temp: " + tempString);
|
|
|
|
- }
|
|
|
|
- // 换行写入
|
|
|
|
- buffer.append(tempString).append("\r\n");
|
|
|
|
- }
|
|
|
|
- reader.close();
|
|
|
|
- FileUtil.writeUtf8String(buffer.toString(), outPath);
|
|
|
|
- } catch (IOException ex) {
|
|
|
|
- ex.printStackTrace();
|
|
|
|
- } finally {
|
|
|
|
- if (reader != null) {
|
|
|
|
- try {
|
|
|
|
- reader.close();
|
|
|
|
- } catch (IOException ex) {
|
|
|
|
- ex.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|