|
@@ -94,6 +94,10 @@ public class RunBuild {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 场景渲染
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
private void buildCopy(String data) {
|
|
|
String[] datas = data.split(":;");
|
|
|
String vrNum = datas[0];
|
|
@@ -546,7 +550,7 @@ public class RunBuild {
|
|
|
|
|
|
if(objectJson.containsKey("progress")){
|
|
|
Integer progress = objectJson.getInteger("progress");
|
|
|
- log.info("第{}次获取上传进度,进度为{}%", times++, progress);
|
|
|
+ log.info("第{}次获取渲染进度,进度为{}%", times++, progress);
|
|
|
SceneLightEntity sceneLightEntity = new SceneLightEntity();
|
|
|
sceneLightEntity.setId(Long.valueOf(taskId));
|
|
|
sceneLightEntity.setProgress(progress);
|
|
@@ -645,6 +649,10 @@ public class RunBuild {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 模型上传
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
private void modelBuild(String data){
|
|
|
String[] datas = data.split(":;");
|
|
|
String modelUploadId = datas[0];
|
|
@@ -873,6 +881,10 @@ public class RunBuild {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成封面图
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
private void modelCreatThum(String data){
|
|
|
String[] datas = data.split(":;");
|
|
|
String fileId = datas[0];
|
|
@@ -892,63 +904,12 @@ public class RunBuild {
|
|
|
jsonObject.put("taskType", taskType);
|
|
|
jsonObject.put("taskId", userId);
|
|
|
jsonObject.put("params1", JSONObject.parseObject(dataJson).getJSONObject("Param1"));
|
|
|
- while (true){
|
|
|
- String buildResult = OkHttpUtils.httpPostJson(modelBuildUrl + "pro", jsonObject.toJSONString());
|
|
|
- JSONObject buildJson = JSONObject.parseObject(buildResult);
|
|
|
-
|
|
|
- if("isBusy".equals(buildJson.getString("msg"))){
|
|
|
- Thread.sleep(2000L);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if("error".equals(buildJson.getString("state"))){
|
|
|
- FileUtils.writeFile(filePath + "/error-pro-thum.json", buildJson.toJSONString());
|
|
|
- throw new RuntimeException(fileId + ":" + taskType + "方式pro接口返回error错误");
|
|
|
- }
|
|
|
|
|
|
- break;
|
|
|
- }
|
|
|
+ postExaggerateSurace(fileId, modelId, taskType, filePath, jsonObject);
|
|
|
|
|
|
Thread.sleep(1000L);
|
|
|
- boolean over = false;
|
|
|
- while (true) {
|
|
|
- String checkResult = OkHttpUtils.httpPostJson(modelBuildUrl + "check", jsonObject.toJSONString());
|
|
|
- JSONObject checkJson = JSONObject.parseObject(checkResult);
|
|
|
-
|
|
|
- JSONArray checkArray = checkJson.getJSONArray("msg");
|
|
|
-
|
|
|
- if (checkArray.size() == 0) {
|
|
|
- FileUtils.writeFile(filePath + "/error-check-thum.json", checkJson.toJSONString());
|
|
|
- throw new RuntimeException(fileId + ":" + taskType + "方式check接口返回error错误");
|
|
|
- }
|
|
|
-
|
|
|
- for(int i = 0, len = checkArray.size(); i < len; i++){
|
|
|
- JSONObject objectJson = checkArray.getJSONObject(i);
|
|
|
-
|
|
|
- if("error".equals(objectJson.getString("state"))){
|
|
|
- FileUtils.writeFile(filePath + "/error-check-thum.json", checkJson.toJSONString());
|
|
|
- throw new RuntimeException(fileId + ":" + taskType + "方式check接口返回error错误");
|
|
|
- }
|
|
|
-
|
|
|
- if(objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
|
|
|
- "done".equals(objectJson.getString("state")) )){
|
|
|
- over = true;
|
|
|
- }
|
|
|
-
|
|
|
- if(objectJson.containsKey("progress")){
|
|
|
- modelUploadEntity = new ModelUploadEntity();
|
|
|
- modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
- modelUploadEntity.setProgress(objectJson.getInteger("progress"));
|
|
|
- modelUploadService.update(modelUploadEntity);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(over){
|
|
|
- break;
|
|
|
- }
|
|
|
|
|
|
- Thread.sleep(1000L);
|
|
|
- }
|
|
|
+ checkExaggerateSurace(jsonObject, filePath, fileId, modelId, taskType);
|
|
|
|
|
|
uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + fileId + "/" + fileId + "_preview.jpg", filePath + fileId + "_preview.jpg");
|
|
|
modelUploadEntity = new ModelUploadEntity();
|
|
@@ -957,7 +918,7 @@ public class RunBuild {
|
|
|
modelUploadEntity.setProgress(100);
|
|
|
modelUploadService.update(modelUploadEntity);
|
|
|
}catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("生成封面失败-{}", e);
|
|
|
modelUploadEntity = new ModelUploadEntity();
|
|
|
modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
modelUploadEntity.setThumStatus(-1);
|
|
@@ -965,4 +926,94 @@ public class RunBuild {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 轮询检查渲染接口
|
|
|
+ * @param jsonObject
|
|
|
+ * @param filePath
|
|
|
+ * @param fileId
|
|
|
+ * @param modelId
|
|
|
+ * @param taskType
|
|
|
+ * @throws IOException
|
|
|
+ * @throws InterruptedException
|
|
|
+ */
|
|
|
+ private void checkExaggerateSurace(JSONObject jsonObject,
|
|
|
+ String filePath,
|
|
|
+ String fileId,
|
|
|
+ String modelId,
|
|
|
+ String taskType
|
|
|
+ ) throws IOException, InterruptedException {
|
|
|
+ boolean over = false;
|
|
|
+ while (true) {
|
|
|
+ String checkResult = OkHttpUtils.httpPostJson(modelBuildUrl + "check", jsonObject.toJSONString());
|
|
|
+ JSONObject checkJson = JSONObject.parseObject(checkResult);
|
|
|
+
|
|
|
+ JSONArray checkArray = checkJson.getJSONArray("msg");
|
|
|
+
|
|
|
+ if (checkArray.size() == 0) {
|
|
|
+ FileUtils.writeFile(filePath + "/error-check-thum.json", checkJson.toJSONString());
|
|
|
+ throw new RuntimeException(fileId + ":" + taskType + "方式check接口返回error错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i = 0, len = checkArray.size(); i < len; i++){
|
|
|
+ JSONObject objectJson = checkArray.getJSONObject(i);
|
|
|
+
|
|
|
+ if("error".equals(objectJson.getString("state"))){
|
|
|
+ FileUtils.writeFile(filePath + "/error-check-thum.json", checkJson.toJSONString());
|
|
|
+ throw new RuntimeException(fileId + ":" + taskType + "方式check接口返回error错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
|
|
|
+ "done".equals(objectJson.getString("state")) )){
|
|
|
+ over = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(objectJson.containsKey("progress")){
|
|
|
+ ModelUploadEntity modelUploadEntity = new ModelUploadEntity();
|
|
|
+ modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
+ modelUploadEntity.setProgress(objectJson.getInteger("progress"));
|
|
|
+ modelUploadService.update(modelUploadEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(over){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ Thread.sleep(1000L);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 请求封面渲染接口获取接口数据
|
|
|
+ * @param fileId
|
|
|
+ * @param modelId
|
|
|
+ * @param taskType
|
|
|
+ * @param filePath
|
|
|
+ * @param jsonObject
|
|
|
+ * @throws InterruptedException
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ private void postExaggerateSurace(String fileId, String modelId, String taskType, String filePath, JSONObject jsonObject) throws InterruptedException, IOException {
|
|
|
+ while (true){
|
|
|
+ String url = modelBuildUrl + "pro";
|
|
|
+ String json = jsonObject.toJSONString();
|
|
|
+ log.info("modelId-{}, 请求封面渲染接口获取接口数据-{},参数-{}", modelId, json);
|
|
|
+ String buildResult = OkHttpUtils.httpPostJson(url, json);
|
|
|
+ JSONObject buildJson = JSONObject.parseObject(buildResult);
|
|
|
+ log.info("请求封面渲染接口返回数据-{}", buildJson);
|
|
|
+
|
|
|
+ if("isBusy".equals(buildJson.getString("msg"))){
|
|
|
+ Thread.sleep(2000L);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if("error".equals(buildJson.getString("state"))){
|
|
|
+ FileUtils.writeFile(filePath + "/error-pro-thum.json", buildJson.toJSONString());
|
|
|
+ throw new RuntimeException(fileId + ":" + taskType + "方式pro接口返回error错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|