Kaynağa Gözat

修改文件名变为雪花ID,增加数据同步接口

xiewenjie 3 yıl önce
ebeveyn
işleme
e820ded66b
18 değiştirilmiş dosya ile 587 ekleme ve 94 silme
  1. 2 2
      pom.xml
  2. 2 0
      sxz-application/src/main/resources/application-dev.properties
  3. 2 0
      sxz-application/src/main/resources/application-devuat.properties
  4. 2 0
      sxz-application/src/main/resources/application-prod.properties
  5. 2 0
      sxz-application/src/main/resources/application-uat.properties
  6. 38 0
      sxz-base/src/main/java/com/fdkk/sxz/util/SnowIdUtil.java
  7. 143 0
      sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/DataBucketController.java
  8. 5 1
      sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/ManagerController.java
  9. 23 14
      sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/custom/ComponetManagerController.java
  10. 19 18
      sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/custom/CustomManagerController.java
  11. 7 1
      sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IRenovationPartsDetailService.java
  12. 10 4
      sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/ICustomComponentService.java
  13. 8 2
      sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/ICustomProductService.java
  14. 70 29
      sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/impl/CustomComponentServiceImpl.java
  15. 84 9
      sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/impl/CustomProductServiceImpl.java
  16. 143 9
      sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsDetailServiceImpl.java
  17. 4 5
      sxz-modules/src/main/java/com/fdkk/sxz/entity/BaseEntity.java
  18. 23 0
      sxz-modules/src/main/java/com/fdkk/sxz/vo/request/RequestDataBucket.java

+ 2 - 2
pom.xml

@@ -124,7 +124,7 @@
             <dependency>
                 <groupId>com.baomidou</groupId>
                 <artifactId>mybatis-plus-boot-starter</artifactId>
-                <version>3.4.3.2</version>
+                <version>3.4.3.4</version>
             </dependency>
             <dependency>
                 <groupId>com.h2database</groupId>
@@ -148,7 +148,7 @@
             <dependency>
                 <groupId>com.github.jsqlparser</groupId>
                 <artifactId>jsqlparser</artifactId>
-                <version>2.1</version>
+                <version>4.2</version>
             </dependency>
 
             <dependency>

+ 2 - 0
sxz-application/src/main/resources/application-dev.properties

@@ -88,3 +88,5 @@ dingding.warning.address=https://oapi.dingtalk.com/robot/send?access_token=13ae0
 #缓存接口日志时间(单位小时)
 logsTimeOut=4
 driveLetter=Z:
+#雪花ID生成终端ID
+snowflake.wordId=2

+ 2 - 0
sxz-application/src/main/resources/application-devuat.properties

@@ -89,3 +89,5 @@ dingding.warning.address=https://oapi.dingtalk.com/robot/send?access_token=13ae0
 #缓存接口日志时间(单位小时)
 logsTimeOut=4
 driveLetter=Z:
+#雪花ID生成终端ID
+snowflake.wordId=3

+ 2 - 0
sxz-application/src/main/resources/application-prod.properties

@@ -88,3 +88,5 @@ max.obj.url=http://120.78.65.189:8080/
 #缓存接口日志时间(单位小时)
 logsTimeOut=4
 driveLetter=Z:
+#雪花ID生成终端ID
+snowflake.wordId=1

+ 2 - 0
sxz-application/src/main/resources/application-uat.properties

@@ -90,3 +90,5 @@ dingding.warning.address=https://oapi.dingtalk.com/robot/send?access_token=13ae0
 logsTimeOut=4
 driveLetter=Z:
 server.tomcat.basedir=/mnt/tomcatTmp
+#雪花ID生成终端ID
+snowflake.wordId=1

+ 38 - 0
sxz-base/src/main/java/com/fdkk/sxz/util/SnowIdUtil.java

@@ -0,0 +1,38 @@
+package com.fdkk.sxz.util;
+
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Xiewj
+ * @date 2021/10/22
+ */
+@Slf4j
+@Component
+public class SnowIdUtil {
+
+    @Value("snowflake.wordId")
+    private String wordId;
+
+
+    private volatile static SnowIdUtil instance = null;
+
+    public static SnowIdUtil getInstance() {
+        if (SnowIdUtil.instance == null) {
+            synchronized (SnowIdUtil.class) {
+                if (SnowIdUtil.instance == null) {
+                    SnowIdUtil.instance = SpringUtil.getBean(SnowIdUtil.class);
+                }
+            }
+        }
+        return SnowIdUtil.instance;
+    }
+
+    public String getNextIdStr() {
+        return IdUtil.getSnowflake(Long.parseLong(wordId)).nextIdStr();
+    }
+
+}

+ 143 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/DataBucketController.java

@@ -0,0 +1,143 @@
+package com.fdkk.sxz.webApi.controller;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.fdkk.sxz.annotation.auth.NoAuthentication;
+import com.fdkk.sxz.annotation.log.AroundLog;
+import com.fdkk.sxz.base.Result;
+import com.fdkk.sxz.constant.CodeConstant;
+import com.fdkk.sxz.util.UploadToOssUtil;
+import com.fdkk.sxz.vo.request.RequestDataBucket;
+import com.fdkk.sxz.webApi.service.IRenovationPartsDetailService;
+import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
+import com.fdkk.sxz.webApi.service.custom.ICustomProductService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.File;
+
+/**
+ * @author Xiewj
+ * @date 2021/10/19
+ */
+@Slf4j
+@RestController
+@RequestMapping("/change/data")
+@Api(tags = "数据迁移模块")
+public class DataBucketController {
+
+
+    @Value("${main.url}")
+    private String mainUrl;
+
+    @Autowired
+    private IRenovationPartsDetailService renovationPartsDetailService;
+
+    @Autowired
+    private ICustomProductService customProductService;
+
+    @Autowired
+    private ICustomComponentService customComponentService;
+
+    @Autowired
+    private UploadToOssUtil uploadToOssUtil;
+
+
+    @Value("${server.file.location}")
+    private String buildPath;
+
+    /**
+     * 数据上传
+     *
+     * @return
+     */
+    @ApiOperation("数据上传")
+    @RequestMapping(value = "/dataPush", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ids", value = "注解集合", dataType = "list"),
+            @ApiImplicitParam(name = "type", value = "1,普通模型 ,2,定制模型  ,3,组件", dataType = "int")})
+    @NoAuthentication
+    @AroundLog(name = "数据上传")
+    public Result dataPush(@RequestBody RequestDataBucket param) throws Exception {
+        if (ObjectUtil.isNull(param.getIds()) && param.getIds().length <= 0) {
+            return Result.failure(CodeConstant.FAILURE_CODE_3001, CodeConstant.FAILURE_MSG_3001);
+        }
+        //step 1 准备数据
+        DataBucketController.log.info("处理数据开始,ids ={},数据类型={}", param.getIds().toString(), param.getType());
+        JSONArray res = null;
+        switch (param.getType()) {
+            case 1:
+                res = renovationPartsDetailService.dataPostHandler(param);
+                break;
+            case 2:
+                res = customProductService.dataPostHandler(param);
+                break;
+            case 3:
+                res = customComponentService.dataPostHandler(param);
+                break;
+        }
+
+        DataBucketController.log.info("处理数据结束");
+        if (ObjectUtil.isNotNull(res)) {
+            //step 2 数据上传到OSS
+            DataBucketController.log.info("上传开始");
+            String version = IdUtil.getSnowflake().nextIdStr();
+            uploadToOssUtil.uploadTo4dTjw(res.toJSONString().getBytes(), "domain/sxz/DataBucket/syncData/" + version + "/SyncData.json");
+            DataBucketController.log.info("上传结束,上传版本号={}", version);
+            //step 3 返回json地址
+
+            ////step 4 发送到任务处理
+            //String resultData = OkHttpUtils.httpGet(mainUrl + "/change/data/dataPush/" + version + "/type/" + param.getType());
+            //JSONObject resultJson = JSON.parseObject(resultData)    ;
+            return Result.success(version);
+
+        }
+        return Result.success("无处理");
+    }
+
+    /**
+     * 数据上传
+     *
+     * @return
+     */
+    @ApiOperation("数据处理任务接收")
+    @RequestMapping(value = "/dataPush/{version}/type/{type}", method = RequestMethod.GET)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "version", value = "版本号", dataType = "String")})
+    @NoAuthentication
+    @AroundLog(name = "数据处理任务接收")
+    public Result dataGetHandler(@PathVariable String version, @PathVariable Integer type) {
+        //step 1 处理数据
+        String path = buildPath + "Output" + File.separator + version + ".json";
+        uploadToOssUtil.downloadFileTo4dTjw("domain/sxz/DataBucket/syncData/" + version + "/SyncData.json", path);
+        //step 2 处理完毕,删除oss路径
+        Boolean res = false;
+        if (FileUtil.exist(path)) {
+            switch (type) {
+                case 1:
+                    res = renovationPartsDetailService.dataGetHandler(path);
+                    break;
+                case 2:
+                    res = customProductService.dataGetHandler(path);
+                    break;
+                case 3:
+                    res = customComponentService.dataGetHandler(path);
+                    break;
+            }
+        } else {
+            return Result.failure("文件不存在");
+        }
+        if (!res) {
+            return Result.failure("处理结果" + res);
+        }
+        return Result.success("处理结果" + res);
+    }
+}

+ 5 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/ManagerController.java

@@ -112,6 +112,10 @@ public class ManagerController extends BaseController {
     @Autowired
     private RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方
 
+    @Autowired
+    private SnowIdUtil snowIdUtil;
+
+
     /**
      * 上传模型文件
      *
@@ -139,7 +143,7 @@ public class ManagerController extends BaseController {
         ModelUploadEntity modelUploadEntity = null;
         ComponentModelUploadEntity componentModelUploadEntity = null;
         do {
-            fileId = RandomUtil.generateShortUuid();
+            fileId = snowIdUtil.getNextIdStr();
             modelUploadEntity = modelUploadService.findByFileId(fileId);
             componentModelUploadEntity = componentModelUploadService.findByFileId(fileId);
 

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

@@ -3,8 +3,6 @@ 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;
@@ -16,12 +14,16 @@ 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.*;
+import com.fdkk.sxz.util.CreateObjUtil;
+import com.fdkk.sxz.util.FileUtils;
+import com.fdkk.sxz.util.SnowIdUtil;
+import com.fdkk.sxz.util.UploadToOssUtil;
 import com.fdkk.sxz.vo.request.*;
 import com.fdkk.sxz.vo.response.ResponseComponentManager;
 import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
 import com.fdkk.sxz.webApi.service.IModelUploadService;
-import com.fdkk.sxz.webApi.service.custom.*;
+import com.fdkk.sxz.webApi.service.custom.ICustomComponentClassifyService;
+import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
@@ -39,7 +41,10 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
 
 /**
  * @description: 定制家具——库模块相关API接口
@@ -59,7 +64,6 @@ public class ComponetManagerController extends BaseController {
     private RabbitTemplate rabbitTemplate;  //使用RabbitTemplate,这提供了接收/发送等等方
 
 
-
     @Autowired
     private ICustomComponentService customComponentService;
 
@@ -80,6 +84,8 @@ public class ComponetManagerController extends BaseController {
 
     @Value("${build.url}")
     private String buildUrl;
+    @Autowired
+    private SnowIdUtil snowIdUtil;
 
     /**
      * 根据上传id,删除上传模型
@@ -143,6 +149,7 @@ public class ComponetManagerController extends BaseController {
         }
         return customComponentService.updatePartsDetailExamine(param);
     }
+
     /**
      * 通过id查询上传模型进度
      *
@@ -161,6 +168,7 @@ public class ComponetManagerController extends BaseController {
 
         return Result.success(componentModelUploadService.findComponent(param.getId()));
     }
+
     /**
      * 生成封面图
      *
@@ -188,7 +196,7 @@ public class ComponetManagerController extends BaseController {
 
         rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.LIGHT,
                 modelUploadEntity.getFileId() + ":;" + modelUploadEntity.getUserId() + ":;" +
-                        modelUploadEntity.getId() + ":;" + jsonData + ":;modelPreview"+":;"+3);
+                        modelUploadEntity.getId() + ":;" + jsonData + ":;modelPreview" + ":;" + 3);
 
         componentModelUploadService.updateById(modelUploadEntity);
         return Result.success();
@@ -220,13 +228,13 @@ public class ComponetManagerController extends BaseController {
 
         String fileId = null;
         ModelUploadEntity modelUploadEntity = null;
-        ComponentModelUploadEntity componentModelUploadEntity =null;
+        ComponentModelUploadEntity componentModelUploadEntity = null;
         do {
-            fileId = RandomUtil.generateShortUuid();
+            fileId = snowIdUtil.getNextIdStr();
             modelUploadEntity = modelUploadService.findByFileId(fileId);
-            componentModelUploadEntity= componentModelUploadService.findByFileId(fileId);
+            componentModelUploadEntity = componentModelUploadService.findByFileId(fileId);
 
-        } while (modelUploadEntity != null&&componentModelUploadEntity!=null);
+        } while (modelUploadEntity != null && componentModelUploadEntity != null);
 
 
         componentModelUploadEntity = new ComponentModelUploadEntity();
@@ -273,7 +281,7 @@ public class ComponetManagerController extends BaseController {
 
         boolean falg = true;
         for (String targetPath : allList) {
-            log.info("解压后的-{}文件全路径是-{}", fileId, targetPath);
+            ComponetManagerController.log.info("解压后的-{}文件全路径是-{}", fileId, targetPath);
             if (targetPath.toLowerCase().endsWith(".max")) {
                 falg = false;
                 new File(targetPath).renameTo(new File(targetPath.substring(
@@ -283,14 +291,15 @@ public class ComponetManagerController extends BaseController {
         }
 
         if (falg) {
-            log.error("上传的数据类型不正确-{}", fileId);
+            ComponetManagerController.log.error("上传的数据类型不正确-{}", fileId);
             return Result.failure(CodeConstant.FAILURE_CODE_4013, CodeConstant.FAILURE_MSG_4013);
         }
 
         componentModelUploadService.save(componentModelUploadEntity);
 
 
-        rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.MODEL, componentModelUploadEntity.getId() + ":;" + fileId + ":;" + userId + ":;" + modelType + ":;" + "false"+":;" +"3");
+        rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.MODEL, componentModelUploadEntity.getId() + ":;" + fileId + ":;" + userId + ":;" + modelType + ":;" + "false" + ":;"
+                + "3");
 
         return Result.success(componentModelUploadEntity);
     }

+ 19 - 18
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/custom/CustomManagerController.java

@@ -4,23 +4,26 @@ 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;
 import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.constant.CodeConstant;
-import com.fdkk.sxz.entity.*;
+import com.fdkk.sxz.entity.ComponentModelUploadEntity;
+import com.fdkk.sxz.entity.ModelUploadEntity;
 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.*;
+import com.fdkk.sxz.util.CreateObjUtil;
+import com.fdkk.sxz.util.FileUtils;
+import com.fdkk.sxz.util.SnowIdUtil;
+import com.fdkk.sxz.util.UploadToOssUtil;
 import com.fdkk.sxz.vo.request.RequestCustomProduct;
 import com.fdkk.sxz.vo.request.RequestModelCustomUpload;
 import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
-import com.fdkk.sxz.vo.response.*;
+import com.fdkk.sxz.vo.response.ResponseCustomComponent;
+import com.fdkk.sxz.vo.response.ResponseCustomProductManager;
 import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
 import com.fdkk.sxz.webApi.service.IModelUploadService;
 import com.fdkk.sxz.webApi.service.custom.*;
@@ -34,7 +37,6 @@ 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;
 
@@ -42,7 +44,6 @@ 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;
 import java.util.List;
 
@@ -90,6 +91,8 @@ public class CustomManagerController extends BaseController {
 
     @Value("${build.url}")
     private String buildUrl;
+    @Autowired
+    private SnowIdUtil snowIdUtil;
 
     /**
      * 生成封面图
@@ -118,14 +121,13 @@ public class CustomManagerController extends BaseController {
 
         rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.LIGHT,
                 modelUploadEntity.getFileId() + ":;" + modelUploadEntity.getUserId() + ":;" +
-                        modelUploadEntity.getId() + ":;" + jsonData + ":;customFurniturePreview:;"+2);
+                        modelUploadEntity.getId() + ":;" + jsonData + ":;customFurniturePreview:;" + 2);
 
         modelUploadService.updateById(modelUploadEntity);
         return Result.success();
     }
 
 
-
     /**
      * 更新模型审核状态
      *
@@ -189,13 +191,13 @@ public class CustomManagerController extends BaseController {
 
         String fileId = null;
         ModelUploadEntity modelUploadEntity = null;
-        ComponentModelUploadEntity componentModelUploadEntity =null;
+        ComponentModelUploadEntity componentModelUploadEntity = null;
         do {
-            fileId = RandomUtil.generateShortUuid();
+            fileId = snowIdUtil.getNextIdStr();
             modelUploadEntity = modelUploadService.findByFileId(fileId);
-            componentModelUploadEntity= componentModelUploadService.findByFileId(fileId);
+            componentModelUploadEntity = componentModelUploadService.findByFileId(fileId);
 
-        } while (modelUploadEntity != null&&componentModelUploadEntity!=null);
+        } while (modelUploadEntity != null && componentModelUploadEntity != null);
 
         modelUploadEntity = new ModelUploadEntity();
         modelUploadEntity.setUserId(Long.valueOf(userId));
@@ -241,7 +243,7 @@ public class CustomManagerController extends BaseController {
 
         boolean falg = true;
         for (String targetPath : allList) {
-            log.info("解压后的-{}文件全路径是-{}", fileId, targetPath);
+            CustomManagerController.log.info("解压后的-{}文件全路径是-{}", fileId, targetPath);
             if (targetPath.toLowerCase().endsWith(".max")) {
                 falg = false;
                 new File(targetPath).renameTo(new File(targetPath.substring(
@@ -251,14 +253,14 @@ public class CustomManagerController extends BaseController {
         }
 
         if (falg) {
-            log.error("上传的数据类型不正确-{}", fileId);
+            CustomManagerController.log.error("上传的数据类型不正确-{}", fileId);
             return Result.failure(CodeConstant.FAILURE_CODE_4013, CodeConstant.FAILURE_MSG_4013);
         }
 
         modelUploadService.save(modelUploadEntity);
 
 
-        rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.MODEL, modelUploadEntity.getId() + ":;" + fileId + ":;" + userId + ":;" + modelType + ":;" + "true"+":;" +"2");
+        rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.MODEL, modelUploadEntity.getId() + ":;" + fileId + ":;" + userId + ":;" + modelType + ":;" + "true" + ":;" + "2");
 
         return Result.success(modelUploadEntity);
     }
@@ -287,7 +289,6 @@ public class CustomManagerController extends BaseController {
         if (ObjectUtil.isNotNull(param.getRecStatus()) && param.getRecStatus().equals("I")) {
             Boolean removeFlag = productService.removeById(entity.getId());
             if (removeFlag && ObjectUtil.isNotNull(entity.getComponentTypeIds())) {
-                List<ResponseCustomComponent> responseCustomComponents = new ArrayList<>();
                 JSONArray components = JSONArray.parseArray(entity.getComponentTypeIds());
                 //获取每个配件加入集合
                 components.forEach(c -> {
@@ -366,7 +367,7 @@ public class CustomManagerController extends BaseController {
             ResponseCustomProductManager manager = new ResponseCustomProductManager();
             BeanUtil.copyProperties(customProductEntity, manager, false);
             CustomProductFirstclassifyEntity firstclassifyEntity = productFirstclassifyService.findById(customProductEntity.getParentId());
-            if (ObjectUtil.isNotNull(firstclassifyEntity)){
+            if (ObjectUtil.isNotNull(firstclassifyEntity)) {
                 manager.setModelId(customProductEntity.getModelId());
                 manager.setTypeName(firstclassifyEntity.getName());
             }

+ 7 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IRenovationPartsDetailService.java

@@ -1,10 +1,12 @@
 package com.fdkk.sxz.webApi.service;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.fdkk.sxz.base.IBaseService;
-import com.github.pagehelper.PageInfo;
 import com.fdkk.sxz.entity.RenovationPartsDetailEntity;
+import com.fdkk.sxz.vo.request.RequestDataBucket;
 import com.fdkk.sxz.vo.response.ResponseRenovationPartsDetail;
+import com.github.pagehelper.PageInfo;
 
 import java.util.List;
 
@@ -22,5 +24,9 @@ public interface IRenovationPartsDetailService extends IBaseService<RenovationPa
     PageInfo<RenovationPartsDetailEntity> findAllByUserId(Long userId, String name, Integer pageNum, Integer pageSize);
 
 
+    JSONArray dataPostHandler(RequestDataBucket param);
+
+
+    Boolean dataGetHandler(String filePath);
 
 }

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

@@ -1,10 +1,12 @@
 package com.fdkk.sxz.webApi.service.custom;
 
+import com.alibaba.fastjson.JSONArray;
 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.RequestDataBucket;
 import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseCustomComponent;
 import com.github.pagehelper.PageInfo;
@@ -21,17 +23,21 @@ import java.util.List;
 public interface ICustomComponentService extends IBaseService<CustomComponentEntity> {
 
 
-  PageInfo<CustomComponentEntity> listByPage(RequestCustomComponent param);
+    PageInfo<CustomComponentEntity> listByPage(RequestCustomComponent param);
 
 
-  List<CustomComponentEntity> list(RequestCustomComponent param);
+    List<CustomComponentEntity> list(RequestCustomComponent param);
 
 
-  CustomComponentEntity findByFileId(String FileId);
+    CustomComponentEntity findByFileId(String FileId);
 
 
-  List<ResponseCustomComponent>  findComponentByParentId(RequestCustom param);
+    List<ResponseCustomComponent> findComponentByParentId(RequestCustom param);
 
 
     Result updatePartsDetailExamine(RequestRenovationPartsDetailManager param) throws IOException;
+
+    JSONArray dataPostHandler(RequestDataBucket param);
+
+    Boolean dataGetHandler(String path);
 }

+ 8 - 2
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/custom/ICustomProductService.java

@@ -1,10 +1,12 @@
 package com.fdkk.sxz.webApi.service.custom;
 
+import com.alibaba.fastjson.JSONArray;
 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.RequestDataBucket;
 import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseCustomProduct;
 import com.github.pagehelper.PageInfo;
@@ -21,11 +23,15 @@ import java.util.List;
 public interface ICustomProductService extends IBaseService<CustomProductEntity> {
 
 
-  PageInfo<CustomProductEntity> listByPage(RequestCustomProduct param);
+    PageInfo<CustomProductEntity> listByPage(RequestCustomProduct param);
 
 
-  List<ResponseCustomProduct> findProductByParentId(RequestCustom param);
+    List<ResponseCustomProduct> findProductByParentId(RequestCustom param);
 
 
     Result updatePartsDetailExamine(RequestRenovationPartsDetailManager param) throws IOException;
+
+    JSONArray dataPostHandler(RequestDataBucket param);
+
+    Boolean dataGetHandler(String path);
 }

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

@@ -1,7 +1,9 @@
 package com.fdkk.sxz.webApi.service.custom.impl;
 
+import cn.hutool.core.io.file.FileReader;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -11,16 +13,15 @@ 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.RequestDataBucket;
 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;
@@ -66,36 +67,36 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
 
     @Override
     public PageInfo<CustomComponentEntity> listByPage(RequestCustomComponent param) {
-            LambdaQueryWrapper<CustomComponentEntity> wrapper =  Wrappers.lambdaQuery();
-        if (ObjectUtil.isNotNull(param.getName())&& StrUtil.isNotEmpty(param.getName())){
-            wrapper.like(CustomComponentEntity::getName,param.getName());
+        LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(param.getName()) && StrUtil.isNotEmpty(param.getName())) {
+            wrapper.like(CustomComponentEntity::getName, param.getName());
         }
-        if (ObjectUtil.isNotNull(param.getUserId())){
-            wrapper.eq(CustomComponentEntity::getUserId,param.getUserId());
+        if (ObjectUtil.isNotNull(param.getUserId())) {
+            wrapper.eq(CustomComponentEntity::getUserId, param.getUserId());
         }
         param.setOrderBy("create_time");
         param.setSortBy("desc");
-            return super.listByPage(param,wrapper);
+        return super.listByPage(param, wrapper);
     }
 
 
     @Override
     public CustomComponentEntity findByFileId(String FileId) {
-        LambdaQueryWrapper<CustomComponentEntity> wrapper =  Wrappers.lambdaQuery();
-        if (ObjectUtil.isNotNull(FileId)&&StrUtil.isNotEmpty(FileId)){
-            wrapper.in(CustomComponentEntity::getFileId,FileId);
+        LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(FileId) && StrUtil.isNotEmpty(FileId)) {
+            wrapper.in(CustomComponentEntity::getFileId, FileId);
         }
         return getOne(wrapper);
     }
 
     @Override
     public List<CustomComponentEntity> list(RequestCustomComponent param) {
-        LambdaQueryWrapper<CustomComponentEntity> wrapper =  Wrappers.lambdaQuery();
-        if (ObjectUtil.isNotNull(param.getIds())){
-            wrapper.in(CustomComponentEntity::getId,param.getIds());
+        LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(param.getIds())) {
+            wrapper.in(CustomComponentEntity::getId, param.getIds());
         }
-        if (ObjectUtil.isNotNull(param.getModelId())){
-            wrapper.in(CustomComponentEntity::getModelId,param.getModelId());
+        if (ObjectUtil.isNotNull(param.getModelId())) {
+            wrapper.in(CustomComponentEntity::getModelId, param.getModelId());
         }
         return list(wrapper);
     }
@@ -103,17 +104,17 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
 
     @Override
     public List<ResponseCustomComponent> findComponentByParentId(RequestCustom param) {
-        LambdaQueryWrapper<CustomComponentEntity> wrapper =  Wrappers.lambdaQuery();
-        if (ObjectUtil.isNotNull(param.getParentId())){
-            wrapper.eq(CustomComponentEntity::getComponentTypeId,param.getParentId());
+        LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(param.getParentId())) {
+            wrapper.eq(CustomComponentEntity::getComponentTypeId, param.getParentId());
         }
-        wrapper.eq(CustomComponentEntity::getExamine,1);
-        wrapper.eq(CustomComponentEntity::getIsShow,1);
-        return list(wrapper).stream().map(a ->{
-            ResponseCustomComponent customComponent=new ResponseCustomComponent();
+        wrapper.eq(CustomComponentEntity::getExamine, 1);
+        wrapper.eq(CustomComponentEntity::getIsShow, 1);
+        return list(wrapper).stream().map(a -> {
+            ResponseCustomComponent customComponent = new ResponseCustomComponent();
             BeanUtils.copyProperties(a, customComponent);
             CustomComponentClassifyEntity componentClassifyEntity = componentClassifyService.findById(a.getComponentTypeId());
-            if (ObjectUtil.isNotNull(componentClassifyEntity)){
+            if (ObjectUtil.isNotNull(componentClassifyEntity)) {
                 customComponent.setComponentTypeName(componentClassifyEntity.getName());
             }
             customComponent.setType("component");
@@ -129,9 +130,9 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
             componentEntity.setExamine(param.getExamine());
             componentEntity.setExamineTime(new Date());
             ComponentModelUploadEntity modelUploadEntity = componentModelUploadService.findByPartsDetailId(componentEntity.getId());
-            if (ObjectUtil.isNotNull(modelUploadEntity)){
+            if (ObjectUtil.isNotNull(modelUploadEntity)) {
                 //入库前先提交模型到模型库,失败返回提示
-                JSONArray syncDataArray=new JSONArray();
+                JSONArray syncDataArray = new JSONArray();
                 JSONObject object = new JSONObject();
                 object.put("Name", modelUploadEntity.getFileId());
                 object.put("UserID", modelUploadEntity.getUserId());
@@ -141,16 +142,16 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
 
                 JSONObject jsonObject = new JSONObject();
                 String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
-                log.info("更新模型库,syncmodel接口参数:" );
+                CustomComponentServiceImpl.log.info("更新模型库,syncmodel接口参数:");
                 uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
                         version + "/SyncData.json");
-                log.info("上传完成SyncData.jsn:"+version);
+                CustomComponentServiceImpl.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);
+                        CustomComponentServiceImpl.log.info("更新模型库,syncmodel接口失败:" + resultData);
                         throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
                     }
                 }
@@ -159,4 +160,44 @@ public class CustomComponentServiceImpl extends BaseServiceImpl<ICustomComponent
         }
         return Result.success();
     }
+
+
+    @Override
+    public JSONArray dataPostHandler(RequestDataBucket param) {
+        LambdaQueryWrapper<CustomComponentEntity> wrapper = Wrappers.lambdaQuery();
+        List<CustomComponentEntity> list = list(wrapper);
+        JSONArray res = new JSONArray();
+        CustomComponentServiceImpl.log.info("需迁移数据数量为{}", list.size());
+        list.forEach(a -> {
+            /****1:处理 tb_custom_component 表 *****/
+            JSONObject entity = (JSONObject) JSONObject.toJSON(a);
+            entity.remove("id");
+            res.add(entity);
+        });
+        CustomComponentServiceImpl.log.info("数据准备完毕");
+        return res;
+    }
+
+    @Override
+    public Boolean dataGetHandler(String path) {
+        FileReader fileReader = new FileReader(path);
+        try {
+            JSONArray dataList = JSON.parseArray(fileReader.readString());
+            CustomComponentServiceImpl.log.info("需迁移数据数量为{}", dataList.size());
+            if (dataList.size() > 0) {
+                dataList.forEach(a -> {
+                    JSONObject componentEntityJson = (JSONObject) JSONObject.toJSON(a);
+                    CustomComponentEntity componentEntity = JSONObject.toJavaObject(componentEntityJson, CustomComponentEntity.class);
+                    boolean saveFlag = save(componentEntity);
+                    CustomComponentServiceImpl.log.info("组件保存结果{}", saveFlag);
+
+                });
+                CustomComponentServiceImpl.log.info("处理完成", path);
+            }
+        } catch (Exception e) {
+            CustomComponentServiceImpl.log.info("数据处理报错");
+            throw new RuntimeException("数据处理报错");
+        }
+        return true;
+    }
 }

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

@@ -1,19 +1,16 @@
 package com.fdkk.sxz.webApi.service.custom.impl;
 
+import cn.hutool.core.io.file.FileReader;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-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;
@@ -23,10 +20,10 @@ 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.RequestDataBucket;
 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;
@@ -45,7 +42,6 @@ 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;
 
@@ -178,21 +174,100 @@ public class CustomProductServiceImpl extends BaseServiceImpl<ICustomProductMapp
         if (param.getExamine().intValue() == 1) {
             JSONObject jsonObject = new JSONObject();
             String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
-            log.info("更新模型库,syncmodel接口参数:" + syncDataArray.toJSONString());
+            CustomProductServiceImpl.log.info("更新模型库,syncmodel接口参数:" + syncDataArray.toJSONString());
             uploadToOssUtil.uploadTo4dTjw(syncDataArray.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
                     version + "/SyncData.json");
-            log.info("上传完成SyncData.jsn:" + version);
+            CustomProductServiceImpl.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);
+                    CustomProductServiceImpl.log.info("更新模型库,syncmodel接口失败:" + resultData);
                     throw new BusinessException("更新模型库,syncmodel接口失败:" + resultData);
                 }
             }
         }
         return Result.success();
     }
+
+
+    @Override
+    public JSONArray dataPostHandler(RequestDataBucket param) {
+        LambdaQueryWrapper<CustomProductEntity> wrapper = Wrappers.lambdaQuery();
+        List<CustomProductEntity> list = list(wrapper);
+        JSONArray res = new JSONArray();
+        CustomProductServiceImpl.log.info("需迁移数据数量为{}", list.size());
+        list.forEach(a -> {
+            /****1:处理 tb_custom_component 表 *****/
+            JSONObject entity = (JSONObject) JSONObject.toJSON(a);
+            JSONArray entityChild = new JSONArray();
+            entity.remove("id");
+            /****1:处理 tb_custom_component 表 *****/
+            if (StrUtil.isNotEmpty(a.getComponentTypeIds())) {
+                JSONArray components = JSONArray.parseArray(a.getComponentTypeIds());
+                //获取每个配件加入集合
+                components.forEach(c -> {
+                    Long id = Long.valueOf((String) c);
+                    CustomComponentEntity componentEntity = customComponentService.findById(id);
+                    if (ObjectUtil.isNotNull(componentEntity)) {
+                        JSONObject componentsEntity = (JSONObject) JSONObject.toJSON(componentEntity);
+                        componentsEntity.remove("id");
+                        entityChild.add(componentsEntity);
+                    }
+                });
+            }
+            entity.put("child", entityChild);
+            res.add(entity);
+        });
+        CustomProductServiceImpl.log.info("数据准备完毕");
+        return res;
+    }
+
+    @Override
+    @Transactional(rollbackFor = BusinessException.class)
+    public Boolean dataGetHandler(String path) {
+        FileReader fileReader = new FileReader(path);
+        try {
+            JSONArray dataList = JSON.parseArray(fileReader.readString());
+            CustomProductServiceImpl.log.info("需迁-成品-移数据数量为{}", dataList.size());
+            if (dataList.size() > 0) {
+                dataList.forEach(a -> {
+                    JSONObject customProductJson = (JSONObject) JSONObject.toJSON(a);
+                    CustomProductEntity entity = JSONObject.toJavaObject(customProductJson, CustomProductEntity.class);
+                    boolean saveFlag = save(entity);
+                    CustomProductServiceImpl.log.info("定制模型保存结果{}", saveFlag);
+                    JSONArray ids = new JSONArray();
+                    if (saveFlag) {
+                        if (customProductJson.containsKey("child")) {
+                            JSONArray child = customProductJson.getJSONArray("child");
+                            CustomProductServiceImpl.log.info("需迁移-组件-数据数量为B{}", child.size());
+                            child.forEach(c -> {
+                                JSONObject childJsonObject = (JSONObject) JSONObject.toJSON(c);
+                                CustomComponentEntity componentEntity = JSONObject.toJavaObject(childJsonObject, CustomComponentEntity.class);
+                                boolean componentSaveFlag = customComponentService.save(componentEntity);
+                                CustomProductServiceImpl.log.info("组件保存结果{}", componentSaveFlag);
+                                if (componentSaveFlag) {
+                                    ids.add(componentEntity.getId());
+                                }
+                            });
+                        }
+                    }
+                    CustomProductServiceImpl.log.info("定制模型保存ids数量{}", ids.size());
+                    if (ids.size() > 0) {
+                        entity.setComponentTypeIds(ids.toString());
+                        boolean updateFlag = updateById(entity);
+                        CustomProductServiceImpl.log.info("定制模型保存ids结果{}", updateFlag);
+                    }
+                });
+                CustomProductServiceImpl.log.info("处理完成", path);
+            }
+
+        } catch (Exception e) {
+            CustomProductServiceImpl.log.info("数据处理报错");
+            throw new RuntimeException("数据处理报错");
+        }
+        return true;
+    }
 }

+ 143 - 9
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/RenovationPartsDetailServiceImpl.java

@@ -1,14 +1,31 @@
 package com.fdkk.sxz.webApi.service.impl;
 
+import cn.hutool.core.io.file.FileReader;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSON;
+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.impl.BaseServiceImpl;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
+import com.fdkk.sxz.entity.ModelUploadEntity;
+import com.fdkk.sxz.entity.RenovationPartsAttachingEntity;
 import com.fdkk.sxz.entity.RenovationPartsDetailEntity;
+import com.fdkk.sxz.entity.RenovationPartsSizeEntity;
+import com.fdkk.sxz.exception.BusinessException;
+import com.fdkk.sxz.vo.request.RequestDataBucket;
+import com.fdkk.sxz.vo.response.ResponseRenovationPartsAttaching;
+import com.fdkk.sxz.vo.response.ResponseRenovationPartsDetail;
+import com.fdkk.sxz.vo.response.ResponseRenovationPartsSize;
 import com.fdkk.sxz.webApi.mapper.IRenovationPartsAttachingMapper;
 import com.fdkk.sxz.webApi.mapper.IRenovationPartsDetailMapper;
-import com.fdkk.sxz.webApi.mapper.IRenovationPartsSizeMapper;
+import com.fdkk.sxz.webApi.service.IModelUploadService;
+import com.fdkk.sxz.webApi.service.IRenovationPartsAttachingService;
 import com.fdkk.sxz.webApi.service.IRenovationPartsDetailService;
-import com.fdkk.sxz.vo.response.ResponseRenovationPartsDetail;
+import com.fdkk.sxz.webApi.service.IRenovationPartsSizeService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
@@ -21,6 +38,7 @@ import java.util.List;
  */
 @Service
 @Transactional
+@Slf4j
 public class RenovationPartsDetailServiceImpl extends BaseServiceImpl<IRenovationPartsDetailMapper, RenovationPartsDetailEntity> implements IRenovationPartsDetailService {
 
     @Qualifier("IRenovationPartsDetailMapper")
@@ -31,24 +49,28 @@ public class RenovationPartsDetailServiceImpl extends BaseServiceImpl<IRenovatio
     @Autowired
     private IRenovationPartsAttachingMapper renovationPartsAttachingMapper;
 
-    @Qualifier("IRenovationPartsSizeMapper")
     @Autowired
-    private IRenovationPartsSizeMapper renovationPartsSizeMapper;
+    private IRenovationPartsSizeService renovationPartsSizeService;
+    @Autowired
+    private IRenovationPartsAttachingService renovationPartsAttachingService;
+
+    @Autowired
+    private IModelUploadService modelUploadService;
 
 
     @Override
     public List<ResponseRenovationPartsDetail> findDetailByTypeId(Long id, Long colorId, Long classifyId) {
-        if(colorId != null && colorId.longValue() == 0){
+        if (colorId != null && colorId.longValue() == 0) {
             colorId = null;
         }
-        if(classifyId != null && classifyId.longValue() == 0){
+        if (classifyId != null && classifyId.longValue() == 0) {
             classifyId = null;
         }
         List<ResponseRenovationPartsDetail> detailList = mapper.findDetailByTypeId(id, colorId, classifyId);
 
         for (ResponseRenovationPartsDetail responseRenovationPartsDetail : detailList) {
             responseRenovationPartsDetail.setEditing(renovationPartsAttachingMapper.findAttachinByDetailId(responseRenovationPartsDetail.getId()));
-            responseRenovationPartsDetail.setSize(renovationPartsSizeMapper.findSizeByDetailId(responseRenovationPartsDetail.getId()));
+            responseRenovationPartsDetail.setSize(renovationPartsSizeService.findSizeByDetailId(responseRenovationPartsDetail.getId()));
         }
         return detailList;
     }
@@ -71,4 +93,116 @@ public class RenovationPartsDetailServiceImpl extends BaseServiceImpl<IRenovatio
         PageInfo<RenovationPartsDetailEntity> pageInfo = new PageInfo<>(list);
         return pageInfo;
     }
+
+
+    @Override
+    public JSONArray dataPostHandler(RequestDataBucket param) {
+        LambdaQueryWrapper<RenovationPartsDetailEntity> wrapper = Wrappers.lambdaQuery();
+        wrapper.in(RenovationPartsDetailEntity::getId, param.getIds());
+        List<RenovationPartsDetailEntity> list = list(wrapper);
+        RenovationPartsDetailServiceImpl.log.info("需迁移数据数量为{}", list.size());
+        JSONArray res = new JSONArray();
+        list.forEach(a -> {
+            /****1:处理 tb_renovation_parts_detail 表 *****/
+            JSONObject entity = (JSONObject) JSONObject.toJSON(a);
+            entity.remove("id");
+            /****2:处理 tb_renovation_parts_size 表 *****/
+            ResponseRenovationPartsSize partsSize = renovationPartsSizeService.findSizeByDetailId(a.getId());
+            if (ObjectUtil.isNotNull(partsSize)) {
+                JSONObject partsSizeJson = (JSONObject) JSONObject.toJSON(partsSize);
+                partsSizeJson.remove("id");
+                entity.put("partsSize", partsSizeJson);
+            }
+            /****3:处理 tb_renovation_parts_attaching 表 *****/
+            ResponseRenovationPartsAttaching attachinByDetailId = renovationPartsAttachingService.findAttachinByDetailId(a.getId());
+            if (ObjectUtil.isNotNull(attachinByDetailId)) {
+                JSONObject attachinByDetailJson = (JSONObject) JSONObject.toJSON(attachinByDetailId);
+                attachinByDetailJson.remove("id");
+                entity.put("attaching", attachinByDetailJson);
+            }
+            /****4:处理 tb_model_upload 表 *****/
+            ModelUploadEntity uploadModel = modelUploadService.findByFileId(a.getName());
+            if (ObjectUtil.isNotNull(uploadModel)) {
+                JSONObject cache = JSON.parseObject(uploadModel.getCacheData());
+                JSONObject uploadModelJson = (JSONObject) JSONObject.toJSON(uploadModel);
+                uploadModelJson.remove("id");
+                uploadModelJson.remove("cacheData");
+                uploadModelJson.put("cache", cache);
+                entity.put("uploadModel", uploadModelJson);
+            }
+            res.add(entity);
+        });
+        RenovationPartsDetailServiceImpl.log.info("数据准备完毕");
+        return res;
+    }
+
+    @Override
+    @Transactional(rollbackFor = BusinessException.class)
+    public Boolean dataGetHandler(String filePath) {
+        FileReader fileReader = new FileReader(filePath);
+        try {
+            JSONArray dataList = JSON.parseArray(fileReader.readString());
+            RenovationPartsDetailServiceImpl.log.info("需迁-移数据数量为{}", dataList.size());
+            if (dataList.size() > 0) {
+                dataList.forEach(a -> {
+                    JSONObject renovationPartsDetailEntityJson = (JSONObject) JSONObject.toJSON(a);
+                    RenovationPartsDetailEntity entity = JSONObject.toJavaObject(renovationPartsDetailEntityJson, RenovationPartsDetailEntity.class);
+                    ResponseRenovationPartsDetail partsDetail = findByName(entity.getName());
+                    if (ObjectUtil.isNull(partsDetail)) {
+                        boolean saveFlag = save(entity);
+                        RenovationPartsDetailServiceImpl.log.info("模型保存结果{}", saveFlag);
+                        if (saveFlag) {
+                            /****2:处理 tb_renovation_parts_size 表 *****/
+                            if (renovationPartsDetailEntityJson.containsKey("partsSize")) {
+                                JSONObject partsSizeJson = renovationPartsDetailEntityJson.getJSONObject("partsSize");
+                                RenovationPartsSizeEntity partsSize = JSONObject.toJavaObject(partsSizeJson, RenovationPartsSizeEntity.class);
+                                partsSize.setPartsDetailId(entity.getId());
+                                boolean savePartsSize = renovationPartsSizeService.save(partsSize);
+                                RenovationPartsDetailServiceImpl.log.info("partsSize保存结果{}", savePartsSize);
+                            }
+                            /****3:处理 tb_renovation_parts_attaching 表 *****/
+                            if (renovationPartsDetailEntityJson.containsKey("attaching")) {
+                                JSONObject attachingJson = renovationPartsDetailEntityJson.getJSONObject("attaching");
+                                RenovationPartsAttachingEntity attaching = JSONObject.toJavaObject(attachingJson, RenovationPartsAttachingEntity.class);
+                                attaching.setPartsDetailId(entity.getId());
+                                boolean saveAttaching = renovationPartsAttachingService.save(attaching);
+                                RenovationPartsDetailServiceImpl.log.info("saveAttaching保存结果{}", saveAttaching);
+                            }
+                            /****4:处理 tb_model_upload 表 *****/
+                            if (renovationPartsDetailEntityJson.containsKey("uploadModel")) {
+                                JSONObject uploadModelJson = renovationPartsDetailEntityJson.getJSONObject("uploadModel");
+                                ModelUploadEntity uploadModel = JSONObject.toJavaObject(uploadModelJson, ModelUploadEntity.class);
+                                ModelUploadEntity uploadModelS = modelUploadService.findByFileId(uploadModel.getFileId());
+                                if (ObjectUtil.isNull(uploadModelS)) {
+                                    uploadModel.setPartsDetailId(partsDetail.getId());
+                                    uploadModel.setUserId(371L);
+                                    boolean saveAttaching = modelUploadService.save(uploadModel);
+                                    if (saveAttaching && uploadModelJson.containsKey("cache")) {
+                                        JSONObject cache = uploadModelJson.getJSONObject("cache");
+                                        cache.put("id", uploadModel.getId());
+                                        cache.put("modelUploadId", uploadModel.getId());
+                                        cache.put("userId", uploadModel.getUserId());
+                                        if (cache.containsKey("cacheData")) {
+                                            JSONObject cacheData = cache.getJSONObject("cacheData");
+                                            cacheData.put("id", uploadModel.getId());
+                                            cacheData.put("modelUploadId", uploadModel.getId());
+                                            cacheData.put("userId", uploadModel.getUserId());
+                                        }
+                                        uploadModel.setCacheData(cache.toJSONString());
+                                        modelUploadService.updateById(uploadModel);
+                                    }
+                                    RenovationPartsDetailServiceImpl.log.info("tb_model_upload保存结果{}", saveAttaching);
+                                }
+                            }
+                        }
+                    }
+                });
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("数据处理报错");
+        }
+        return true;
+    }
 }

+ 4 - 5
sxz-modules/src/main/java/com/fdkk/sxz/entity/BaseEntity.java

@@ -1,6 +1,5 @@
 package com.fdkk.sxz.entity;
 
-import com.alibaba.fastjson.annotation.JSONField;
 import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
@@ -12,21 +11,21 @@ import java.util.Date;
 @Data
 public abstract class BaseEntity implements Serializable {
 
-    @TableId(value="id", type= IdType.AUTO)
+    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(value = "create_time",fill = FieldFill.INSERT)
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//set
+    @TableField(value = "create_time", fill = FieldFill.INSERT)
     private Date createTime;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(value = "update_time",fill = FieldFill.UPDATE)
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//set
+    @TableField(value = "update_time", fill = FieldFill.UPDATE)
     private Date updateTime;
 
     @TableField(value = "rec_status")
-    @TableLogic(value = "A",delval = "I")
+    @TableLogic(value = "A", delval = "I")
     private String recStatus;
 
 }

+ 23 - 0
sxz-modules/src/main/java/com/fdkk/sxz/vo/request/RequestDataBucket.java

@@ -0,0 +1,23 @@
+package com.fdkk.sxz.vo.request;
+
+import com.fdkk.sxz.base.RequestBase;
+import lombok.Data;
+
+/**
+ * @author Xiewj
+ * @date 2021/10/19
+ */
+@Data
+public class RequestDataBucket extends RequestBase {
+
+    private Long id;
+
+    private int type;
+    
+    private String name;
+
+    private String[] ids;
+
+    private String url;
+
+}