lwhhszx пре 1 година
родитељ
комит
f1d01d201d
30 измењених фајлова са 909 додато и 166 уклоњено
  1. 20 12
      src/main/java/com/example/xiaoshiweixinback/business/utils/FileUtils.java
  2. 47 1
      src/main/java/com/example/xiaoshiweixinback/business/utils/ReadExcelUtils.java
  3. 40 0
      src/main/java/com/example/xiaoshiweixinback/controller/ImportController.java
  4. 3 3
      src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java
  5. 1 1
      src/main/java/com/example/xiaoshiweixinback/domain/AssoproductCategory.java
  6. 1 1
      src/main/java/com/example/xiaoshiweixinback/domain/Product.java
  7. 3 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductAddDTO.java
  8. 10 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/UploadCategoryParamsVO.java
  9. 62 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/UploadProductParamsVO.java
  10. 5 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductVO.java
  11. 31 5
      src/main/java/com/example/xiaoshiweixinback/service/AssoproductCategoryService.java
  12. 45 1
      src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java
  13. 105 33
      src/main/java/com/example/xiaoshiweixinback/service/ProductService.java
  14. 1 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentFromExcelService.java
  15. 2 2
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ExcuteUploadSettingService.java
  16. 2 2
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetFilesFromOPSService.java
  17. 1 1
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetOPSFileByExcelService.java
  18. 2 2
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetPatentFromSzService.java
  19. 0 87
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProduct.java
  20. 100 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductCategoryService.java
  21. 120 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductService.java
  22. 2 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/PatentData.java
  23. 70 0
      src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadPatentBatchUtil.java
  24. 1 1
      src/main/resources/application.yml
  25. 72 0
      src/main/resources/jsons/uploadCategory.json
  26. 79 0
      src/main/resources/jsons/uploadProduct.json
  27. 25 10
      src/main/resources/mapper/ProductMapper.xml
  28. 59 0
      src/test/java/com/example/xiaoshiweixinback/ImportProductTests.java
  29. 0 2
      src/test/java/com/example/xiaoshiweixinback/NoticeServiceTest.java
  30. 0 1
      src/test/java/com/example/xiaoshiweixinback/TicketServiceTests.java

+ 20 - 12
src/main/java/com/example/xiaoshiweixinback/business/utils/FileUtils.java

@@ -23,13 +23,11 @@ public class FileUtils {
         //获取 applicationHome 内的路径 ...\target\classes 到这一层级下
         File file = ah.getSource();
         //获取 file的parentFile 即最后一级之前的所有层级路径(包括盘符) 这里能获得到的最终层级为  ...\target 后续用FILE_SEPARATOR(系统路径分割通配符 即 "\") 以及fileName拼接生成存放文件的目录层级 即为根目录 root
-        String rootPath =null;
+        String rootPath = null;
 
-        if (fileName!=null&&!fileName.equals(""))
-        {
-            rootPath= file.getParentFile().toString() + FILE_SEPARATOR + fileName;
-        }
-        else {
+        if (fileName != null && !fileName.equals("")) {
+            rootPath = file.getParentFile().toString() + FILE_SEPARATOR + fileName;
+        } else {
             rootPath = file.getParentFile().toString();
         }
         //根据上方生成的根目录路径 生成对应文件夹 没有就新建
@@ -40,7 +38,8 @@ public class FileUtils {
         //返回的最终形式为 盘符:\项目层级\target\file
         return rootPath;
     }
-    public static  File getPictureFileByUrl(String dataUrl) throws IOException {
+
+    public static File getPictureFileByUrl(String dataUrl) throws IOException {
 
         URL url = new URL(dataUrl);  //想要读取的url地址
         InputStream in = url.openStream();
@@ -57,10 +56,16 @@ public class FileUtils {
         in.close();
         return file;
     }
-    public String analysisJsonFile() {
+
+    public String analysisJsonFile(String configName) {
+
+        if (configName == null) {
+            configName = "uploadSetting.json";
+        }
+
         ApplicationHome ah = new ApplicationHome(ToolUtil.class);
         File file = ah.getSource();
-        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + "uploadSetting.json";
+        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + configName;
         BufferedReader reader = null;
         StringBuilder last = new StringBuilder();
         InputStreamReader inputStreamReader;
@@ -86,7 +91,8 @@ public class FileUtils {
         }
         return last.toString();
     }
-    public static   File  getFileByBytes(byte[] bytes, String prefix, String suffix) {
+
+    public static File getFileByBytes(byte[] bytes, String prefix, String suffix) {
         BufferedOutputStream bos = null;
         FileOutputStream fos = null;
         File file = null;
@@ -120,12 +126,13 @@ public class FileUtils {
                     e.printStackTrace();
                 }
             }
-            return  file;
+            return file;
         }
     }
+
     public static File multipartFileToFile(MultipartFile file) throws Exception {
         File toFile = null;
-        if (file == null ||file.equals("") || file.getSize() <= 0) {
+        if (file == null || file.equals("") || file.getSize() <= 0) {
             file = null;
         } else {
             InputStream ins = null;
@@ -136,6 +143,7 @@ public class FileUtils {
         }
         return toFile;
     }
+
     //获取流文件
     private static void inputStreamToFile(InputStream ins, File file) {
         try {

+ 47 - 1
src/main/java/com/example/xiaoshiweixinback/business/utils/ReadExcelUtils.java

@@ -106,7 +106,6 @@ public class ReadExcelUtils {
     public static PatentData readExcelOneRow(File tempFile, Sheet sheet, int row) throws IOException {
         //创建返回最终结果的对象 patentData
         PatentData patentData = new PatentData();
-        //装载专利数据(除了摘要附图)的map:(key:表头如 "公开(公告)号"  value:表头对应内容如 "CN1307082B")
         Map<Object, Object> map = new HashMap<>();
         //装载摘要附图的对象
         PictureData pictureData = null;
@@ -301,4 +300,51 @@ System.out.println("daoru");
         return pictureDatas;
     }
 
+
+    public static Integer getExcelTotal(Sheet sheet) throws IOException {
+        //读取总行数
+        int rows = sheet.getPhysicalNumberOfRows();
+
+        //返回文件总行数-1(即专利总数量)
+        return rows - 1;
+    }
+
+
+    /**
+     * 获取一行专利的全部数据(专利内容数据 + 摘要附图)
+     *
+     * @param tempFile Excel临时文件
+     * @param row      行数
+     * @return 返回装载专利数据(专利内容数据 + 摘要附图)的对象
+     */
+    public static PatentData readExcelOneRow2(File tempFile, Sheet sheet, int row) throws IOException {
+        //创建返回最终结果的对象 patentData
+        PatentData patentData = new PatentData();
+        Map<Object, Object> map = new HashMap<>();
+        //装载摘要附图的对象
+        List<PictureData> pictureDatas = new ArrayList<>();
+
+        //开始装载专利数据
+        Row firstRow = sheet.getRow(0);
+        Row needRow = sheet.getRow(row);
+        //获得总列数
+        int columns = firstRow.getLastCellNum();
+        for (int i = 0; i < columns; i++) {
+            map.put(firstRow.getCell(i) + "", ExcelUtils.getValue(needRow.getCell(i)) + "");
+        }
+
+        //开始装载专利摘要附图(判断用07还是03的方法获取图片)
+        String suffix = tempFile.getName().substring(tempFile.getName().lastIndexOf("."));
+        if (suffix.equals(".xls") || suffix.equals(".XLS")) {
+        } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
+            pictureDatas = getPictures((XSSFSheet) sheet, row);
+        }
+
+        //返回结果对象装载结果
+        patentData.setMap(map);
+        patentData.setPictureDataList(pictureDatas);
+
+        return patentData;
+    }
+
 }

+ 40 - 0
src/main/java/com/example/xiaoshiweixinback/controller/ImportController.java

@@ -0,0 +1,40 @@
+package com.example.xiaoshiweixinback.controller;
+
+import com.example.xiaoshiweixinback.business.common.Constants;
+import com.example.xiaoshiweixinback.business.common.Response;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
+import com.example.xiaoshiweixinback.service.importPatent.excel.GetOPSFileByExcelService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProductService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+
+@Slf4j
+@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/import")
+@RestController
+@RequiredArgsConstructor
+public class ImportController {
+    private final GetOPSFileByExcelService getOPSFileByExcelService;
+private final GetPatentFromSzService getPatentFromSzService;
+private final ImportProductService importProductService;
+    @Operation(summary = "导入产品")
+    @PostMapping("/importProduct")
+    private Response importProduct(@RequestBody MultipartFile file) throws Exception {
+      File newFile=  FileUtils.multipartFileToFile(file);
+        importProductService.importProject(newFile);
+        return Response.success("records");
+    }
+
+    @Operation(summary = "导入产品类别")
+    @PostMapping("/importProductCategory")
+    private Response importProductCategory(@RequestBody MultipartFile file) throws Exception {
+        File newFile=  FileUtils.multipartFileToFile(file);
+        importProductService.importProject(newFile);
+        return Response.success("records");
+    }
+}

+ 3 - 3
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -94,7 +94,7 @@ public class ProductController {
     public Response addOrUpdateHotProduct(@RequestBody HotProductAddDTO hotProductAddDTO) {
         Integer id =null;
         try {
-             id = productService.addOrUpdateHotProduct(hotProductAddDTO);
+             id = productService.addOrUpdateHotProduct(hotProductAddDTO,null);
         } catch (BusinessException e) {
             return Response.error(e.getErrorCode(),e.getMessage());
         }
@@ -115,7 +115,7 @@ public class ProductController {
     @checkLogin
     @Operation(summary = "上下架产品")
     @PostMapping("/updateProductIfShow")
-    public Response updateProductIfShow(UpdateProductShowDTO updateProductShowDTO) {
+    public Response updateProductIfShow(@RequestBody UpdateProductShowDTO updateProductShowDTO) {
         List<Integer> ids = productService.updateProductIfShow(updateProductShowDTO);
         return Response.success(ids);
     }
@@ -123,7 +123,7 @@ public class ProductController {
     @checkLogin
     @Operation(summary = "删除产品")
     @PostMapping("/deleteHotProduct")
-    public Response deleteHotProduct(HotProductDeleteDTO hotProductDeleteDTO) {
+    public Response deleteHotProduct(@RequestBody HotProductDeleteDTO hotProductDeleteDTO) {
         List<Integer> ids = productService.deleteHotProduct(hotProductDeleteDTO);
         return Response.success(ids);
     }

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/domain/AssoproductCategory.java

@@ -28,6 +28,6 @@ public class AssoproductCategory extends BaseEntity<AssoproductCategory> {
     /**
      * 
      */
-    private Integer categoryId;
+    private Integer productCategoryId;
 
 }

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/domain/Product.java

@@ -73,7 +73,7 @@ public class Product extends BaseEntity<Product> {
     /**
      * 
      */
-    private DateTime createTime;
+    private Date createTime;
     private String locNum;
 
 

+ 3 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductAddDTO.java

@@ -52,4 +52,7 @@ public class HotProductAddDTO {
     private List<String> fileGuids;
     private Boolean ifShow;
     private Integer productCategoryId;
+    private Boolean ifHot;
+
+
 }

+ 10 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/UploadCategoryParamsVO.java

@@ -0,0 +1,10 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class UploadCategoryParamsVO {
+    private List<String> categoryList;
+}

+ 62 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/UploadProductParamsVO.java

@@ -0,0 +1,62 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class UploadProductParamsVO {
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     *
+     */
+    private String name;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+    /**
+     * 来源
+     */
+    private String sourceFrom;
+
+    /**
+     * 售卖平台
+     */
+    private String sellPlatform;
+
+    /**
+     *
+     */
+    private Boolean ifHot;
+
+    /**
+     * 是否显示(上架)
+     */
+    private Boolean ifShow;
+
+    /**
+     *  是否自定义
+     */
+    private Boolean ifCustomized;
+    private String bestSellingBrand;
+    private Double price;
+    private String platformLink;
+    private String competitorCom;
+    private String competitorLink;
+    private String locNum;
+    private String priceStr;
+    private List<String> categoryList;
+}

+ 5 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductVO.java

@@ -55,4 +55,9 @@ public class ProductVO {
     private Boolean ifHot;
     private Integer assoId;
     private Integer productCategoryId;
+    private String sourceFrom;
+    private String categoryName;
+    private String categoryPath;
+    private String path;
+    private Boolean ifShow;
 }

+ 31 - 5
src/main/java/com/example/xiaoshiweixinback/service/AssoproductCategoryService.java

@@ -1,19 +1,45 @@
 package com.example.xiaoshiweixinback.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.domain.AssoproductCategory;
 import com.example.xiaoshiweixinback.mapper.AssoproductCategoryMapper;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 
 /**
-* @author admin
-* @description 针对表【asso_ product_category(产品-产品类别关联表)】的数据库操作Service实现
-* @createDate 2024-03-29 15:28:16
-*/
+ * @author admin
+ * @description 针对表【asso_ product_category(产品-产品类别关联表)】的数据库操作Service实现
+ * @createDate 2024-03-29 15:28:16
+ */
 @Service
 public class AssoproductCategoryService extends ServiceImpl<AssoproductCategoryMapper, AssoproductCategory> {
-
+    public void addOrUpdate(Integer productId, Integer productCategoryId) {
+        if (productCategoryId == null) {
+            LambdaQueryWrapper<AssoproductCategory> queryWrapper2 = new LambdaQueryWrapper<>();
+            queryWrapper2.eq(AssoproductCategory::getProductId, productId);
+            this.remove(queryWrapper2);
+            return;
+        }
+        LambdaQueryWrapper<AssoproductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AssoproductCategory::getProductId, productId);
+        AssoproductCategory assoproductCategor = this.getOne(queryWrapper, false);
+        if (assoproductCategor == null) {
+            AssoproductCategory assoproductCategory = new AssoproductCategory();
+            assoproductCategory.setProductId(productId);
+            assoproductCategory.setProductCategoryId(productCategoryId);
+            assoproductCategory.insert();
+        } else {
+            assoproductCategor.setProductCategoryId(productCategoryId);
+            assoproductCategor.updateById();
+        }
+        return;
+    }
 }
 
 

+ 45 - 1
src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java

@@ -277,7 +277,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             } else {
                 category.setPath(parentCategory.getId() + "/");
             }
-            this.getParentPath(category.getId(), category.getPath(),category.getLevel());
+            this.getParentPath(category.getId(), category.getPath(), category.getLevel());
         } else {
             Integer parentId = category.getParentId();
             Integer level = category.getLevel();
@@ -440,6 +440,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
 
     /**
      * 修改产品类别高层级变低层级
+     *
      * @param id
      * @param path
      * @param level
@@ -469,6 +470,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
 
     /**
      * 修改产品类别低层级变高层级
+     *
      * @param id
      * @param parentId
      * @param level
@@ -573,6 +575,48 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         return productCategories;
     }
 
+
+    public Integer addCategorysByStr(List<String> categorys) {
+
+        if(categorys==null||categorys.size()==0){
+            return  null;
+        }
+        Integer parentId = 0;
+        ProductCategory last = null;
+        for (int i = 0; i < categorys.size(); i++) {
+            Integer level = i + 1;
+            //根据 层级和名称查询
+            LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(ProductCategory::getName, categorys.get(i))
+                    .eq(ProductCategory::getLevel, level)
+                    .eq(ProductCategory::getParentId, parentId);
+            ProductCategory productCategory = this.getOne(queryWrapper, false);
+
+            if (productCategory == null) {
+                productCategory = new ProductCategory();
+                productCategory.setLevel(level);
+                productCategory.setName(categorys.get(i));
+
+                if (last != null) {
+                    if (last.getPath() != null) {
+                        productCategory.setPath(last.getPath() + last.getId() + "/");
+                    } else {
+                        productCategory.setPath(last.getId() + "/");
+                    }
+                    productCategory.setParentId(parentId);
+                }
+                else {
+                    productCategory.setParentId(0);
+                }
+                productCategory.insert();
+
+            }
+            last = productCategory;
+            parentId =last.getId();
+        }
+        return last.getId();
+
+    }
 }
 
 

+ 105 - 33
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -9,6 +9,7 @@ import com.example.xiaoshiweixinback.business.common.base.SystemFile;
 import com.example.xiaoshiweixinback.business.exception.BusinessException;
 import com.example.xiaoshiweixinback.business.utils.CacheUtil;
 import com.example.xiaoshiweixinback.business.utils.LoginUtils;
+import com.example.xiaoshiweixinback.business.utils.StringUtils;
 import com.example.xiaoshiweixinback.domain.*;
 import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
 import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
@@ -21,8 +22,11 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -40,8 +44,9 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     private final AssoProductFileService assoProductFileService;
     private final FileManagerService fileManagerService;
     private final AssoPersonProductService assoPersonProductService;
-    private final VipService vipService;
-    private  ProductCategoryService productCategoryService;
+    private final ProductCategoryService productCategoryService;
+    private final AssoproductCategoryService assoproductCategoryService;
+
     /**
      * 查询爆款产品
      *
@@ -57,7 +62,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         records.setData(new ArrayList<>());
         records.setTotal(0L);
         String name = productDTO.getName();
-
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
         //查询登录人关联的产品类别id
         List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
 
@@ -67,10 +72,13 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         getProductDTO.setCurrent(current);
         getProductDTO.setSize(size);
         getProductDTO.setCategoryIds(ids);
+        if (!personnelVO.getPersonType().equals(0)) {
+            getProductDTO.setIfShow(true);
+        }
         if (ids != null) {
             List<ProductVO> productVOs = this.getBaseMapper().getProductByCategory(getProductDTO);
             Long count = this.getBaseMapper().getProductCount(getProductDTO);
-            this.loadProduct(productVOs,false);
+            this.loadProduct(productVOs, false);
             records.setData(productVOs);
             records.setTotal(count);
         }
@@ -78,8 +86,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     }
 
 
-
-    private void loadProduct(List<ProductVO> productVOS,Boolean ifCotentCategoryPath) {
+    private void loadProduct(List<ProductVO> productVOS, Boolean ifCotentCategoryPath) {
         PersonnelVO personnelVO = null;
         try {
             personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
@@ -99,7 +106,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             return;
         }
         List<Integer> ids = productVOS.stream().map(ProductVO::getId).collect(Collectors.toList());
-        List<Integer> projectCategoryIds=productVOS.stream().map(ProductVO::getProductCategoryId).collect(Collectors.toList());
+        List<Integer> projectCategoryIds = productVOS.stream().map(ProductVO::getProductCategoryId).collect(Collectors.toList());
         List<SystemFile> systemFiles = new ArrayList<>();
 
         if (ids.size() != 0) {
@@ -123,10 +130,9 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             }
 
         }
-
-        if(projectCategoryIds.size()!=0){
-            productCategoryService.getProductCategory(projectCategoryIds,ifCotentCategoryPath);
-
+        List<ProductCategory> productCategories = new ArrayList<>();
+        if (projectCategoryIds.size() != 0) {
+            productCategories = productCategoryService.getProductCategory(projectCategoryIds, ifCotentCategoryPath);
 
         }
 
@@ -151,18 +157,40 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
                 }
             }
 
-         //
-
+            //装载产品类别
+            if (productVO.getProductCategoryId() != null && productCategories.size() > 0) {
+                ProductCategory productCategory = productCategories.stream().filter(item -> item.getId().equals(productVO.getProductCategoryId())).findFirst().orElse(null);
+
+                if (productCategory != null) {
+                    productVO.setCategoryName(productCategory.getName());
+                    productVO.setPath(productCategory.getPath());
+                    if (ifCotentCategoryPath == true) {
+                        String path = productCategory.getPath();
+                        if (path != null) {
+                            String[] cIdArrs = path.split("/");
+                            List<String> names = new ArrayList<>();
+                            for (int i = 0; i < cIdArrs.length; i++) {
+                                Integer cId = Integer.parseInt(cIdArrs[i]);
+                                ProductCategory temCategory = productCategories.stream().filter(item -> item.getId().equals(cId)).findFirst().orElse(null);
+                                if (temCategory != null) {
+                                    names.add(temCategory.getName());
+                                }
+                            }
+                            String pathName = StringUtils.join(names, "/");
+                            productVO.setCategoryPath(pathName);
+                        }
+                    }
+                }
+            }
         }
     }
 
 
-
     @Transactional(rollbackFor = Exception.class)
     public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
         Product product = new Product();
         if (productAddDTO.getId() == null) {
-            product = this.addProduct(productAddDTO);
+            product = this.addProduct(productAddDTO,null);
             AssoPersonProductDTO assoPersonProductDTO = new AssoPersonProductDTO();
             assoPersonProductDTO.setProductId(product.getId());
             assoPersonProductDTO.setConcernType(productAddDTO.getConcernType());
@@ -175,11 +203,16 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public Product addProduct(Object productAddDTO) {
+    public Product addProduct(Object productAddDTO,String createUuid) {
         Product product = new Product();
         BeanUtils.copyProperties(productAddDTO, product);
-        PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
-        product.setCreateId(personnelVO.getUuid());
+        if(createUuid==null) {
+            PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
+            product.setCreateId(personnelVO.getUuid());
+        }
+        else {
+            product.setCreateId(createUuid);
+        }
         product.setIfCustomized(true);
         product.insert();
         return product;
@@ -225,7 +258,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         getProductDTO.setConcernTypes(productDTO.getConcernTypes());
         List<ProductVO> productVOs = this.getBaseMapper().getConcernProduct(getProductDTO);
         Long count = this.getBaseMapper().getConcernProductCount(getProductDTO);
-        this.loadProduct(productVOs,false);
+        this.loadProduct(productVOs, false);
         records.setData(productVOs);
         records.setTotal(count);
         return records;
@@ -233,34 +266,38 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
 
 
     @Transactional(rollbackFor = Exception.class)
-    public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO) {
+    public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO,String createId) {
         Product product = new Product();
-        String name =hotProductAddDTO.getName();
-        if(name==null){
-            throw new BusinessException("608","产品名称不可为空");
+        String name = hotProductAddDTO.getName();
+        Integer categoryId = hotProductAddDTO.getProductCategoryId();
+        if (name == null) {
+            throw new BusinessException("608", "产品名称不可为空");
         }
-        LambdaQueryWrapper<Product> queryWrapper =new LambdaQueryWrapper<>();
-        queryWrapper.eq(Product::getName,name)
-                    .eq(Product::getIfHot,true);
-        Product orgProject =this.getOne(queryWrapper,false);
-        if(product!=null){
-            throw new BusinessException("607","产品名称不可重复");
+        LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Product::getName, name)
+                .eq(Product::getIfHot, true);
+        Product orgProject = this.getOne(queryWrapper, false);
+        if (orgProject != null) {
+            throw new BusinessException("607", "产品名称不可重复");
         }
 
         if (hotProductAddDTO.getId() == null) {
-            product = this.addProduct(hotProductAddDTO);
+            hotProductAddDTO.setIfHot(true);
+            product = this.addProduct(hotProductAddDTO, createId);
         } else {
             product = this.updateProduct(hotProductAddDTO, hotProductAddDTO.getId());
         }
         assoProductFileService.addOrUpdateProductFile(product.getId(), hotProductAddDTO.getFileGuids());
+
+        assoproductCategoryService.addOrUpdate(product.getId(), categoryId);
         return product.getId();
     }
 
 
     /**
-     * 根据id查询爆款专利
+     * 查询产品详情
      *
-     * @param id
+     * @param
      * @return
      */
     public ProductVO queryHotProductDetail(Integer id) {
@@ -270,9 +307,17 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             return productVO;
         }
         BeanUtils.copyProperties(product, productVO);
+
+        //查询相关产品类别id
+        LambdaQueryWrapper<AssoproductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AssoproductCategory::getProductId, product.getId());
+        AssoproductCategory assoproductCategory = assoproductCategoryService.getOne(queryWrapper, false);
+        if (assoproductCategory != null) {
+            productVO.setProductCategoryId(assoproductCategory.getProductCategoryId());
+        }
         List<ProductVO> productVOS = new ArrayList<>();
         productVOS.add(productVO);
-        this.loadProduct(productVOS,true);
+        this.loadProduct(productVOS, true);
         return productVO;
     }
 
@@ -314,6 +359,33 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         this.removeBatchByIds(ids);
         return ids;
     }
+
+
+
+    public void ImportProduct(MultipartFile multipartFile) {
+        String guid = "";
+
+        //上传文件
+        try {
+            List<String> guids = fileManagerService.uploadFileGetGuid(Arrays.asList(multipartFile));
+            if (guids == null | guids.size() == 0) {
+                throw new BusinessException("607", "上传文件错误");
+            }
+            guid =guids.get(0);
+        } catch (Exception e) {
+            throw new BusinessException("607", "上传文件错误");
+        }
+
+        //创建导入产品任务
+
+
+        //导入产品
+
+
+        //发送消息
+
+    }
+
 }
 
 

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentFromExcelService.java

@@ -49,7 +49,7 @@ private GetPatentPictureFromExcelService getPatentPictureFromExcelService;
             Integer sourceId = 1;
             Integer total = ReadExcelUtils.textExcel(tempFile, sourceId.toString());
             //解析数据源类,通过数据来源id(如1:智慧芽)解析数据源配置文件,获得数据源配置文件对象jsonData
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(sourceId.toString());
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(sourceId.toString(),null);
             //解析Excel文件获得工作簿
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
             Integer x = 0;

+ 2 - 2
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ExcuteUploadSettingService.java

@@ -20,9 +20,9 @@ public class ExcuteUploadSettingService {
      * @param sourceId 数据来源id
      * @return 返回数据源配置文件对象
      */
-    public List<UploadSettingVO.Column> ExcuteUploadSetting(String sourceId) {
+    public List<UploadSettingVO.Column> ExcuteUploadSetting(String sourceId,String configName) {
         //获得uploadSetting.json配置文件的JSON串
-        String getSettingJson = new FileUtils().analysisJsonFile();
+        String getSettingJson = new FileUtils().analysisJsonFile(configName);
         //查找并装载本次导入的专利需要的数据源(如智慧芽)的对应配置(如前台传来的数据来源id是1,即“智慧芽”,那么jsonData装载的就是智慧芽的数据源配置)
         List<UploadSettingVO.Column> jsonData = UploadPatentBatchUtil.parsingConfigurationFiles(sourceId, getSettingJson);
         return jsonData;

+ 2 - 2
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetFilesFromOPSService.java

@@ -42,7 +42,7 @@ public class GetFilesFromOPSService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);
@@ -76,7 +76,7 @@ public class GetFilesFromOPSService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetOPSFileByExcelService.java

@@ -43,7 +43,7 @@ public class GetOPSFileByExcelService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 332; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);

+ 2 - 2
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetPatentFromSzService.java

@@ -51,7 +51,7 @@ public class GetPatentFromSzService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);
@@ -97,7 +97,7 @@ public class GetPatentFromSzService {
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);

+ 0 - 87
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProduct.java

@@ -1,87 +0,0 @@
-package com.example.xiaoshiweixinback.service.importPatent.excel;
-
-import cn.hutool.core.util.IdUtil;
-import com.example.xiaoshiweixinback.business.utils.ExcelUtils;
-import com.example.xiaoshiweixinback.business.utils.FileUtils;
-import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
-import com.example.xiaoshiweixinback.business.utils.RedisUtil;
-import com.example.xiaoshiweixinback.domain.AssoProductFile;
-import com.example.xiaoshiweixinback.domain.Product;
-import com.example.xiaoshiweixinback.service.AssoProductFileService;
-import com.example.xiaoshiweixinback.service.ProductService;
-import com.example.xiaoshiweixinback.service.common.FileManagerService;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.ss.usermodel.PictureData;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-@Service
-public class ImportProduct {
-
-    @Autowired
-    private ProductService productService;
-
-    @Autowired
-    private FileManagerService fileManagerService;
-    @Autowired
-    private AssoProductFileService assoProductFileService;
-    public void importProject() {
-        try {
-            File tempFile = new File("C:\\Users\\admin\\Desktop\\exce\\product.xlsx");
-
-            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
-            for (int i = 2; i < 80; i++) {
-                PatentData patentData = ReadExcelUtils.readExcelOneRow(tempFile, sheet, i);
-                Map<Object, Object> map = patentData.getMap();
-                Object o = map.get("序号");
-                System.out.println(o);
-                if (map.get("序号").equals("")) {
-                    continue;
-                }
-                PictureData pictureData = patentData.getPictureData();
-
-                String ext = pictureData.suggestFileExtension();
-                byte[] data = pictureData.getData();
-                String picName = IdUtil.simpleUUID();
-                File file = FileUtils.getFileByBytes(data, picName, "." + ext);
-        String c =   fileManagerService.uploadFileWithGuid(file,picName);
-Product product =this.loadProduct(map);
-product.insert();
-                AssoProductFile assoProductFile =new AssoProductFile();
-                assoProductFile.setProductId(product.getId());
-                assoProductFile.setFileGuid(picName);
-                assoProductFile.insert();
-            }
-        } catch (Exception e) {
-        }
-
-
-    }
-
-    private Product loadProduct(Map<Object,Object> map){
-         Product product =new Product();
-         product.setName(map.get("产品名称").toString());
-         product.setSearchCondition(map.get("关键词").toString());
-         product.setSourceFrom(map.get("卖家").toString());
-         product.setSellPlatform(map.get("网站名").toString());
-         product.setIfHot(true);
-         product.setIfCustomized(false);
-         product.setBestSellingBrand(map.get("销冠品牌").toString());
-         String p =map.get("金额").toString().replace("$","");
-       Double price =  Double.parseDouble(p);
-         product.setPrice(price);
-         product.setPlatformLink(map.get("产品网页链接").toString());
-        product.setLocNum(map.get("LOC分类号").toString());
-        return product;
-    }
-
-}

+ 100 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductCategoryService.java

@@ -0,0 +1,100 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+import cn.hutool.core.util.IdUtil;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.utils.FileUtils;
+import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
+import com.example.xiaoshiweixinback.domain.Product;
+import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
+import com.example.xiaoshiweixinback.entity.product.UploadCategoryParamsVO;
+import com.example.xiaoshiweixinback.entity.product.UploadProductParamsVO;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.service.AssoProductFileService;
+import com.example.xiaoshiweixinback.service.ProductCategoryService;
+import com.example.xiaoshiweixinback.service.ProductService;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import org.apache.poi.ss.usermodel.PictureData;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class ImportProductCategoryService {
+
+    @Autowired
+    private ProductService productService;
+
+    @Autowired
+    private FileManagerService fileManagerService;
+    @Autowired
+    private AssoProductFileService assoProductFileService;
+    @Autowired
+    private ExcuteUploadSettingService excuteUploadSettingService;
+
+    @Autowired
+    private ProductCategoryService productCategoryService;
+
+    public void importProductCategory(File tempFile) {
+        try {
+            PersonnelVO personnelVO =new PersonnelVO();
+            personnelVO.setUuid("123");
+            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+            Integer total = ReadExcelUtils.getExcelTotal(sheet);
+
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting("1", "uploadCategory.json");
+
+            for (int i = 1; i < total; i++) {
+                PatentData patentData = ReadExcelUtils.readExcelOneRow2(tempFile, sheet, i);
+                Map<Object, Object> map = patentData.getMap();
+                UploadCategoryParamsVO uploadParamsVO = UploadPatentBatchUtil.processCategoryData(map, jsonData);
+                if (uploadParamsVO.getCategoryList() == null||uploadParamsVO.getCategoryList().size()==0) {
+                    continue;
+                }
+                List<PictureData> pictureDataList = patentData.getPictureDataList();
+
+                HotProductAddDTO hotProductAddDTO = this.loadCategoryAddVO(uploadParamsVO, pictureDataList);
+                try {
+                    productService.addOrUpdateHotProduct(hotProductAddDTO,personnelVO.getUuid());
+                } catch (Exception e) {
+                    continue;
+                }
+            }
+        } catch (Exception e) {
+        }
+
+
+    }
+
+    private HotProductAddDTO loadCategoryAddVO(UploadCategoryParamsVO uploadParamsVO, List<PictureData> pictureDataList) throws Exception {
+        Integer categoryId = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
+
+        HotProductAddDTO hotProductAddDTO = new HotProductAddDTO();
+        BeanUtils.copyProperties(uploadParamsVO, hotProductAddDTO);
+        hotProductAddDTO.setIfHot(true);
+        hotProductAddDTO.getFileGuids();
+        List<String> fileIds = new ArrayList<>();
+        for (PictureData pictureData : pictureDataList) {
+            String ext = pictureData.suggestFileExtension();
+            byte[] data = pictureData.getData();
+            String picName = IdUtil.simpleUUID();
+            File file = FileUtils.getFileByBytes(data, picName, "." + ext);
+            try {
+                List<String> guids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
+                fileIds.add(guids.get(0));
+            } catch (Exception e) {
+                throw new BusinessException("607", "上传错误");
+            }
+
+        }
+        hotProductAddDTO.setFileGuids(fileIds);
+        hotProductAddDTO.setProductCategoryId(categoryId);
+        return hotProductAddDTO;
+    }
+}

+ 120 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/ImportProductService.java

@@ -0,0 +1,120 @@
+package com.example.xiaoshiweixinback.service.importPatent.excel;
+
+import cn.hutool.core.util.IdUtil;
+import com.example.xiaoshiweixinback.business.exception.BusinessException;
+import com.example.xiaoshiweixinback.business.utils.*;
+import com.example.xiaoshiweixinback.domain.AssoProductFile;
+import com.example.xiaoshiweixinback.domain.Product;
+import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
+import com.example.xiaoshiweixinback.entity.product.UploadProductParamsVO;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.service.AssoProductFileService;
+import com.example.xiaoshiweixinback.service.ProductCategoryService;
+import com.example.xiaoshiweixinback.service.ProductService;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.ss.usermodel.PictureData;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+@Service
+public class ImportProductService {
+
+    @Autowired
+    private ProductService productService;
+
+    @Autowired
+    private FileManagerService fileManagerService;
+    @Autowired
+    private AssoProductFileService assoProductFileService;
+    @Autowired
+    private ExcuteUploadSettingService excuteUploadSettingService;
+
+    @Autowired
+    private ProductCategoryService productCategoryService;
+
+    public void importProject(File tempFile) {
+        try {
+            PersonnelVO personnelVO =new PersonnelVO();
+            personnelVO.setUuid("123");
+            Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+            Integer total = ReadExcelUtils.getExcelTotal(sheet);
+
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting("1", "uploadProduct.json");
+
+            for (int i = 1; i < total; i++) {
+                PatentData patentData = ReadExcelUtils.readExcelOneRow2(tempFile, sheet, i);
+                Map<Object, Object> map = patentData.getMap();
+                UploadProductParamsVO uploadParamsVO = UploadPatentBatchUtil.processProductData(map, jsonData);
+                if (uploadParamsVO.getName() == null) {
+                    continue;
+                }
+                List<PictureData> pictureDataList = patentData.getPictureDataList();
+
+                HotProductAddDTO hotProductAddDTO = this.loadProductAddVO(uploadParamsVO, pictureDataList);
+                try {
+                    productService.addOrUpdateHotProduct(hotProductAddDTO,personnelVO.getUuid());
+                } catch (Exception e) {
+                    continue;
+                }
+            }
+        } catch (Exception e) {
+        }
+
+
+    }
+
+    private Product loadProduct(Map<Object, Object> map) {
+        Product product = new Product();
+        product.setName(map.get("产品名称").toString());
+        product.setSearchCondition(map.get("关键词").toString());
+        product.setSourceFrom(map.get("卖家").toString());
+        product.setSellPlatform(map.get("网站名").toString());
+        product.setIfHot(true);
+        product.setIfCustomized(false);
+        product.setBestSellingBrand(map.get("销冠品牌").toString());
+        String p = map.get("金额").toString().replace("$", "");
+        Double price = Double.parseDouble(p);
+        product.setPrice(price);
+        product.setPlatformLink(map.get("产品网页链接").toString());
+        product.setLocNum(map.get("LOC分类号").toString());
+        return product;
+    }
+
+
+    private HotProductAddDTO loadProductAddVO(UploadProductParamsVO uploadParamsVO, List<PictureData> pictureDataList) throws Exception {
+        Integer categoryId = productCategoryService.addCategorysByStr(uploadParamsVO.getCategoryList());
+
+        HotProductAddDTO hotProductAddDTO = new HotProductAddDTO();
+        BeanUtils.copyProperties(uploadParamsVO, hotProductAddDTO);
+        hotProductAddDTO.setIfHot(true);
+        hotProductAddDTO.getFileGuids();
+        List<String> fileIds = new ArrayList<>();
+        for (PictureData pictureData : pictureDataList) {
+            String ext = pictureData.suggestFileExtension();
+            byte[] data = pictureData.getData();
+            String picName = IdUtil.simpleUUID();
+            File file = FileUtils.getFileByBytes(data, picName, "." + ext);
+            try {
+                List<String> guids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
+                fileIds.add(guids.get(0));
+            } catch (Exception e) {
+                throw new BusinessException("607", "上传错误");
+            }
+
+        }
+        hotProductAddDTO.setFileGuids(fileIds);
+        hotProductAddDTO.setProductCategoryId(categoryId);
+        return hotProductAddDTO;
+    }
+}

+ 2 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/PatentData.java

@@ -4,6 +4,7 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 import org.apache.poi.ss.usermodel.PictureData;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -21,5 +22,6 @@ public class PatentData {
      * 专利摘要附图
      */
     private PictureData pictureData;
+    private List<PictureData> pictureDataList;
 
 }

+ 70 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/UploadPatentBatchUtil.java

@@ -4,6 +4,8 @@ package com.example.xiaoshiweixinback.service.importPatent.excel;
 import com.example.xiaoshiweixinback.business.utils.DataProcessHandler;
 import com.example.xiaoshiweixinback.business.utils.JsonUtils;
 import com.example.xiaoshiweixinback.business.utils.StringUtils;
+import com.example.xiaoshiweixinback.entity.product.UploadCategoryParamsVO;
+import com.example.xiaoshiweixinback.entity.product.UploadProductParamsVO;
 import org.springframework.stereotype.Component;
 
 import java.lang.reflect.Field;
@@ -235,4 +237,72 @@ public class UploadPatentBatchUtil {
         uploadParamsVO.setCustomerFieldList(list);
         return uploadParamsVO;
     }
+
+
+
+    public static UploadProductParamsVO processProductData(Map<Object, Object> row, List<UploadSettingVO.Column> jsonData) {
+        UploadProductParamsVO uploadParamsVO = new UploadProductParamsVO();
+        try {
+            for (Object object : row.keySet()) {
+                String key = object.toString();
+                Object value = row.get(key);
+
+                if (StringUtils.isNotNull(value) && !value.equals("") && !value.equals("-") && !value.equals("\\")) {
+                    //将配置项与Excel栏位进行比对
+                    List<UploadSettingVO.Column> temVOColumn = getColumn(jsonData, key);
+                    for (UploadSettingVO.Column column : temVOColumn) {
+                        //创建处理对象
+                        Object processData = DataProcessHandler.getData(column.getHandler(), column.getJarOrClassPath());
+                        //调用处理对象中的对应处理方法对Excel中的数据进行处理
+                        Object getProcessData = null;
+                        if (processData != null) {
+                            Method method = processData.getClass().getMethod("processData", Object.class, Object.class);
+                            getProcessData = method.invoke(processData, value.toString(), column.getSplitSymbol());
+                        }
+                        //将格式化后的数据装配到VO类
+                        assemblyObject(uploadParamsVO, column.getColumn(), getProcessData);
+
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return uploadParamsVO;
+    }
+
+
+
+    public static UploadCategoryParamsVO processCategoryData(Map<Object, Object> row, List<UploadSettingVO.Column> jsonData) {
+        UploadCategoryParamsVO uploadParamsVO = new UploadCategoryParamsVO();
+        try {
+            for (Object object : row.keySet()) {
+                String key = object.toString();
+                Object value = row.get(key);
+
+                if (StringUtils.isNotNull(value) && !value.equals("") && !value.equals("-") && !value.equals("\\")) {
+                    //将配置项与Excel栏位进行比对
+                    List<UploadSettingVO.Column> temVOColumn = getColumn(jsonData, key);
+                    for (UploadSettingVO.Column column : temVOColumn) {
+                        //创建处理对象
+                        Object processData = DataProcessHandler.getData(column.getHandler(), column.getJarOrClassPath());
+                        //调用处理对象中的对应处理方法对Excel中的数据进行处理
+                        Object getProcessData = null;
+                        if (processData != null) {
+                            Method method = processData.getClass().getMethod("processData", Object.class, Object.class);
+                            getProcessData = method.invoke(processData, value.toString(), column.getSplitSymbol());
+                        }
+                        //将格式化后的数据装配到VO类
+                        assemblyObject(uploadParamsVO, column.getColumn(), getProcessData);
+
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return uploadParamsVO;
+    }
 }

+ 1 - 1
src/main/resources/application.yml

@@ -1,7 +1,7 @@
 server:
   servlet:
     context-path: /
-  port: 8901
+  port: 8902
 #  sa-token:
 #  activity-timeout: 18000
 #  token-name: token

+ 72 - 0
src/main/resources/jsons/uploadCategory.json

@@ -0,0 +1,72 @@
+[
+  {
+    "sourceId": "1",
+    "sourceName": "Amazson",
+    "name": "亚马逊",
+    "column": [
+      {
+        "setName": "产品名称",
+        "column": "name",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "描述",
+        "column": "description",
+        "splitSymbol": "1,\\|",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "销冠品牌",
+        "column": "bestSellingBrand",
+        "splitSymbol": " ",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "卖家",
+        "column": "sourceFrom",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "金额",
+        "column": "priceStr",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "网站名",
+        "column": "sellPlatform",
+        "splitSymbol": "\\|",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "产品网页链接",
+        "column": "platformLink",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "关键词",
+        "column": "searchCondition",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "产品分类",
+        "column": "categoryList",
+        "splitSymbol": ">",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      }
+    ]
+  }
+]

+ 79 - 0
src/main/resources/jsons/uploadProduct.json

@@ -0,0 +1,79 @@
+[
+  {
+    "sourceId": "1",
+    "sourceName": "Amazson",
+    "name": "亚马逊",
+    "column": [
+      {
+        "setName": "产品名称",
+        "column": "name",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "描述",
+        "column": "description",
+        "splitSymbol": "1,\\|",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "销冠品牌",
+        "column": "bestSellingBrand",
+        "splitSymbol": " ",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "卖家",
+        "column": "sourceFrom",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "金额",
+        "column": "priceStr",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "网站名",
+        "column": "sellPlatform",
+        "splitSymbol": "\\|",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "产品网页链接",
+        "column": "platformLink",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "关键词",
+        "column": "searchCondition",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "LOC分类号",
+        "column": "locNum",
+        "splitSymbol": "",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      },
+      {
+        "setName": "产品分类",
+        "column": "categoryList",
+        "splitSymbol": ">",
+        "handler": "cn.cslg.pas.common.utils.handler.StringHandler",
+        "jarOrClassPath": "./Wispro-CodeWarehouse-BackEnd.jar"
+      }
+    ]
+  }
+]

+ 25 - 10
src/main/resources/mapper/ProductMapper.xml

@@ -5,12 +5,12 @@
     <select id="getProductByCategory" resultType="com.example.xiaoshiweixinback.entity.vo.ProductVO">
         select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as sellPlatform,pe.name
         as createName ,p.create_time as createTime,p.best_selling_brand as bestSellingBrand,p.price as
-        price,p.platform_link as platformLink,apc.product_category_id as productCategoryId
+        price,p.platform_link as platformLink,apc.product_category_id as productCategoryId,p.if_show as ifShow
         from product as p
         left join asso_product_category as apc on p.id =product_id
         left join person as pe on p.create_id =pe.uuid
         <where>
-            p.if_hot = true and p.if_show = true and p.search_condition IS NOT NULL and p.search_condition != ''
+            p.if_hot = true  and p.search_condition IS NOT NULL and p.search_condition != ''
             <if test="getProductDTO.name!=null and getProductDTO.name!=''">
                 and p.name like CONCAT('%',#{getProductDTO.name},'%')
             </if>
@@ -20,12 +20,6 @@
                     #{item}
                 </foreach>
             </if>
-            <if test="getProductDTO.current!=null and getProductDTO.size!=null">
-                limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.size}
-            </if>
-            <if test="getProductDTO.ifShow!=null">
-                and p.if_show =#{getProductDTO.ifShow}
-            </if>
             <if test="getProductDTO.ifShow!=null">
                 and p.if_show =#{getProductDTO.ifShow}
             </if>
@@ -42,6 +36,11 @@
             <if test="getProductDTO.bestSellingBrand!=null and getProductDTO.bestSellingBrand!=''">
                 and p.best_selling_brand like CONCAT('%',#{getProductDTO.bestSellingBrand},'%')
             </if>
+            order by p.create_time desc
+            <if test="getProductDTO.current!=null and getProductDTO.size!=null">
+                limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.size}
+            </if>
+
 
         </where>
 
@@ -53,7 +52,7 @@
         asso_product_category as apc on p.id =product_id
         left join person as pe on p.create_id =pe.uuid
         <where>
-            p.if_hot = true and p.if_show =true and p.search_condition IS NOT NULL and p.search_condition != ''
+            p.if_hot = true  and p.search_condition IS NOT NULL and p.search_condition != ''
             <if test="getProductDTO.name!=null and getProductDTO.name!=''">
                 and p.name like CONCAT('%',#{getProductDTO.name},'%')
             </if>
@@ -63,6 +62,22 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="getProductDTO.ifShow!=null">
+                and p.if_show =#{getProductDTO.ifShow}
+            </if>
+
+            <if test="getProductDTO.productCategoryIds!=null and getProductDTO.productCategoryIds.size()>0">
+                and apc.product_category_id in
+                <foreach collection="getProductDTO.productCategoryIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="getProductDTO.sourceFrom!=null and getProductDTO.sourceFrom!=''">
+                and p.source_from like CONCAT('%',#{getProductDTO.sourceFrom},'%')
+            </if>
+            <if test="getProductDTO.bestSellingBrand!=null and getProductDTO.bestSellingBrand!=''">
+                and p.best_selling_brand like CONCAT('%',#{getProductDTO.bestSellingBrand},'%')
+            </if>
         </where>
         ) as c
 
@@ -101,7 +116,7 @@
         select count(*) from ( select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as
         sellPlatform,pe.name
         as createName ,p.create_time as createTime,p.best_selling_brand as bestSellingBrand,p.price as
-        price,p.platform_link as platformLink
+        price,p.platform_link as platformLink,p.source_from as sourceFrom
         from
         asso_person_product as app
         left join product as p on app.product_id =p.id

+ 59 - 0
src/test/java/com/example/xiaoshiweixinback/ImportProductTests.java

@@ -0,0 +1,59 @@
+package com.example.xiaoshiweixinback;
+
+import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.expressManager;
+import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.treeNode;
+import com.example.xiaoshiweixinback.entity.ops.ImagesInfoVO;
+import com.example.xiaoshiweixinback.entity.ops.PubNo;
+import com.example.xiaoshiweixinback.service.common.OPSService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
+import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProductService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Lazy;
+
+import java.util.List;
+
+
+@SpringBootTest
+class ImportProductTests {
+
+    @Autowired
+    @Lazy
+    private ImportProductService importProduct;
+
+    @Autowired
+    private GetPatentFromSzService getPatentFromSzService;
+    @Autowired
+    private OPSService opsService;
+    @Test
+    void contextLoads() {
+        String condition ="TI=ni $W5 (hao OR ya)";
+        try {
+            treeNode tree = expressManager.getInstance().Parse(condition, false);
+System.out.println(tree);
+        }
+        catch (Exception e){}
+    }
+
+    @Test
+    public void test1() {
+        PubNo pubNo =new PubNo();
+        pubNo.setCountry("US");
+        pubNo.setNumber("D942334");
+        pubNo.setKind("S");
+
+
+//        USD942334S
+try {
+    List<ImagesInfoVO>  imagesInfoVOS =opsService.getImageInfos("USD942334S");
+    ImagesInfoVO infoVO = imagesInfoVOS.stream().filter(item -> item.getImageType().equals("Drawing")).findFirst().orElse(null);
+ opsService.getImages(infoVO,"USD942334S");
+
+    System.out.println(imagesInfoVOS);
+}
+    catch (Exception e){
+    e.printStackTrace();
+    }
+    }
+}

+ 0 - 2
src/test/java/com/example/xiaoshiweixinback/NoticeServiceTest.java

@@ -2,11 +2,9 @@ package com.example.xiaoshiweixinback;
 
 import com.example.xiaoshiweixinback.entity.shortMessage.ShortMessageVO;
 import com.example.xiaoshiweixinback.service.common.NoticeService;
-import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProduct;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Lazy;
 
 @SpringBootTest
 public class NoticeServiceTest {

+ 0 - 1
src/test/java/com/example/xiaoshiweixinback/TicketServiceTests.java

@@ -2,7 +2,6 @@ package com.example.xiaoshiweixinback;
 
 import com.example.xiaoshiweixinback.service.OrderService;
 import com.example.xiaoshiweixinback.service.importPatent.excel.GetPatentFromSzService;
-import com.example.xiaoshiweixinback.service.importPatent.excel.ImportProduct;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;