|
@@ -1,5 +1,6 @@
|
|
|
package com.gis.listener;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import com.gis.constant.CmdConstant;
|
|
|
import com.gis.constant.ConfigConstant;
|
|
|
import com.gis.constant.RabbitConfig;
|
|
@@ -8,6 +9,7 @@ import com.gis.exception.BaseRuntimeException;
|
|
|
import com.gis.mapper.SceneMapper;
|
|
|
import com.gis.server.SceneService;
|
|
|
import com.gis.task.AsyncTask;
|
|
|
+import com.gis.util.AliyunOssUtil;
|
|
|
import com.gis.util.CmdUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -16,6 +18,8 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Created by owen on 2021/1/12 0012 10:05
|
|
@@ -35,12 +39,20 @@ public class PanoConsumer {
|
|
|
SceneMapper sceneMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- AsyncTask asyncTask;
|
|
|
+ AliyunOssUtil aliyunOssUtil;
|
|
|
+
|
|
|
+// @Autowired
|
|
|
+// AsyncTask asyncTask;
|
|
|
|
|
|
|
|
|
@RabbitHandler
|
|
|
public void getMessage(String param) {
|
|
|
log.warn("run Listener PanoConsumer: " + param);
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
cmdPano(param);
|
|
|
log.warn("end Listener PanoConsumer: "+ param);
|
|
|
}
|
|
@@ -63,7 +75,8 @@ public class PanoConsumer {
|
|
|
CmdUtils.cmdPano(cmd);
|
|
|
long end = System.currentTimeMillis();
|
|
|
log.info("切图完成耗时: {} s" ,(end-start)/1000);
|
|
|
- asyncTask.uploadOss(entity);
|
|
|
+ uploadOss(entity);
|
|
|
+
|
|
|
|
|
|
entity.setStatus(3);
|
|
|
} catch (Exception e) {
|
|
@@ -76,6 +89,43 @@ public class PanoConsumer {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void uploadOss(SceneEntity entity) throws IOException {
|
|
|
+
|
|
|
+ log.info("run uploadOss, id: " + entity.getId());
|
|
|
+ String houseId = entity.getHouseId();
|
|
|
+ String sceneCode = entity.getSceneCode();
|
|
|
+ log.info("sceneCode: " + sceneCode);
|
|
|
+ String dirCode = houseId + "/" + sceneCode;
|
|
|
+ String basePath = configConstant.filePath + dirCode;
|
|
|
+ // 上传oss: vtour/panos vtour/tour.xml
|
|
|
+ String dirPath = basePath + "/vtour/panos";
|
|
|
+
|
|
|
+ long OssStart = System.currentTimeMillis();
|
|
|
+ log.info("dirPath: " + dirPath);
|
|
|
+ log.info("dirCode: " + dirCode);
|
|
|
+ log.info("ossBasePath: " + configConstant.ossBasePath);
|
|
|
+
|
|
|
+ String tourPath = basePath + "/vtour/tour.xml";
|
|
|
+ log.info("tourPath: " + tourPath);
|
|
|
+ if (!FileUtil.isFile(tourPath)) {
|
|
|
+ String msg = "服务器tour.xml不存在";
|
|
|
+ log.error(msg);
|
|
|
+ throw new BaseRuntimeException(msg);
|
|
|
+ }
|
|
|
+ String tourOssPath = configConstant.ossBasePath + dirCode + "/vtour/tour.xml";
|
|
|
+ log.info("tourOssPath: " + tourOssPath);
|
|
|
+ aliyunOssUtil.upload(tourPath, tourOssPath);
|
|
|
+ log.info("tour.xml上传oss完成");
|
|
|
+ aliyunOssUtil.uploadDir(dirPath, sceneCode, configConstant.ossBasePath, houseId);
|
|
|
+ log.info("全局切图目录上传oss完成");
|
|
|
+ long OssEnd = System.currentTimeMillis();
|
|
|
+ log.info("uploadOss耗时: {} s" ,(OssEnd-OssStart)/1000);
|
|
|
+ // 2: 完成
|
|
|
+
|
|
|
+ log.info("end uploadOss, sceneId: " + entity.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|