排序优化

This commit is contained in:
wangliwen 2022-05-25 10:04:42 +08:00
parent db8319022e
commit 2a6e4959b3
1 changed files with 10 additions and 11 deletions

View File

@ -211,16 +211,15 @@ public class CensusController {
}).collect(Collectors.toList());
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join();
result.sort(Comparator.comparing(x -> {
ObjectMapper mapper = new ObjectMapper();
try {
Map m = mapper.readValue(mapper.writeValueAsString(x), Map.class);
return ObjectUtil.length(m.get("provide"));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
).reversed()
);
ObjectMapper mapper = new ObjectMapper();
try {
Map m = mapper.readValue(mapper.writeValueAsString(x), Map.class);
return ObjectUtil.length(m.get("provide"));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
).reversed().thenComparing(i -> i.toString()));
return new Result<List<Map<String, Object>>>().ok(result);
}
@ -288,7 +287,7 @@ public class CensusController {
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}).reversed()
}).reversed().thenComparing(i -> i.toString())
);
return new Result<List<Map<String, Object>>>().ok(result);
}