|
@@ -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.download.bean.ImageTypeDetail;
|
|
|
import com.fdkankan.download.bean.LaserResultData;
|
|
|
import com.fdkankan.download.bean.ResultData;
|
|
|
import com.fdkankan.download.callback.ErrorCallback;
|
|
@@ -36,6 +37,7 @@ import oshi.software.os.windows.WindowsOperatingSystem;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.nio.charset.Charset;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -70,7 +72,7 @@ public class LaserService implements ILaserService {
|
|
|
@Value("${path.zip-local}")
|
|
|
private String zipLocalFormat;
|
|
|
@Override
|
|
|
- public void downloadHandler(String num) throws Exception {
|
|
|
+ public String downloadHandler(String num) throws Exception {
|
|
|
String url = host.concat(String.format(offlineData, num));
|
|
|
try {
|
|
|
LaserResultData<List<OfflineDTO> > resultData = httpClient.get(url, new SuccessLaserCallback(), new ErrorCallback());
|
|
@@ -78,61 +80,63 @@ public class LaserService implements ILaserService {
|
|
|
OperatingSystem os = OshiUtil.getOs();
|
|
|
|
|
|
List<OfflineDTO> data = resultData.getData();
|
|
|
- for (OfflineDTO datum : data) {
|
|
|
- //1 json ,2下载,3深度图 ,4全景图
|
|
|
- switch (datum.getType()) {
|
|
|
- case 1:
|
|
|
- FileUtil.writeUtf8String(JSON.toJSONStringWithDateFormat(datum.getData(),"yyyy-MM-dd HH:mm:ss").replaceAll("\\n", " ").replaceAll("\\t", " "), sourceLocal+ File.separator+datum.getPath());
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- if (os instanceof WindowsOperatingSystem){
|
|
|
- String path = datum.getKey();
|
|
|
- if (datum.getKey().startsWith("/")) {
|
|
|
- path = path.substring(1);
|
|
|
- }
|
|
|
- List<String> strings = fYunFileService.listRemoteFiles(bucket,path);
|
|
|
- for (String key : strings) {
|
|
|
- if (StrUtil.isEmpty(FileUtil.extName(key))){
|
|
|
- continue;
|
|
|
+ List<OfflineDTO> dataDetails = Collections.synchronizedList(data);
|
|
|
+ synchronized(dataDetails) {
|
|
|
+ data.parallelStream().forEach(datum -> {
|
|
|
+ //1 json ,2下载,3深度图 ,4全景图
|
|
|
+ switch (datum.getType()) {
|
|
|
+ case 1:
|
|
|
+ FileUtil.writeUtf8String(JSON.toJSONStringWithDateFormat(datum.getData(), "yyyy-MM-dd HH:mm:ss").replaceAll("\\n", " ").replaceAll("\\t", " "), sourceLocal + File.separator + datum.getPath());
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (os instanceof WindowsOperatingSystem) {
|
|
|
+ String path = datum.getKey();
|
|
|
+ if (datum.getKey().startsWith("/")) {
|
|
|
+ path = path.substring(1);
|
|
|
}
|
|
|
- String srcPath=key;
|
|
|
- if(!key.startsWith("/")){
|
|
|
- srcPath = "/"+key;
|
|
|
+ List<String> strings = fYunFileService.listRemoteFiles(bucket, path);
|
|
|
+ for (String key : strings) {
|
|
|
+ if (StrUtil.isEmpty(FileUtil.extName(key))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String srcPath = key;
|
|
|
+ if (!key.startsWith("/")) {
|
|
|
+ srcPath = "/" + key;
|
|
|
+ }
|
|
|
+ this.downloadFile(laserResourceUrl + key, sourceLocal +
|
|
|
+ File.separator + num +
|
|
|
+ File.separator + "www" +
|
|
|
+ File.separator + num + srcPath);
|
|
|
}
|
|
|
- this.downloadFile(laserResourceUrl+key,sourceLocal+
|
|
|
- File.separator+num+
|
|
|
- File.separator+"www"+
|
|
|
- File.separator+num+srcPath);
|
|
|
- }
|
|
|
- }else{
|
|
|
- String srcPath=datum.getKey();
|
|
|
- if("/".equals(datum.getKey().substring(0,1))){
|
|
|
- srcPath = srcPath.substring(1);
|
|
|
+ } else {
|
|
|
+ String srcPath = datum.getKey();
|
|
|
+ if ("/".equals(datum.getKey().substring(0, 1))) {
|
|
|
+ srcPath = srcPath.substring(1);
|
|
|
+ }
|
|
|
+ fYunFileService.downloadFileByCommand(bucket, sourceLocal + datum.getPath(), srcPath);
|
|
|
}
|
|
|
- fYunFileService.downloadFileByCommand(bucket,sourceLocal+datum.getPath(),srcPath);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3:
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
// if (os instanceof WindowsOperatingSystem){
|
|
|
String path = datum.getKey();
|
|
|
if (datum.getKey().startsWith("/")) {
|
|
|
path = path.substring(1);
|
|
|
}
|
|
|
- List<String> strings = fYunFileService.listRemoteFiles(bucket,path);
|
|
|
+ List<String> strings = fYunFileService.listRemoteFiles(bucket, path);
|
|
|
for (String key : strings) {
|
|
|
- if (StrUtil.isEmpty(FileUtil.extName(key))||FileUtil.extName(key).equalsIgnoreCase("ply")){
|
|
|
+ if (StrUtil.isEmpty(FileUtil.extName(key)) || FileUtil.extName(key).equalsIgnoreCase("ply")) {
|
|
|
continue;
|
|
|
}
|
|
|
- this.downloadFile(laserResourceUrl+key,sourceLocal+
|
|
|
- File.separator+num+
|
|
|
- File.separator+"www"+
|
|
|
- File.separator+num+
|
|
|
- File.separator+"wwwroot"+
|
|
|
- File.separator+datum.getSceneCode()+
|
|
|
- File.separator+"data"+
|
|
|
- File.separator+datum.getSceneCode()+
|
|
|
- File.separator+"depthmap"+
|
|
|
- File.separator+FileUtil.getName(key));
|
|
|
+ this.downloadFile(laserResourceUrl + key, sourceLocal +
|
|
|
+ File.separator + num +
|
|
|
+ File.separator + "www" +
|
|
|
+ File.separator + num +
|
|
|
+ File.separator + "wwwroot" +
|
|
|
+ File.separator + datum.getSceneCode() +
|
|
|
+ File.separator + "data" +
|
|
|
+ File.separator + datum.getSceneCode() +
|
|
|
+ File.separator + "depthmap" +
|
|
|
+ File.separator + FileUtil.getName(key));
|
|
|
}
|
|
|
// }else{
|
|
|
// String srcPath=datum.getKey();
|
|
@@ -147,13 +151,18 @@ public class LaserService implements ILaserService {
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- downloadService.cutImg(datum.getSceneCode(),sourceLocal+datum.getPath(),"4k","tiles");
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ try {
|
|
|
+ downloadService.cutImg(datum.getSceneCode(), sourceLocal + datum.getPath(), "4k", "tiles");
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
String path=sourceLocal+File.separator+num;
|
|
|
|
|
@@ -181,14 +190,15 @@ public class LaserService implements ILaserService {
|
|
|
String zipPath = String.format(this.zipLocalFormat, num + "_laser");
|
|
|
FileUtil.move(file,new File(zipPath),true);
|
|
|
log.info("生成完成");
|
|
|
+ return zipPath;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ throw e;
|
|
|
}finally {
|
|
|
// String path=sourceLocal+File.separator+num;
|
|
|
// FileUtil.del(path);
|
|
|
}
|
|
|
-
|
|
|
+ return "";
|
|
|
}
|
|
|
@SneakyThrows
|
|
|
public File offlineZip(String sceneCode, String path, String target) {
|