Browse Source

更新:
注释线程池,oss没有用异步

wuweihao 4 years ago
parent
commit
c6a49055d9

+ 6 - 1
cms_pano_consumer/remark.md

@@ -1,3 +1,8 @@
 # 切图命令
  1. ./krpanotools makepano -config=templates/vtour-multires.config /root/user/owen_test/krpano/test.jpg
- 2. krpanotools makepano -config=templates/vtour-multires.config /home/720yun/krpano/test.jpg
+ 2. krpanotools makepano -config=templates/vtour-multires.config /home/720yun/krpano/test.jpg
+ 
+ 
+# 注意
+    2021-02-25 
+    启动线程池后,server、mapper @@Autowired注入失败,目前注释了线程池,此问题还没解决

+ 0 - 1
cms_pano_consumer/src/main/java/com/gis/ConsumerApplication.java

@@ -3,7 +3,6 @@ package com.gis;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
-
 @SpringBootApplication
 public class ConsumerApplication {
 

+ 24 - 1
cms_pano_consumer/src/main/java/com/gis/controller/TestController.java

@@ -1,11 +1,13 @@
 package com.gis.controller;
 
-import com.gis.dto.HouseDto;
+import com.gis.entity.SceneEntity;
+import com.gis.mapper.SceneMapper;
 import com.gis.util.Result;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -17,6 +19,24 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("aa")
 public class TestController {
 
+//    @Autowired
+//    SceneService sceneService;
+
+    @Autowired
+    SceneMapper sceneMapper;
+
+
+    @GetMapping("find/{code}")
+    private Result find(@PathVariable String code){
+        log.info("run find");
+//        SceneEntity entity = sceneService.findById(code);
+        SceneEntity entity = sceneMapper.selectByPrimaryKey(code);
+        log.info("entity: " + entity.toString());
+
+        return Result.success();
+
+    }
+
 
     @GetMapping("bb")
     private Result addHouse(){
@@ -40,4 +60,7 @@ public class TestController {
     }
 
 
+
+
+
 }

+ 0 - 46
cms_pano_consumer/src/main/java/com/gis/dto/HouseDto.java

@@ -1,46 +0,0 @@
-package com.gis.dto;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-/**
- * Created by owen on 2021/1/13 0013 14:35
- */
-@Data
-public class HouseDto {
-
-    @ApiModelProperty(value = "创建者ID")
-    private String createById;
-
-    @ApiModelProperty(value = "房源标题")
-    private String houseTitle;
-
-    @ApiModelProperty(value = "房源类型")
-    private Integer type;
-
-    @ApiModelProperty(value = "场景链接")
-    private String vrLink;
-
-    @ApiModelProperty(value = "封面照片url")
-    private String coverImagUrl;
-
-    @ApiModelProperty(value = "所属楼盘ID")
-    private String estateId;
-
-//              "auditTime": "",
-//              "auditorId": "",
-//              "auditorName": "",
-//              "coverImagUrl": "",
-//              "createById": "",
-//              "createByName": "",
-//              "createTime": "",
-//              "estateId": "",
-//              "houseTitle": "",
-//              "id": "",
-//              "isDelete": 0,
-//              "online": 0,
-//              "status": 0,
-//              "type": 0,
-//              "updateTime": "",
-//              "vrLink": ""
-}

+ 0 - 18
cms_pano_consumer/src/main/java/com/gis/feign/HouseFeign.java

@@ -1,18 +0,0 @@
-//package com.gis.feign;
-//
-//import com.gis.dto.HouseDto;
-//import com.gis.util.Result;
-//import org.springframework.cloud.openfeign.FeignClient;
-//import org.springframework.http.MediaType;
-//import org.springframework.web.bind.annotation.PostMapping;
-//import org.springframework.web.bind.annotation.RequestBody;
-//
-///**
-// * Created by owen on 2021/1/13 0013 14:15
-// */
-//@FeignClient(value = "fbc-project-manager")
-//public interface HouseFeign {
-//
-//    @PostMapping(value = "/fcb/house/addHouse", consumes = MediaType.APPLICATION_JSON_VALUE, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
-//    Result addHouse(@RequestBody HouseDto param);
-//}

+ 52 - 2
cms_pano_consumer/src/main/java/com/gis/listener/PanoConsumer.java

@@ -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());
+    }
+
+
 
 
 

+ 45 - 42
cms_pano_consumer/src/main/java/com/gis/task/TaskExecutePool.java

@@ -1,42 +1,45 @@
-package com.gis.task;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * Created by owen on 2017/8/29.
- */
-@Configuration
-@EnableAsync
-public class TaskExecutePool {
-
-    @Value("${spring.task.pool.corePoolSize}")
-    private int corePoolSize;
-    @Value("${spring.task.pool.corePoolSize}")
-    private int maxPoolSize;
-    @Value("${spring.task.pool.keepAliveSeconds}")
-    private int keepAliveSeconds;
-    @Value("${spring.task.pool.queueCapacity}")
-    private int queueCapacity;
-
-    @Bean
-    public Executor taskExecutor() {
-        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        executor.setCorePoolSize(corePoolSize);
-        executor.setMaxPoolSize(maxPoolSize);
-        executor.setQueueCapacity(queueCapacity);
-        executor.setKeepAliveSeconds(keepAliveSeconds);
-        executor.setThreadNamePrefix("MyExecutor-");
-        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
-        // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
-        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-        executor.initialize();
-        return executor;
-    }
-}
+//package com.gis.task;
+//
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.scheduling.annotation.EnableAsync;
+//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.concurrent.Executor;
+//import java.util.concurrent.ThreadPoolExecutor;
+//
+///**
+// * Created by owen on 2017/8/29.
+// * https://blog.csdn.net/h2453532874/article/details/108480673
+// */
+////@Configuration
+//@Component
+//@EnableAsync
+//public class TaskExecutePool {
+//
+//    @Value("${spring.task.pool.corePoolSize}")
+//    private int corePoolSize;
+//    @Value("${spring.task.pool.corePoolSize}")
+//    private int maxPoolSize;
+//    @Value("${spring.task.pool.keepAliveSeconds}")
+//    private int keepAliveSeconds;
+//    @Value("${spring.task.pool.queueCapacity}")
+//    private int queueCapacity;
+//
+//    @Bean
+//    public Executor taskExecutor() {
+//        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+//        executor.setCorePoolSize(corePoolSize);
+//        executor.setMaxPoolSize(maxPoolSize);
+//        executor.setQueueCapacity(queueCapacity);
+//        executor.setKeepAliveSeconds(keepAliveSeconds);
+//        executor.setThreadNamePrefix("MyExecutor-");
+//        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
+//        // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
+//        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+//        executor.initialize();
+//        return executor;
+//    }
+//}

+ 2 - 2
cms_pano_consumer/src/main/java/com/gis/util/AliyunOssUtil.java

@@ -111,9 +111,9 @@ public class AliyunOssUtil {
         if (filepaths.size() > 50) {
             int i = 1;
             for (String filePath : filepaths.keySet()) {
-                if (i%100 == 0) {
+                if (i%400 == 0) {
 
-                    log.info("i= " +i + ", 文件:" + filePath + "到阿里云:" + filepaths.get(filePath));
+                    log.debug("i= " +i + ", 文件:" + filePath + "到阿里云:" + filepaths.get(filePath));
                 }
                 upload2(filePath, filepaths.get(filePath));
                 i ++ ;

+ 1 - 1
cms_pano_consumer/src/main/resources/application-dev.properties

@@ -37,7 +37,7 @@ spring.datasource.druid.stat-view-servlet.enabled=true
 #spring.rabbitmq.password=guest
 
 # rabbitmq ¼¯ÈºÅäÖÃ
-spring.rabbitmq.address=192.168.0.135:5672
+spring.rabbitmq.address=127.0.0.1:5672
 spring.rabbitmq.username=guest
 spring.rabbitmq.password=guest
 spring.rabbitmq.virtual-host=/

+ 1 - 1
cms_pano_consumer/src/main/resources/application-sit.properties

@@ -67,7 +67,7 @@ oss.domain=https://oss-xiaoan.oss-cn-shenzhen.aliyuncs.com/
 #log
 logging.path=/home/data/${project.name}_log
 logging.config=classpath:logback-spring.xml
-logging.level.com.gis=info
+logging.level.com.gis=debug
 
 
 # ÉÏ´«Îļþ±£´æÂ·¾¶

+ 3 - 0
cms_pano_fcb/remark.md

@@ -114,6 +114,9 @@ sit:
    ex_011869840
    4Dade_lhl01
    
+   潘莉蓝
+   ex_123039440   4Dade_pll01
+   
    
    /tmp/a/