From d704e2eb55bedad83e067b13263199a69facd56e Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 17 Jun 2022 11:20:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E6=97=B6no=20such=20index=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elasticsearch/BaseElasticsearchService.java | 1 - .../lili/modules/goods/service/GoodsSkuService.java | 3 ++- .../member/serviceimpl/FootprintServiceImpl.java | 7 ++----- .../payment/kit/params/dto/CashierParam.java | 5 +++-- .../search/serviceimpl/EsGoodsIndexServiceImpl.java | 13 +++++++------ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java index c1d956be..fec64277 100644 --- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java +++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java @@ -85,7 +85,6 @@ public abstract class BaseElasticsearchService { */ protected void createIndexRequest(String index) { try { - deleteIndexRequest(index); CreateIndexRequest request = new CreateIndexRequest(index); //Settings for this index request.settings(Settings.builder() diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java index 754a5edf..8a322a79 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsSkuService.java @@ -143,7 +143,8 @@ public interface GoodsSkuService extends IService { /** * 分页查询商品sku信息 * - * @param searchParams 查询参数 + * @param page 分页参数 + * @param queryWrapper 查询参数 * @return 商品sku信息 */ IPage getGoodsSkuDTOByPage(Page page, Wrapper queryWrapper); diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java index d5b315b8..41e4b815 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java @@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Objects; @@ -85,15 +84,13 @@ public class FootprintServiceImpl extends ServiceImpl esGoodsIndexIPage = new Page(); + IPage esGoodsIndexIPage = new Page<>(); if (footPrintPages.getRecords() == null || footPrintPages.getRecords().isEmpty()) { return esGoodsIndexIPage; } else { List list = esGoodsSearchService.getEsGoodsBySkuIds( - footPrintPages.getRecords().stream().map(item -> { - return item.getSkuId(); - }).collect(Collectors.toList())); + footPrintPages.getRecords().stream().map(FootPrint::getSkuId).collect(Collectors.toList())); //去除为空的商品数据 list.removeIf(Objects::isNull); diff --git a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java index 4bdfcbe5..75bf50d2 100644 --- a/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java +++ b/framework/src/main/java/cn/lili/modules/payment/kit/params/dto/CashierParam.java @@ -1,5 +1,6 @@ package cn.lili.modules.payment.kit.params.dto; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.utils.StringUtils; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -18,7 +19,7 @@ import java.util.List; @ToString public class CashierParam { - static Long MAX_DETAIL_LENGTH = 30L; + static final Long MAX_DETAIL_LENGTH = 30L; @ApiModelProperty(value = "价格") private Double price; @@ -46,7 +47,7 @@ public class CashierParam { private Double walletValue; public String getDetail() { - if (StringUtils.isEmpty(detail)) { + if (CharSequenceUtil.isEmpty(detail)) { return "清单详细"; } return StringUtils.filterSpecialChart(StringUtils.sub(detail, 30)); diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index 773e603d..ae81c85d 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -86,9 +86,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements private final Map fieldMap = ReflectUtil.getFieldMap(EsGoodsIndex.class); - private final String KEY_SUCCESS = "success"; - private final String KEY_FAIL = "fail"; - private final String KEY_PROCESSED = "processed"; + private static final String KEY_SUCCESS = "success"; + private static final String KEY_FAIL = "fail"; + private static final String KEY_PROCESSED = "processed"; @Autowired private ElasticsearchProperties elasticsearchProperties; @@ -105,8 +105,6 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements @Autowired private GoodsSkuService goodsSkuService; @Autowired - private GoodsService goodsService; - @Autowired private BrandService brandService; @Autowired @@ -425,8 +423,11 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements //如果索引存在,则删除,重新生成。 这里应该有更优解。 boolean indexExist = this.indexExist(indexName); if (regeneratorIndex || !indexExist) { + if (indexExist) { + this.deleteIndexRequest(indexName); + } //如果索引不存在,则创建索引 - createIndexRequest(indexName); + this.createIndexRequest(indexName); } Map resultMap = (Map) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix());