|
@@ -71,54 +71,52 @@ public class HaixinServiceImpl implements IHaixinService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void noticHaixin(String num, boolean buildSuccess) throws Exception {
|
|
public void noticHaixin(String num, boolean buildSuccess) throws Exception {
|
|
-
|
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
String taskId = scenePlus.getTaskId();
|
|
String taskId = scenePlus.getTaskId();
|
|
-
|
|
|
|
String zipDir = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "haixin/";
|
|
String zipDir = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "haixin/";
|
|
String zipPath = zipDir + num + ".zip";
|
|
String zipPath = zipDir + num + ".zip";
|
|
- if(buildSuccess){//计算成功,把原始资源打压缩包
|
|
|
|
- //复制scene_edit_data/num/data/mapping目录到view目录
|
|
|
|
- String editMappingPath = "/oss/4dkankan/" + String.format(UploadFilePath.DATA_EDIT_PATH, num) + "mapping";
|
|
|
|
- String viewMappingPath = "/oss/4dkankan/" + String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mapping";
|
|
|
|
- if(FileUtil.exist(editMappingPath)){
|
|
|
|
- FileUtil.copyContent(new File(editMappingPath), new File(viewMappingPath), true);
|
|
|
|
|
|
+ try {
|
|
|
|
+ if(buildSuccess){//计算成功,把原始资源打压缩包
|
|
|
|
+ //复制scene_edit_data/num/data/mapping目录到view目录
|
|
|
|
+ String editMappingPath = "/oss/4dkankan/" + String.format(UploadFilePath.DATA_EDIT_PATH, num) + "mapping";
|
|
|
|
+ String viewMappingPath = "/oss/4dkankan/" + String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mapping";
|
|
|
|
+ if(FileUtil.exist(editMappingPath)){
|
|
|
|
+ FileUtil.copyContent(new File(editMappingPath), new File(viewMappingPath), true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String viewPath = "/oss/4dkankan/" + String.format(UploadFilePath.VIEW_PATH, num);
|
|
|
|
+
|
|
|
|
+ //删除user目录
|
|
|
|
+ String userViewPath = "/oss/4dkankan/" + String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
|
|
+ FileUtil.del(userViewPath);
|
|
|
|
+
|
|
|
|
+ //打压缩包
|
|
|
|
+ this.zip(viewPath, zipPath);
|
|
|
|
+
|
|
|
|
+ //上传到fastdf
|
|
|
|
+ String url = haixinHost.concat(API_FDFS_UPLOAD);
|
|
|
|
+ List<File> files = FileUtil.loopFiles(zipDir);
|
|
|
|
+ List<String> fileNameRemoteList = new ArrayList<>();
|
|
|
|
+ String finalUrl = url;
|
|
|
|
+ files.stream().forEach(file->{
|
|
|
|
+ JSONObject jsonObject = haixinClient.uploadToFdfs(finalUrl, file.getAbsolutePath());
|
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
+ fileNameRemoteList.add(data.getString("fileNameRemote"));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //通知计算结果
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ for (String fileNameRemote : fileNameRemoteList) {
|
|
|
|
+ sb.append(",").append(fileNameRemote);
|
|
|
|
+ }
|
|
|
|
+ this.sendResult(taskId, sb.substring(1));
|
|
|
|
+ }else{
|
|
|
|
+ this.sendResult(taskId, null);
|
|
}
|
|
}
|
|
-
|
|
|
|
- String viewPath = "/oss/4dkankan/" + String.format(UploadFilePath.VIEW_PATH, num);
|
|
|
|
-
|
|
|
|
- //删除user目录
|
|
|
|
- String userViewPath = "/oss/4dkankan/" + String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
|
|
- FileUtil.del(userViewPath);
|
|
|
|
-
|
|
|
|
- //打压缩包
|
|
|
|
- this.zip(viewPath, zipPath);
|
|
|
|
-
|
|
|
|
- //上传到fastdf
|
|
|
|
- String url = haixinHost.concat(API_FDFS_UPLOAD);
|
|
|
|
- List<File> files = FileUtil.loopFiles(zipDir);
|
|
|
|
- List<String> fileNameRemoteList = new ArrayList<>();
|
|
|
|
- String finalUrl = url;
|
|
|
|
- files.stream().forEach(file->{
|
|
|
|
- JSONObject jsonObject = haixinClient.uploadToFdfs(finalUrl, file.getAbsolutePath());
|
|
|
|
- JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
- fileNameRemoteList.add(data.getString("fileNameRemote"));
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- //通知计算结果
|
|
|
|
- url = haixinHost.concat(API_SUBMIT_RENDER_RESULT);
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
|
- for (String fileNameRemote : fileNameRemoteList) {
|
|
|
|
- sb.append(",").append(fileNameRemote);
|
|
|
|
- }
|
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
|
- params.put("vendor","A0BF");
|
|
|
|
- params.put("projectId", taskId);
|
|
|
|
- params.put("packetPath", sb.substring(1));
|
|
|
|
- haixinClient.postJson(url, params);
|
|
|
|
-
|
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.warn("推送计算结果失败,taskId:{}", taskId, e);
|
|
|
|
+ this.sendResult(taskId, null);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void zip(String sourcePath, String zipPath) throws Exception {
|
|
private void zip(String sourcePath, String zipPath) throws Exception {
|
|
@@ -126,4 +124,14 @@ public class HaixinServiceImpl implements IHaixinService {
|
|
String cmd = "cd " + sourcePath + " && zip -r -s 2048M " + zipPath + " *";//&& mv -f " + zipPath + " " + target
|
|
String cmd = "cd " + sourcePath + " && zip -r -s 2048M " + zipPath + " *";//&& mv -f " + zipPath + " " + target
|
|
CmdUtils.callLineSh(cmd, 200);
|
|
CmdUtils.callLineSh(cmd, 200);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendResult(String taskId, String packetPath){
|
|
|
|
+ String url = haixinHost.concat(API_SUBMIT_RENDER_RESULT);
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
|
+ params.put("vendor","A0BF");
|
|
|
|
+ params.put("projectId", taskId);
|
|
|
|
+ params.put("packetPath", packetPath);
|
|
|
|
+ haixinClient.postJson(url, params);
|
|
|
|
+ }
|
|
}
|
|
}
|