|
@@ -74,7 +74,8 @@ public class ProtocolProductsServiceImpl extends ServiceImpl<ProtocolProductsMa
|
|
|
return TableDataInfo.build();
|
|
return TableDataInfo.build();
|
|
|
}
|
|
}
|
|
|
List<Long> productIds = protocolProducts.stream().map(ProtocolProducts::getProductId).distinct().toList();
|
|
List<Long> productIds = protocolProducts.stream().map(ProtocolProducts::getProductId).distinct().toList();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ TableDataInfo<ProductBaseVo> tableDataInfo = TableDataInfo.build();
|
|
|
// 使用ES查询
|
|
// 使用ES查询
|
|
|
try {
|
|
try {
|
|
|
LambdaEsQueryWrapper<ProductBaseVo> esQueryWrapper = new LambdaEsQueryWrapper<ProductBaseVo>()
|
|
LambdaEsQueryWrapper<ProductBaseVo> esQueryWrapper = new LambdaEsQueryWrapper<ProductBaseVo>()
|
|
@@ -83,7 +84,7 @@ public class ProtocolProductsServiceImpl extends ServiceImpl<ProtocolProductsMa
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getBrandId()), ProductBaseVo::getBrandId, bo.getBrandId())
|
|
.eq(ObjectUtil.isNotEmpty(bo.getBrandId()), ProductBaseVo::getBrandId, bo.getBrandId())
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()), ProductBaseVo::getProductStatus, bo.getProductStatus())
|
|
.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()), ProductBaseVo::getProductStatus, bo.getProductStatus())
|
|
|
.orderByAsc(ProductBaseVo::getId);
|
|
.orderByAsc(ProductBaseVo::getId);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查ES索引是否存在
|
|
// 检查ES索引是否存在
|
|
|
if (!productEsMapper.existsIndex("productbasevo")) {
|
|
if (!productEsMapper.existsIndex("productbasevo")) {
|
|
|
log.warn("ES索引 [productbasevo] 不存在,降级到数据库查询");
|
|
log.warn("ES索引 [productbasevo] 不存在,降级到数据库查询");
|
|
@@ -94,16 +95,14 @@ public class ProtocolProductsServiceImpl extends ServiceImpl<ProtocolProductsMa
|
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()),"b.product_status", bo.getProductStatus());
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()),"b.product_status", bo.getProductStatus());
|
|
|
lqw.orderByAsc("b.id");
|
|
lqw.orderByAsc("b.id");
|
|
|
List<ProductBaseVo> result = productBaseMapper.selectAllList(lqw);
|
|
List<ProductBaseVo> result = productBaseMapper.selectAllList(lqw);
|
|
|
- TableDataInfo<ProductBaseVo> tableDataInfo = TableDataInfo.build(result);
|
|
|
|
|
|
|
+ tableDataInfo = TableDataInfo.build(result);
|
|
|
tableDataInfo.setTotal(productIds.size());
|
|
tableDataInfo.setTotal(productIds.size());
|
|
|
- return tableDataInfo;
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
List<ProductBaseVo> result = productEsMapper.selectList(esQueryWrapper);
|
|
List<ProductBaseVo> result = productEsMapper.selectList(esQueryWrapper);
|
|
|
- TableDataInfo<ProductBaseVo> tableDataInfo = TableDataInfo.build(result);
|
|
|
|
|
|
|
+ tableDataInfo = TableDataInfo.build(result);
|
|
|
tableDataInfo.setTotal(productIds.size());
|
|
tableDataInfo.setTotal(productIds.size());
|
|
|
- return tableDataInfo;
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("ES查询协议产品失败,降级到数据库查询: {}", e.getMessage(), e);
|
|
log.error("ES查询协议产品失败,降级到数据库查询: {}", e.getMessage(), e);
|
|
|
QueryWrapper<ProductBase> lqw = Wrappers.query();
|
|
QueryWrapper<ProductBase> lqw = Wrappers.query();
|
|
@@ -113,10 +112,13 @@ public class ProtocolProductsServiceImpl extends ServiceImpl<ProtocolProductsMa
|
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()),"b.product_status", bo.getProductStatus());
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()),"b.product_status", bo.getProductStatus());
|
|
|
lqw.orderByAsc("b.id");
|
|
lqw.orderByAsc("b.id");
|
|
|
List<ProductBaseVo> result = productBaseMapper.selectAllList(lqw);
|
|
List<ProductBaseVo> result = productBaseMapper.selectAllList(lqw);
|
|
|
- TableDataInfo<ProductBaseVo> tableDataInfo = TableDataInfo.build(result);
|
|
|
|
|
|
|
+ tableDataInfo = TableDataInfo.build(result);
|
|
|
tableDataInfo.setTotal(productIds.size());
|
|
tableDataInfo.setTotal(productIds.size());
|
|
|
- return tableDataInfo;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ tableDataInfo.getRows().forEach(item -> {
|
|
|
|
|
+ item.setAgreementPrice(protocolProducts.stream().filter(o -> o.getProductId().equals(item.getId())).findFirst().get().getAgreementPrice());
|
|
|
|
|
+ });
|
|
|
|
|
+ return tableDataInfo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|