dsx 1 rok pred
rodič
commit
3a31f15632

+ 2 - 0
src/main/java/com/fdkankan/download/entity/DownloadLog.java

@@ -50,6 +50,8 @@ public class DownloadLog implements Serializable {
      */
     private String reason;
 
+    private Long interval;
+
     private Timestamp createTime;
 
     private Timestamp updateTime;

+ 57 - 57
src/main/java/com/fdkankan/download/listener/RsyncSceneListener.java

@@ -1,57 +1,57 @@
-package com.fdkankan.download.listener;
-
-import cn.hutool.core.io.FileUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.common.util.CmdUtils;
-import com.fdkankan.download.constant.CommonConstant;
-import com.rabbitmq.client.Channel;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.nio.charset.StandardCharsets;
-
-@Slf4j
-@Component
-public class RsyncSceneListener {
-
-    public final static String RSYNC_CMD = "rsync -avP -e 'ssh -p $port' $source $user@$host:$dest";
-
-    @Value("${rsync.host}")
-    private String host;
-
-    @Value("${rsync.port}")
-    private String port;
-
-    @Value("${rsync.username}")
-    private String username;
-
-    @Value("${rsync.dest}")
-    private  String dest;
-
-    /**
-     * 场景计算状态日志记录
-     * @param channel
-     * @param message
-     * @throws Exception
-     */
-    @RabbitListener(
-            queuesToDeclare = @Queue("rsync-scene"),
-            concurrency = "2"
-    )
-    public void buildScenePreHandler(Channel channel, Message message) throws Exception {
-        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
-        System.out.println(msg);
-        JSONObject jsonObject = JSON.parseObject(msg);
-        String path = jsonObject.getString("path");
-        String cmd = RSYNC_CMD.replace("$port", port).replace("$source", path).replace("$user", username).replace("$host", host).replace("$dest", dest);
-        CmdUtils.callLineSh(cmd);
-        FileUtil.del(path);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-
-}
+//package com.fdkankan.download.listener;
+//
+//import cn.hutool.core.io.FileUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.alibaba.fastjson.JSONObject;
+//import com.fdkankan.common.util.CmdUtils;
+//import com.fdkankan.download.constant.CommonConstant;
+//import com.rabbitmq.client.Channel;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.amqp.core.Message;
+//import org.springframework.amqp.rabbit.annotation.Queue;
+//import org.springframework.amqp.rabbit.annotation.RabbitListener;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.stereotype.Component;
+//
+//import java.nio.charset.StandardCharsets;
+//
+//@Slf4j
+//@Component
+//public class RsyncSceneListener {
+//
+//    public final static String RSYNC_CMD = "rsync -avP -e 'ssh -p $port' $source $user@$host:$dest";
+//
+//    @Value("${rsync.host}")
+//    private String host;
+//
+//    @Value("${rsync.port}")
+//    private String port;
+//
+//    @Value("${rsync.username}")
+//    private String username;
+//
+//    @Value("${rsync.dest}")
+//    private  String dest;
+//
+//    /**
+//     * 场景计算状态日志记录
+//     * @param channel
+//     * @param message
+//     * @throws Exception
+//     */
+//    @RabbitListener(
+//            queuesToDeclare = @Queue("rsync-scene"),
+//            concurrency = "2"
+//    )
+//    public void buildScenePreHandler(Channel channel, Message message) throws Exception {
+//        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+//        System.out.println(msg);
+//        JSONObject jsonObject = JSON.parseObject(msg);
+//        String path = jsonObject.getString("path");
+//        String cmd = RSYNC_CMD.replace("$port", port).replace("$source", path).replace("$user", username).replace("$host", host).replace("$dest", dest);
+//        CmdUtils.callLineSh(cmd);
+//        FileUtil.del(path);
+//        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+//    }
+//
+//}

+ 1 - 1
src/main/java/com/fdkankan/download/service/IDownloadLogService.java

@@ -19,7 +19,7 @@ public interface IDownloadLogService extends IService<DownloadLog> {
      * @param num 场景码
      * @param type 类型 kankan、laser
      */
-    void saveLog(String num, String type, Integer status, String reason);
+    void saveLog(String num, String type, Integer status, String reason, Long interval);
 
 
 }

+ 2 - 1
src/main/java/com/fdkankan/download/service/impl/DownloadLogServiceImpl.java

@@ -25,12 +25,13 @@ public class DownloadLogServiceImpl extends ServiceImpl<DownloadLogMapper, Downl
     }
 
     @Override
-    public void saveLog(String num, String type, Integer status, String reason) {
+    public void saveLog(String num, String type, Integer status, String reason, Long interval) {
         DownloadLog downloadLog = new DownloadLog();
         downloadLog.setNum(num);
         downloadLog.setType(type);
         downloadLog.setStatus(status);
         downloadLog.setReason(reason);
+        downloadLog.setInterval(interval);
         this.save(downloadLog);
     }
 }

+ 7 - 2
src/main/java/com/fdkankan/download/service/impl/DownloadServiceImpl.java

@@ -14,6 +14,7 @@ import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.constant.SceneKind;
 import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.util.DateExtUtil;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.download.constant.CommonConstant;
 import com.fdkankan.download.bean.ImageType;
@@ -137,7 +138,7 @@ public class DownloadServiceImpl implements IDownloadService {
 //            AtomicInteger count = new AtomicInteger(0);
 
             //定义压缩包
-            zipPath = String.format(this.zipLocalFormat, num);
+            zipPath = String.format(this.zipLocalFormat, DateExtUtil.format(new Date(), DateExtUtil.dateStyle6), num);
             File zipFile = new File(zipPath);
             if(!zipFile.getParentFile().exists()){
                 zipFile.getParentFile().mkdirs();
@@ -173,6 +174,8 @@ public class DownloadServiceImpl implements IDownloadService {
             //打压缩包
             ZipUtil.zip(String.format(this.sourceLocal, num, ""), zipPath);
 
+            FileUtil.del(String.format(this.sourceLocal, num, ""));
+
             return zipPath;
 
             // TODO: 2024/1/4 生成的压缩包放哪里待定
@@ -207,7 +210,9 @@ public class DownloadServiceImpl implements IDownloadService {
 //        fYunFileService.downloadFileByCommand(String.format(sourceLocal, num, this.wwwroot), String.format(UploadFilePath.VIEW_PATH, num));
         List<String> strings = fYunFileService.listRemoteFiles(String.format(UploadFilePath.VIEW_PATH, num));
         strings.stream().forEach(str->{
-            fYunFileService.downloadFile(str, String.format(sourceLocal, num, this.wwwroot).concat(str));
+            if(!str.contains("/tiles/4k/") && !str.contains("/tiles/2k/")){
+                fYunFileService.downloadFile(str, String.format(sourceLocal, num, this.wwwroot).concat(str));
+            }
         });
 //        fYunFileService.downloadFile(String.format(UploadFilePath.VIEW_PATH, num), String.format(sourceLocal, num, this.wwwroot));
 

+ 15 - 9
src/main/java/com/fdkankan/download/service/impl/GenSceneRunnerImpl.java

@@ -1,6 +1,8 @@
 package com.fdkankan.download.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.date.TimeInterval;
 import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.thread.ExecutorBuilder;
 import cn.hutool.core.util.ArrayUtil;
@@ -50,7 +52,7 @@ public class GenSceneRunnerImpl implements CommandLineRunner {
     @Autowired
     private RabbitMqProducer mqProducer;
 
-    private final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setCorePoolSize(5).setMaxPoolSize(5).build();
+    private final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setCorePoolSize(30).setMaxPoolSize(30).build();
 
     @Autowired
     ILaserService laserService;
@@ -82,6 +84,8 @@ public class GenSceneRunnerImpl implements CommandLineRunner {
                         continue;
                     }
 
+                    Thread.sleep(5000L);
+
                     List<DownloadLog> downloadLogList = downloadLogService.getByNum(scenePlus.getNum());
                     Set<String> types = downloadLogList.stream().map(DownloadLog::getType).collect(Collectors.toSet());
 
@@ -92,13 +96,14 @@ public class GenSceneRunnerImpl implements CommandLineRunner {
                             threadPoolExecutor.submit(() -> {
                                 try {
                                     // TODO: 2024/1/3 文杰实现
+                                    TimeInterval timer = DateUtil.timer();
                                     String zipPath = laserService.downloadHandler(scenePlus.getNum());
-                                    if (StrUtil.isNotEmpty(zipPath)){
-                                        send(zipPath);
-                                    }
-                                    downloadLogService.saveLog(scenePlus.getNum(), "laser", CommonSuccessStatus.SUCCESS.code(), null);
+//                                    if (StrUtil.isNotEmpty(zipPath)){
+//                                        send(zipPath);
+//                                    }
+                                    downloadLogService.saveLog(scenePlus.getNum(), "laser", CommonSuccessStatus.SUCCESS.code(), null, timer.intervalMinute());
                                 } catch (Exception e) {
-                                    downloadLogService.saveLog(scenePlus.getNum(), "laser", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000));
+                                    downloadLogService.saveLog(scenePlus.getNum(), "laser", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000), null);
                                     log.error("点云场景打包失败,num:{}", scenePlus.getNum(), e);
                                 }
                             });
@@ -114,12 +119,13 @@ public class GenSceneRunnerImpl implements CommandLineRunner {
                         if(!types.contains("kankan")) {
                             threadPoolExecutor.submit(() -> {
                                 try {
+                                    TimeInterval timer = DateUtil.timer();
                                     String zipPath = downloadService.downloadHandler(scenePlus.getNum());
-                                    send(zipPath);
-                                    downloadLogService.saveLog(scenePlus.getNum(), "kankan", CommonSuccessStatus.SUCCESS.code(), null);
+//                                    send(zipPath);
+                                    downloadLogService.saveLog(scenePlus.getNum(), "kankan", CommonSuccessStatus.SUCCESS.code(), null, timer.intervalMinute());
                                 } catch (Exception e) {
                                     log.error("看看场景打包失败,num:{}", scenePlus.getNum(), e);
-                                    downloadLogService.saveLog(scenePlus.getNum(), "kankan", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000));
+                                    downloadLogService.saveLog(scenePlus.getNum(), "kankan", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000), null);
                                 }
                             });
                         }

+ 3 - 1
src/main/java/com/fdkankan/download/service/impl/LaserService.java

@@ -10,6 +10,7 @@ import cn.hutool.system.oshi.OshiUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.util.CmdUtils;
+import com.fdkankan.common.util.DateExtUtil;
 import com.fdkankan.download.bean.ImageTypeDetail;
 import com.fdkankan.download.bean.LaserResultData;
 import com.fdkankan.download.bean.ResultData;
@@ -38,6 +39,7 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.nio.charset.Charset;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -187,7 +189,7 @@ public class LaserService  implements ILaserService {
                 }
                 String target=num + "_laser.zip";
                 File file=offlineZip(num, path, target);
-                String zipPath = String.format(this.zipLocalFormat, num + "_laser");
+                String zipPath = String.format(this.zipLocalFormat, DateExtUtil.format(new Date(), DateExtUtil.dateStyle6),num + "_laser");
                 FileUtil.move(file,new File(zipPath),true);
                 log.info("生成完成");
                 return zipPath;

+ 1 - 1
src/main/resources/application-prod.yml

@@ -88,7 +88,7 @@ zip:
 path:
   v4school: /mnt/scene_download_statics/v4local/
   source-local: /home/backend/downloads/scenes/%s/%s
-  zip-local: /home/backend/downloads/scenes/%s.zip
+  zip-local: /mnt/scenes/%s/%s.zip
   zip-root: wwwroot/
   zip-oss: downloads/scenes/%s.zip
   laserschool: /mnt/fdkk_laser/uploadPath/offlineGenerate/