Commit 6a340eb7 authored by muhong's avatar muhong

修改 小程序缓存

parent b57ffbae
...@@ -37,8 +37,10 @@ import java.io.ByteArrayInputStream; ...@@ -37,8 +37,10 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.System;
import java.net.URL; import java.net.URL;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
public class ItemServiceImpl implements ItemService { public class ItemServiceImpl implements ItemService {
...@@ -70,39 +72,25 @@ public class ItemServiceImpl implements ItemService { ...@@ -70,39 +72,25 @@ public class ItemServiceImpl implements ItemService {
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
if (StringUtils.isNotBlank(dto.getName())) { if (StringUtils.isNotBlank(dto.getName())) {
EsSearchRequestDto esSearchRequestDto = new EsSearchRequestDto(); EsSearchRequestDto esSearchRequestDto = new EsSearchRequestDto();
esSearchRequestDto.setPage(1);
esSearchRequestDto.setSize(10000);
esSearchRequestDto.setContent(dto.getName()); esSearchRequestDto.setContent(dto.getName());
EsPageInfo esPageInfo = itemEsDao.findList(esSearchRequestDto); esSearchRequestDto.setSize(16);
if (Objects.nonNull(esPageInfo) && CollectionUtils.isNotEmpty(esPageInfo.getDataList())) { List<ItemOfEs> list = itemEsDao.getCuewords(esSearchRequestDto);
Set<String> set = new HashSet<>(); if (CollectionUtils.isNotEmpty(list)) {
esPageInfo.getDataList().forEach(s -> { names = list.stream()
ItemOfEs es = (ItemOfEs) s; .map(ItemOfEs::getName).collect(Collectors.toList());
String name = es.getName(); for (String name : names) {
// 处理特殊字符 // 处理特殊字符
name = name.replaceAll("\\s*|\r|\n|\t", ""); name = name.replaceAll("\\s*|\r|\n|\t", "");
name = name.replaceAll("/P", ""); name = name.replaceAll("/P", "");
if (name.contains(",")) { name = name.replaceAll(",", "");
int index = name.indexOf(","); // 超过15个字的15个字符
name = name.substring(0, index);
}
// 超过15个字的截取前15个字符
if (name.length() > 15) { if (name.length() > 15) {
name = name.substring(0, 15); int index = name.indexOf(dto.getName());
} if (index + dto.getName().length() > 15) {
if (name.contains(dto.getName())) { name = name.substring(index + dto.getName().length() - 15, index + dto.getName().length());
set.add(name); } else {
} name = name.substring(0, 15);
}); }
// 取16个名称
if (set.size() <= 16) {
names = new ArrayList<>(set);
} else {
int i = 1;
Iterator<String> iterator = set.iterator();
while (i <= 16) {
names.add(iterator.next());
i++;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment