浏览代码

add offline queue5

xiewj 3 月之前
父节点
当前提交
cbcc491673

+ 4 - 0
720yun_fd_base/gis_service/src/main/java/com/gis/service/WorkHotsFodderService.java

@@ -4,6 +4,8 @@ package com.gis.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gis.domain.entity.WorkHotsFodderEntity;
 
+import java.util.List;
+
 
 /**
  * Created by owen on 2020/3/11 0011 16:14
@@ -30,4 +32,6 @@ public interface WorkHotsFodderService extends IService<WorkHotsFodderEntity> {
     void removeByWorkIdAndType(String workId,  String type);
     void removeByWorkId(String workId);
     void removeBySceneCodeWorkIdAndType(String sceneCode,String workId,  String type);
+
+    List<WorkHotsFodderEntity> findAllByWorkId(String workId);
 }

+ 14 - 0
720yun_fd_base/gis_service/src/main/java/com/gis/service/impl/WorkHotsFodderServiceImpl.java

@@ -11,6 +11,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Collections;
+import java.util.List;
+
 
 /**
  * Created by owen on 2020/3/11 0011 16:16
@@ -93,4 +96,15 @@ public class WorkHotsFodderServiceImpl extends ServiceImpl<WorkHotsFodderMapper,
         wrapper.eq(WorkHotsFodderEntity::getType, type);
         remove(wrapper);
     }
+
+    @Override
+    public List<WorkHotsFodderEntity> findAllByWorkId(String workId) {
+        if (StrUtil.isEmpty(workId)){
+            return Collections.emptyList();
+        }
+        LambdaQueryWrapper<WorkHotsFodderEntity> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(WorkHotsFodderEntity::getWorkId, workId);
+        wrapper.eq(WorkHotsFodderEntity::getIsDelete, 0);
+        return list(wrapper);
+    }
 }

+ 28 - 4
720yun_fd_consumer/src/main/java/com/gis/listener/container/WorkOfflineListener.java

@@ -17,8 +17,7 @@ import com.gis.common.util.RedisUtil;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.WorkOfflineDTO;
 import com.gis.domain.dto.WorkOfflineDoneDTO;
-import com.gis.domain.entity.WorkEntity;
-import com.gis.domain.entity.WorkNavigationEntity;
+import com.gis.domain.entity.*;
 import com.gis.domain.vo.WorkIdVO;
 import com.gis.domain.vo.WorkViewVo;
 import com.gis.oss.constant.CmdConstant;
@@ -80,6 +79,17 @@ public class WorkOfflineListener implements ChannelAwareMessageListener {
 
     @Value("${other-bucket.fdkk}")
     String fdkkBucket;
+
+    @Autowired
+    WorkHotService workHotService;
+
+    @Autowired
+    WorkHotsFodderService workHotsFodderService;
+
+    @Autowired
+    FodderService fodderService;
+
+
     @Override
     @LogAnnotation
     public void onMessage(Message message, Channel channel) throws Exception {
@@ -134,6 +144,19 @@ public class WorkOfflineListener implements ChannelAwareMessageListener {
                 String meshBasePath = param.getPath() + File.separator + "mesh";
                 redisUtil.set(progressKey, 20);
 
+                //下载热点资源
+
+                List<WorkHotsFodderEntity> workHotsFodderEntityList = workHotsFodderService.findAllByWorkId(param.getWorkId());
+                workHotsFodderEntityList.forEach(workHotsFodderEntity -> {
+                    FodderEntity fodderEntity = fodderService.getById(workHotsFodderEntity.getFodderId());
+                    if (ObjUtil.isNotEmpty(fodderEntity)&&fodderEntity.getStatus()==3){
+                        log.info("下载热点资源:{}", fodderEntity.getOssPath());
+                        String ossKeyHot = fodderEntity.getOssPath().replaceAll(fileStorageTemplate.calculateUrl(""), "");
+                        String defaultDataPath =basePath+File.separator+ossKeyHot;
+                        fileStorageTemplate.ossDownloadFileToLocal(ossKeyHot, defaultDataPath);
+                    }
+                });
+
                 // 处理关联的作品和场景
                 List<WorkNavigationEntity> workNavigationEntities = workNavigationService.selectByWorkId(workEntity.getId());
 
@@ -147,6 +170,7 @@ public class WorkOfflineListener implements ChannelAwareMessageListener {
                             String PanoOssKey = baseOssKey + "/" + workNavigationEntity.getSceneCode();
                             log.info("下载作品类-全景图:{},下载路径-PanoOssKey", workNavigationEntity.getSceneCode(), PanoOssKey);
                             OssShUtil.yunDownload(PanoOssKey, basePath + File.separator + baseOssKey);
+
                         } else if (workNavigationEntity.getType().equalsIgnoreCase("4dkk")) {
                             // 整合离线包
                             String zipPath = meshBasePath + File.separator + workNavigationEntity.getSceneCode() + ".zip";
@@ -199,11 +223,11 @@ public class WorkOfflineListener implements ChannelAwareMessageListener {
                 CmdUtils.callLineSh(zipCmd);
 
                 log.info("开始将文件上传OSS");
-                String zipOssKey = "720yun_fd_manage/"+workEntity.getId()+"/" + zipName;
+                String zipOssKey = "720yun_fd_manage/offline/"+workEntity.getId()+"/" + zipName;
                 redisUtil.set(progressKey, 90);
                 OssShUtil.yunUpload(param.getPath() + File.separator + zipName,zipOssKey);
                 redisUtil.set(progressKey, 100);
-                String ossUrl = fileStorageTemplate.calculateUrl(zipOssKey);
+                String ossUrl = fileStorageTemplate.calculateUrl(zipOssKey)+"?t="+System.currentTimeMillis();
                 log.info("上传OSS完成,{}", ossUrl );
                 workService.updateOfflineStatusAndUrl(param.getWorkId(), 3,ossUrl);
                 WorkOfflineDoneDTO workOfflineDoneDTO=new WorkOfflineDoneDTO();