|
@@ -11,6 +11,7 @@ import com.fdkk.sxz.annotation.log.AroundLog;
|
|
import com.fdkk.sxz.base.BaseController;
|
|
import com.fdkk.sxz.base.BaseController;
|
|
import com.fdkk.sxz.base.Result;
|
|
import com.fdkk.sxz.base.Result;
|
|
import com.fdkk.sxz.entity.*;
|
|
import com.fdkk.sxz.entity.*;
|
|
|
|
+import com.fdkk.sxz.exception.BusinessException;
|
|
import com.fdkk.sxz.util.*;
|
|
import com.fdkk.sxz.util.*;
|
|
import com.fdkk.sxz.webApi.service.*;
|
|
import com.fdkk.sxz.webApi.service.*;
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
@@ -31,11 +32,13 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -649,48 +652,23 @@ public class ManagerController extends BaseController {
|
|
log.info("文件存在");
|
|
log.info("文件存在");
|
|
renovationPartsDetailEntity.setMviewPath(prefix + "domain/eHome/furniture/temp/" + modelUploadEntity.getFileId() + ".mview");
|
|
renovationPartsDetailEntity.setMviewPath(prefix + "domain/eHome/furniture/temp/" + modelUploadEntity.getFileId() + ".mview");
|
|
}
|
|
}
|
|
- //入库前先提交模型到模型库,失败返回提示
|
|
|
|
- String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- JSONArray array = new JSONArray();
|
|
|
|
- JSONObject object = new JSONObject();
|
|
|
|
- object.put("Name", renovationPartsDetailEntity.getName());
|
|
|
|
- object.put("UserID", modelUploadEntity.getUserId());
|
|
|
|
- String postfix = "datasmith";
|
|
|
|
- if (modelUploadEntity.getFileType() == 0) {
|
|
|
|
- postfix = "fbx";
|
|
|
|
- }
|
|
|
|
- object.put("Postfix", postfix);
|
|
|
|
- object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + modelUploadEntity.getFileId());
|
|
|
|
- array.add(object);
|
|
|
|
- jsonObject.put("version", version);
|
|
|
|
-
|
|
|
|
- log.info("更新模型库,syncmodel接口参数:" + jsonObject.toJSONString());
|
|
|
|
- uploadToOssUtil.uploadTo4dTjw(array.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
|
|
|
|
- version + "/SyncData.json");
|
|
|
|
|
|
+
|
|
// 加锁,同一个模型只能请求一次3d渲染,防止同一账号在登录多个客户端下同时操作一个模型导致出问题
|
|
// 加锁,同一个模型只能请求一次3d渲染,防止同一账号在登录多个客户端下同时操作一个模型导致出问题
|
|
Result result;
|
|
Result result;
|
|
synchronized (param.getModelUploadId()) {
|
|
synchronized (param.getModelUploadId()) {
|
|
- result = synchronizedupdateByIdModel(param, modelUploadEntity, jsonObject, glbPath, renovationPartsDetailEntity);
|
|
|
|
|
|
+ result = synchronizedupdateByIdModel(param, modelUploadEntity, glbPath, renovationPartsDetailEntity);
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
private Result synchronizedupdateByIdModel(RequestRenovationPartsDetailManager param,
|
|
private Result synchronizedupdateByIdModel(RequestRenovationPartsDetailManager param,
|
|
- ModelUploadEntity modelUploadEntity,
|
|
|
|
- JSONObject jsonObject, String glbPath,
|
|
|
|
|
|
+ ModelUploadEntity modelUploadEntity, String glbPath,
|
|
RenovationPartsDetailEntity renovationPartsDetailEntity) throws Exception {
|
|
RenovationPartsDetailEntity renovationPartsDetailEntity) throws Exception {
|
|
if (checkReaptPost(param)) {
|
|
if (checkReaptPost(param)) {
|
|
log.info("模型已被提交,模型id-{}", param.getModelUploadId());
|
|
log.info("模型已被提交,模型id-{}", param.getModelUploadId());
|
|
return Result.failure(9999, "模型已被提交,模型id-" + param.getModelUploadId());
|
|
return Result.failure(9999, "模型已被提交,模型id-" + param.getModelUploadId());
|
|
}
|
|
}
|
|
|
|
|
|
- String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
|
|
|
|
- JSONObject resultJson = JSONObject.parseObject(resultData);
|
|
|
|
- if ("error".equals(resultJson.getString("state"))) {
|
|
|
|
- log.info("更新模型库,syncmodel接口失败:" + resultData);
|
|
|
|
- return Result.failure(CodeConstant.FAILURE_CODE_4015, CodeConstant.FAILURE_MSG_4015);
|
|
|
|
- }
|
|
|
|
|
|
|
|
//判断缩略图是否存在,在就保存缩略图
|
|
//判断缩略图是否存在,在就保存缩略图
|
|
String imgPath = glbPath.replace(modelUploadEntity.getFileId() + ".glb", modelUploadEntity.getFileId() + "_preview.jpg");
|
|
String imgPath = glbPath.replace(modelUploadEntity.getFileId() + ".glb", modelUploadEntity.getFileId() + "_preview.jpg");
|
|
@@ -785,18 +763,48 @@ public class ManagerController extends BaseController {
|
|
@ApiImplicitParam(name = "examine", value = "审核,0审核中,1审核通过,-1审核失败", dataType = "String")})
|
|
@ApiImplicitParam(name = "examine", value = "审核,0审核中,1审核通过,-1审核失败", dataType = "String")})
|
|
@NoAuthentication
|
|
@NoAuthentication
|
|
@AroundLog(name = "更新模型审核状态")
|
|
@AroundLog(name = "更新模型审核状态")
|
|
- public Result updatePartsDetailExamine(@RequestBody RequestRenovationPartsDetailManager param) {
|
|
|
|
|
|
+ @Transactional(rollbackFor = BusinessException.class)
|
|
|
|
+ public Result updatePartsDetailExamine(@RequestBody RequestRenovationPartsDetailManager param) throws IOException {
|
|
if (param.getId() == null || param.getExamine() == null) {
|
|
if (param.getId() == null || param.getExamine() == null) {
|
|
return Result.failure(CodeConstant.FAILURE_CODE_3001, CodeConstant.FAILURE_MSG_3001);
|
|
return Result.failure(CodeConstant.FAILURE_CODE_3001, CodeConstant.FAILURE_MSG_3001);
|
|
}
|
|
}
|
|
|
|
|
|
RenovationPartsDetailEntity renovationPartsDetailEntity = renovationPartsDetailService.findById(param.getId());
|
|
RenovationPartsDetailEntity renovationPartsDetailEntity = renovationPartsDetailService.findById(param.getId());
|
|
renovationPartsDetailEntity.setId(param.getId());
|
|
renovationPartsDetailEntity.setId(param.getId());
|
|
- renovationPartsDetailEntity.setExamine(param.getExamine());
|
|
|
|
- renovationPartsDetailEntity.setExamineTime(new Date());
|
|
|
|
-
|
|
|
|
|
|
|
|
if (param.getExamine().intValue() == 1) {
|
|
if (param.getExamine().intValue() == 1) {
|
|
|
|
+ renovationPartsDetailEntity.setExamine(param.getExamine());
|
|
|
|
+ renovationPartsDetailEntity.setExamineTime(new Date());
|
|
|
|
+ ModelUploadEntity modelUploadEntity = modelUploadService.findByPartsDetailId(param.getId());
|
|
|
|
+ if (ObjectUtil.isNotNull(modelUploadEntity)){
|
|
|
|
+ //入库前先提交模型到模型库,失败返回提示
|
|
|
|
+ String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ JSONArray array = new JSONArray();
|
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
|
+ object.put("Name", renovationPartsDetailEntity.getName());
|
|
|
|
+ object.put("UserID", modelUploadEntity.getUserId());
|
|
|
|
+ String postfix = "datasmith";
|
|
|
|
+ if (modelUploadEntity.getFileType() == 0) {
|
|
|
|
+ postfix = "fbx";
|
|
|
|
+ }
|
|
|
|
+ object.put("Postfix", postfix);
|
|
|
|
+ object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + modelUploadEntity.getFileId());
|
|
|
|
+ array.add(object);
|
|
|
|
+ jsonObject.put("version", version);
|
|
|
|
+
|
|
|
|
+ log.info("更新模型库,syncmodel接口参数:" + jsonObject.toJSONString());
|
|
|
|
+ uploadToOssUtil.uploadTo4dTjw(array.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
|
|
|
|
+ version + "/SyncData.json");
|
|
|
|
+
|
|
|
|
+ String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(resultData);
|
|
|
|
+ if ("error".equals(resultJson.getString("state"))) {
|
|
|
|
+ log.info("更新模型库,syncmodel接口失败:" + resultData);
|
|
|
|
+ renovationPartsDetailEntity.setExamine(0);
|
|
|
|
+ return Result.failure(CodeConstant.FAILURE_CODE_4015, CodeConstant.FAILURE_MSG_4015);
|
|
|
|
+ }
|
|
|
|
+
|
|
uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getImg().replace(prefix, ""),
|
|
uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getImg().replace(prefix, ""),
|
|
renovationPartsDetailEntity.getImg().replace("/temp/", "/models/").replace(prefix, ""));
|
|
renovationPartsDetailEntity.getImg().replace("/temp/", "/models/").replace(prefix, ""));
|
|
uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getPath().replace(prefix, ""),
|
|
uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getPath().replace(prefix, ""),
|
|
@@ -815,11 +823,13 @@ public class ManagerController extends BaseController {
|
|
renovationPartsDetailEntity.setImg(renovationPartsDetailEntity.getImg().replace("/temp/", "/models/"));
|
|
renovationPartsDetailEntity.setImg(renovationPartsDetailEntity.getImg().replace("/temp/", "/models/"));
|
|
renovationPartsDetailEntity.setHighImg(renovationPartsDetailEntity.getHighImg().replace("/temp/", "/models/"));
|
|
renovationPartsDetailEntity.setHighImg(renovationPartsDetailEntity.getHighImg().replace("/temp/", "/models/"));
|
|
renovationPartsDetailEntity.setPath(renovationPartsDetailEntity.getPath().replace("/temp/", "/models/"));
|
|
renovationPartsDetailEntity.setPath(renovationPartsDetailEntity.getPath().replace("/temp/", "/models/"));
|
|
-
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
renovationPartsDetailService.updateById(renovationPartsDetailEntity);
|
|
renovationPartsDetailService.updateById(renovationPartsDetailEntity);
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|