From 9f68db8d73080832f286e6bc74942f4b8c9c71e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E5=95=B8=E9=9D=9E?= <8153694@qq.com>
Date: Mon, 9 Oct 2023 11:26:21 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A7=E5=93=81=E5=88=86?=
 =?UTF-8?q?=E7=B1=BB=E4=B8=8E=E5=85=AC=E5=8F=B8=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../service/impl/ProductServiceImpl.java      | 23 +++----------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/enterprise-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java b/enterprise-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java
index ab2574b..766112a 100644
--- a/enterprise-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java
+++ b/enterprise-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java
@@ -112,7 +112,7 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
         List<ProductEntity> productList = productCategoryResult.getList().stream().map(item -> {
             ProductEntity productEntity = this.getCache(item.getProductId().toString());
             if (!ObjectUtils.isEmpty(productEntity)) {
-                String companyIds = companyProductService.find(new CompanyProductQuery().productId(productEntity.getId())).stream().map(i -> i.getProductId().toString()).collect(Collectors.joining(","));
+                String companyIds = companyProductService.find(new CompanyProductQuery().productId(productEntity.getId())).stream().map(i -> i.getCompanyId().toString()).collect(Collectors.joining(","));
                 productEntity.setCompanyId(companyIds);
                 productEntity.setCategoryId(entity.getCategoryId());
             }
@@ -124,29 +124,12 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
     @Override
     protected void findAfter(ProductEntity params, PageInfo pageInfo, Context context, List<ProductEntity> list) throws AppException {
         list.forEach(item -> {
-            String categoryIds = productCategoryService.find(new ProductCategoryQuery().productId(item.getId())).stream().map(i -> i.getCategoryId().toString()).collect(Collectors.joining(","));
-            String companyIds = companyProductService.find(new CompanyProductQuery().productId(item.getId())).stream().map(i -> i.getProductId().toString()).collect(Collectors.joining(","));
+            String categoryIds = productCategoryService.find(new ProductCategoryQuery().productId(item.getId())).stream().map(i -> i.getCategoryId().toString()).distinct().collect(Collectors.joining(","));
+            String companyIds = companyProductService.find(new CompanyProductQuery().productId(item.getId())).stream().map(i -> i.getCompanyId().toString()).distinct().collect(Collectors.joining(","));
             item.setCompanyId(companyIds);
             item.setCategoryId(categoryIds);
         });
 
-
-        if (!ObjectUtils.isEmpty(params.getCategoryId())) {
-            //绉嶇被涓嶄负绌� 鍒犻櫎鎺夌┖鐨�
-            Iterator<ProductEntity> iterator = list.iterator();
-            while (iterator.hasNext()) {
-                ProductEntity product = iterator.next();
-
-                String categoryIds = productCategoryService.find(new ProductCategoryQuery().productId(product.getId())).stream().map(i -> i.getCategoryId().toString()).collect(Collectors.joining(","));
-            }
-
-        }
-
-        if (!ObjectUtils.isEmpty(params.getCompanyId())) {
-            //鍏徃鏌ヨ涓嶄负绌�
-        }
-
-
     }
 
     @Override
-- 
2.24.3