|
@@ -1,14 +1,22 @@
|
|
package com.fdkankan.contro.mq.service.impl;
|
|
package com.fdkankan.contro.mq.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.fdkankan.contro.entity.OrigFileUpload;
|
|
import com.fdkankan.contro.entity.OrigFileUploadBatch;
|
|
import com.fdkankan.contro.entity.OrigFileUploadBatch;
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
import com.fdkankan.contro.mq.service.CallBuildService;
|
|
import com.fdkankan.contro.mq.service.CallBuildService;
|
|
import com.fdkankan.contro.service.IOrigFileUploadBatchService;
|
|
import com.fdkankan.contro.service.IOrigFileUploadBatchService;
|
|
import com.fdkankan.contro.service.IOrigFileUploadService;
|
|
import com.fdkankan.contro.service.IOrigFileUploadService;
|
|
import com.fdkankan.contro.service.IScenePlusService;
|
|
import com.fdkankan.contro.service.IScenePlusService;
|
|
|
|
+import com.fdkankan.contro.util.HttpUtilExt;
|
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
@@ -19,7 +27,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.File;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
@@ -67,7 +77,7 @@ public class CallBuildServiceImpl implements CallBuildService {
|
|
}
|
|
}
|
|
for (String uuid : map.keySet()) {
|
|
for (String uuid : map.keySet()) {
|
|
ScenePlus scenePlus = scenePlusService.getByUuid(uuid);
|
|
ScenePlus scenePlus = scenePlusService.getByUuid(uuid);
|
|
- boolean lock = redisLockUtil.lock("push-modeling-pre:" + scenePlus.getNum(), scenePlus.getNum(), 20*60);
|
|
|
|
|
|
+ boolean lock = redisLockUtil.lock("push-modeling-pre:" + scenePlus.getNum(), scenePlus.getNum(), 30*60);
|
|
if(!lock){
|
|
if(!lock){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -83,6 +93,19 @@ public class CallBuildServiceImpl implements CallBuildService {
|
|
}
|
|
}
|
|
BuildSceneCallMessage mqMessage = JSON.parseObject(map.get(uuid).getLast().getMqContent(), BuildSceneCallMessage.class);
|
|
BuildSceneCallMessage mqMessage = JSON.parseObject(map.get(uuid).getLast().getMqContent(), BuildSceneCallMessage.class);
|
|
mqMessage.getExt().put("batchId", batchIdStr.substring(1));
|
|
mqMessage.getExt().put("batchId", batchIdStr.substring(1));
|
|
|
|
+
|
|
|
|
+ String threeCamType = (String) mqMessage.getExt().get("threeCamType");
|
|
|
|
+ //如果场景原始资源上传批次id不为空,则需要下载批次文件上传到oss目录
|
|
|
|
+ if(StrUtil.isNotEmpty(batchIdStr)){
|
|
|
|
+ for (String batchId : batchIdStr.substring(1).split(",")) {
|
|
|
|
+ if(StrUtil.isNotEmpty(threeCamType) && "yzl".equals(threeCamType)){
|
|
|
|
+ this.downloadOrigFile4Yzl(batchId, mqMessage.getPath());
|
|
|
|
+ }else{
|
|
|
|
+ this.downloadOrigFile(batchId, mqMessage.getPath());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
|
|
rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
|
|
|
|
|
|
long incr = redisUtil.incr("modeling-count:" + scenePlus.getNum(), 1);
|
|
long incr = redisUtil.incr("modeling-count:" + scenePlus.getNum(), 1);
|
|
@@ -97,6 +120,76 @@ public class CallBuildServiceImpl implements CallBuildService {
|
|
log.info("推送计算定时任务结束");
|
|
log.info("推送计算定时任务结束");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void downloadOrigFile4Yzl(String batchId, String dataSource){
|
|
|
|
+ if(StrUtil.isEmpty(batchId)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OrigFileUpload sceneUpData = origFileUploadService.getByBatchIdAndFileName(batchId, "scene_up_data.txt");
|
|
|
|
+ String sceneUpDataPath = dataSource + "/" + "scene_up_data.txt";
|
|
|
|
+ HttpUtilExt.downloadFileAndCheck(sceneUpData.getFileUrl(), sceneUpDataPath, 60000);
|
|
|
|
+ String sceneUpDataStr = FileUtil.readUtf8String(sceneUpDataPath);
|
|
|
|
+ JSONArray fileJsonArray = JSON.parseArray(sceneUpDataStr);
|
|
|
|
+ Map<String, String> fileMap = fileJsonArray.stream().collect(Collectors.toMap(v -> ((JSONObject) v).getString("fileName"), v -> ((JSONObject) v).getString("filePath")));
|
|
|
|
+
|
|
|
|
+ List<OrigFileUpload> fileList = origFileUploadService.getByBatchId(batchId);
|
|
|
|
+ if(CollUtil.isEmpty(fileList)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String homePath = "/oss/4dkankan/" + SceneUtil.getHomePath(dataSource);
|
|
|
|
+
|
|
|
|
+ fileList.parallelStream().forEach(origFileUpload->{
|
|
|
|
+ String relativeFilePath = fileMap.get(origFileUpload.getFileName());
|
|
|
|
+ if(StrUtil.isNotEmpty(relativeFilePath)){
|
|
|
|
+ int times = 0;
|
|
|
|
+ String filePath = homePath.concat(relativeFilePath);
|
|
|
|
+ log.info("开始下载原始文件, url:{}, filePath:{}", origFileUpload.getFileUrl(), filePath);
|
|
|
|
+ do{
|
|
|
|
+ try {
|
|
|
|
+ ++times;
|
|
|
|
+ HttpUtil.downloadFile(origFileUpload.getFileUrl(), new File(filePath), 3 * 60 * 1000);
|
|
|
|
+ if(FileUtil.exist(filePath)){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.info("原始文件第{}次下载失败,fileUrl:{}, filePath:{}", times, origFileUpload.getFileUrl(), filePath);
|
|
|
|
+ }
|
|
|
|
+ }while (times < 4);
|
|
|
|
+ log.info("下载原始文件结束, url:{}, filePath:{}", origFileUpload.getFileUrl(), filePath);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void downloadOrigFile(String batchId, String dataSource){
|
|
|
|
+ if(StrUtil.isEmpty(batchId)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<OrigFileUpload> fileList = origFileUploadService.getByBatchId(batchId);
|
|
|
|
+ if(CollUtil.isEmpty(fileList)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String homePath = "/oss/4dkankan/" + SceneUtil.getHomePath(dataSource);
|
|
|
|
+
|
|
|
|
+ fileList.parallelStream().forEach(origFileUpload->{
|
|
|
|
+ int times = 0;
|
|
|
|
+ String filePath = homePath.concat(origFileUpload.getFileName());
|
|
|
|
+ log.info("开始下载原始文件, url:{}, filePath:{}", origFileUpload.getFileUrl(), filePath);
|
|
|
|
+ do{
|
|
|
|
+ try {
|
|
|
|
+ ++times;
|
|
|
|
+ HttpUtil.downloadFile(origFileUpload.getFileUrl(), new File(filePath), 3 * 60 * 1000);
|
|
|
|
+ if(FileUtil.exist(filePath)){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.info("原始文件第{}次下载失败,fileUrl:{}, filePath:{}", times, origFileUpload.getFileUrl(), filePath);
|
|
|
|
+ }
|
|
|
|
+ }while (times < 3);
|
|
|
|
+ log.info("下载原始文件结束, url:{}, filePath:{}", origFileUpload.getFileUrl(), filePath);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
List<OrigFileUploadBatch> list = new ArrayList<>();
|
|
List<OrigFileUploadBatch> list = new ArrayList<>();
|
|
OrigFileUploadBatch a = new OrigFileUploadBatch();
|
|
OrigFileUploadBatch a = new OrigFileUploadBatch();
|
|
@@ -116,7 +209,5 @@ public class CallBuildServiceImpl implements CallBuildService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|