Commit 6a340eb7 authored by muhong's avatar muhong

修改 小程序缓存

parent b57ffbae
......@@ -37,8 +37,10 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.System;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ItemServiceImpl implements ItemService {
......@@ -70,39 +72,25 @@ public class ItemServiceImpl implements ItemService {
List<String> names = new ArrayList<>();
if (StringUtils.isNotBlank(dto.getName())) {
EsSearchRequestDto esSearchRequestDto = new EsSearchRequestDto();
esSearchRequestDto.setPage(1);
esSearchRequestDto.setSize(10000);
esSearchRequestDto.setContent(dto.getName());
EsPageInfo esPageInfo = itemEsDao.findList(esSearchRequestDto);
if (Objects.nonNull(esPageInfo) && CollectionUtils.isNotEmpty(esPageInfo.getDataList())) {
Set<String> set = new HashSet<>();
esPageInfo.getDataList().forEach(s -> {
ItemOfEs es = (ItemOfEs) s;
String name = es.getName();
esSearchRequestDto.setSize(16);
List<ItemOfEs> list = itemEsDao.getCuewords(esSearchRequestDto);
if (CollectionUtils.isNotEmpty(list)) {
names = list.stream()
.map(ItemOfEs::getName).collect(Collectors.toList());
for (String name : names) {
// 处理特殊字符
name = name.replaceAll("\\s*|\r|\n|\t", "");
name = name.replaceAll("/P", "");
if (name.contains(",")) {
int index = name.indexOf(",");
name = name.substring(0, index);
}
// 超过15个字的截取前15个字符
name = name.replaceAll(",", "");
// 超过15个字的15个字符
if (name.length() > 15) {
int index = name.indexOf(dto.getName());
if (index + dto.getName().length() > 15) {
name = name.substring(index + dto.getName().length() - 15, index + dto.getName().length());
} else {
name = name.substring(0, 15);
}
if (name.contains(dto.getName())) {
set.add(name);
}
});
// 取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