master:获取索引名称调整;

pull/1121/head
liujiang 2025-11-16 20:52:43 +08:00
parent 4c1544fde9
commit 38a115a9fc
15 changed files with 81 additions and 48 deletions

View File

@ -38,6 +38,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -84,6 +85,8 @@ public class GtAndFhbBiz22222222Controller extends BaseController {
final IPictureService pictureService;
final FsNotice fsNotice;
final SysDictDataMapper dictDataMapper;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
// 系统枚举 鞋面内里材质
private static final String DICT_TYPE_SHOE_UPPER_LINING_MATERIAL = "shoe_upper_lining_material";
@ -533,13 +536,13 @@ public class GtAndFhbBiz22222222Controller extends BaseController {
List<BulkOperation> bulkOperations = new ArrayList<>();
for (ESProductDTO esProductDTO : esProductDTOList) {
BulkOperation bulkOperation = new BulkOperation.Builder()
.index(i -> i.id(esProductDTO.getStoreProdId()).index(Constants.ES_IDX_PRODUCT_INFO).document(esProductDTO))
.index(i -> i.id(esProductDTO.getStoreProdId()).index(ES_INDEX_NAME).document(esProductDTO))
.build();
bulkOperations.add(bulkOperation);
}
// 执行批量插入
try {
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(Constants.ES_IDX_PRODUCT_INFO).operations(bulkOperations));
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(ES_INDEX_NAME).operations(bulkOperations));
log.info("批量新增到 ES 成功的 id列表: {}", response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());

View File

@ -38,6 +38,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -84,6 +85,9 @@ public class GtAndFhbBizController extends BaseController {
final IPictureService pictureService;
final FsNotice fsNotice;
final SysDictDataMapper dictDataMapper;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
// 系统枚举 鞋面内里材质
private static final String DICT_TYPE_SHOE_UPPER_LINING_MATERIAL = "shoe_upper_lining_material";
@ -497,7 +501,7 @@ public class GtAndFhbBizController extends BaseController {
}
// 2025.10.16 增加一重保险客户优惠必须是大于0的且必须滤重
fhbCusDiscCacheList = fhbCusDiscCacheList.stream().filter(x -> x.getDiscount() > 0).distinct().collect(Collectors.toList());
List<FhbProdStockVO.SMPSRecordVO> fhbStockCacheList = redisCache
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_STOCK_KEY + initVO.getSupplierId());
if (CollectionUtils.isEmpty(fhbStockCacheList)) {
@ -598,13 +602,13 @@ public class GtAndFhbBizController extends BaseController {
List<BulkOperation> bulkOperations = new ArrayList<>();
for (ESProductDTO esProductDTO : esProductDTOList) {
BulkOperation bulkOperation = new BulkOperation.Builder()
.index(i -> i.id(esProductDTO.getStoreProdId()).index(Constants.ES_IDX_PRODUCT_INFO).document(esProductDTO))
.index(i -> i.id(esProductDTO.getStoreProdId()).index(ES_INDEX_NAME).document(esProductDTO))
.build();
bulkOperations.add(bulkOperation);
}
// 执行批量插入
try {
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(Constants.ES_IDX_PRODUCT_INFO).operations(bulkOperations));
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(ES_INDEX_NAME).operations(bulkOperations));
log.info("批量新增到 ES 成功的 id列表: {}", response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());

View File

@ -37,6 +37,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -79,6 +80,8 @@ public class GtAndTyBiz222222Controller extends BaseController {
final EsClientWrapper esClientWrapper;
final FsNotice fsNotice;
final SysDictDataMapper dictDataMapper;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
// 系统枚举 鞋面内里材质
private static final String DICT_TYPE_SHOE_UPPER_LINING_MATERIAL = "shoe_upper_lining_material";
@ -541,13 +544,13 @@ public class GtAndTyBiz222222Controller extends BaseController {
List<BulkOperation> bulkOperations = new ArrayList<>();
for (ESProductDTO esProductDTO : esProductDTOList) {
BulkOperation bulkOperation = new BulkOperation.Builder()
.index(i -> i.id(esProductDTO.getStoreProdId()).index(Constants.ES_IDX_PRODUCT_INFO).document(esProductDTO))
.index(i -> i.id(esProductDTO.getStoreProdId()).index(ES_INDEX_NAME).document(esProductDTO))
.build();
bulkOperations.add(bulkOperation);
}
// 执行批量插入
try {
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(Constants.ES_IDX_PRODUCT_INFO).operations(bulkOperations));
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(ES_INDEX_NAME).operations(bulkOperations));
log.info("批量新增到 ES 成功的 id列表: {}", response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());

View File

@ -37,6 +37,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -79,6 +80,8 @@ public class GtAndTyBizController extends BaseController {
final EsClientWrapper esClientWrapper;
final FsNotice fsNotice;
final SysDictDataMapper dictDataMapper;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
// 系统枚举 鞋面内里材质
private static final String DICT_TYPE_SHOE_UPPER_LINING_MATERIAL = "shoe_upper_lining_material";
@ -583,13 +586,13 @@ public class GtAndTyBizController extends BaseController {
List<BulkOperation> bulkOperations = new ArrayList<>();
for (ESProductDTO esProductDTO : esProductDTOList) {
BulkOperation bulkOperation = new BulkOperation.Builder()
.index(i -> i.id(esProductDTO.getStoreProdId()).index(Constants.ES_IDX_PRODUCT_INFO).document(esProductDTO))
.index(i -> i.id(esProductDTO.getStoreProdId()).index(ES_INDEX_NAME).document(esProductDTO))
.build();
bulkOperations.add(bulkOperation);
}
// 执行批量插入
try {
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(Constants.ES_IDX_PRODUCT_INFO).operations(bulkOperations));
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(ES_INDEX_NAME).operations(bulkOperations));
log.info("批量新增到 ES 成功的 id列表: {}", response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());

View File

@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@ -67,6 +68,8 @@ public class GtOnlyBizController extends BaseController {
final EsClientWrapper esClientWrapper;
final IPictureService pictureService;
final FsNotice fsNotice;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
/**
@ -293,13 +296,13 @@ public class GtOnlyBizController extends BaseController {
List<BulkOperation> bulkOperations = new ArrayList<>();
for (ESProductDTO esProductDTO : esProductDTOList) {
BulkOperation bulkOperation = new BulkOperation.Builder()
.index(i -> i.id(esProductDTO.getStoreProdId()).index(Constants.ES_IDX_PRODUCT_INFO).document(esProductDTO))
.index(i -> i.id(esProductDTO.getStoreProdId()).index(ES_INDEX_NAME).document(esProductDTO))
.build();
bulkOperations.add(bulkOperation);
}
// 执行批量插入
try {
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(Constants.ES_IDX_PRODUCT_INFO).operations(bulkOperations));
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(ES_INDEX_NAME).operations(bulkOperations));
log.info("批量新增到 ES 成功的 id列表: {}", response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());
@ -441,6 +444,7 @@ public class GtOnlyBizController extends BaseController {
/**
* GT
*
* @param userId
* @param gtProdSkuVO
* @return

View File

@ -31,6 +31,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
@ -72,7 +73,8 @@ public class GtOtherBizAfterController extends BaseController {
final EsClientWrapper esClientWrapper;
final IPictureService pictureService;
final FsNotice fsNotice;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
/**
* step1
@ -325,13 +327,13 @@ public class GtOtherBizAfterController extends BaseController {
List<BulkOperation> bulkOperations = new ArrayList<>();
for (ESProductDTO esProductDTO : esProductDTOList) {
BulkOperation bulkOperation = new BulkOperation.Builder()
.index(i -> i.id(esProductDTO.getStoreProdId()).index(Constants.ES_IDX_PRODUCT_INFO).document(esProductDTO))
.index(i -> i.id(esProductDTO.getStoreProdId()).index(ES_INDEX_NAME).document(esProductDTO))
.build();
bulkOperations.add(bulkOperation);
}
// 执行批量插入
try {
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(Constants.ES_IDX_PRODUCT_INFO).operations(bulkOperations));
BulkResponse response = esClientWrapper.getEsClient().bulk(b -> b.index(ES_INDEX_NAME).operations(bulkOperations));
log.info("单独处理GT货号到 ES 成功的 id列表: {}", response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = response.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());

View File

@ -59,6 +59,7 @@ es:
password: wXd3iRUcqHzxZPtKsDRn
maxConnTotal: 4
maxConnPerRoute: 2
indexName: dev_product_info
# 开发环境配置
server:
# 服务器的HTTP端口默认为9310

View File

@ -59,6 +59,7 @@ es:
password: 0tP&3!GZZDMrglBm&kWJyw
maxConnTotal: 4
maxConnPerRoute: 2
indexName: dev_product_info
# 开发环境配置
server:
# 服务器的HTTP端口默认为9310

View File

@ -59,6 +59,7 @@ es:
password: 0tP&3!GZZDMrglBm&kWJyw
maxConnTotal: 100
maxConnPerRoute: 50
indexName: product_info
# 开发环境配置
server:
# 服务器的HTTP端口默认为9310

View File

@ -8,11 +8,10 @@ import java.util.concurrent.ConcurrentHashMap;
/**
*
*
*
* @author ruoyi
*/
public class Constants
{
public class Constants {
/**
* UTF-8
*/
@ -161,18 +160,18 @@ public class Constants
/**
* json
*/
public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" };
public static final String[] JSON_WHITELIST_STR = {"org.springframework", "com.ruoyi"};
/**
* 访
*/
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi.quartz.task" };
public static final String[] JOB_WHITELIST_STR = {"com.ruoyi.quartz.task"};
/**
*
*/
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config", "com.ruoyi.generator" };
public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config", "com.ruoyi.generator"};
public static final String UNDELETED = "0";
public static final String DELETED = "2";
@ -278,10 +277,6 @@ public class Constants
*
*/
public static final String RELEASE_YEAR_SEASON_DICT = "release_year_season";
/**
* ES product_info
*/
public static final String ES_IDX_PRODUCT_INFO = "product_info";
/**
* ID
*/
@ -334,8 +329,8 @@ public class Constants
public static final BigDecimal ALI_SERVICE_FEE_RATE = BigDecimal.valueOf(0.006);
public static final String INNER_MATERIAL = "内里材质";
public static final String OUTER_MATERIAL = "里料材质";
public static final String INNER_MATERIAL = "内里材质";
public static final String OUTER_MATERIAL = "里料材质";
public static final String UPPER_MATERIAL = "upperMaterial";
public static final String UPPER_MATERIAL_NAME = "帮面材质";

View File

@ -57,6 +57,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -130,6 +131,8 @@ public class XktTask {
final IWebsitePCNewProdService websitePCNewProdService;
final IWebsitePCStoreService websitePCStoreService;
final IWebsiteAPPService websiteAPPService;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
/**
*
@ -824,12 +827,12 @@ public class XktTask {
put("storeWeight", ObjectUtils.defaultIfNull(storeWeightMap.get(storeProd.getStoreId()), Constants.WEIGHT_DEFAULT_ZERO));
}}))
.id(String.valueOf(storeProd.getId()))
.index(Constants.ES_IDX_PRODUCT_INFO))
.index(ES_INDEX_NAME))
.build());
});
try {
// 调用bulk方法执行批量更新操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(ES_INDEX_NAME).operations(list));
log.info("定时任务,批量更新档口权重到 ES 成功的 id列表: {}", bulkResponse.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = bulkResponse.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());
@ -1052,7 +1055,7 @@ public class XktTask {
// 使用商品ID作为文档ID
.id(String.valueOf(product.getId()))
// 索引名称
.index(Constants.ES_IDX_PRODUCT_INFO)
.index(ES_INDEX_NAME)
// 插入的数据
.document(esProductDTO))
.build();
@ -1061,7 +1064,7 @@ public class XktTask {
}
// 执行批量插入
try {
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(b -> b.index(Constants.ES_IDX_PRODUCT_INFO).operations(bulkOperations));
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(b -> b.index(ES_INDEX_NAME).operations(bulkOperations));
log.info("定时发布商品,批量新增商品到 ES 成功的 id列表: {}", bulkResponse.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = bulkResponse.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());
@ -1693,12 +1696,12 @@ public class XktTask {
put("tags", updateTags);
}}))
.id(String.valueOf(storeProdId))
.index(Constants.ES_IDX_PRODUCT_INFO))
.index(ES_INDEX_NAME))
.build());
});
try {
// 调用bulk方法执行批量更新操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(ES_INDEX_NAME).operations(list));
log.info("批量更新商品标签到 ES 成功的 id列表: {}", bulkResponse.items().stream().map(BulkResponseItem::id).collect(Collectors.toList()));
// 有哪些没执行成功的,需要发飞书通知
List<String> successIdList = bulkResponse.items().stream().map(BulkResponseItem::id).collect(Collectors.toList());

View File

@ -57,6 +57,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -109,6 +110,8 @@ public class StoreProductServiceImpl implements IStoreProductService {
final OSSClientWrapper ossClient;
final TencentAuthManager tencentAuthManager;
final FsNotice fsNotice;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
/**
@ -1127,7 +1130,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
ESProductDTO esProductDTO = this.getESDTO(storeProd, storeProdDTO, storeName);
try {
// 向索引中添加数据
CreateResponse createResponse = esClientWrapper.getEsClient().create(e -> e.index(Constants.ES_IDX_PRODUCT_INFO)
CreateResponse createResponse = esClientWrapper.getEsClient().create(e -> e.index(ES_INDEX_NAME)
.id(storeProd.getId().toString()).document(esProductDTO));
log.info("createResponse.result() = {}", createResponse.result());
} catch (Exception e) {
@ -1147,7 +1150,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
ESProductDTO esProductDTO = this.getESDTO(storeProd, updateDTO, storeName);
try {
UpdateResponse<ESProductDTO> updateResponse = esClientWrapper.getEsClient().update(u -> u
.index(Constants.ES_IDX_PRODUCT_INFO).doc(esProductDTO).id(storeProd.getId().toString()), ESProductDTO.class);
.index(ES_INDEX_NAME).doc(esProductDTO).id(storeProd.getId().toString()), ESProductDTO.class);
log.info("updateResponse.result() = {}", updateResponse.result());
} catch (Exception e) {
fsNotice.sendMsg2DefaultChat("更新商品同步到ES 失败", "storeProdId: " + storeProd.getId());
@ -1206,9 +1209,9 @@ public class StoreProductServiceImpl implements IStoreProductService {
try {
// 删除ES索引文档
List<BulkOperation> list = storeProdIdList.stream().map(x -> new BulkOperation.Builder().delete(
d -> d.id(String.valueOf(x)).index(Constants.ES_IDX_PRODUCT_INFO)).build()).collect(Collectors.toList());
d -> d.id(String.valueOf(x)).index(ES_INDEX_NAME)).build()).collect(Collectors.toList());
// 调用bulk方法执行批量插入操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(ES_INDEX_NAME).operations(list));
log.info("bulkResponse.items() = {}", bulkResponse.items());
} catch (IOException | RuntimeException e) {
// 记录日志并抛出或处理异常
@ -1238,10 +1241,10 @@ public class StoreProductServiceImpl implements IStoreProductService {
.setParCateId(esDTO.getParCateId()).setParCateName(esDTO.getParCateName()).setProdPrice(esDTO.getProdPrice()).setStoreName(esDTO.getStoreName())
.setSeason(esDTO.getSeason()).setStyle(esDTO.getStyle()).setCreateTime(createTime);
return new BulkOperation.Builder().create(d -> d.document(esProductDTO).id(String.valueOf(x.getId()))
.index(Constants.ES_IDX_PRODUCT_INFO)).build();
.index(ES_INDEX_NAME)).build();
}).collect(Collectors.toList());
// 调用bulk方法执行批量插入操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(ES_INDEX_NAME).operations(list));
System.out.println("bulkResponse.items() = " + bulkResponse.items());
}
@ -1421,12 +1424,12 @@ public class StoreProductServiceImpl implements IStoreProductService {
put("prodStatus", prodStatus);
}}))
.id(String.valueOf(storeProdId))
.index(Constants.ES_IDX_PRODUCT_INFO))
.index(ES_INDEX_NAME))
.build());
});
try {
// 调用bulk方法执行批量更新操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(ES_INDEX_NAME).operations(list));
log.info("bulkResponse.result() = {}", bulkResponse.items());
} catch (IOException | RuntimeException e) {
// 记录日志并抛出或处理异常

View File

@ -34,6 +34,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -80,6 +81,8 @@ public class StoreServiceImpl implements IStoreService {
final StoreCustomerMapper storeCusMapper;
final StoreFactoryMapper storeFactoryMapper;
final IStoreProductDemandTemplateService storeTemplateService;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
/**
*
@ -445,9 +448,9 @@ public class StoreServiceImpl implements IStoreService {
/**
*
* 1.
* 2. 使 [使 ]
* 3. 使
* 1.
* 2. 使 [使 ]
* 3. 使
*
* @param storeId ID
* @return StoreExpireResDTO
@ -762,12 +765,12 @@ public class StoreServiceImpl implements IStoreService {
put("storeWeight", storeWeight);
}}))
.id(String.valueOf(storeProd.getId()))
.index(Constants.ES_IDX_PRODUCT_INFO))
.index(ES_INDEX_NAME))
.build());
});
try {
// 调用bulk方法执行批量更新操作
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(Constants.ES_IDX_PRODUCT_INFO).operations(list));
BulkResponse bulkResponse = esClientWrapper.getEsClient().bulk(e -> e.index(ES_INDEX_NAME).operations(list));
log.info("bulkResponse.result() = {}", bulkResponse.items());
} catch (IOException | RuntimeException e) {
// 记录日志并抛出或处理异常

View File

@ -44,6 +44,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -78,6 +79,8 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
final UserSubscriptionsMapper userSubMapper;
final UserFavoritesMapper userFavMapper;
final StoreMemberMapper storeMemberMapper;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
/**
* APP
@ -1119,7 +1122,7 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
Query query = new Query.Builder().bool(boolQuery.build()).build();
// 执行搜索
SearchResponse<ESProductDTO> resList = esClientWrapper.getEsClient()
.search(s -> s.index(Constants.ES_IDX_PRODUCT_INFO)
.search(s -> s.index(ES_INDEX_NAME)
.query(query)
.from((searchDTO.getPageNum() - 1) * searchDTO.getPageSize())
.size(searchDTO.getPageSize())

View File

@ -48,6 +48,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -86,6 +87,9 @@ public class WebsitePCServiceImpl implements IWebsitePCService {
final IPictureService pictureService;
final UserSubscriptionsMapper userSubsMapper;
final SysProductCategoryMapper prodCateMapper;
@Value("${es.indexName}")
private String ES_INDEX_NAME;
/**
* PC
@ -916,7 +920,7 @@ public class WebsitePCServiceImpl implements IWebsitePCService {
Query query = new Query.Builder().bool(boolQuery.build()).build();
// 执行搜索
SearchResponse<ESProductDTO> resList = esClientWrapper.getEsClient()
.search(s -> s.index(Constants.ES_IDX_PRODUCT_INFO)
.search(s -> s.index(ES_INDEX_NAME)
.query(query)
.from((searchDTO.getPageNum() - 1) * searchDTO.getPageSize())
.size(searchDTO.getPageSize())