Commit 67b0423e by xmh

搜索结果排序

1 parent f18285fc
......@@ -459,8 +459,19 @@ public class ReidService {
options.put("agg", true);
CompletableFuture<AlgResult> future = matchClient.matchPerson(2, person, reidPoolName, Collections.emptyList(), options);
AlgResult result = future.get();
List<String> personUnidList = new ArrayList<>();
Map<String, Float> personScoreMap = new HashMap<>();
List<Person> matchBodies = result.getMatchBodies();
List<String> personUnidList = matchBodies.stream().filter(x -> x.getScore() > 60F).map(Person::getPersonId).filter(x -> !personUnidSet.contains(x)).collect(Collectors.toList());
for (Person match : matchBodies) {
String personId = match.getPersonId();
if (match.getScore() < 60F || personUnidSet.contains(personId)) {
continue;
}
personScoreMap.put(personId, match.getScore());
personUnidList.add(personId);
}
if (personUnidList.size() == 0) {
return Collections.emptyMap();
}
......@@ -471,11 +482,26 @@ public class ReidService {
final Set<String> matchFilter = currentPerson == null ? Collections.emptySet() : getMatchFilter(currentPerson, packId);
Map<String, List<SubTask>> collect = subTasks.stream().collect(Collectors.groupingBy(SubTask::getPersonUnid, Collectors.toList()));
Map<String, List<SubTask>> collect = subTasks.stream().sorted(
(o1, o2) -> {
String o1P = o1.getPersonUnid();
String o2P = o2.getPersonUnid();
Float o1s = personScoreMap.get(o1P);
Float o2s = personScoreMap.get(o2P);
if (o2s == null) {
return 1;
} else if (o1s != null) {
return o1s > o2s ? 1 : o1s.equals(o2s) ? 0 : -1;
} else {
return -1;
}
}
).collect(Collectors.groupingBy(SubTask::getPersonUnid, LinkedHashMap::new, Collectors.toList()));
HashMap<String, Map<String, List<SubTask>>> ret = new HashMap<>();
Map<String, List<SubTask>> hideMap = new HashMap<>();
Map<String, List<SubTask>> displayMap = new HashMap<>();
Map<String, List<SubTask>> hideMap = new LinkedHashMap<>();
Map<String, List<SubTask>> displayMap = new LinkedHashMap<>();
ret.put("hide", hideMap);
ret.put("display", displayMap);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!