关键词模糊查询优化。

product
BAWEI 2 years ago
parent 5a213421ff
commit b0f5c9184e

@ -186,17 +186,17 @@ public class DataInterfaceServiceImpl extends ServiceImpl<DataInterfaceMapper, D
} }
} else { } else {
ActionResult result; ActionResult result;
if (StringUtils.isNotEmpty(page.getBissId())){ if (StringUtils.isNotEmpty(page.getBissId())) {
Map map = new HashMap(); Map map = new HashMap();
map.put("id",page.getBissId()); map.put("id", page.getBissId());
result = infoToId(id, null, map); result = infoToId(id, null, map);
}else{ } else {
result = infoToId(id, null, null); result = infoToId(id, null, null);
} }
DataInterfaceActionVo actionVo = (DataInterfaceActionVo) result.getData(); DataInterfaceActionVo actionVo = (DataInterfaceActionVo) result.getData();
if (actionVo.getData() instanceof List) { if (actionVo.getData() instanceof List) {
dataList = (List<Map<String, Object>>) actionVo.getData(); dataList = (List<Map<String, Object>>) actionVo.getData();
if(page.getExcludeFields() != null && page.getExcludeFields().size() > 0){ if (page.getExcludeFields() != null && page.getExcludeFields().size() > 0) {
dataList = dataList.stream().filter(datas -> !(page.getExcludeFields().contains(datas.get("license_num")))).collect(Collectors.toList()); dataList = dataList.stream().filter(datas -> !(page.getExcludeFields().contains(datas.get("license_num")))).collect(Collectors.toList());
} }
total = dataList.size(); total = dataList.size();
@ -205,18 +205,17 @@ public class DataInterfaceServiceImpl extends ServiceImpl<DataInterfaceMapper, D
//dataList = PageUtil.getListPage((int) page.getCurrentPage(), total , dataList); //dataList = PageUtil.getListPage((int) page.getCurrentPage(), total , dataList);
//dataList = PageUtil.getListPage((int) page.getCurrentPage(), (int) page.getPageSize(), dataList); //dataList = PageUtil.getListPage((int) page.getCurrentPage(), (int) page.getPageSize(), dataList);
} }
if (StringUtil.isNotEmpty(page.getKeyword())) { // if (StringUtil.isNotEmpty(page.getRelationField())) {
//dataList = dataList.stream().filter(t -> page.getKeyword().equals(String.valueOf(t.get(page.getRelationField())))).collect(Collectors.toList()); // //dataList = dataList.stream().filter(t -> page.getKeyword().equals(String.valueOf(t.get(page.getRelationField())))).collect(Collectors.toList());
dataList = dataList.stream().filter(t -> String.valueOf(t.get(page.getRelationField())).contains(page.getKeyword())).collect(Collectors.toList()); // dataList = dataList.stream().filter(t -> String.valueOf(t.get(page.getRelationField())).contains(page.getKeyword())).collect(Collectors.toList());
} // }
PaginationVO pagination = new PaginationVO();
page.setTotal(dataList.size());
if (StringUtil.isNotEmpty(page.getKeyword()) && StringUtil.isNotEmpty(page.getColumnOptions())) { if (StringUtil.isNotEmpty(page.getKeyword()) && StringUtil.isNotEmpty(page.getColumnOptions())) {
String[] colOptions = page.getColumnOptions().split(","); String[] colOptions = page.getColumnOptions().split(",");
dataList = dataList.stream().filter(t ->{ dataList = dataList.stream().filter(t -> {
boolean isFit = false; boolean isFit = false;
for (String c : colOptions){ for (String c : colOptions) {
if (String.valueOf(t.get(c)).contains(page.getKeyword())){ if (String.valueOf(t.get(c)).contains(page.getKeyword())) {
isFit = true; isFit = true;
break; break;
} }
@ -225,10 +224,12 @@ public class DataInterfaceServiceImpl extends ServiceImpl<DataInterfaceMapper, D
} }
).collect(Collectors.toList()); ).collect(Collectors.toList());
} }
PaginationVO pagination = new PaginationVO();
page.setTotal(dataList.size());
dataList = PageUtil.getListPage((int) page.getCurrentPage(), (int) page.getPageSize(), dataList); dataList = PageUtil.getListPage((int) page.getCurrentPage(), (int) page.getPageSize(), dataList);
pagination = JsonUtil.getJsonToBean(page, PaginationVO.class); pagination = JsonUtil.getJsonToBean(page, PaginationVO.class);
//PaginationVO pagination = JsonUtil.getJsonToBean(page, PaginationVO.class);
//pagination.setTotal(total);
return ActionResult.page(dataList, pagination, dataProcessing); return ActionResult.page(dataList, pagination, dataProcessing);
} }
@ -236,11 +237,11 @@ public class DataInterfaceServiceImpl extends ServiceImpl<DataInterfaceMapper, D
public Map<String, Object> infoToInfo(String id, DataInterfacePage page) { public Map<String, Object> infoToInfo(String id, DataInterfacePage page) {
Map<String, Object> dataMap = new HashMap<>(); Map<String, Object> dataMap = new HashMap<>();
ActionResult result; ActionResult result;
if (StringUtils.isNotEmpty(page.getBissId())){ if (StringUtils.isNotEmpty(page.getBissId())) {
Map map = new HashMap(); Map map = new HashMap();
map.put("id",page.getBissId()); map.put("id", page.getBissId());
result = infoToId(id, null, map); result = infoToId(id, null, map);
}else{ } else {
result = infoToId(id, null, null); result = infoToId(id, null, null);
} }
DataInterfaceActionVo actionVo = (DataInterfaceActionVo) result.getData(); DataInterfaceActionVo actionVo = (DataInterfaceActionVo) result.getData();
@ -486,7 +487,6 @@ public class DataInterfaceServiceImpl extends ServiceImpl<DataInterfaceMapper, D
} }
/** /**
* SQL * SQL
* *

Loading…
Cancel
Save