소스 검색

4/23 工单修改

lwhhszx 1 년 전
부모
커밋
ba292e9465

+ 3 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/ImageUtil.java

@@ -34,6 +34,9 @@ public class ImageUtil {
         return image;
     }
     public static File cutImage(BufferedImage bufferedImage, Integer x, Integer y, String name) throws Exception {
+       if(bufferedImage==null){
+           return null;
+       }
         BufferedImage newBufferedImage = bufferedImage.getSubimage(x, y, bufferedImage.getWidth(), bufferedImage.getHeight()-300);
         File imgCutFile = new File(name);
         ImageIO.write(newBufferedImage, "jpeg", imgCutFile);

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

@@ -54,4 +54,5 @@ public class ProductVO {
     private Integer concernType;
     private Boolean ifHot;
     private Integer assoId;
+    private Integer productCategoryId;
 }

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

@@ -35,7 +35,9 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -78,7 +80,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
 
         if (parentId == 0) {
             queryWrapper.isNull(ProductCategory::getParentId);
-        } else if (parentId != 0){
+        } else if (parentId != 0) {
             queryWrapper.eq(ProductCategory::getParentId, parentId);
         }
 
@@ -467,6 +469,48 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         }
         return str;
     }
+
+
+    /**
+     * 查询产品类别
+     *
+     * @param ids
+     * @param ifContentPath
+     * @return
+     */
+    public List<ProductCategory> getProductCategory(List<Integer> ids, Boolean ifContentPath) {
+        if (ids == null || ids.size() == 0) {
+            return new ArrayList<>();
+        }
+
+        LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(ProductCategory::getId, ids);
+        List<ProductCategory> productCategories = this.list(queryWrapper);
+
+        if (ifContentPath) {
+            List<String> paths = productCategories.stream().map(ProductCategory::getPath).collect(Collectors.toList());
+            List<Integer> trueIds = productCategories.stream().map(ProductCategory::getId).collect(Collectors.toList());
+            Set<Integer> set = new HashSet<>();
+            set.addAll(trueIds);
+            paths.forEach(item -> {
+                if (item != null) {
+                    String[] arr = item.split("/");
+                    for (int i = 0; i > arr.length; i++) {
+                        set.add(Integer.parseInt(arr[i]));
+                    }
+                }
+            });
+
+            if (set.size() != 0) {
+                LambdaQueryWrapper<ProductCategory> queryWrapper1 = new LambdaQueryWrapper<>();
+                queryWrapper1.in(ProductCategory::getId, ids);
+                productCategories = this.list(queryWrapper1);
+            }
+        }
+
+        return productCategories;
+    }
+
 }
 
 

+ 22 - 9
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -9,10 +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.domain.AssoPersonFunction;
-import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
-import com.example.xiaoshiweixinback.domain.AssoProductFile;
-import com.example.xiaoshiweixinback.domain.Product;
+import com.example.xiaoshiweixinback.domain.*;
 import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
 import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
 import com.example.xiaoshiweixinback.entity.product.*;
@@ -44,7 +41,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     private final FileManagerService fileManagerService;
     private final AssoPersonProductService assoPersonProductService;
     private final VipService vipService;
-
+    private  ProductCategoryService productCategoryService;
     /**
      * 查询爆款产品
      *
@@ -73,14 +70,16 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         if (ids != null) {
             List<ProductVO> productVOs = this.getBaseMapper().getProductByCategory(getProductDTO);
             Long count = this.getBaseMapper().getProductCount(getProductDTO);
-            this.loadProduct(productVOs);
+            this.loadProduct(productVOs,false);
             records.setData(productVOs);
             records.setTotal(count);
         }
         return records;
     }
 
-    private void loadProduct(List<ProductVO> productVOS) {
+
+
+    private void loadProduct(List<ProductVO> productVOS,Boolean ifCotentCategoryPath) {
         PersonnelVO personnelVO = null;
         try {
             personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
@@ -100,7 +99,9 @@ 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<SystemFile> systemFiles = new ArrayList<>();
+
         if (ids.size() != 0) {
             //根据产品类别id获得产品类别与文件关联表
             LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
@@ -123,6 +124,12 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
 
         }
 
+        if(projectCategoryIds.size()!=0){
+            productCategoryService.getProductCategory(projectCategoryIds,ifCotentCategoryPath);
+
+
+        }
+
         for (ProductVO productVO : productVOS) {
 //装载文件信息
             List<AssoProductFile> assoProductFilesTemp = assoProductFiles.stream().filter(item -> item.getProductId().equals(productVO.getId())).collect(Collectors.toList());
@@ -136,15 +143,21 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
                 }
             }
 
+            //装载关注类型
             if (assoPersonProducts.size() != 0) {
                 AssoPersonProduct assoPersonProduct = assoPersonProducts.stream().filter(item -> item.getProductId().equals(productVO.getId())).findFirst().orElse(null);
                 if (assoPersonProduct != null) {
                     productVO.setConcernType(assoPersonProduct.getConcernType());
                 }
             }
+
+         //
+
         }
     }
 
+
+
     @Transactional(rollbackFor = Exception.class)
     public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
         Product product = new Product();
@@ -212,7 +225,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);
+        this.loadProduct(productVOs,false);
         records.setData(productVOs);
         records.setTotal(count);
         return records;
@@ -259,7 +272,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         BeanUtils.copyProperties(product, productVO);
         List<ProductVO> productVOS = new ArrayList<>();
         productVOS.add(productVO);
-        this.loadProduct(productVOS);
+        this.loadProduct(productVOS,true);
         return productVO;
     }
 

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

@@ -45,7 +45,7 @@ public class GetOPSFileByExcelService {
 
             List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
 
-            for (int r = 0; r < total; r++) {
+            for (int r = 332; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);
                 Map<Object, Object> map = new HashMap<>();
                 for (int i = 0; i < columns; i++) {

+ 1 - 1
src/main/resources/mapper/ProductMapper.xml

@@ -5,7 +5,7 @@
     <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
+        price,p.platform_link as platformLink,apc.product_category_id as productCategoryId
         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