Commit 1e54f5b1 authored by shiyu's avatar shiyu

Merge remote-tracking branch 'origin/master'

parents dcb78f84 960658b9
...@@ -13,7 +13,6 @@ import com.wwdz.ch.db.bean.EsPageInfo; ...@@ -13,7 +13,6 @@ import com.wwdz.ch.db.bean.EsPageInfo;
import com.wwdz.ch.db.bean.ItemOfEs; import com.wwdz.ch.db.bean.ItemOfEs;
import com.wwdz.ch.db.dao.*; import com.wwdz.ch.db.dao.*;
import com.wwdz.ch.db.domain.*; import com.wwdz.ch.db.domain.*;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.dto.request.EsSearchRequestDto; import com.wwdz.ch.db.dto.request.EsSearchRequestDto;
import com.wwdz.ch.db.es.ItemEsDao; import com.wwdz.ch.db.es.ItemEsDao;
import com.wwdz.ch.wx.entity.request.ItemRequestDto; import com.wwdz.ch.wx.entity.request.ItemRequestDto;
...@@ -71,9 +70,44 @@ public class ItemServiceImpl implements ItemService { ...@@ -71,9 +70,44 @@ public class ItemServiceImpl implements ItemService {
@Override @Override
public Result nameList(ItemRequestDto dto) { public Result nameList(ItemRequestDto dto) {
try { try {
CoinRequestDto coinRequestDto = new CoinRequestDto(); List<String> names = new ArrayList<>();
coinRequestDto.setName(dto.getName()); if (StringUtils.isNotBlank(dto.getName())) {
List<String> names = itemDao.findNames(coinRequestDto); EsSearchRequestDto esSearchRequestDto = new EsSearchRequestDto();
esSearchRequestDto.setPage(1);
esSearchRequestDto.setSize(1000);
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();
// 处理特殊字符
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个字符
if (name.length() > 15) {
name = name.substring(0, 15);
}
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++;
}
}
}
}
return Result.success(names); return Result.success(names);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询藏品名称联想失败", e); logger.error("查询藏品名称联想失败", e);
......
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