From fbcae732923bd5dfaddd400a75a2f9476796234d Mon Sep 17 00:00:00 2001 From: liyj <1617420630@qq.com> Date: Thu, 18 Dec 2025 10:47:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=93=81=E7=89=8C=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BB=A5=E5=8F=8A=E5=95=86=E5=93=81=E6=9D=A1=E7=A0=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=B8=8A=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sync/exelModel/SxCategoryModelExcel.java | 6 ++-- .../service/impl/SyncBaseThirdSxAbstract.java | 34 ++++++++++++------- .../impl/SyncShopImageServiceImpl.java | 10 +++--- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/exelModel/SxCategoryModelExcel.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/exelModel/SxCategoryModelExcel.java index 64d58e8f..bc13a11c 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/exelModel/SxCategoryModelExcel.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/exelModel/SxCategoryModelExcel.java @@ -38,7 +38,7 @@ public class SxCategoryModelExcel { @ExcelProperty(value = "第二级分类", index =2) private String second_category_name; - @ApiModelProperty(value = "品牌名称") - @ExcelProperty(value = "品牌名称", index =3) - private String brandName; +// @ApiModelProperty(value = "品牌名称") +// @ExcelProperty(value = "品牌名称", index =3) +// private String brandName; } \ No newline at end of file diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java index 36814cc1..71c85633 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncBaseThirdSxAbstract.java @@ -41,6 +41,8 @@ import com.suisung.mall.common.utils.DateTimeUtils; import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.common.utils.StringUtils; import com.suisung.mall.common.utils.phone.PhoneNumberUtils; +import com.suisung.mall.core.consts.ConstantRedis; +import com.suisung.mall.core.web.service.RedisService; import com.suisung.mall.shop.base.service.ShopBaseProductBrandService; import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService; import com.suisung.mall.shop.base.service.ShopBaseProductSpecService; @@ -102,9 +104,12 @@ public abstract class SyncBaseThirdSxAbstract{ @Autowired private LibraryProductService libraryProductService; + @Autowired + private RedisService redisService; + @Autowired public static final Set FORBID_CATEGORY= Collections.unmodifiableSet(new HashSet<>( - Arrays.asList("香烟类","香烟","烟类", "烟") + Arrays.asList("香烟类","香烟","烟类", "烟","烟草") )); /** @@ -141,6 +146,16 @@ public abstract class SyncBaseThirdSxAbstract{ } List productTypeList = new ArrayList<>(); Map productTypeListMap=new HashMap<>(); + //JSONObject o = (JSONObject) categoryListJSON.get(0); + // String brandName=o.getStr("brandName","其它品牌"); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("store_id",Integer.valueOf(storeId)); + //queryWrapper.in("brand_name",Arrays.asList(brandName.split(","))); + // queryWrapper.eq("brand_name",brandName); + List shopBaseProductBrands=productBrandService.list(queryWrapper); + String brandIds=shopBaseProductBrands.stream() + .map(shopBaseProductBrand -> String.valueOf(shopBaseProductBrand.getBrand_id())) + .collect(Collectors.joining(",")); for (int i = 0; i < list.size(); i++) { String categoryName=list.get(i).getCategory_name(); if(StringUtils.isNotEmpty(getForbidCategory(categoryName))){ @@ -155,15 +170,7 @@ public abstract class SyncBaseThirdSxAbstract{ ShopBaseProductType productType=new ShopBaseProductType(); productType.setType_is_draft(1);//发布 productType.setStore_id(Integer.valueOf(storeId)); - String brandName=o.getStr("brandName","其它品牌"); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("store_id",Integer.valueOf(storeId)); - queryWrapper.in("brand_name",Arrays.asList(brandName.split(","))); - // queryWrapper.eq("brand_name",brandName); - List shopBaseProductBrands=productBrandService.list(queryWrapper); - String brandIds=shopBaseProductBrands.stream() - .map(shopBaseProductBrand -> String.valueOf(shopBaseProductBrand.getBrand_id())) - .collect(Collectors.joining(",")); + if (o != null) { // 重要:分类类型处理(强调共性) Integer typeId = 1001; @@ -877,7 +884,6 @@ public abstract class SyncBaseThirdSxAbstract{ shopProductIndex.setProduct_sale_time(currentDate.getTime()); shopProductIndex.setStore_category_ids(""); // 店铺分类编号(DOT) shopProductIndex.setProduct_tags("");// 商品标签(DOT) - shopProductIndex.setBrand_id(0); shopProductIndex.setProduct_name(productName); // 产品名称:店铺平台先在对用表中检索后通过id检索,检索使用 shopProductIndex.setProduct_name_index(productName); // 名称索引关键字(DOT) shopProductIndex.setCategory_id(categoryId); // 商品分类 @@ -1098,7 +1104,7 @@ public abstract class SyncBaseThirdSxAbstract{ } // spec_id++; } - + List shopBaseProductTypeReidisKeyList=new ArrayList<>(); if(!insertShopBaseProductSpecList.isEmpty()){ List specIdList=shopNumberSeqService.getBatchSpecId(insertShopBaseProductSpecList.size()); for(int i=0;i imageMappingDtos=CovertToShopProductImage(list);//调用es排除异常重新连接 - syncBatchShopImage(imageMappingDtos); + syncBatchShopImage(imageMappingDtos,StateCode.PRODUCT_STATE_OFF_THE_SHELF); success.getAndIncrement(); message= "成功" + finalI; break; @@ -163,7 +163,7 @@ public class SyncShopImageServiceImpl implements SyncShopImageService { final int finalI = i; futures.add(executor.submit(() -> { try { - syncBatchShopImage(imageMappingDtos); + syncBatchShopImage(imageMappingDtos,StateCode.PRODUCT_STATE_NORMAL); success.getAndIncrement(); return "图库匹配成功" + finalI; } catch (Exception e) { @@ -192,7 +192,7 @@ public class SyncShopImageServiceImpl implements SyncShopImageService { * 把匹配的数据更新到商品的图库表 * @param imageMappingDtos */ - private void syncBatchShopImage(List imageMappingDtos){ + private void syncBatchShopImage(List imageMappingDtos,int product_state_id){ if(CollectionUtil.isEmpty(imageMappingDtos)){ log.info("没有匹配到图库"); return; @@ -223,14 +223,14 @@ public class SyncShopImageServiceImpl implements SyncShopImageService { shopProductImageList.add(shopProductImage); shopProductBase.setProduct_id(imageMappingDto.getProductId()); shopProductBase.setProduct_image(thumb); - shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF); + shopProductBase.setProduct_state_id(product_state_id); shopProductBaseList.add(shopProductBase); shopProductItem.setProduct_id(imageMappingDto.getProductId()); shopProductItem.setItem_enable(StateCode.PRODUCT_STATE_NORMAL); shopProductItemList.add(shopProductItem); ShopProductIndex shopProductIndex=new ShopProductIndex(); shopProductIndex.setProduct_id(imageMappingDto.getProductId()); - shopProductIndex.setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF); + shopProductIndex.setProduct_state_id(product_state_id); shopProductIndexList.add(shopProductIndex); } synchronized (this){