ソースを参照

增加日志打印

xiewenjie 4 年 前
コミット
195dc67f66

+ 37 - 30
sxz-core/src/main/java/com/fdkk/sxz/other/listener/RunBuild.java

@@ -1113,52 +1113,59 @@ public class RunBuild {
      * @throws InterruptedException
      * @throws IOException
      */
-    private void checkResultJson(String fileId, String filePath, JSONObject jsonObject, String modelUploadId) throws InterruptedException, IOException {
+    private void checkResultJson(String fileId, String filePath, JSONObject jsonObject, String modelUploadId) {
         // 循环检查渲染结果的次数
         int times = 0;
         boolean over = false;
-        while (true) {
-            String checkResult = OkHttpUtils.httpPostJson(modelBuildUrl + "check", jsonObject.toJSONString());
-            JSONObject checkJson = JSONObject.parseObject(checkResult);
-
-            JSONArray checkArray = checkJson.getJSONArray("msg");
+        try {
+            while (true) {
+                String checkResult = OkHttpUtils.httpPostJson(modelBuildUrl + "check", jsonObject.toJSONString());
+                log.info("checkResult的长度为-{}", checkResult.length());
 
-            log.info("请求检查3d场景渲染接口获取接口数据-{}", checkJson);
+                JSONObject checkJson = JSONObject.parseObject(checkResult);
 
-            if (checkArray.size() == 0) {
-                FileUtils.writeFile(filePath + "/error-check-model.json", checkJson.toJSONString());
-                throw new RuntimeException(fileId + ":datafactory方式check接口返回error错误");
-            }
+                JSONArray checkArray = checkJson.getJSONArray("msg");
 
-            for (int i = 0, len = checkArray.size(); i < len; i++) {
-                JSONObject objectJson = checkArray.getJSONObject(i);
+                log.info("请求检查3d场景渲染接口获取接口数据-{}", checkJson);
 
-                if ("error".equals(objectJson.getString("state"))) {
+                if (checkArray.size() == 0) {
                     FileUtils.writeFile(filePath + "/error-check-model.json", checkJson.toJSONString());
                     throw new RuntimeException(fileId + ":datafactory方式check接口返回error错误");
                 }
 
-                if (objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
-                        "done".equals(objectJson.getString("state")))) {
-                    over = true;
-                }
+                for (int i = 0, len = checkArray.size(); i < len; i++) {
+                    JSONObject objectJson = checkArray.getJSONObject(i);
 
-                if (objectJson.containsKey("progress")) {
-                    Integer progress = objectJson.getInteger("progress");
-                    log.info("第{}次获取上传进度,进度为{}%", times++, progress);
-                    ModelUploadEntity modelUploadEntity = new ModelUploadEntity();
-                    modelUploadEntity.setId(Long.valueOf(modelUploadId));
-                    modelUploadEntity.setProgress(progress);
-                    modelUploadService.updateById(modelUploadEntity);
-                }
+                    if ("error".equals(objectJson.getString("state"))) {
+                        FileUtils.writeFile(filePath + "/error-check-model.json", checkJson.toJSONString());
+                        throw new RuntimeException(fileId + ":datafactory方式check接口返回error错误");
+                    }
 
-            }
+                    if (objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
+                            "done".equals(objectJson.getString("state")))) {
+                        over = true;
+                    }
 
-            if (over) {
-                break;
+                    if (objectJson.containsKey("progress")) {
+                        Integer progress = objectJson.getInteger("progress");
+                        log.info("第{}次获取上传进度,进度为{}%", times++, progress);
+                        ModelUploadEntity modelUploadEntity = new ModelUploadEntity();
+                        modelUploadEntity.setId(Long.valueOf(modelUploadId));
+                        modelUploadEntity.setProgress(progress);
+                        modelUploadService.updateById(modelUploadEntity);
+                    }
+
+                }
+                if (over) {
+                    break;
+                }
+
+                Thread.sleep(1000L);
             }
+        }catch (Exception e){
+            e.printStackTrace();
+            log.info("循环检查3d渲染报错{}",e.getMessage());
 
-            Thread.sleep(1000L);
         }
     }