|
@@ -6,9 +6,11 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkk.sxz.constant.ConstantFileName;
|
|
|
import com.fdkk.sxz.constant.ConstantFilePath;
|
|
|
+import com.fdkk.sxz.entity.ModelUploadOfflineEntity;
|
|
|
import com.fdkk.sxz.other.mq.TopicRabbitConfig;
|
|
|
import com.fdkk.sxz.util.*;
|
|
|
import com.fdkk.sxz.vo.request.RequestQueue;
|
|
|
+import com.fdkk.sxz.webApi.service.IModelUploadOfflineService;
|
|
|
import com.fdkk.sxz.webApi.service.IRenovationPartsDetailService;
|
|
|
import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
|
|
|
import com.fdkk.sxz.webApi.service.custom.ICustomProductService;
|
|
@@ -49,18 +51,26 @@ public class Model3dBuild {
|
|
|
private ICustomComponentService customComponentService;
|
|
|
@Autowired
|
|
|
RedisUtil redisUtil;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IModelUploadOfflineService modelUploadOfflineService;
|
|
|
|
|
|
@RabbitHandler
|
|
|
@RabbitListener(queues = TopicRabbitConfig.MODEL_BIZ_3D)
|
|
|
public void modelBiz3d(Message<RequestQueue> message) {
|
|
|
Model3dBuild.log.info("modelBiz3d同步消息开始:" + message + ",开始同步");
|
|
|
String token = RedisUtil.tryLock("modelBiz3d:" + message.getPayload().getName(), 60 * 60 * 1000);
|
|
|
+ ModelUploadOfflineEntity modelUploadOfflineEntity = new ModelUploadOfflineEntity();
|
|
|
try {
|
|
|
if (token != null) {
|
|
|
- modelBiz3dHandler(message.getPayload());
|
|
|
+ modelUploadOfflineEntity.setName(message.getPayload().getName());
|
|
|
+ modelUploadOfflineEntity.setStatus(0);
|
|
|
+ modelUploadOfflineEntity.setProgress(0);
|
|
|
+ modelUploadOfflineService.save(modelUploadOfflineEntity);
|
|
|
+ modelBiz3dHandler(message.getPayload(), modelUploadOfflineEntity);
|
|
|
}
|
|
|
} catch (InterruptedException e) {
|
|
|
+ modelUploadOfflineEntity.setStatus(-1);
|
|
|
+ modelUploadOfflineService.updateById(modelUploadOfflineEntity);
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
if (token != null) {
|
|
@@ -69,7 +79,7 @@ public class Model3dBuild {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void modelBiz3dHandler(RequestQueue str) throws InterruptedException {
|
|
|
+ public void modelBiz3dHandler(RequestQueue str, ModelUploadOfflineEntity modelUploadOfflineEntity) throws InterruptedException {
|
|
|
|
|
|
while (true) {
|
|
|
String buildResult = OkHttpUtils.httpPostJson(buildUrl + "pro", JSON.toJSONString(str));
|
|
@@ -111,16 +121,25 @@ public class Model3dBuild {
|
|
|
JSONObject objectJson = checkArray.getJSONObject(i);
|
|
|
|
|
|
if ("error".equals(objectJson.getString("state"))) {
|
|
|
+ modelUploadOfflineEntity.setStatus(-1);
|
|
|
+ modelUploadOfflineService.updateById(modelUploadOfflineEntity);
|
|
|
throw new RuntimeException(str.getName() + ":build方式pro接口返回error错误");
|
|
|
}
|
|
|
|
|
|
if (objectJson.containsKey("state") && ("".equals(objectJson.getString("state")) ||
|
|
|
"done".equals(objectJson.getString("state")) || "error".equals(objectJson.getString("state")))) {
|
|
|
over = true;
|
|
|
+ //完成 存库。。。。。name: XXXXX 完成状态 进度
|
|
|
+ //id ,name status 1完成-2未完成 3-错误 progress
|
|
|
+ modelUploadOfflineEntity.setStatus(1);
|
|
|
+ modelUploadOfflineService.updateById(modelUploadOfflineEntity);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (objectJson.containsKey("progress")) {
|
|
|
Integer progress = objectJson.getInteger("progress");
|
|
|
+ modelUploadOfflineEntity.setProgress(progress);
|
|
|
+ modelUploadOfflineService.updateById(modelUploadOfflineEntity);
|
|
|
Model3dBuild.log.info("str.getName()-{}, 第{}次获取渲染进度,进度为{}%", str.getName(), times++, progress);
|
|
|
}
|
|
|
}
|