|
@@ -0,0 +1,305 @@
|
|
|
+//package com.gis.cms.service.impl;
|
|
|
+//
|
|
|
+//import cn.hutool.core.io.FileUtil;
|
|
|
+//import cn.hutool.core.util.StrUtil;
|
|
|
+//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+//import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+//import com.gis.cms.entity.dto.FodderDto;
|
|
|
+//import com.gis.cms.entity.po.FodderEntity;
|
|
|
+//import com.gis.cms.entity.po.WorkEntity;
|
|
|
+//import com.gis.cms.mapper.FodderMapper;
|
|
|
+//import com.gis.cms.service.FodderService;
|
|
|
+//import com.gis.cms.service.OpsService;
|
|
|
+//import com.gis.cms.service.WorkService;
|
|
|
+//import com.gis.common.base.entity.dto.PageDto;
|
|
|
+//import com.gis.common.base.exception.BaseRuntimeException;
|
|
|
+//import com.gis.common.base.service.impl.IBaseService;
|
|
|
+//import com.gis.common.constant.CmdConstant;
|
|
|
+//import com.gis.common.constant.ConfigConstant;
|
|
|
+//import com.gis.common.constant.ErrorEnum;
|
|
|
+//import com.gis.common.util.*;
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
+//import org.apache.commons.lang3.StringUtils;
|
|
|
+//import org.junit.Test;
|
|
|
+//import org.springframework.beans.BeanUtils;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.stereotype.Service;
|
|
|
+//
|
|
|
+//import java.io.File;
|
|
|
+//import java.util.Arrays;
|
|
|
+//import java.util.List;
|
|
|
+//
|
|
|
+//
|
|
|
+///**
|
|
|
+// * Created by owen on 2020/3/11 0011 16:16
|
|
|
+// */
|
|
|
+//@Slf4j
|
|
|
+//@Service
|
|
|
+//public class OpsServiceImpl implements OpsService {
|
|
|
+//
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// ConfigConstant configConstant;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// WorkService workService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// FileUtils fileUtils;
|
|
|
+//
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Result<WorkEntity> downloadWork(String ids) {
|
|
|
+// BaseRuntimeException.isBlank(ids, null, "输入参数为空");
|
|
|
+// // 替换空格
|
|
|
+// ids = StringUtils.replaceAll(ids, ",", " ");
|
|
|
+// log.info("下载作品目录:{}", ids);
|
|
|
+// String zipName = StrUtils.getTime("work_");
|
|
|
+// zipName = "/download/" + zipName + ".zip";
|
|
|
+//
|
|
|
+// String outPath = configConstant.serverBasePath + zipName;
|
|
|
+// log.info("zip保存路径:{}", outPath);
|
|
|
+// String cmd = CmdConstant.zip;
|
|
|
+// cmd = cmd.replaceAll("@output", outPath);
|
|
|
+// cmd = cmd.replaceAll("@workPace", configConstant.serverBasePath + "/work");
|
|
|
+// cmd = cmd.replaceAll("@inDir", ids);
|
|
|
+//
|
|
|
+// CmdUtils.callShLine(cmd, null);
|
|
|
+//
|
|
|
+// return Result.success(zipName);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Result<WorkEntity> downloadPano(String ids) {
|
|
|
+// BaseRuntimeException.isBlank(ids, null, "输入参数为空");
|
|
|
+// List<WorkEntity> list = workService.listByIds(Arrays.asList(ids));
|
|
|
+// log.info("作品数量: {}", list.size());
|
|
|
+// StringBuffer dir = new StringBuffer();
|
|
|
+// for (WorkEntity entity : list) {
|
|
|
+// String sceneCodes = entity.getSceneCodes();
|
|
|
+// if (StringUtils.isNotBlank(sceneCodes)){
|
|
|
+// dir.append(sceneCodes).append(",");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// String dirCode = dir.toString();
|
|
|
+// // 替换空格
|
|
|
+// dirCode = StringUtils.replaceAll(dirCode, ",", " ");
|
|
|
+//// dirCode = StringUtils.substringBeforeLast(dirCode, ",");
|
|
|
+// log.info("下载全景目录:{}", dirCode);
|
|
|
+// String zipName = StrUtils.getTime("pano_");
|
|
|
+// zipName = "/download/" + zipName + ".zip";
|
|
|
+//
|
|
|
+// String outPath = configConstant.serverBasePath + zipName;
|
|
|
+// log.info("zip保存路径:{}", outPath);
|
|
|
+// String cmd = CmdConstant.zip;
|
|
|
+// cmd = cmd.replaceAll("@output", outPath);
|
|
|
+// cmd = cmd.replaceAll("@workPace", configConstant.serverBasePath );
|
|
|
+// cmd = cmd.replaceAll("@inDir", dirCode);
|
|
|
+//
|
|
|
+// CmdUtils.callShLine(cmd, 100);
|
|
|
+//
|
|
|
+//
|
|
|
+// return Result.success(zipName);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Result mergeTour(String workId) {
|
|
|
+// WorkEntity entity = workService.getById(workId);
|
|
|
+// BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
|
|
|
+// String sceneCodes = entity.getSceneCodes();
|
|
|
+// log.info("场景码:{}", sceneCodes);
|
|
|
+// BaseRuntimeException.isBlank(sceneCodes, null, "场景码为空, 不需要合并");
|
|
|
+//
|
|
|
+// String[] split = sceneCodes.split(",");
|
|
|
+//
|
|
|
+// // tourXml路径
|
|
|
+// String downloadPath;
|
|
|
+// String basePath = configConstant.serverBasePath;
|
|
|
+// int size = split.length;
|
|
|
+// log.info("场景数量: {}", size);
|
|
|
+// BaseRuntimeException.isHas(size==0, null, "场景码为空, 不需要合并");
|
|
|
+// String firstTourPath = File.separator + split[0] + "/vtour/tour.xml";
|
|
|
+// if (size == 1){
|
|
|
+// log.info("firstTourPath:{}", firstTourPath);
|
|
|
+// downloadPath = firstTourPath;
|
|
|
+// } else {
|
|
|
+// // 获取scene标签集合
|
|
|
+// StringBuffer sceneLabels = new StringBuffer();
|
|
|
+// int i = 0;
|
|
|
+// String tourPath;
|
|
|
+// for (String sceneCode : split) {
|
|
|
+// tourPath = basePath + File.separator + sceneCode + "/vtour/tour.xml";
|
|
|
+// String scene = getSceneLabel(tourPath);
|
|
|
+// sceneLabels.append(scene).append("\r\n");
|
|
|
+// i++;
|
|
|
+// }
|
|
|
+// log.info("标签数量: {}", i );
|
|
|
+//
|
|
|
+// // 获取第一个xml, 做为基础模板
|
|
|
+// String firstXml = handleFirstXml(basePath + firstTourPath);
|
|
|
+// // 合并
|
|
|
+// StringBuffer buffer = new StringBuffer();
|
|
|
+// buffer.append(firstXml).append(" ");
|
|
|
+// buffer.append(sceneLabels).append(" ");
|
|
|
+// buffer.append("</krpano>");
|
|
|
+// // 保存路径
|
|
|
+// downloadPath = "/download/" + workId + "_tour.xml";
|
|
|
+// String savePath = configConstant.serverBasePath + File.separator + downloadPath;
|
|
|
+// FileUtil.writeUtf8String(buffer.toString(), savePath);
|
|
|
+// log.info("合并完成,保存路径: {}", savePath);
|
|
|
+//
|
|
|
+// }
|
|
|
+// log.info("下载地址: {}", downloadPath);
|
|
|
+//
|
|
|
+// return Result.success(downloadPath);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public Result pack(String workId) {
|
|
|
+// // 复制作品目录
|
|
|
+// WorkEntity entity = workService.getById(workId);
|
|
|
+// BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
|
|
|
+// copyWork(workId);
|
|
|
+//
|
|
|
+// // 复制场景目录
|
|
|
+// copyScene(workId, entity.getSceneCodes());
|
|
|
+//
|
|
|
+// // 合并tour.xml
|
|
|
+// mergeTour(workId, entity.getSceneCodes());
|
|
|
+//
|
|
|
+// // 压缩
|
|
|
+// zipWork(workId);
|
|
|
+// String filePath = "/download/" + workId + ".zip";
|
|
|
+// log.info("zip地址:{}", configConstant.serverBasePath + filePath);
|
|
|
+// return Result.success(filePath);
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void zipWork(String workId) {
|
|
|
+// String outPath = configConstant.serverBasePath + "/download/" + workId +".zip";
|
|
|
+//// String intPath = configConstant.serverBasePath + "/download/" + workId ;
|
|
|
+//
|
|
|
+// String cmd = CmdConstant.zip;
|
|
|
+// cmd = cmd.replaceAll("@output", outPath);
|
|
|
+// cmd = cmd.replaceAll("@workPace", configConstant.serverBasePath + "/download" );
|
|
|
+// // 已引入工作目录, 直接填写目录即可
|
|
|
+// cmd = cmd.replaceAll("@inDir", workId);
|
|
|
+//
|
|
|
+// CmdUtils.callShLine(cmd, 100);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void copyScene(String workId, String sceneCodes) {
|
|
|
+// log.info("场景码: {}", sceneCodes);
|
|
|
+// if (StringUtils.isBlank(sceneCodes)){
|
|
|
+// log.info("场景码为空, 不需要下载");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// String[] split = sceneCodes.split(",");
|
|
|
+// log.info("场景数量 : {}", split.length);
|
|
|
+// String outPath = configConstant.serverBasePath + "/download/" + workId;
|
|
|
+// String inPath;
|
|
|
+// for (String sceneCode : split) {
|
|
|
+// inPath = configConstant.serverBasePath + "/" + sceneCode + "/vtour/panos/" + sceneCode + ".tiles";
|
|
|
+// String cmd = StrUtil.format("cp -r {} {} ", inPath, outPath);
|
|
|
+// CmdUtils.callCmd(cmd);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void copyWork(String workId) {
|
|
|
+// // 复制到指定目录
|
|
|
+// String outPath = configConstant.serverBasePath + "/download/";
|
|
|
+// String checkPath = outPath + workId;
|
|
|
+// // 存在则删除
|
|
|
+// if (FileUtil.isDirectory(checkPath)){
|
|
|
+// FileUtil.del(checkPath);
|
|
|
+// }
|
|
|
+// String inPath = configConstant.serverBasePath + "/work/" + workId;
|
|
|
+// String cmd = StrUtil.format("cp -r {} {} ", inPath, outPath);
|
|
|
+// CmdUtils.callCmd(cmd);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void mergeTour(String workId, String sceneCodes) {
|
|
|
+// String[] split = sceneCodes.split(",");
|
|
|
+// // tourXml路径
|
|
|
+// String downloadPath;
|
|
|
+// String outPath = configConstant.serverBasePath + "/download/" + workId;
|
|
|
+// String basePath = configConstant.serverBasePath;
|
|
|
+// int size = split.length;
|
|
|
+// log.info("场景数量: {}", size);
|
|
|
+// BaseRuntimeException.isHas(size==0, null, "场景码为空, 不需要合并");
|
|
|
+// String firstTourPath = File.separator + split[0] + "/vtour/tour.xml";
|
|
|
+// if (size == 1){
|
|
|
+// log.info("firstTourPath:{}", firstTourPath);
|
|
|
+// FileUtil.copy(configConstant.serverBasePath + firstTourPath, outPath, true);
|
|
|
+// } else {
|
|
|
+// // 获取scene标签集合
|
|
|
+// StringBuffer sceneLabels = new StringBuffer();
|
|
|
+// int i = 0;
|
|
|
+// String tourPath;
|
|
|
+// for (String sceneCode : split) {
|
|
|
+// tourPath = basePath + File.separator + sceneCode + "/vtour/tour.xml";
|
|
|
+// String scene = getSceneLabel(tourPath);
|
|
|
+// sceneLabels.append(scene).append("\r\n");
|
|
|
+// i++;
|
|
|
+// }
|
|
|
+// log.info("标签数量: {}", i );
|
|
|
+//
|
|
|
+// // 获取第一个xml, 做为基础模板
|
|
|
+// String firstXml = handleFirstXml(basePath + firstTourPath);
|
|
|
+// // 合并
|
|
|
+// StringBuffer buffer = new StringBuffer();
|
|
|
+// buffer.append(firstXml).append(" ");
|
|
|
+// buffer.append(sceneLabels).append(" ");
|
|
|
+// buffer.append("</krpano>");
|
|
|
+// // 保存路径
|
|
|
+// downloadPath = "/download/" + workId + "/tour.xml";
|
|
|
+// String savePath = configConstant.serverBasePath + File.separator + downloadPath;
|
|
|
+// FileUtil.writeUtf8String(buffer.toString(), savePath);
|
|
|
+// log.info("合并完成,保存路径: {}", savePath);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 处理第一个xml
|
|
|
+// * @param filePath
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// private static String handleFirstXml(String filePath){
|
|
|
+//
|
|
|
+// String s = FileUtil.readString(filePath, "UTF-8");
|
|
|
+//
|
|
|
+// // 截取</krpano>之前的
|
|
|
+// s = StrUtil.subBefore(s, "<scene name=", false);
|
|
|
+// return s;
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取Scene标签值
|
|
|
+// * @param filePath tour.xml路径
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// private static String getSceneLabel(String filePath){
|
|
|
+// String s = FileUtil.readString(filePath, "UTF-8");
|
|
|
+// // 截取</action>之后的
|
|
|
+// s = StrUtil.subAfter(s, "</action>", true);
|
|
|
+// // 截取</krpano>之前的
|
|
|
+// s = StrUtil.subBefore(s, "</krpano>", true);
|
|
|
+// return s;
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void test(){
|
|
|
+// String str = "1";
|
|
|
+// System.out.println(Arrays.asList(str));
|
|
|
+//
|
|
|
+// }
|
|
|
+//}
|