|
@@ -26,6 +26,7 @@ import org.springframework.messaging.Message;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -76,8 +77,111 @@ public class AddMoldelBuild {
|
|
|
@RabbitListener(queues = TopicRabbitConfig.ADDMODEL)
|
|
|
public void syncModel(Message<RequestRenovationPartsDetailManager> message) {
|
|
|
AddMoldelBuild.log.info("模型syncmodel:" + message.getPayload() + ",开始同步");
|
|
|
- syncModelHandler(message.getPayload());
|
|
|
+ if (message.getPayload().getQueryType() == 3) {
|
|
|
+ syncModel(message.getPayload());
|
|
|
|
|
|
+ } else {
|
|
|
+ syncModelHandler(message.getPayload());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void syncModel(RequestRenovationPartsDetailManager param) {
|
|
|
+ String token = RedisUtil.tryLock(param.getModelUploadId().toString() + "syncModel", 60 * 1000);
|
|
|
+ try {
|
|
|
+ if (token != null) {
|
|
|
+ String objPath = buildPath + "upload/" + param.getFileId() + "/" + param.getFileId() + ".obj";
|
|
|
+ //下载OBJ。
|
|
|
+ uploadToOssUtil.download(objPath, param.getObjPath());
|
|
|
+ //先执行python-NewResortForOne脚本,处理obj文件
|
|
|
+ AddMoldelBuild.log.info("NewResortForOne脚本处理ojb:");
|
|
|
+ CreateObjUtil.objHandle(objPath);
|
|
|
+
|
|
|
+ String glbPath = objPath.replace(".obj", ".glb");
|
|
|
+ AddMoldelBuild.log.info("处理glb:");
|
|
|
+ CreateObjUtil.objToGlb(objPath, glbPath);
|
|
|
+ AddMoldelBuild.log.info("上传glb:");
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(glbPath, "domain/eHome/furniture/models/" + param.getFileId() + ".glb");
|
|
|
+
|
|
|
+ RenovationPartsDetailEntity renovationPartsDetailEntity = new RenovationPartsDetailEntity();
|
|
|
+ BeanUtils.copyProperties(param, renovationPartsDetailEntity);
|
|
|
+ renovationPartsDetailEntity.setExamine(0);
|
|
|
+ renovationPartsDetailEntity.setName(param.getFileId());
|
|
|
+ renovationPartsDetailEntity.setPath(prefix + "domain/eHome/furniture/models/" + param.getFileId() + ".glb");
|
|
|
+ renovationPartsDetailEntity.setImg(param.getImg());
|
|
|
+ renovationPartsDetailEntity.setHighImg(param.getImg());
|
|
|
+
|
|
|
+ AddMoldelBuild.log.info("保存吸附方式:");
|
|
|
+ RenovationPartsAttachingEntity renovationPartsAttachingEntity = new RenovationPartsAttachingEntity();
|
|
|
+ if ("wall".equals(param.getAttachingType())) {
|
|
|
+ renovationPartsAttachingEntity.setCeilAttaching(false);
|
|
|
+ renovationPartsAttachingEntity.setWallAttaching(true);
|
|
|
+ renovationPartsAttachingEntity.setFloorAttaching(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("ceil".equals(param.getAttachingType())) {
|
|
|
+ renovationPartsAttachingEntity.setCeilAttaching(true);
|
|
|
+ renovationPartsAttachingEntity.setWallAttaching(false);
|
|
|
+ renovationPartsAttachingEntity.setFloorAttaching(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("floor".equals(param.getAttachingType())) {
|
|
|
+ renovationPartsAttachingEntity.setCeilAttaching(false);
|
|
|
+ renovationPartsAttachingEntity.setWallAttaching(false);
|
|
|
+ renovationPartsAttachingEntity.setFloorAttaching(true);
|
|
|
+ }
|
|
|
+ renovationPartsAttachingEntity.setPartsDetailId(renovationPartsDetailEntity.getId());
|
|
|
+ renovationPartsAttachingService.save(renovationPartsAttachingEntity);
|
|
|
+ AddMoldelBuild.log.info("保存长宽高:");
|
|
|
+ if (param.getX() != null && param.getY() != null && param.getZ() != null) {
|
|
|
+ RenovationPartsSizeEntity renovationPartsSizeEntity = new RenovationPartsSizeEntity();
|
|
|
+ renovationPartsSizeEntity.setX(param.getX());
|
|
|
+ renovationPartsSizeEntity.setY(param.getY());
|
|
|
+ renovationPartsSizeEntity.setZ(param.getZ());
|
|
|
+ renovationPartsSizeEntity.setPartsDetailId(renovationPartsDetailEntity.getId());
|
|
|
+ renovationPartsSizeService.save(renovationPartsSizeEntity);
|
|
|
+ }
|
|
|
+ renovationPartsDetailEntity.setMviewStatus(1);
|
|
|
+ renovationPartsDetailEntity.setExamine(1);
|
|
|
+ renovationPartsDetailEntity.setExamineTime(new Date());
|
|
|
+ renovationPartsDetailEntity.setName(param.getFileId());
|
|
|
+
|
|
|
+ AddMoldelBuild.log.info("renovationPartsDetailEntity:");
|
|
|
+ Boolean saveFlag = renovationPartsDetailService.save(renovationPartsDetailEntity);
|
|
|
+ if (!saveFlag) {
|
|
|
+ throw new RuntimeException(param.getFileId() + ":添加到模型库失败");
|
|
|
+
|
|
|
+ }
|
|
|
+ String messageStr = renovationPartsDetailEntity.getId() + ":;1:;" + objPath + ":;" + param.getFileId();
|
|
|
+ AddMoldelBuild.log.info("配件obj转换成mview格式");
|
|
|
+ Map<String, String> paramsMap = new HashMap<>();
|
|
|
+ paramsMap.put("uuid", param.getFileId());
|
|
|
+ paramsMap.put("inObj", objPath);
|
|
|
+ paramsMap.put("outFilePath", objPath.replace(".obj", ""));
|
|
|
+ paramsMap.put("resData", messageStr);
|
|
|
+ OkHttpUtils.httpPostForm(maxObjUrl + "toToolbag", paramsMap);
|
|
|
+ Thread.sleep(1000);
|
|
|
+
|
|
|
+
|
|
|
+ AddMoldelBuild.log.info("保存ModelUploadEntity:");
|
|
|
+ ModelUploadEntity modelUploadEntity = new ModelUploadEntity();
|
|
|
+ modelUploadEntity.setUserId(param.getUserId());
|
|
|
+ modelUploadEntity.setObjPath(objPath.replace(buildPath, ""));
|
|
|
+ modelUploadEntity.setAddStatus(2);
|
|
|
+ modelUploadEntity.setStatus(1);
|
|
|
+ modelUploadEntity.setFileType(1);
|
|
|
+ modelUploadEntity.setPartsDetailId(renovationPartsDetailEntity.getId());
|
|
|
+ modelUploadService.save(modelUploadEntity);
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ AddMoldelBuild.log.error("直接模型入库报错-{}", e.getMessage());
|
|
|
+ } finally {
|
|
|
+ if (token != null) {
|
|
|
+ RedisUtil.unlock(param.getModelUploadId().toString(), token);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void syncModelHandler(RequestRenovationPartsDetailManager param) {
|
|
@@ -122,7 +226,7 @@ public class AddMoldelBuild {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- AddMoldelBuild.log.error("提交模型保存-{}", e.getMessage());
|
|
|
+ AddMoldelBuild.log.error("提交模型报错-{}", e.getMessage());
|
|
|
if (ObjectUtil.isNotNull(modelUploadEntity)) {
|
|
|
modelUploadEntity.setAddStatus(-1);
|
|
|
modelUploadService.updateById(modelUploadEntity);
|