|
@@ -585,203 +585,204 @@ public class RunBuild {
|
|
|
buildType = datas[7];
|
|
|
}
|
|
|
|
|
|
- SceneStyleEntity sceneStyleEntity = null;
|
|
|
-
|
|
|
-
|
|
|
- LambdaQueryWrapper<SceneStyleEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
- wrapper.eq(SceneStyleEntity::getStyleNum, vrNum);
|
|
|
-
|
|
|
-
|
|
|
- List<SceneStyleEntity> list = sceneStyleService.list(wrapper);
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
- sceneStyleEntity = list.get(0);
|
|
|
- } else {
|
|
|
- RunBuild.log.info("场景不存在,出现异常");
|
|
|
- return;
|
|
|
- }
|
|
|
|
|
|
- SceneStyleEntity updateSceneStyleEntity = new SceneStyleEntity();
|
|
|
- updateSceneStyleEntity.setId(sceneStyleEntity.getId());
|
|
|
-
|
|
|
- try {
|
|
|
- // run方法具体重写
|
|
|
- RunBuild.log.info("查询计算服务器状态");
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
-// boolean ready = false;
|
|
|
- if ("".equals(dateType)) {
|
|
|
- dateType = "day";
|
|
|
+ //上锁保证只有一个在消费,加锁一个钟,成功消费就解锁了
|
|
|
+ String token = RedisUtil.tryLock(taskId, 60 * 60 * 1000);
|
|
|
+ if (token != null) {
|
|
|
+ SceneStyleEntity entity = sceneStyleService.findById(taskId);
|
|
|
+ if (entity == null) {
|
|
|
+ RunBuild.log.info("场景不存在,出现异常");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- RunBuild.log.info("调用计算api");
|
|
|
- jsonObject.put("name", vrNum);
|
|
|
- jsonObject.put("taskType", buildType);
|
|
|
- jsonObject.put("map", dateType);
|
|
|
- jsonObject.put("resolution", Integer.parseInt(type));
|
|
|
- jsonObject.put("ratio", ratio);
|
|
|
- jsonObject.put("taskId", taskId);
|
|
|
- jsonObject.put("quality", Integer.parseInt(quality));
|
|
|
- int num[] = new int[1];
|
|
|
- num[0] = -1;
|
|
|
- jsonObject.put("ids", num);
|
|
|
+ SceneStyleEntity updateSceneStyleEntity = new SceneStyleEntity();
|
|
|
+ updateSceneStyleEntity.setId(entity.getId());
|
|
|
|
|
|
- //调用pro之前等待一秒,需要清理缓存
|
|
|
- Thread.sleep(1000L);
|
|
|
- while (true) {
|
|
|
- String buildResult = OkHttpUtils.httpPostJson(lightBuildUrl + "pro", jsonObject.toJSONString());
|
|
|
- JSONObject buildJson = JSONObject.parseObject(buildResult);
|
|
|
+ try {
|
|
|
+ // run方法具体重写
|
|
|
+ RunBuild.log.info("查询计算服务器状态");
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+// boolean ready = false;
|
|
|
+ if ("".equals(dateType)) {
|
|
|
+ dateType = "day";
|
|
|
+ }
|
|
|
|
|
|
- RunBuild.log.info("请求3d场景渲染接口获取接口数据-{}", buildJson);
|
|
|
+ RunBuild.log.info("调用计算api");
|
|
|
+ jsonObject.put("name", vrNum);
|
|
|
+ jsonObject.put("taskType", buildType);
|
|
|
+ jsonObject.put("map", dateType);
|
|
|
+ jsonObject.put("resolution", Integer.parseInt(type));
|
|
|
+ jsonObject.put("ratio", ratio);
|
|
|
+ jsonObject.put("taskId", taskId);
|
|
|
+ jsonObject.put("quality", Integer.parseInt(quality));
|
|
|
+ int num[] = new int[1];
|
|
|
+ num[0] = -1;
|
|
|
+ jsonObject.put("ids", num);
|
|
|
+
|
|
|
+ //调用pro之前等待一秒,需要清理缓存
|
|
|
+ Thread.sleep(1000L);
|
|
|
+ while (true) {
|
|
|
+ String buildResult = OkHttpUtils.httpPostJson(lightBuildUrl + "pro", jsonObject.toJSONString());
|
|
|
+ JSONObject buildJson = JSONObject.parseObject(buildResult);
|
|
|
+
|
|
|
+ RunBuild.log.info("请求3d场景渲染接口获取接口数据-{}", buildJson);
|
|
|
+
|
|
|
+ if ("isBusy".equals(buildJson.getString("msg"))) {
|
|
|
+ Thread.sleep(2000L);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- if ("isBusy".equals(buildJson.getString("msg"))) {
|
|
|
- Thread.sleep(2000L);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if ("error".equals(buildJson.getString("state"))) {
|
|
|
+ FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-pro.json", buildJson.toJSONString());
|
|
|
+ throw new RuntimeException(vrNum + ":light方式pro接口返回error错误");
|
|
|
+ }
|
|
|
|
|
|
- if ("error".equals(buildJson.getString("state"))) {
|
|
|
- FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-pro.json", buildJson.toJSONString());
|
|
|
- throw new RuntimeException(vrNum + ":light方式pro接口返回error错误");
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- //等待3秒后请求check
|
|
|
- Thread.sleep(3000L);
|
|
|
+ //等待3秒后请求check
|
|
|
+ Thread.sleep(3000L);
|
|
|
|
|
|
// boolean uploadObj = true;
|
|
|
- //是否计算结束
|
|
|
- boolean over = false;
|
|
|
-
|
|
|
- jsonObject = new JSONObject();
|
|
|
- jsonObject.put("name", vrNum);
|
|
|
- jsonObject.put("taskType", buildType);
|
|
|
- jsonObject.put("taskId", taskId);
|
|
|
- jsonObject.put("ratio", ratio);
|
|
|
- int times = 0;
|
|
|
- while (true) {
|
|
|
- String checkResult = OkHttpUtils.httpPostJson(lightBuildUrl + "check", jsonObject.toJSONString());
|
|
|
- JSONObject checkJson = JSONObject.parseObject(checkResult);
|
|
|
-
|
|
|
- RunBuild.log.info("请求检查3d场景渲染接口获取接口数据-{}", checkJson);
|
|
|
+ //是否计算结束
|
|
|
+ boolean over = false;
|
|
|
|
|
|
- JSONArray checkArray = checkJson.getJSONArray("msg");
|
|
|
+ jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("name", vrNum);
|
|
|
+ jsonObject.put("taskType", buildType);
|
|
|
+ jsonObject.put("taskId", taskId);
|
|
|
+ jsonObject.put("ratio", ratio);
|
|
|
+ int times = 0;
|
|
|
+ while (true) {
|
|
|
+ String checkResult = OkHttpUtils.httpPostJson(lightBuildUrl + "check", jsonObject.toJSONString());
|
|
|
+ JSONObject checkJson = JSONObject.parseObject(checkResult);
|
|
|
|
|
|
- if (checkArray.size() == 0) {
|
|
|
- FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-check.json", checkJson.toJSONString());
|
|
|
- throw new RuntimeException(vrNum + ":light方式check接口返回error错误");
|
|
|
- }
|
|
|
+ RunBuild.log.info("请求检查3d场景渲染接口获取接口数据-{}", checkJson);
|
|
|
|
|
|
- for (int i = 0, len = checkArray.size(); i < len; i++) {
|
|
|
- JSONObject objectJson = checkArray.getJSONObject(i);
|
|
|
+ JSONArray checkArray = checkJson.getJSONArray("msg");
|
|
|
|
|
|
- if ("error".equals(objectJson.getString("state"))) {
|
|
|
+ if (checkArray.size() == 0) {
|
|
|
FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-check.json", checkJson.toJSONString());
|
|
|
throw new RuntimeException(vrNum + ":light方式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 ("error".equals(objectJson.getString("state"))) {
|
|
|
+ FileUtils.writeFile(buildPath + "Input/" + vrNum + buildType + "/error-check.json", checkJson.toJSONString());
|
|
|
+ throw new RuntimeException(vrNum + ":light方式check接口返回error错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
|
|
|
+ "done".equals(objectJson.getString("state")))) {
|
|
|
+ over = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (objectJson.containsKey("progress")) {
|
|
|
+ Integer progress = objectJson.getInteger("progress");
|
|
|
+ RunBuild.log.info("第{}次获取渲染进度,进度为{}%", times++, progress);
|
|
|
+ SceneLightEntity sceneLightEntity = new SceneLightEntity();
|
|
|
+ sceneLightEntity.setId(Long.valueOf(taskId));
|
|
|
+ sceneLightEntity.setProgress(progress);
|
|
|
+ sceneLightService.updateById(sceneLightEntity);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (objectJson.containsKey("progress")) {
|
|
|
- Integer progress = objectJson.getInteger("progress");
|
|
|
- RunBuild.log.info("第{}次获取渲染进度,进度为{}%", times++, progress);
|
|
|
- SceneLightEntity sceneLightEntity = new SceneLightEntity();
|
|
|
- sceneLightEntity.setId(Long.valueOf(taskId));
|
|
|
- sceneLightEntity.setProgress(progress);
|
|
|
- sceneLightService.updateById(sceneLightEntity);
|
|
|
+ if (over) {
|
|
|
+ break;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (over) {
|
|
|
- break;
|
|
|
+ Thread.sleep(500L);
|
|
|
}
|
|
|
|
|
|
- Thread.sleep(500L);
|
|
|
- }
|
|
|
-
|
|
|
- RunBuild.log.info("计算完成:" + buildPath + "Output/" + vrNum);
|
|
|
-
|
|
|
- if ("light".equals(buildType)) {
|
|
|
- updateSceneStyleEntity.setLightStatus(1);
|
|
|
- updateSceneStyleEntity.setLightVersion(sceneStyleEntity.getLightVersion() + 1);
|
|
|
- }
|
|
|
+ RunBuild.log.info("计算完成:" + buildPath + "Output/" + vrNum);
|
|
|
|
|
|
- if ("pano".equals(buildType)) {
|
|
|
- updateSceneStyleEntity.setPanoStatus(1);
|
|
|
- updateSceneStyleEntity.setPanoVersion(sceneStyleEntity.getPanoVersion() + 1);
|
|
|
- }
|
|
|
- updateSceneStyleEntity.setUpdateTime(new Date());
|
|
|
- sceneStyleService.updateById(updateSceneStyleEntity);
|
|
|
+ if ("light".equals(buildType)) {
|
|
|
+ updateSceneStyleEntity.setLightStatus(1);
|
|
|
+ updateSceneStyleEntity.setLightVersion(entity.getLightVersion() + 1);
|
|
|
+ }
|
|
|
|
|
|
- SceneLightEntity sceneLightEntity = new SceneLightEntity();
|
|
|
- sceneLightEntity.setId(Long.valueOf(taskId));
|
|
|
- if ("light".equals(buildType)) {
|
|
|
- sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/preview/" + taskId + "/preview.jpg");
|
|
|
-
|
|
|
- LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
|
|
|
- wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
- List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
|
|
|
- if (statisticsEntityList.size() > 0) {
|
|
|
- StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
|
|
|
- statisticsEntity.setLightNum(statisticsEntity.getLightNum() + 1);
|
|
|
- statisticsService.updateById(statisticsEntity);
|
|
|
- } else {
|
|
|
- StatisticsEntity statisticsEntity = new StatisticsEntity();
|
|
|
- statisticsEntity.setLightNum(1);
|
|
|
- statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
- statisticsService.save(statisticsEntity);
|
|
|
+ if ("pano".equals(buildType)) {
|
|
|
+ updateSceneStyleEntity.setPanoStatus(1);
|
|
|
+ updateSceneStyleEntity.setPanoVersion(entity.getPanoVersion() + 1);
|
|
|
}
|
|
|
- }
|
|
|
- if ("pano".equals(buildType)) {
|
|
|
- sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg");
|
|
|
- String panoPath = buildPath + "Output/" + vrNum + "pano";
|
|
|
-
|
|
|
- FileUtils.deleteDirectory(panoPath);
|
|
|
- File panoFile = new File(panoPath);
|
|
|
- if (!panoFile.exists()) {
|
|
|
- panoFile.mkdirs();
|
|
|
+ updateSceneStyleEntity.setUpdateTime(new Date());
|
|
|
+ sceneStyleService.updateById(updateSceneStyleEntity);
|
|
|
+
|
|
|
+ SceneLightEntity sceneLightEntity = new SceneLightEntity();
|
|
|
+ sceneLightEntity.setId(Long.valueOf(taskId));
|
|
|
+ if ("light".equals(buildType)) {
|
|
|
+ sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/preview/" + taskId + "/preview.jpg");
|
|
|
+
|
|
|
+ LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
|
|
|
+ wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
+ List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
|
|
|
+ if (statisticsEntityList.size() > 0) {
|
|
|
+ StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
|
|
|
+ statisticsEntity.setLightNum(statisticsEntity.getLightNum() + 1);
|
|
|
+ statisticsService.updateById(statisticsEntity);
|
|
|
+ } else {
|
|
|
+ StatisticsEntity statisticsEntity = new StatisticsEntity();
|
|
|
+ statisticsEntity.setLightNum(1);
|
|
|
+ statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
+ statisticsService.save(statisticsEntity);
|
|
|
+ }
|
|
|
}
|
|
|
- uploadToOssUtil.download("images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg", panoPath + "/pano_sphere.jpg");
|
|
|
- CreateObjUtil.panoCutaway(panoPath + "/pano_sphere.jpg");
|
|
|
+ if ("pano".equals(buildType)) {
|
|
|
+ sceneLightEntity.setImg("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg");
|
|
|
+ String panoPath = buildPath + "Output/" + vrNum + "pano";
|
|
|
+
|
|
|
+ FileUtils.deleteDirectory(panoPath);
|
|
|
+ File panoFile = new File(panoPath);
|
|
|
+ if (!panoFile.exists()) {
|
|
|
+ panoFile.mkdirs();
|
|
|
+ }
|
|
|
+ uploadToOssUtil.download("images/images" + vrNum + "/tiles/pano/" + taskId + "/pano_sphere.jpg", panoPath + "/pano_sphere.jpg");
|
|
|
+ CreateObjUtil.panoCutaway(panoPath + "/pano_sphere.jpg");
|
|
|
+
|
|
|
+ if (new File(panoPath + "/vtour").exists()) {
|
|
|
+ CreateObjUtil.ossUploadCommon(panoPath + "/vtour", "4dkankan/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour");
|
|
|
+ sceneLightEntity.setFilePath("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour/tour.html");
|
|
|
+ }
|
|
|
|
|
|
- if (new File(panoPath + "/vtour").exists()) {
|
|
|
- CreateObjUtil.ossUploadCommon(panoPath + "/vtour", "4dkankan/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour");
|
|
|
- sceneLightEntity.setFilePath("https://4dkk.4dage.com/images/images" + vrNum + "/tiles/pano/" + taskId + "/vtour/tour.html");
|
|
|
+ LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
|
|
|
+ wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
+ List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
|
|
|
+ if (statisticsEntityList.size() > 0) {
|
|
|
+ StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
|
|
|
+ statisticsEntity.setPanoNum(statisticsEntity.getPanoNum() + 1);
|
|
|
+ statisticsService.updateById(statisticsEntity);
|
|
|
+ } else {
|
|
|
+ StatisticsEntity statisticsEntity = new StatisticsEntity();
|
|
|
+ statisticsEntity.setPanoNum(1);
|
|
|
+ statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
+ statisticsService.save(statisticsEntity);
|
|
|
+ }
|
|
|
}
|
|
|
+ sceneLightEntity.setStatus(1);
|
|
|
+ sceneLightEntity.setUpdateTime(new Date());
|
|
|
+ sceneLightService.updateById(sceneLightEntity);
|
|
|
+ } catch (Exception e) {
|
|
|
+ //渲染失败,修改风格表和灯光预览相册集
|
|
|
+ updateSceneStyleEntity.setLightStatus(-1);
|
|
|
+ updateSceneStyleEntity.setLightVersion(entity.getLightVersion() + 1);
|
|
|
+ updateSceneStyleEntity.setUpdateTime(new Date());
|
|
|
+ sceneStyleService.updateById(updateSceneStyleEntity);
|
|
|
+
|
|
|
+ SceneLightEntity sceneLightEntity = new SceneLightEntity();
|
|
|
+ sceneLightEntity.setId(Long.valueOf(taskId));
|
|
|
+ sceneLightEntity.setStatus(-1);
|
|
|
+ sceneLightEntity.setUpdateTime(new Date());
|
|
|
+ sceneLightService.updateById(sceneLightEntity);
|
|
|
|
|
|
- LambdaQueryWrapper<StatisticsEntity> wrapper1 = Wrappers.lambdaQuery();
|
|
|
- wrapper1.eq(StatisticsEntity::getStatisticsDate, DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
- List<StatisticsEntity> statisticsEntityList = statisticsService.list(wrapper1);
|
|
|
- if (statisticsEntityList.size() > 0) {
|
|
|
- StatisticsEntity statisticsEntity = statisticsEntityList.get(0);
|
|
|
- statisticsEntity.setPanoNum(statisticsEntity.getPanoNum() + 1);
|
|
|
- statisticsService.updateById(statisticsEntity);
|
|
|
- } else {
|
|
|
- StatisticsEntity statisticsEntity = new StatisticsEntity();
|
|
|
- statisticsEntity.setPanoNum(1);
|
|
|
- statisticsEntity.setStatisticsDate(DateUtil.date2String(new Date(), DateUtil.YYYY_MM_DD_DATE_FORMAT));
|
|
|
- statisticsService.save(statisticsEntity);
|
|
|
+ RunBuild.log.error("渲染失败-{}", e);
|
|
|
+ } finally {
|
|
|
+ MDC.clear();
|
|
|
+ if (token != null) {
|
|
|
+ RedisUtil.unlock(taskId, token);
|
|
|
}
|
|
|
}
|
|
|
- sceneLightEntity.setStatus(1);
|
|
|
- sceneLightEntity.setUpdateTime(new Date());
|
|
|
- sceneLightService.updateById(sceneLightEntity);
|
|
|
- } catch (Exception e) {
|
|
|
- //渲染失败,修改风格表和灯光预览相册集
|
|
|
- updateSceneStyleEntity.setLightStatus(-1);
|
|
|
- updateSceneStyleEntity.setLightVersion(sceneStyleEntity.getLightVersion() + 1);
|
|
|
- updateSceneStyleEntity.setUpdateTime(new Date());
|
|
|
- sceneStyleService.updateById(updateSceneStyleEntity);
|
|
|
-
|
|
|
- SceneLightEntity sceneLightEntity = new SceneLightEntity();
|
|
|
- sceneLightEntity.setId(Long.valueOf(taskId));
|
|
|
- sceneLightEntity.setStatus(-1);
|
|
|
- sceneLightEntity.setUpdateTime(new Date());
|
|
|
- sceneLightService.updateById(sceneLightEntity);
|
|
|
-
|
|
|
- RunBuild.log.error("渲染失败-{}", e);
|
|
|
}
|
|
|
}
|
|
|
|