|
@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.io.file.FileReader;
|
|
|
import cn.hutool.core.io.file.FileWriter;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -14,9 +15,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fdkk.sxz.constant.ConstantFileName;
|
|
|
import com.fdkk.sxz.constant.ConstantFilePath;
|
|
|
import com.fdkk.sxz.entity.*;
|
|
|
+import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
|
|
|
import com.fdkk.sxz.other.mq.TopicRabbitConfig;
|
|
|
import com.fdkk.sxz.webApi.service.*;
|
|
|
import com.fdkk.sxz.util.*;
|
|
|
+import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
@@ -56,6 +59,9 @@ public class RunBuild {
|
|
|
@Autowired
|
|
|
private IComponentModelUploadService componentModelUploadService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICustomComponentService customComponentService;
|
|
|
+
|
|
|
@Value("${server.file.location}")
|
|
|
private String buildPath;
|
|
|
|
|
@@ -78,16 +84,16 @@ public class RunBuild {
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
@RabbitHandler
|
|
|
- @RabbitListener(queues = "topic.change")
|
|
|
+ @RabbitListener(queues = TopicRabbitConfig.CHANGE)
|
|
|
public void change(String str) {
|
|
|
log.info("场景:" + str + ",开始计算");
|
|
|
buildCopy(str);
|
|
|
}
|
|
|
|
|
|
@RabbitHandler
|
|
|
- @RabbitListener(queues = "topic.light")
|
|
|
+ @RabbitListener(queues = TopicRabbitConfig.LIGHT)
|
|
|
public void light(String str) {
|
|
|
- if (str.contains("modelPreview")) {
|
|
|
+ if (str.contains("modelPreview")||str.contains("customFurniturePreview")) {
|
|
|
log.info("模型:" + str + ",开始生成封面图");
|
|
|
modelCreatThum(str);
|
|
|
} else {
|
|
@@ -97,7 +103,6 @@ public class RunBuild {
|
|
|
}
|
|
|
|
|
|
@RabbitHandler
|
|
|
-// @RabbitListener(queues = "topic.model.copy")
|
|
|
@RabbitListener(queues = TopicRabbitConfig.MODEL)
|
|
|
public void model(String str) {
|
|
|
log.info("模型转换:" + str);
|
|
@@ -684,291 +689,417 @@ public class RunBuild {
|
|
|
String modelType = datas[3];
|
|
|
//true表示定制,FALSE表示成品
|
|
|
String flag = datas[4];
|
|
|
+ //1 成品 2 定制 3 组件
|
|
|
+ String UploadType = datas[5];
|
|
|
|
|
|
+ ModelUploadEntity modelUploadEntity =null;
|
|
|
|
|
|
- ModelUploadEntity modelUploadEntity = modelUploadService.findById(Long.valueOf(modelUploadId));
|
|
|
- try {
|
|
|
|
|
|
- String path = buildPath + "upload";
|
|
|
- String filePath = path + File.separator + fileId + File.separator;
|
|
|
+ ComponentModelUploadEntity componentModelUploadEntity=null;
|
|
|
|
|
|
- List<String> allList = new ArrayList<>();
|
|
|
- FileUtils.readfilePath(filePath, allList);
|
|
|
- String maxPath = "";
|
|
|
- String maxName = "";
|
|
|
- for (String targetPath : allList) {
|
|
|
- if (targetPath.toLowerCase().endsWith(".max")) {
|
|
|
- maxPath = targetPath;
|
|
|
- break;
|
|
|
+ //上锁保证只有一个在消费,加锁一个钟,成功消费就解锁了
|
|
|
+ String token = RedisUtil.tryLock(fileId, 60*60*1000);
|
|
|
+ if (token != null ){
|
|
|
+ log.info("已有同样的fileId:"+fileId+",正在消费了");
|
|
|
+ log.info("暂无的fileId:"+fileId+"消费,继续执行处理逻辑");
|
|
|
+ try {
|
|
|
+ String path = buildPath + "upload";
|
|
|
+ String filePath = path + File.separator + fileId + File.separator;
|
|
|
+
|
|
|
+ List<String> allList = new ArrayList<>();
|
|
|
+ FileUtils.readfilePath(filePath, allList);
|
|
|
+ String maxPath = "";
|
|
|
+ String maxName = "";
|
|
|
+ for (String targetPath : allList) {
|
|
|
+ if (targetPath.toLowerCase().endsWith(".max")) {
|
|
|
+ maxPath = targetPath;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- maxName = maxPath.replace(filePath, "");
|
|
|
+ maxName = maxPath.replace(filePath, "");
|
|
|
|
|
|
- String max = new File(maxPath).getName();
|
|
|
- Thread.sleep(1000);
|
|
|
- log.info("开始运行maxToDatasmith");
|
|
|
- String maxUrl = maxObjUrl + "maxToDatasmith?uuid=" + fileId + "&max=" + maxName + "&flag=" + flag;
|
|
|
- log.info("请求maxToDatasmith地址-{}", maxUrl);
|
|
|
- OkHttpUtils.httpGet(maxUrl);
|
|
|
- log.info("运行maxToDatasmith结束-{}", fileId);
|
|
|
+ String max = new File(maxPath).getName();
|
|
|
+ Thread.sleep(1000);
|
|
|
+ log.info("开始运行maxToDatasmith");
|
|
|
+ String maxUrl = maxObjUrl + "maxToDatasmith?uuid=" + fileId + "&max=" + maxName + "&flag=" + flag;
|
|
|
+ log.info("请求maxToDatasmith地址-{}", maxUrl);
|
|
|
+ OkHttpUtils.httpGet(maxUrl);
|
|
|
+ log.info("运行maxToDatasmith结束-{}", fileId);
|
|
|
|
|
|
- String filesTxt = filePath + max.replace(".max", "") + "/files.txt";
|
|
|
- if (!new File(filesTxt).exists()) {
|
|
|
- log.info("运行maxToDatasmith失败,没有files.txt文件:" + filesTxt);
|
|
|
- throw new RuntimeException(fileId + ":运行maxToDatasmith失败,没有files.txt文件");
|
|
|
- }
|
|
|
+ String filesTxt = filePath + max.replace(".max", "") + "/files.txt";
|
|
|
+ if (!new File(filesTxt).exists()) {
|
|
|
+ log.info("运行maxToDatasmith失败,没有files.txt文件:" + filesTxt);
|
|
|
+ throw new RuntimeException(fileId + ":运行maxToDatasmith失败,没有files.txt文件");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- String[] files = FileUtils.readFile(filesTxt).split(";");
|
|
|
+ String[] files = FileUtils.readFile(filesTxt).split(";");
|
|
|
|
|
|
- //判断obj文件是否有vt 开头
|
|
|
- String obj = filePath + max.replace(".max", "");
|
|
|
- //判断是否存在/furniture.json
|
|
|
- String furniture = filePath + max.replace(".max", "");
|
|
|
+ //判断obj文件是否有vt 开头
|
|
|
+ String obj = filePath + max.replace(".max", "");
|
|
|
+ //判断是否存在/furniture.json
|
|
|
+ String furniture = filePath + max.replace(".max", "");
|
|
|
|
|
|
- //判断是否存在/MeshMatMap.txt
|
|
|
- String MeshMatMap = filePath + max.replace(".max", "");
|
|
|
+ //判断是否存在/MeshMatMap.txt
|
|
|
+ String MeshMatMap = filePath + max.replace(".max", "");
|
|
|
|
|
|
- for (String file : files) {
|
|
|
- if (file.endsWith("Output.obj")) {
|
|
|
- obj = obj + file;
|
|
|
- }
|
|
|
- if (file.endsWith("furniture.json")) {
|
|
|
- furniture = furniture + file;
|
|
|
- }
|
|
|
- if (file.endsWith("MeshMatMap.txt")) {
|
|
|
- MeshMatMap = MeshMatMap + file;
|
|
|
+ for (String file : files) {
|
|
|
+ if (file.endsWith("Output.obj")) {
|
|
|
+ obj = obj + file;
|
|
|
+ }
|
|
|
+ if (file.endsWith("furniture.json")) {
|
|
|
+ furniture = furniture + file;
|
|
|
+ }
|
|
|
+ if (file.endsWith("MeshMatMap.txt")) {
|
|
|
+ MeshMatMap = MeshMatMap + file;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if (!ObjProcess.hasVt(obj)) {
|
|
|
- //没有vt,直接报错
|
|
|
- modelUploadEntity.setStatus(-2);
|
|
|
- modelUploadService.updateById(modelUploadEntity);
|
|
|
- return;
|
|
|
- }
|
|
|
|
|
|
- if (flag.equals("true")) {
|
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("name", fileId);
|
|
|
- jsonObject.put("taskType", "customFurniture");
|
|
|
- jsonObject.put("taskId", userId);
|
|
|
- jsonObject.put("postfix", modelType);
|
|
|
- JSONArray params1 = new JSONArray();
|
|
|
|
|
|
|
|
|
- //处理 furniture.json
|
|
|
- JSONArray furnitureJson = null;
|
|
|
- if (StrUtil.isNotEmpty(furniture)) {
|
|
|
- FileReader fileReader = new FileReader(furniture);
|
|
|
- furnitureJson = JSON.parseArray(fileReader.readString());
|
|
|
- }
|
|
|
- JSONObject jsonObj = JSON.parseObject(JSON.toJSONString(furnitureJson.get(0)));
|
|
|
- JSONArray componentSlots = jsonObj.getJSONArray("componentSlots");
|
|
|
-
|
|
|
- for (Object componentSlot : componentSlots) {
|
|
|
- JSONObject component = JSON.parseObject(JSONObject.toJSONString(componentSlot)).getJSONObject("component");
|
|
|
- String filesId = component.getString("name");
|
|
|
- String componentPath = filePath + max.replace(".max", "") + "/" + filesId;
|
|
|
-
|
|
|
- String objFileRealPath = "";
|
|
|
- String udatasmitFileRealPath = "";
|
|
|
- String udsmeshFileRealPath = "";
|
|
|
- String mtlPathFileRealPath= "";
|
|
|
- String keyPath = "domain/eHome/furniture/InitialData/" + modelType + "/" + filesId + "/";
|
|
|
-
|
|
|
- if (StrUtil.isNotEmpty(component.getString("template"))) {
|
|
|
- objFileRealPath = component.getString("template").replaceAll("Z:/OneKeyDecorate", buildPath);
|
|
|
- }
|
|
|
+ String objPath = filePath + fileId + ".obj";
|
|
|
+ File target = null;
|
|
|
|
|
|
- if (StrUtil.isNotEmpty(component.getString("mtlPath"))) {
|
|
|
- mtlPathFileRealPath = component.getString("mtlPath").replaceAll("Z:/OneKeyDecorate", buildPath);
|
|
|
- }
|
|
|
+ switch (UploadType){
|
|
|
+ case "1":
|
|
|
+ modelUploadEntity = modelUploadService.findById(Long.valueOf(modelUploadId));
|
|
|
|
|
|
- if (StrUtil.isNotEmpty(component.getString("datasmith"))) {
|
|
|
- udatasmitFileRealPath = component.getString("datasmith").replaceAll("Z:/OneKeyDecorate", buildPath);
|
|
|
- }
|
|
|
+ if (!ObjProcess.hasVt(obj)) {
|
|
|
+ //没有vt,直接报错
|
|
|
+ modelUploadEntity.setStatus(-2);
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (StrUtil.isNotEmpty(component.getString("smithAssetPath"))) {
|
|
|
- //贴图和udsmesh都在这个目录,直接批量传
|
|
|
- udsmeshFileRealPath = component.getString("smithAssetPath").replaceAll("Z:/OneKeyDecorate", buildPath);
|
|
|
- //获取目录所有文件然后上传
|
|
|
- List<File> udsmeshfiles = FileUtil.loopFiles(udsmeshFileRealPath);
|
|
|
- for (File file : udsmeshfiles) {
|
|
|
- uploadToOssUtil.uploadTo4dTjw(file.getPath(), keyPath + file.getName());
|
|
|
+ for (String file : files) {
|
|
|
+ target = new File(filePath + max.replace(".max", "") + file);
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(filePath + max.replace(".max", "") + file, "domain/eHome/furniture/InitialData/" + modelType + "/" + fileId + "/" + target.getName());
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ Thread.sleep(2000L);
|
|
|
|
|
|
|
|
|
- uploadToOssUtil.uploadTo4dTjw(objFileRealPath, keyPath + filesId + ".obj");
|
|
|
|
|
|
- uploadToOssUtil.uploadTo4dTjw(udatasmitFileRealPath, keyPath + filesId + ".udatasmith");
|
|
|
|
|
|
- uploadToOssUtil.uploadTo4dTjw(mtlPathFileRealPath, keyPath + filesId + ".mtl");
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("name", fileId);
|
|
|
+ jsonObject.put("taskType", "datafactory");
|
|
|
+ jsonObject.put("taskId", userId);
|
|
|
+ jsonObject.put("postfix", modelType);
|
|
|
+// String buildResult = OkHttpUtils.httpPostJson(buildUrl + "pro", jsonObject.toJSONString());
|
|
|
|
|
|
+ postJson(fileId, filePath, jsonObject);
|
|
|
|
|
|
- //覆盖json里面的name
|
|
|
+ Thread.sleep(1000L);
|
|
|
|
|
|
- params1.add(filesId);
|
|
|
+ checkResultJson(fileId, filePath, jsonObject, modelUploadId);
|
|
|
|
|
|
+ Integer facesNum = 0;
|
|
|
+ if ("fbx".equals(modelType)) {
|
|
|
+ String ossUrl = "domain/eHome/furniture/ue4data/" + fileId + "/" + fileId + "_preview.jpg";
|
|
|
+ String localUrl = filePath + fileId + "_preview.jpg";
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw(ossUrl, localUrl);
|
|
|
+ log.info("ossUrl-{}", ossUrl);
|
|
|
+ log.info("本地Url-{}", localUrl);
|
|
|
|
|
|
- log.info("处理配件,大小为{}", component.toJSONString());
|
|
|
- ComponentModelUploadEntity componentModelUploadEntity = new ComponentModelUploadEntity();
|
|
|
+ String maxObjUrlGet = maxObjUrl + "fbxToObj?uuid=" + fileId + "&fbx=" + fileId +
|
|
|
+ ".fbx&obj=" + fileId + ".obj&jpg=" + fileId + ".jpg&r=30";
|
|
|
+ OkHttpUtils.httpGet(maxObjUrlGet);
|
|
|
+ log.info("请求maxObj地址-{}", maxObjUrlGet);
|
|
|
+ }
|
|
|
|
|
|
- BeanUtil.copyProperties(modelUploadEntity, componentModelUploadEntity, false);
|
|
|
+ if ("datasmith".equals(modelType)) {
|
|
|
+ String ossDownlUrl = "domain/eHome/furniture/ue4data/" + fileId;
|
|
|
+ CreateObjUtil.ossCommonUtilCp(ossDownlUrl, filePath);
|
|
|
+ log.info("oss下载datasmith-{}", ossDownlUrl);
|
|
|
|
|
|
- String objPaths = objFileRealPath;
|
|
|
- componentModelUploadEntity.setId(null);
|
|
|
- componentModelUploadEntity.setFileId(filesId);
|
|
|
- componentModelUploadEntity.setObjPath(objPaths.replace(buildPath, ""));
|
|
|
- componentModelUploadEntity.setStatus(1);
|
|
|
- componentModelUploadEntity.setProgress(100);
|
|
|
- componentModelUploadEntity.setMtlPath(mtlPathFileRealPath);
|
|
|
- if (JSON.parseObject(JSONObject.toJSONString(componentSlot)).containsKey("origin")) {
|
|
|
- componentModelUploadEntity.setCacheData(JSON.parseObject(JSONObject.toJSONString(componentSlot)).getJSONObject("origin").toJSONString());
|
|
|
- }
|
|
|
- componentModelUploadEntity.setPartsModelUploadId(modelUploadEntity.getId());
|
|
|
- componentModelUploadService.save(componentModelUploadEntity);
|
|
|
- //保存id,方便后续拿预览图
|
|
|
- component.put("id",componentModelUploadEntity.getId());
|
|
|
- log.info("处理配件集合,完成保存配件,ID:{}", componentModelUploadEntity);
|
|
|
+ if (new File(filePath + fileId + "-base.obj").exists()) {
|
|
|
+ facesNum = ObjProcess.findFacesNum(filePath + fileId + "-base.obj");
|
|
|
|
|
|
- }
|
|
|
+ String maxObjUrlGet = maxObjUrl + "objToObj?uuid=" + fileId + "&inObj=" + fileId +
|
|
|
+ "-base.obj&outObj=" + fileId + ".obj&r=3000";
|
|
|
+ OkHttpUtils.httpGet(maxObjUrlGet);
|
|
|
+ log.info("请求maxObj地址-{}", maxObjUrlGet);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- uploadToOssUtil.uploadTo4dTjw(furniture, "domain/eHome/furniture/CustomFurniture/" + fileId + "/" + fileId + ".json");
|
|
|
+ log.info("obj路径-{}", objPath);
|
|
|
+ if (!new File(objPath).exists()) {
|
|
|
+ log.info("obj文件生成失败:" + objPath);
|
|
|
+ throw new RuntimeException("obj文件生成失败");
|
|
|
+ }
|
|
|
|
|
|
+ if (new File(filePath + fileId + "_preview.jpg").exists()) {
|
|
|
+ modelUploadEntity.setThumPath((filePath + fileId + "_preview.jpg").replace(buildPath, ""));
|
|
|
+ }
|
|
|
|
|
|
- uploadToOssUtil.uploadTo4dTjw(MeshMatMap, "domain/eHome/furniture/CustomFurniture/" + fileId + "/" + "MeshMatMap.txt");
|
|
|
+ modelUploadEntity.setStatus(1);
|
|
|
+ modelUploadEntity.setProgress(100);
|
|
|
+ modelUploadEntity.setObjPath(objPath.replace(buildPath, ""));
|
|
|
+ modelUploadEntity.setFacesNum(facesNum);
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+
|
|
|
+ modelUploadEntity = modelUploadService.findById(Long.valueOf(modelUploadId));
|
|
|
+
|
|
|
+ if (!ObjProcess.hasVt(obj)) {
|
|
|
+ //没有vt,直接报错
|
|
|
+ modelUploadEntity.setStatus(-2);
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ JSONObject postJsonObj = new JSONObject();
|
|
|
+ postJsonObj.put("name", fileId);
|
|
|
+ postJsonObj.put("taskType", "customFurniture");
|
|
|
+ postJsonObj.put("taskId", userId);
|
|
|
+ postJsonObj.put("postfix", modelType);
|
|
|
+ JSONArray params1 = new JSONArray();
|
|
|
|
|
|
- //分组处理文件
|
|
|
- Thread.sleep(2000L);
|
|
|
|
|
|
- jsonObject.put("params1", params1);
|
|
|
- postJson(fileId, filePath, jsonObject);
|
|
|
+ //处理 furniture.json
|
|
|
+ JSONArray furnitureJson = null;
|
|
|
+ if (StrUtil.isNotEmpty(furniture)) {
|
|
|
+ FileReader fileReader = new FileReader(furniture);
|
|
|
+ furnitureJson = JSON.parseArray(fileReader.readString());
|
|
|
+ }
|
|
|
+ JSONObject uploadModelJson = JSON.parseObject(JSON.toJSONString(furnitureJson.get(0)));
|
|
|
+ JSONArray componentSlots = uploadModelJson.getJSONArray("componentSlots");
|
|
|
+
|
|
|
+ log.info("furnitureJson.json-componentSlots长度:" + componentSlots.size());
|
|
|
+
|
|
|
+ JSONObject jsonObj =new JSONObject();
|
|
|
+ jsonObj.put("width",uploadModelJson.get("width"));
|
|
|
+ jsonObj.put("height",uploadModelJson.get("height"));
|
|
|
+ jsonObj.put("depth",uploadModelJson.get("depth"));
|
|
|
+ modelUploadEntity.setCacheData(jsonObj.toJSONString());
|
|
|
+ JSONArray saveJsonArray=new JSONArray();
|
|
|
+
|
|
|
+ for (Object componentSlot : componentSlots) {
|
|
|
+ JSONObject component = JSON.parseObject(JSONObject.toJSONString(componentSlot)).getJSONObject("component");
|
|
|
+ String filesId = component.getString("name");
|
|
|
+
|
|
|
+ String objFileRealPath = "";
|
|
|
+ String udatasmitFileRealPath = "";
|
|
|
+ String udsmeshFileRealPath = "";
|
|
|
+ String mtlPathFileRealPath= "";
|
|
|
+ String keyPath = "domain/eHome/furniture/InitialData/" + modelType + "/" + filesId + "/";
|
|
|
+
|
|
|
+ if (StrUtil.isNotEmpty(component.getString("template"))) {
|
|
|
+ objFileRealPath = component.getString("template").replaceAll("Z:/OneKeyDecorate/", buildPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.isNotEmpty(component.getString("templateMtl"))) {
|
|
|
+ mtlPathFileRealPath = component.getString("templateMtl").replaceAll("Z:/OneKeyDecorate/", buildPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.isNotEmpty(component.getString("datasmith"))) {
|
|
|
+ udatasmitFileRealPath = component.getString("datasmith").replaceAll("Z:/OneKeyDecorate/", buildPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.isNotEmpty(component.getString("smithAssetPath"))) {
|
|
|
+ //贴图和udsmesh都在这个目录,直接批量传
|
|
|
+ udsmeshFileRealPath = component.getString("smithAssetPath").replaceAll("Z:/OneKeyDecorate/", buildPath);
|
|
|
+ //获取目录所有文件然后上传
|
|
|
+ List<File> udsmeshfiles = FileUtil.loopFiles(udsmeshFileRealPath);
|
|
|
+ for (File file : udsmeshfiles) {
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(file.getPath(), keyPath + file.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(objFileRealPath, keyPath + filesId + ".obj");
|
|
|
+
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(udatasmitFileRealPath, keyPath + filesId + ".udatasmith");
|
|
|
+
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(mtlPathFileRealPath, keyPath + filesId + ".mtl");
|
|
|
+
|
|
|
+
|
|
|
+ //覆盖json里面的name
|
|
|
+
|
|
|
+ params1.add(filesId);
|
|
|
+
|
|
|
+
|
|
|
+ log.info("处理配件,大小为{}", component.toJSONString());
|
|
|
+ componentModelUploadEntity = new ComponentModelUploadEntity();
|
|
|
+
|
|
|
+ BeanUtil.copyProperties(modelUploadEntity, componentModelUploadEntity, false);
|
|
|
+
|
|
|
+ componentModelUploadEntity.setId(null);
|
|
|
+ componentModelUploadEntity.setFileId(filesId);
|
|
|
+ componentModelUploadEntity.setStatus(-1);
|
|
|
+ componentModelUploadEntity.setProgress(0);
|
|
|
+ componentModelUploadEntity.setMtlPath(mtlPathFileRealPath);
|
|
|
+ if (JSON.parseObject(JSONObject.toJSONString(componentSlot)).containsKey("origin")) {
|
|
|
+ JSONObject cache=new JSONObject();
|
|
|
+ cache.put("origin",JSON.parseObject(JSONObject.toJSONString(componentSlot)).get("origin"));
|
|
|
+ JSONObject deploy=new JSONObject();
|
|
|
+ deploy.put("width",component.getFloat("width"));
|
|
|
+ deploy.put("depth",component.getFloat("depth"));
|
|
|
+ deploy.put("height",component.getFloat("height"));
|
|
|
+ cache.put("deploy",deploy);
|
|
|
+ componentModelUploadEntity.setCacheData(cache.toJSONString());
|
|
|
+ }
|
|
|
+ componentModelUploadEntity.setPartsModelUploadId(modelUploadEntity.getId());
|
|
|
+ componentModelUploadService.save(componentModelUploadEntity);
|
|
|
+ //保存id,方便后续拿预览图
|
|
|
+ component.put("id",componentModelUploadEntity.getId());
|
|
|
+ log.info("处理配件集合,完成保存配件,ID:{}", componentModelUploadEntity);
|
|
|
+ saveJsonArray.add(component);
|
|
|
+ }
|
|
|
|
|
|
- Thread.sleep(1000L);
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(furniture, "domain/eHome/furniture/CustomFurniture/" + fileId + "/" + fileId + ".json");
|
|
|
|
|
|
- checkResultJson(fileId, filePath, jsonObject, modelUploadId);
|
|
|
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(MeshMatMap, "domain/eHome/furniture/CustomFurniture/" + fileId + "/" + "MeshMatMap.txt");
|
|
|
|
|
|
- //拿预览图+obj 成品+组件
|
|
|
- if (jsonObj.containsKey("name")) {
|
|
|
- String productName = jsonObj.getString("name");
|
|
|
- uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + productName + "/" + productName + "_preview.jpg", filePath + productName + "_preview.jpg");
|
|
|
- uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + productName + "/" + productName + ".obj", filePath + productName + "-base.obj");
|
|
|
- modelUploadEntity.setThumPath(filePath + productName + "_preview.jpg");
|
|
|
- modelUploadEntity.setObjPath(filePath + productName + ".obj");
|
|
|
- Thread.sleep(1000L);
|
|
|
|
|
|
- }
|
|
|
+ //分组处理文件
|
|
|
+ Thread.sleep(2000L);
|
|
|
+
|
|
|
+ postJsonObj.put("params1", params1);
|
|
|
+ postJson(fileId, filePath, postJsonObj);
|
|
|
|
|
|
- for (Object componentSlot : componentSlots) {
|
|
|
- JSONObject component = JSON.parseObject(JSONObject.toJSONString(componentSlot)).getJSONObject("component");
|
|
|
- if (component.containsKey("name")) {
|
|
|
- String componentName = component.getString("name");
|
|
|
- uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + componentName + "/" + componentName + "_preview.jpg", filePath + componentName + "_preview.jpg");
|
|
|
- uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + componentName + "/" + componentName + "-base.obj", filePath + componentName + ".obj");
|
|
|
- ComponentModelUploadEntity componentEntity =componentModelUploadService.findById(component.getLong("id"));
|
|
|
- componentEntity.setThumPath(filePath + componentName + "_preview.jpg");
|
|
|
- componentEntity.setObjPath(filePath + componentName + ".obj");
|
|
|
- componentEntity.setStatus(1);
|
|
|
- componentModelUploadService.updateById(componentEntity);
|
|
|
Thread.sleep(1000L);
|
|
|
|
|
|
- }
|
|
|
+ checkResultJson(fileId, filePath, postJsonObj, modelUploadId);
|
|
|
|
|
|
- }
|
|
|
+ String productName ="";
|
|
|
+ //拿预览图+obj 成品+组件
|
|
|
+ if (uploadModelJson.containsKey("name")) {
|
|
|
+ productName = uploadModelJson.getString("name");
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + productName + "/" + productName + "_preview.jpg", filePath + productName + "_preview.jpg");
|
|
|
+ modelUploadEntity.setThumPath(filePath.replace(buildPath, "") + productName + "_preview.jpg");
|
|
|
+ Thread.sleep(1000L);
|
|
|
+ log.info("处理成品生成后的预览图"+modelUploadEntity.getThumPath());
|
|
|
|
|
|
- modelUploadEntity.setStatus(1);
|
|
|
- modelUploadEntity.setProgress(100);
|
|
|
-// modelUploadEntity.setObjPath(objPath.replace(buildPath, ""));
|
|
|
- modelUploadService.updateById(modelUploadEntity);
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
+ for (Object componentSlot : saveJsonArray) {
|
|
|
+ JSONObject component = JSON.parseObject(JSONObject.toJSONString(componentSlot));
|
|
|
+ if (component.containsKey("name")) {
|
|
|
+
|
|
|
+ String componentName = component.getString("name");
|
|
|
+ String uploadPath=filePath +componentName+"/" ;
|
|
|
+ if (!FileUtil.exist(uploadPath)){
|
|
|
+ FileUtil.mkdir(uploadPath);
|
|
|
+ }
|
|
|
+ uploadPath=uploadPath+componentName;
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/"+productName+"/" + componentName + "/" + componentName + "_preview.jpg",uploadPath+"_preview.jpg" );
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/"+productName+"/" + componentName + "/" + componentName + "-base.obj", uploadPath+ ".obj");
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/"+productName+"/" + componentName + "/" + componentName + ".mtl", uploadPath+ ".mtl");
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/"+productName+"/" + componentName + "/" + componentName + ".jpg", uploadPath+ ".jpg");
|
|
|
+ ComponentModelUploadEntity componentEntity =componentModelUploadService.findById(component.getLong("id"));
|
|
|
+ if (componentEntity != null) {
|
|
|
+ componentEntity.setThumPath(uploadPath.replace(buildPath, "") + "_preview.jpg");
|
|
|
+ componentEntity.setObjPath(uploadPath.replace(buildPath, "") + ".obj");
|
|
|
+ componentEntity.setMtlPath(uploadPath.replace(buildPath, "") + ".mtl");
|
|
|
+ //TODO 贴图是啥
|
|
|
+ componentEntity.setImgPath(uploadPath.replace(buildPath, "") + ".jpg");
|
|
|
+ componentEntity.setStatus(1);
|
|
|
+ componentEntity.setProgress(100);
|
|
|
+ componentEntity.setThumStatus(1);
|
|
|
+ componentEntity.setThumProgress(100);
|
|
|
+ componentModelUploadService.updateById(componentEntity);
|
|
|
+ log.info("处理配件生成后的预览图"+componentEntity.getThumPath()+"|obj"+componentEntity.getObjPath()+"|mtl"+componentEntity.getMtlPath());
|
|
|
+ Thread.sleep(1000L);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- File target = null;
|
|
|
- for (String file : files) {
|
|
|
- target = new File(filePath + max.replace(".max", "") + file);
|
|
|
- uploadToOssUtil.uploadTo4dTjw(filePath + max.replace(".max", "") + file, "domain/eHome/furniture/InitialData/" + modelType + "/" + fileId + "/" + target.getName());
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- Thread.sleep(2000L);
|
|
|
+ modelUploadEntity.setStatus(1);
|
|
|
+ modelUploadEntity.setProgress(100);
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+ log.info("配件逻处理完毕");
|
|
|
+ break;
|
|
|
|
|
|
+ case "3":
|
|
|
+ componentModelUploadEntity=componentModelUploadService.findById(Long.valueOf(modelUploadId));
|
|
|
|
|
|
- String objPath = filePath + fileId + ".obj";
|
|
|
- String imgPath = filePath + fileId + ".jpg";
|
|
|
+ for (String file : files) {
|
|
|
+ target = new File(filePath + max.replace(".max", "") + file);
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(filePath + max.replace(".max", "") + file, "domain/eHome/furniture/InitialData/" + modelType + "/" + fileId + "/" + target.getName());
|
|
|
+ }
|
|
|
|
|
|
+ Thread.sleep(2000L);
|
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("name", fileId);
|
|
|
- jsonObject.put("taskType", "datafactory");
|
|
|
- jsonObject.put("taskId", userId);
|
|
|
- jsonObject.put("postfix", modelType);
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject componetJsonObject = new JSONObject();
|
|
|
+ componetJsonObject.put("name", fileId);
|
|
|
+ componetJsonObject.put("taskType", "datafactory");
|
|
|
+ componetJsonObject.put("taskId", userId);
|
|
|
+ componetJsonObject.put("postfix", modelType);
|
|
|
// String buildResult = OkHttpUtils.httpPostJson(buildUrl + "pro", jsonObject.toJSONString());
|
|
|
|
|
|
- postJson(fileId, filePath, jsonObject);
|
|
|
+ postJson(fileId, filePath, componetJsonObject);
|
|
|
|
|
|
- Thread.sleep(1000L);
|
|
|
+ Thread.sleep(1000L);
|
|
|
|
|
|
- checkResultJson(fileId, filePath, jsonObject, modelUploadId);
|
|
|
+ checkResultJson(fileId, filePath, componetJsonObject, modelUploadId);
|
|
|
|
|
|
- Integer facesNum = 0;
|
|
|
- if ("fbx".equals(modelType)) {
|
|
|
- String ossUrl = "domain/eHome/furniture/ue4data/" + fileId + "/" + fileId + "_preview.jpg";
|
|
|
- String localUrl = filePath + fileId + "_preview.jpg";
|
|
|
- uploadToOssUtil.downloadFileTo4dTjw(ossUrl, localUrl);
|
|
|
- log.info("ossUrl-{}", ossUrl);
|
|
|
- log.info("本地Url-{}", localUrl);
|
|
|
+ if ("datasmith".equals(modelType)) {
|
|
|
+ String ossDownlUrl = "domain/eHome/furniture/ue4data/" + fileId;
|
|
|
+ CreateObjUtil.ossCommonUtilCp(ossDownlUrl, filePath);
|
|
|
+ log.info("oss下载datasmith-{}", ossDownlUrl);
|
|
|
+ if (FileUtil.exist(filePath + fileId + "-base.obj")) {
|
|
|
+ FileUtil.copyFile( filePath + fileId + "-base.obj" ,filePath + fileId + ".obj");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("obj路径-{}", objPath);
|
|
|
+ if (!new File(objPath).exists()) {
|
|
|
+ log.info("obj文件生成失败:" + objPath);
|
|
|
+ throw new RuntimeException("obj文件生成失败");
|
|
|
+ }
|
|
|
|
|
|
- String maxObjUrlGet = maxObjUrl + "fbxToObj?uuid=" + fileId + "&fbx=" + fileId +
|
|
|
- ".fbx&obj=" + fileId + ".obj&jpg=" + fileId + ".jpg&r=30";
|
|
|
- OkHttpUtils.httpGet(maxObjUrlGet);
|
|
|
- log.info("请求maxObj地址-{}", maxObjUrlGet);
|
|
|
- }
|
|
|
+ componentModelUploadEntity.setStatus(1);
|
|
|
+ componentModelUploadEntity.setProgress(100);
|
|
|
|
|
|
- if ("datasmith".equals(modelType)) {
|
|
|
- String ossDownlUrl = "domain/eHome/furniture/ue4data/" + fileId;
|
|
|
- CreateObjUtil.ossCommonUtilCp(ossDownlUrl, filePath);
|
|
|
- log.info("oss下载datasmith-{}", ossDownlUrl);
|
|
|
+ componentModelUploadEntity.setThumStatus(1);
|
|
|
+ componentModelUploadEntity.setThumProgress(100);
|
|
|
+ componentModelUploadEntity.setThumPath(objPath.replace(buildPath, "").replace(".obj", "") + "_preview.jpg");
|
|
|
+ componentModelUploadEntity.setMtlPath(objPath.replace(buildPath, "").replace(".obj", "") + ".mtl");
|
|
|
+// componentModelUploadEntity.setImgPath(objPath.replace(buildPath, "").replace(".obj", "") + ".jpg");
|
|
|
+ componentModelUploadEntity.setObjPath(objPath.replace(buildPath, ""));
|
|
|
+ componentModelUploadService.updateById(componentModelUploadEntity);
|
|
|
+ break;
|
|
|
|
|
|
- if (new File(filePath + fileId + "-base.obj").exists()) {
|
|
|
- facesNum = ObjProcess.findFacesNum(filePath + fileId + "-base.obj");
|
|
|
+ default:
|
|
|
+ break;
|
|
|
|
|
|
- String maxObjUrlGet = maxObjUrl + "objToObj?uuid=" + fileId + "&inObj=" + fileId +
|
|
|
- "-base.obj&outObj=" + fileId + ".obj&r=3000";
|
|
|
- OkHttpUtils.httpGet(maxObjUrlGet);
|
|
|
- log.info("请求maxObj地址-{}", maxObjUrlGet);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- log.info("obj路径-{}", objPath);
|
|
|
- if (!new File(objPath).exists()) {
|
|
|
- log.info("obj文件生成失败:" + objPath);
|
|
|
- throw new RuntimeException("obj文件生成失败");
|
|
|
}
|
|
|
|
|
|
- if (new File(filePath + fileId + "_preview.jpg").exists()) {
|
|
|
- modelUploadEntity.setThumPath((filePath + fileId + "_preview.jpg").replace(buildPath, ""));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("修改模型报错-{}", e.getMessage());
|
|
|
+ if (ObjectUtil.isNotNull(modelUploadEntity)){
|
|
|
+ modelUploadEntity.setStatus(-1);
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+ }else if (ObjectUtil.isNotNull(componentModelUploadEntity)){
|
|
|
+ componentModelUploadEntity.setStatus(-1);
|
|
|
+ componentModelUploadService.findById(Long.valueOf(modelUploadId));
|
|
|
}
|
|
|
|
|
|
- modelUploadEntity.setStatus(1);
|
|
|
- modelUploadEntity.setProgress(100);
|
|
|
- modelUploadEntity.setObjPath(objPath.replace(buildPath, ""));
|
|
|
- modelUploadEntity.setFacesNum(facesNum);
|
|
|
- modelUploadService.updateById(modelUploadEntity);
|
|
|
- }
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("修改模型报错-{}", e.getMessage());
|
|
|
- modelUploadEntity.setStatus(-1);
|
|
|
- modelUploadService.updateById(modelUploadEntity);
|
|
|
+ }finally {
|
|
|
+ if (token!=null){
|
|
|
+ RedisUtil.unlock(fileId, token);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1075,15 +1206,45 @@ public class RunBuild {
|
|
|
String modelId = datas[2];
|
|
|
String dataJson = datas[3];
|
|
|
String taskType = datas[4];
|
|
|
+ //1 + 成品 2定制 3 组件
|
|
|
+ String uploadType = datas[5];
|
|
|
|
|
|
String path = buildPath + "upload";
|
|
|
String filePath = path + File.separator + fileId + File.separator;
|
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
+ switch (uploadType){
|
|
|
+ case "1":
|
|
|
+ endProductHandler(fileId, userId, modelId, dataJson, taskType, uploadType, filePath);
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ customHandler(fileId, userId, modelId, dataJson, taskType, uploadType, filePath);
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ componentHandler(fileId, userId, modelId, dataJson, taskType, uploadType, filePath);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- ModelUploadEntity modelUploadEntity = null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void componentHandler(String fileId, String userId, String modelId, String dataJson, String taskType, String uploadType, String filePath) {
|
|
|
+ ComponentModelUploadEntity componentModelUploadEntity=null;
|
|
|
+ JSONObject jsonObject = null;
|
|
|
+ ModelUploadEntity uploadEntity=null;
|
|
|
try {
|
|
|
- jsonObject.put("name", fileId);
|
|
|
+ jsonObject=new JSONObject();
|
|
|
+ ComponentModelUploadEntity byFileId = componentModelUploadService.findByFileId(fileId);
|
|
|
+ if (ObjectUtil.isNotNull(byFileId.getPartsModelUploadId())){
|
|
|
+ uploadEntity = modelUploadService.findById(byFileId.getPartsModelUploadId());
|
|
|
+ if (ObjectUtil.isNotNull(uploadEntity)){
|
|
|
+ jsonObject.put("name", uploadEntity.getFileId()+"#"+fileId);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ jsonObject.put("name", fileId);
|
|
|
+ }
|
|
|
+
|
|
|
jsonObject.put("taskType", taskType);
|
|
|
jsonObject.put("taskId", userId);
|
|
|
jsonObject.put("params1", JSONObject.parseObject(dataJson).getJSONObject("Param1"));
|
|
@@ -1092,14 +1253,67 @@ public class RunBuild {
|
|
|
|
|
|
Thread.sleep(1000L);
|
|
|
|
|
|
- checkExaggerateSurace(jsonObject, filePath, fileId, modelId, taskType);
|
|
|
+ checkExaggerateSurace(jsonObject, filePath, fileId, modelId, taskType, uploadType);
|
|
|
+ if (ObjectUtil.isNotNull(uploadEntity)){
|
|
|
+ jsonObject.put("name", uploadEntity.getFileId()+"#"+fileId);
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/"+uploadEntity.getFileId()+"/" + fileId + "/" + fileId + "_preview.jpg", filePath + fileId + "_preview.jpg");
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + fileId + "/" + fileId + "_preview.jpg", filePath + fileId + "_preview.jpg");
|
|
|
+ }
|
|
|
+
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(filePath + fileId + "_preview.jpg", "domain/eHome/furniture/models/" +fileId+ "_preview.jpg");
|
|
|
+ componentModelUploadEntity = new ComponentModelUploadEntity();
|
|
|
+ componentModelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
+ componentModelUploadEntity.setThumStatus(1);
|
|
|
+ componentModelUploadEntity.setProgress(100);
|
|
|
+ componentModelUploadService.updateById(componentModelUploadEntity);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("生成封面失败-{}", e);
|
|
|
+ componentModelUploadEntity = new ComponentModelUploadEntity();
|
|
|
+ componentModelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
+ componentModelUploadEntity.setThumStatus(-1);
|
|
|
+ componentModelUploadService.updateById(componentModelUploadEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void customHandler(String fileId, String userId, String modelId, String dataJson, String taskType, String uploadType, String filePath) {
|
|
|
+ ModelUploadEntity modelUploadEntity=null;
|
|
|
+ JSONObject jsonObject = null;
|
|
|
+ try {
|
|
|
+ jsonObject=new JSONObject();
|
|
|
+ JSONArray componentPositions=JSONObject.parseObject(dataJson).getJSONObject("Param1").getJSONArray("componmentPositions");
|
|
|
+ List<String> ids=new LinkedList<>();
|
|
|
+ ids.add(fileId);
|
|
|
+ for (Object componentPosition : componentPositions) {
|
|
|
+ String id = JSON.parseObject(JSONObject.toJSONString(componentPosition)).getString("id");
|
|
|
+ ids.add(id);
|
|
|
+ }
|
|
|
+ jsonObject.put("name", String.join("#",ids));
|
|
|
+ jsonObject.put("taskType", taskType);
|
|
|
+ jsonObject.put("taskId", userId);
|
|
|
+ jsonObject.put("params1", JSONObject.parseObject(dataJson).getJSONObject("Param1"));
|
|
|
+
|
|
|
+ postExaggerateSurace(fileId, modelId, taskType, filePath, jsonObject);
|
|
|
+
|
|
|
+ Thread.sleep(1000L);
|
|
|
+
|
|
|
+ checkExaggerateSurace(jsonObject, filePath, fileId, modelId, taskType, uploadType);
|
|
|
|
|
|
uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + fileId + "/" + fileId + "_preview.jpg", filePath + fileId + "_preview.jpg");
|
|
|
+
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(filePath + fileId + "_preview.jpg", "domain/eHome/furniture/models/" +fileId + "_preview" + ".jpg");
|
|
|
+
|
|
|
modelUploadEntity = new ModelUploadEntity();
|
|
|
modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
modelUploadEntity.setThumStatus(1);
|
|
|
modelUploadEntity.setProgress(100);
|
|
|
modelUploadService.updateById(modelUploadEntity);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
log.error("生成封面失败-{}", e);
|
|
|
modelUploadEntity = new ModelUploadEntity();
|
|
@@ -1107,7 +1321,41 @@ public class RunBuild {
|
|
|
modelUploadEntity.setThumStatus(-1);
|
|
|
modelUploadService.updateById(modelUploadEntity);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ //成品处理
|
|
|
+ private void endProductHandler(String fileId, String userId, String modelId, String dataJson, String taskType, String uploadType, String filePath) {
|
|
|
+ JSONObject jsonObject=null;
|
|
|
+ ModelUploadEntity modelUploadEntity=null;
|
|
|
+ try {
|
|
|
+ jsonObject=new JSONObject();
|
|
|
+ jsonObject.put("name", fileId);
|
|
|
+ jsonObject.put("taskType", taskType);
|
|
|
+ jsonObject.put("taskId", userId);
|
|
|
+ jsonObject.put("params1", JSONObject.parseObject(dataJson).getJSONObject("Param1"));
|
|
|
+
|
|
|
+ postExaggerateSurace(fileId, modelId, taskType, filePath, jsonObject);
|
|
|
+
|
|
|
+ Thread.sleep(1000L);
|
|
|
+
|
|
|
+ checkExaggerateSurace(jsonObject, filePath, fileId, modelId, taskType, uploadType);
|
|
|
+
|
|
|
+ uploadToOssUtil.downloadFileTo4dTjw("domain/eHome/furniture/ue4data/" + fileId + "/" + fileId + "_preview.jpg", filePath + fileId + "_preview.jpg");
|
|
|
+ modelUploadEntity = new ModelUploadEntity();
|
|
|
+ modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
+ modelUploadEntity.setThumStatus(1);
|
|
|
+ modelUploadEntity.setProgress(100);
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("生成封面失败-{}", e);
|
|
|
+ modelUploadEntity = new ModelUploadEntity();
|
|
|
+ modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
+ modelUploadEntity.setThumStatus(-1);
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1118,6 +1366,7 @@ public class RunBuild {
|
|
|
* @param fileId
|
|
|
* @param modelId
|
|
|
* @param taskType
|
|
|
+ * @param uploadType
|
|
|
* @throws IOException
|
|
|
* @throws InterruptedException
|
|
|
*/
|
|
@@ -1125,15 +1374,18 @@ public class RunBuild {
|
|
|
String filePath,
|
|
|
String fileId,
|
|
|
String modelId,
|
|
|
- String taskType
|
|
|
+ String taskType,
|
|
|
+ String uploadType
|
|
|
) throws IOException, InterruptedException {
|
|
|
boolean over = false;
|
|
|
+
|
|
|
+ JSONObject checkPostJson=new JSONObject();
|
|
|
+ checkPostJson.put("name",jsonObject.get("name"));
|
|
|
+ checkPostJson.put("taskType",jsonObject.get("taskType"));
|
|
|
while (true) {
|
|
|
- String checkResult = OkHttpUtils.httpPostJson(modelBuildUrl + "check", jsonObject.toJSONString());
|
|
|
+ String checkResult = OkHttpUtils.httpPostJson(modelBuildUrl + "check", checkPostJson.toString());
|
|
|
JSONObject checkJson = JSONObject.parseObject(checkResult);
|
|
|
-
|
|
|
JSONArray checkArray = checkJson.getJSONArray("msg");
|
|
|
-
|
|
|
if (checkArray.size() == 0) {
|
|
|
FileUtils.writeFile(filePath + "/error-check-thum.json", checkJson.toJSONString());
|
|
|
throw new RuntimeException(fileId + ":" + taskType + "方式check接口返回error错误");
|
|
@@ -1153,10 +1405,17 @@ public class RunBuild {
|
|
|
}
|
|
|
|
|
|
if (objectJson.containsKey("progress")) {
|
|
|
- ModelUploadEntity modelUploadEntity = new ModelUploadEntity();
|
|
|
- modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
- modelUploadEntity.setProgress(objectJson.getInteger("progress"));
|
|
|
- modelUploadService.updateById(modelUploadEntity);
|
|
|
+ if (uploadType.equals("3")){
|
|
|
+ ComponentModelUploadEntity componentModelUploadEntity = new ComponentModelUploadEntity();
|
|
|
+ componentModelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
+ componentModelUploadEntity.setProgress(objectJson.getInteger("progress"));
|
|
|
+ componentModelUploadService.updateById(componentModelUploadEntity);
|
|
|
+ }else {
|
|
|
+ ModelUploadEntity modelUploadEntity = new ModelUploadEntity();
|
|
|
+ modelUploadEntity.setId(Long.valueOf(modelId));
|
|
|
+ modelUploadEntity.setProgress(objectJson.getInteger("progress"));
|
|
|
+ modelUploadService.updateById(modelUploadEntity);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|