|
@@ -16,17 +16,25 @@ import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
|
|
|
import com.fdkk.sxz.webApi.service.*;
|
|
|
import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
|
|
|
import com.fdkk.sxz.webApi.service.custom.ICustomProductService;
|
|
|
+import com.rabbitmq.client.AMQP;
|
|
|
+import com.rabbitmq.client.Channel;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import lombok.val;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
+import org.springframework.amqp.support.AmqpHeaders;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.messaging.Message;
|
|
|
+import org.springframework.messaging.handler.annotation.Header;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -78,6 +86,128 @@ public class AddMoldelBuild {
|
|
|
AddMoldelBuild.log.info("模型syncmodel:" + message.getPayload() + ",开始同步");
|
|
|
syncModelHandler(message.getPayload());
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
+ @RabbitHandler
|
|
|
+ @RabbitListener(queues = TopicRabbitConfig.ADDMODELTO3D)
|
|
|
+ public void addmodelto3d(Message<RequestRenovationPartsDetailManager> message) {
|
|
|
+ AddMoldelBuild.log.info("模型addmodelto3d:" + message.getPayload() + ",开始同步");
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000L*2);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ syncModel(message.getPayload());
|
|
|
+ }
|
|
|
+ public void syncModel(RequestRenovationPartsDetailManager param) {
|
|
|
+ String token = RedisUtil.tryLock(param.getFileId().toString() + "syncModel", 60 * 1000);
|
|
|
+ try {
|
|
|
+ if (token != null) {
|
|
|
+ ModelUploadEntity uploadEntity = modelUploadService.findByFileId(param.getFileId());
|
|
|
+ if (ObjectUtil.isNull(uploadEntity)){
|
|
|
+ String locationPath = buildPath + "upload/" + param.getFileId() + "/";
|
|
|
+ String objPath = locationPath + param.getFileId() + ".obj";
|
|
|
+ String previewPath = locationPath + param.getFileId() + "_preview.jpg";
|
|
|
+
|
|
|
+ CreateObjUtil.ossdownload("4d-tjw",param.getObjPath(),locationPath);
|
|
|
+ //下载OBJ。
|
|
|
+ //先执行python-NewResortForOne脚本,处理obj文件,
|
|
|
+ AddMoldelBuild.log.info("NewResortForOne脚本处理ojb:");
|
|
|
+ CreateObjUtil.objHandle(objPath);
|
|
|
+
|
|
|
+ String glbPath = locationPath + param.getFileId() + ".glb";
|
|
|
+ log.info("obj转换成glb格式路径-{}", glbPath);
|
|
|
+ AddMoldelBuild.log.info("处理glb:objPath{} ,glbPath{}",objPath, glbPath);
|
|
|
+ CreateObjUtil.objToGlb(objPath, glbPath);
|
|
|
+ AddMoldelBuild.log.info("上传glb:");
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(glbPath, "domain/eHome/furniture/models/" + param.getFileId() + ".glb");
|
|
|
+
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw(param.getImg().replace(prefix,""),previewPath);
|
|
|
+
|
|
|
+
|
|
|
+ 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());
|
|
|
+ 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() + ":添加到模型库失败");
|
|
|
+
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String messageStr = renovationPartsDetailEntity.getId() + ":;3:;" + 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());
|
|
|
+ modelUploadEntity.setFacesNum(param.getFacesNum());
|
|
|
+ modelUploadEntity.setObjSize(param.getObjSize());
|
|
|
+ modelUploadEntity.setThumPath(previewPath.replaceAll(buildPath, ""));
|
|
|
+ modelUploadService.save(modelUploadEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ AddMoldelBuild.log.error("直接模型入库报错-{}", e.getMessage());
|
|
|
+ } finally {
|
|
|
+ if (token != null) {
|
|
|
+ RedisUtil.unlock(param.getFileId().toString(), token);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void syncModelHandler(RequestRenovationPartsDetailManager param) {
|
|
@@ -122,7 +252,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);
|