Преглед на файлове

修改审批调用接口逻辑

xiewenjie преди 4 години
родител
ревизия
08878c1dc4

+ 43 - 33
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/ManagerController.java

@@ -11,6 +11,7 @@ import com.fdkk.sxz.annotation.log.AroundLog;
 import com.fdkk.sxz.base.BaseController;
 import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.entity.*;
+import com.fdkk.sxz.exception.BusinessException;
 import com.fdkk.sxz.util.*;
 import com.fdkk.sxz.webApi.service.*;
 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.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
+import java.io.IOException;
 import java.util.*;
 
 /**
@@ -649,48 +652,23 @@ public class ManagerController extends BaseController {
             log.info("文件存在");
             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渲染,防止同一账号在登录多个客户端下同时操作一个模型导致出问题
         Result result;
         synchronized (param.getModelUploadId()) {
-            result = synchronizedupdateByIdModel(param, modelUploadEntity, jsonObject, glbPath, renovationPartsDetailEntity);
+            result = synchronizedupdateByIdModel(param, modelUploadEntity, glbPath, renovationPartsDetailEntity);
         }
         return result;
     }
 
     private Result synchronizedupdateByIdModel(RequestRenovationPartsDetailManager param,
-                                               ModelUploadEntity modelUploadEntity,
-                                               JSONObject jsonObject, String glbPath,
+                                               ModelUploadEntity modelUploadEntity, String glbPath,
                                                RenovationPartsDetailEntity renovationPartsDetailEntity) throws Exception {
         if (checkReaptPost(param)) {
             log.info("模型已被提交,模型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");
@@ -785,18 +763,48 @@ public class ManagerController extends BaseController {
             @ApiImplicitParam(name = "examine", value = "审核,0审核中,1审核通过,-1审核失败", dataType = "String")})
     @NoAuthentication
     @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) {
             return Result.failure(CodeConstant.FAILURE_CODE_3001, CodeConstant.FAILURE_MSG_3001);
         }
 
         RenovationPartsDetailEntity renovationPartsDetailEntity = renovationPartsDetailService.findById(param.getId());
         renovationPartsDetailEntity.setId(param.getId());
-        renovationPartsDetailEntity.setExamine(param.getExamine());
-        renovationPartsDetailEntity.setExamineTime(new Date());
-
 
         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, ""),
                     renovationPartsDetailEntity.getImg().replace("/temp/", "/models/").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.setHighImg(renovationPartsDetailEntity.getHighImg().replace("/temp/", "/models/"));
             renovationPartsDetailEntity.setPath(renovationPartsDetailEntity.getPath().replace("/temp/", "/models/"));
-
+            }
         }
 
         renovationPartsDetailService.updateById(renovationPartsDetailEntity);
 
+
+
         return Result.success();
     }
 

+ 11 - 23
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/custom/ComponetManagerController.java

@@ -3,6 +3,8 @@ package com.fdkk.sxz.webApi.controller.custom;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.fdkk.sxz.annotation.auth.NoAuthentication;
 import com.fdkk.sxz.annotation.log.AroundLog;
 import com.fdkk.sxz.base.BaseController;
@@ -12,11 +14,9 @@ import com.fdkk.sxz.entity.ComponentModelUploadEntity;
 import com.fdkk.sxz.entity.ModelUploadEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
+import com.fdkk.sxz.exception.BusinessException;
 import com.fdkk.sxz.other.mq.TopicRabbitConfig;
-import com.fdkk.sxz.util.CreateObjUtil;
-import com.fdkk.sxz.util.FileUtils;
-import com.fdkk.sxz.util.RandomUtil;
-import com.fdkk.sxz.util.UploadToOssUtil;
+import com.fdkk.sxz.util.*;
 import com.fdkk.sxz.vo.request.*;
 import com.fdkk.sxz.vo.response.ResponseComponentManager;
 import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
@@ -32,11 +32,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
+import java.io.IOException;
 import java.util.*;
 
 /**
@@ -76,6 +78,8 @@ public class ComponetManagerController extends BaseController {
     @Autowired
     private IModelUploadService modelUploadService;
 
+    @Value("${build.url}")
+    private String buildUrl;
 
     /**
      * 根据上传id,删除上传模型
@@ -132,29 +136,13 @@ public class ComponetManagerController extends BaseController {
             @ApiImplicitParam(name = "examine", value = "审核,0审核中,1审核通过,-1审核失败", dataType = "String")})
     @NoAuthentication
     @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) {
             return Result.failure(CodeConstant.FAILURE_CODE_3001, CodeConstant.FAILURE_MSG_3001);
         }
-
-        CustomComponentEntity componentEntity = customComponentService.findById(param.getId());
-        if (ObjectUtil.isNotNull(componentEntity)) {
-//            uploadToOssUtil.copyTo4dTjw(componentEntity.getThumbnailSrc().replace(prefix, ""),
-//                    componentEntity.getThumbnailSrc().replace("/temp/", "/models/").replace(prefix, ""));
-//            uploadToOssUtil.copyTo4dTjw(componentEntity.getTemplate().replace(prefix, ""),
-//                    componentEntity.getTemplate().replace("/temp/", "/models/").replace(prefix, ""));
-//            uploadToOssUtil.deleteTo4dTjw(componentEntity.getThumbnailSrc().replace(prefix, ""));
-//            uploadToOssUtil.deleteTo4dTjw(componentEntity.getTemplate().replace(prefix, ""));
-//            componentEntity.setThumbnailSrc(componentEntity.getThumbnailSrc().replace("/temp/", "/models/"));
-//            componentEntity.setTemplate(componentEntity.getTemplate().replace("/temp/", "/models/"));
-            componentEntity.setExamine(param.getExamine());
-            componentEntity.setExamineTime(new Date());
-            customComponentService.updateById(componentEntity);
-        }
-
-        return Result.success();
+        return customComponentService.updatePartsDetailExamine(param);
     }
-
     /**
      * 通过id查询上传模型进度
      *

+ 9 - 43
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/custom/CustomManagerController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.fdkk.sxz.annotation.auth.NoAuthentication;
 import com.fdkk.sxz.annotation.log.AroundLog;
 import com.fdkk.sxz.base.BaseController;
@@ -13,11 +14,9 @@ import com.fdkk.sxz.entity.*;
 import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
 import com.fdkk.sxz.entity.custuom.CustomProductEntity;
 import com.fdkk.sxz.entity.custuom.CustomProductFirstclassifyEntity;
+import com.fdkk.sxz.exception.BusinessException;
 import com.fdkk.sxz.other.mq.TopicRabbitConfig;
-import com.fdkk.sxz.util.CreateObjUtil;
-import com.fdkk.sxz.util.FileUtils;
-import com.fdkk.sxz.util.RandomUtil;
-import com.fdkk.sxz.util.UploadToOssUtil;
+import com.fdkk.sxz.util.*;
 import com.fdkk.sxz.vo.request.RequestCustomProduct;
 import com.fdkk.sxz.vo.request.RequestModelCustomUpload;
 import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
@@ -35,11 +34,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.LinkedList;
@@ -87,7 +88,8 @@ public class CustomManagerController extends BaseController {
     @Value("${prefix.ali}")
     private String prefix;
 
-
+    @Value("${build.url}")
+    private String buildUrl;
 
     /**
      * 生成封面图
@@ -136,47 +138,11 @@ public class CustomManagerController extends BaseController {
             @ApiImplicitParam(name = "examine", value = "审核,0审核中,1审核通过,-1审核失败", dataType = "String")})
     @NoAuthentication
     @AroundLog(name = "更新模型审核状态")
-    public Result updatePartsDetailExamine(@RequestBody RequestRenovationPartsDetailManager param) {
+    public Result updatePartsDetailExamine(@RequestBody RequestRenovationPartsDetailManager param) throws IOException {
         if (param.getId() == null || param.getExamine() == null) {
             return Result.failure(CodeConstant.FAILURE_CODE_3001, CodeConstant.FAILURE_MSG_3001);
         }
-
-        CustomProductEntity customProductEntity = productService.findById(param.getId());
-        customProductEntity.setId(param.getId());
-        customProductEntity.setExamine(param.getExamine());
-        customProductEntity.setExamineTime(new Date());
-        if (param.getExamine().intValue() == 1) {
-//            uploadToOssUtil.copyTo4dTjw(customProductEntity.getThumbnailSrc().replace(prefix, ""),
-//                    customProductEntity.getThumbnailSrc().replace("/temp/", "/models/").replace(prefix, ""));
-//            uploadToOssUtil.deleteTo4dTjw(customProductEntity.getThumbnailSrc().replace(prefix, ""));
-//            customProductEntity.setThumbnailSrc(customProductEntity.getThumbnailSrc().replace("/temp/", "/models/"));
-        }
-        boolean updateFlag = productService.updateById(customProductEntity);
-
-        if (updateFlag && ObjectUtil.isNotNull(customProductEntity.getComponentTypeIds())) {
-            List<ResponseCustomComponent> responseCustomComponents = new ArrayList<>();
-            JSONArray components = JSONArray.parseArray(customProductEntity.getComponentTypeIds());
-            //获取每个配件加入集合
-            components.forEach(c -> {
-                Long id = Long.valueOf((String) c);
-                CustomComponentEntity componentEntity = customComponentService.findById(id);
-                if (ObjectUtil.isNotNull(componentEntity)) {
-//                    uploadToOssUtil.copyTo4dTjw(componentEntity.getThumbnailSrc().replace(prefix, ""),
-//                            componentEntity.getThumbnailSrc().replace("/temp/", "/models/").replace(prefix, ""));
-//                    uploadToOssUtil.copyTo4dTjw(componentEntity.getTemplate().replace(prefix, ""),
-//                            componentEntity.getTemplate().replace("/temp/", "/models/").replace(prefix, ""));
-//                    uploadToOssUtil.deleteTo4dTjw(componentEntity.getThumbnailSrc().replace(prefix, ""));
-//                    uploadToOssUtil.deleteTo4dTjw(componentEntity.getTemplate().replace(prefix, ""));
-//                    componentEntity.setThumbnailSrc(componentEntity.getThumbnailSrc().replace("/temp/", "/models/"));
-//                    componentEntity.setTemplate(componentEntity.getTemplate().replace("/temp/", "/models/"));
-                    componentEntity.setExamine(param.getExamine());
-                    componentEntity.setExamineTime(new Date());
-                    customComponentService.updateById(componentEntity);
-                }
-            });
-        }
-
-        return Result.success();
+        return productService.updatePartsDetailExamine(param);
     }
 
     /**

+ 2 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IComponentModelUploadService.java

@@ -23,6 +23,8 @@ public interface IComponentModelUploadService extends IBaseService<ComponentMode
 
     ComponentModelUploadEntity findByFileId(String fileId);
 
+    ComponentModelUploadEntity findByPartsDetailId(Long partsDeatilId);
+
     Result saveOrUpdateCustomUpload(RequestModelComponentSaveModel param) throws Exception;
 
     List<ComponentModelUploadEntity> findIsNotPartsDetailId(Long userId, Integer fileType);

+ 4 - 2
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/ICustomComponentService.java

@@ -1,12 +1,15 @@
 package com.fdkk.sxz.webApi.service.custom;
 
 import com.fdkk.sxz.base.IBaseService;
+import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
 import com.fdkk.sxz.vo.request.RequestCustom;
 import com.fdkk.sxz.vo.request.RequestCustomComponent;
+import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseCustomComponent;
 import com.github.pagehelper.PageInfo;
 
+import java.io.IOException;
 import java.util.List;
 
 
@@ -30,6 +33,5 @@ public interface ICustomComponentService extends IBaseService<CustomComponentEnt
   List<ResponseCustomComponent>  findComponentByParentId(RequestCustom param);
 
 
-
-
+    Result updatePartsDetailExamine(RequestRenovationPartsDetailManager param) throws IOException;
 }

+ 4 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/ICustomProductService.java

@@ -1,12 +1,15 @@
 package com.fdkk.sxz.webApi.service.custom;
 
 import com.fdkk.sxz.base.IBaseService;
+import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.entity.custuom.CustomProductEntity;
 import com.fdkk.sxz.vo.request.RequestCustom;
 import com.fdkk.sxz.vo.request.RequestCustomProduct;
+import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseCustomProduct;
 import com.github.pagehelper.PageInfo;
 
+import java.io.IOException;
 import java.util.List;
 
 
@@ -24,4 +27,5 @@ public interface ICustomProductService extends IBaseService<CustomProductEntity>
   List<ResponseCustomProduct> findProductByParentId(RequestCustom param);
 
 
+    Result updatePartsDetailExamine(RequestRenovationPartsDetailManager param) throws IOException;
 }

+ 62 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/impl/CustomComponentServiceImpl.java

@@ -2,25 +2,40 @@ package com.fdkk.sxz.webApi.service.custom.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
+import com.fdkk.sxz.entity.ComponentModelUploadEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
 import com.fdkk.sxz.entity.custuom.CustomProductEntity;
+import com.fdkk.sxz.exception.BusinessException;
+import com.fdkk.sxz.util.OkHttpUtils;
+import com.fdkk.sxz.util.SnowFlakeUUidUtils;
+import com.fdkk.sxz.util.UploadToOssUtil;
 import com.fdkk.sxz.vo.request.RequestCustom;
 import com.fdkk.sxz.vo.request.RequestCustomComponent;
+import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseCustomComponent;
 import com.fdkk.sxz.vo.response.ResponseCustomProduct;
 import com.fdkk.sxz.webApi.mapper.custom.ICustomComponentMapper;
+import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentClassifyService;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
 import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.io.IOException;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -30,6 +45,7 @@ import java.util.stream.Collectors;
  * @date: 2021-09-01 14:15:52
  **/
 @Service
+@Slf4j
 public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponentMapper, CustomComponentEntity> implements ICustomComponentService {
 
     @Qualifier("ICustomComponentMapper")
@@ -40,6 +56,13 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
     private ICustomComponentClassifyService componentClassifyService;
 
 
+    @Autowired
+    private IComponentModelUploadService componentModelUploadService;
+    @Autowired
+    private UploadToOssUtil uploadToOssUtil;
+
+    @Value("${build.url}")
+    private String buildUrl;
 
     @Override
     public PageInfo<CustomComponentEntity> listByPage(RequestCustomComponent param) {
@@ -97,4 +120,43 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
             return customComponent;
         }).collect(Collectors.toList());
     }
+
+    @Override
+    @Transactional(rollbackFor = BusinessException.class)
+    public Result updatePartsDetailExamine(RequestRenovationPartsDetailManager param) throws IOException {
+        CustomComponentEntity componentEntity = findById(param.getId());
+        if (ObjectUtil.isNotNull(componentEntity)) {
+            componentEntity.setExamine(param.getExamine());
+            componentEntity.setExamineTime(new Date());
+            ComponentModelUploadEntity modelUploadEntity = componentModelUploadService.findByPartsDetailId(componentEntity.getId());
+            if (ObjectUtil.isNotNull(modelUploadEntity)){
+                //入库前先提交模型到模型库,失败返回提示
+                JSONArray syncDataArray=new JSONArray();
+                JSONObject object = new JSONObject();
+                object.put("Name", modelUploadEntity.getFileId());
+                object.put("UserID", modelUploadEntity.getUserId());
+                object.put("Postfix", "fbx");
+                object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + modelUploadEntity.getFileId());
+                syncDataArray.add(object);
+
+                JSONObject jsonObject = new JSONObject();
+                String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
+                log.info("更新模型库,syncmodel接口参数:" );
+                uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
+                        version + "/SyncData.json");
+                log.info("上传完成SyncData.jsn:"+version);
+                jsonObject.put("version", version);
+                synchronized (componentEntity.getId()) {
+                    String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
+                    JSONObject resultJson = JSONObject.parseObject(resultData);
+                    if ("error".equals(resultJson.getString("state"))) {
+                        log.info("更新模型库,syncmodel接口失败:" + resultData);
+                        throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
+                    }
+                }
+            }
+            return Result.success(updateById(componentEntity));
+        }
+        return Result.success();
+    }
 }

+ 89 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/impl/CustomProductServiceImpl.java

@@ -10,27 +10,41 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
+import com.fdkk.sxz.entity.ComponentModelUploadEntity;
+import com.fdkk.sxz.entity.ModelUploadEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentClassifyEntity;
 import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
 import com.fdkk.sxz.entity.custuom.CustomProductEntity;
+import com.fdkk.sxz.exception.BusinessException;
+import com.fdkk.sxz.util.OkHttpUtils;
+import com.fdkk.sxz.util.SnowFlakeUUidUtils;
+import com.fdkk.sxz.util.UploadToOssUtil;
 import com.fdkk.sxz.vo.request.RequestCustom;
 import com.fdkk.sxz.vo.request.RequestCustomProduct;
+import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseCustomComponent;
 import com.fdkk.sxz.vo.response.ResponseCustomProduct;
 import com.fdkk.sxz.vo.response.ResponseRenovationPartsDetail;
 import com.fdkk.sxz.webApi.mapper.custom.ICustomProductMapper;
+import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
+import com.fdkk.sxz.webApi.service.IModelUploadService;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentClassifyService;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
 import com.fdkk.sxz.webApi.service.custom.ICustomProductService;
 import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -41,18 +55,28 @@ import java.util.stream.Collectors;
  * @date: 2021-09-01 11:24:32
  **/
 @Service
+@Slf4j
 public class CustomProductServiceImpl extends BaseServiceImpl<ICustomProductMapper, CustomProductEntity> implements ICustomProductService {
 
     @Qualifier("ICustomProductMapper")
     @Autowired
     private ICustomProductMapper customProductMapper;
 
+    @Value("${build.url}")
+    private String buildUrl;
+
     @Autowired
     private ICustomComponentService customComponentService;
 
     @Autowired
     private ICustomComponentClassifyService componentClassifyService;
 
+    @Autowired
+    private IComponentModelUploadService componentModelUploadService;
+    @Autowired
+    private IModelUploadService modelUploadService;
+    @Autowired
+    private UploadToOssUtil uploadToOssUtil;
 
     @Override
     public PageInfo<CustomProductEntity> listByPage(RequestCustomProduct param) {
@@ -118,4 +142,69 @@ public class CustomProductServiceImpl extends BaseServiceImpl<ICustomProductMapp
 
         return bList;
     }
+
+    @Override
+    @Transactional(rollbackFor = BusinessException.class)
+    public Result updatePartsDetailExamine(RequestRenovationPartsDetailManager param) throws IOException {
+        CustomProductEntity customProductEntity = findById(param.getId());
+        customProductEntity.setExamine(param.getExamine());
+        customProductEntity.setExamineTime(new Date());
+        boolean updateFlag = updateById(customProductEntity);
+        JSONArray syncDataArray = new JSONArray();
+        if (updateFlag&&param.getExamine().intValue()==1){
+            ModelUploadEntity uploadEntity = modelUploadService.findByPartsDetailId(customProductEntity.getId());
+            if (ObjectUtil.isNotNull(uploadEntity)) {
+                //入库前先提交模型到模型库,失败返回提示
+                JSONObject object = new JSONObject();
+                object.put("Name", uploadEntity.getFileId());
+                object.put("UserID", uploadEntity.getUserId());
+                object.put("Postfix", "fbx");
+                object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + uploadEntity.getFileId());
+                syncDataArray.add(object);
+            }
+        }
+        if (updateFlag && ObjectUtil.isNotNull(customProductEntity.getComponentTypeIds())) {
+            JSONArray components = JSONArray.parseArray(customProductEntity.getComponentTypeIds());
+            //获取每个配件加入集合
+            components.forEach(c -> {
+                Long id = Long.valueOf((String) c);
+                CustomComponentEntity componentEntity = customComponentService.findById(id);
+                if (ObjectUtil.isNotNull(componentEntity)) {
+                    //入库前先提交模型到模型库,失败返回提示
+                    ComponentModelUploadEntity componentModelUploadEntity = componentModelUploadService.findByPartsDetailId(componentEntity.getId());
+                    if (ObjectUtil.isNotNull(componentModelUploadEntity)) {
+                        JSONObject object = new JSONObject();
+                        object.put("Name", componentModelUploadEntity.getFileId());
+                        object.put("UserID", componentModelUploadEntity.getUserId());
+                        object.put("Postfix", "fbx");
+                        object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + componentModelUploadEntity.getFileId());
+                        syncDataArray.add(object);
+                    }
+                    componentEntity.setExamine(param.getExamine());
+                    componentEntity.setExamineTime(new Date());
+                    customComponentService.updateById(componentEntity);
+                }
+            });
+        }
+
+        if (param.getExamine().intValue() == 1) {
+            JSONObject jsonObject = new JSONObject();
+            String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
+            log.info("更新模型库,syncmodel接口参数:" + syncDataArray.toJSONString());
+            uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
+                    version + "/SyncData.json");
+            log.info("上传完成SyncData.jsn:" + version);
+            jsonObject.put("version", version);
+            synchronized (customProductEntity.getId()) {
+                //链式构建请求
+                String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
+                JSONObject resultJson = JSONObject.parseObject(resultData);
+                if ("error".equals(resultJson.getString("state"))) {
+                    log.info("更新模型库,syncmodel接口失败:" + resultData);
+                    throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
+                }
+            }
+        }
+        return Result.success();
+    }
 }

+ 9 - 27
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/ComponentModelUploadServiceImpl.java

@@ -193,33 +193,7 @@ public class ComponentModelUploadServiceImpl extends BaseServiceImpl<IComponentM
                                 ,"domain/eHome/furniture/simpleObj-Mtl/"+componentModel.getFileId()+"/"+s);
                     }
                     log.info("上传mtl+jpg 到simpleObj-Mtl结束");
-                    //入库前先提交模型到模型库,失败返回提示
-                    JSONArray syncDataArray=new JSONArray();
-
-                    JSONObject object = new JSONObject();
-                    object.put("Name", componentModel.getFileId());
-                    object.put("UserID", componentModel.getUserId());
-                    object.put("Postfix", "fbx");
-                    object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + customComponentEntity.getFileId());
-                    syncDataArray.add(object);
-
-                    JSONObject jsonObject = new JSONObject();
-                    String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
-                    log.info("更新模型库,syncmodel接口参数:" );
-                    uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
-                            version + "/SyncData.json");
-                    log.info("上传完成SyncData.jsn:"+version);
-                    jsonObject.put("version", version);
-
-                    synchronized (customComponentEntity.getId()) {
-                        //链式构建请求
-                        String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
-                        JSONObject resultJson = JSONObject.parseObject(resultData);
-                        if ("error".equals(resultJson.getString("state"))) {
-                            log.info("更新模型库,syncmodel接口失败:" + resultData);
-                            throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
-                        }
-                    }
+
                     return Result.success(componentSaveFlag);
 
                 }
@@ -248,4 +222,12 @@ public class ComponentModelUploadServiceImpl extends BaseServiceImpl<IComponentM
         }
         return getOne(wrapper);
     }
+
+    @Override
+    public ComponentModelUploadEntity findByPartsDetailId(Long partsDeatilId) {
+        LambdaQueryWrapper<ComponentModelUploadEntity> wrapper =  Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(partsDeatilId)&& partsDeatilId>0){
+            wrapper.eq(ComponentModelUploadEntity::getPartsDetailId,partsDeatilId);
+        }
+        return getOne(wrapper);    }
 }

+ 0 - 25
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/ModelUploadServiceImpl.java

@@ -129,7 +129,6 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
             if (ObjectUtil.isNull(param.getModelId())) {
                 //保存
                 log.info("保存成品");
-                JSONArray syncDataArray=new JSONArray();
 
                 ModelUploadEntity modelUploadEntity = modelUploadService.findById(param.getId());
                 if (ObjectUtil.isNotNull(modelUploadEntity)) {
@@ -234,13 +233,6 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
                                             ,"domain/eHome/furniture/simpleObj-Mtl/"+componentModel.getFileId()+"/"+s);
                                 }
                                 log.info("上传mtl+jpg 到simpleObj-Mtl结束");
-                                //入库前先提交模型到模型库,失败返回提示
-                                JSONObject object = new JSONObject();
-                                object.put("Name", componentModel.getFileId());
-                                object.put("UserID", modelUploadEntity.getUserId());
-                                object.put("Postfix", "fbx");
-                                object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + componentModel.getFileId());
-                                syncDataArray.add(object);
                             }
                         }
                     }
@@ -250,23 +242,6 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
                         modelUploadEntity.setPartsDetailId(entity.getId());
                         modelUploadService.updateById(modelUploadEntity);
                     }
-                    JSONObject jsonObject = new JSONObject();
-                    String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
-                    log.info("更新模型库,syncmodel接口参数:" + syncDataArray.toJSONString());
-                    uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
-                            version + "/SyncData.json");
-                    log.info("上传完成SyncData.jsn:"+version);
-                    jsonObject.put("version", version);
-
-                    synchronized (entity.getId()) {
-                        //链式构建请求
-                        String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
-                        JSONObject resultJson = JSONObject.parseObject(resultData);
-                        if ("error".equals(resultJson.getString("state"))) {
-                            log.info("更新模型库,syncmodel接口失败:" + resultData);
-                            throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
-                        }
-                    }
                     return Result.success(saveFlag);
                 }
                 return Result.failure("查询不到成品模型");