List<LinkedHashMap<String, Object>> roomList = new ArrayList<>();
if (StringUtils.isNotBlank(sortField)) {
List<HashMap<String, Object>> rooms = new ArrayList<>();
if ("asc".equals(sortStyle)) {
//中文排序
if ("ConsumerName".equals(sortField) || "AmMeter_Name".equals(sortField)) {
rooms = roomList.stream().sorted((a, b) ->
Collator.getInstance(Locale.CHINA).compare(a.get(sortField).toString(), b.get(sortField).toString())
).collect(Collectors.toList());
} else {
//数字排序
rooms = roomList.stream().sorted(((o1, o2) -> Double.valueOf(o1.get(sortField).toString()).compareTo(Double.valueOf(o2.get(sortField).toString())))).collect(Collectors.toList());
}
} else {
if ("ConsumerName".equals(sortField) || "AmMeter_Name".equals(sortField)) {
rooms = roomList.stream().sorted((a, b) ->
Collator.getInstance(Locale.CHINA).compare(b.get(sortField).toString(), a.get(sortField).toString())
).collect(Collectors.toList());
} else {
rooms = roomList.stream().sorted(((o1, o2) -> Double.valueOf(o2.get(sortField).toString()).compareTo(Double.valueOf(o1.get(sortField).toString())))).collect(Collectors.toList());
}
}
map.put("RoomList", rooms);
} else {
map.put("RoomList", roomList);
}
map.put("sumAfterMulCoefficientValue", sumAfterMulCoefficientValue);
网友评论