|
|
@@ -267,18 +267,67 @@ public class ReformServiceImpl implements ReformService {
|
|
|
.filter(Optional::isPresent)
|
|
|
.map(Optional::get)
|
|
|
.collect(Collectors.toList());
|
|
|
- List<Map<String, Object>> collect = mergedList.stream().sorted(Comparator.comparing(
|
|
|
- (Map<String, Object> map) -> (String) map.get("fa_bu_shi_jian_"),
|
|
|
- Comparator.nullsLast(Comparator.naturalOrder())
|
|
|
- ).thenComparing(
|
|
|
- map -> (String) map.get("wen_jian_bian_hao"),
|
|
|
- Comparator.nullsLast(Comparator.naturalOrder())
|
|
|
- )
|
|
|
- ).collect(Collectors.toList());
|
|
|
+ List<Map<String, Object>> collect = sortByOrder(mergedList, order);
|
|
|
Map<String, Object> map = paginate(collect, pageNo , limit);
|
|
|
result.setVariables(map);
|
|
|
return result;
|
|
|
}
|
|
|
+ public static List<Map<String, Object>> sortByOrder(
|
|
|
+ List<Map<String, Object>> mergedList,
|
|
|
+ String order) {
|
|
|
+
|
|
|
+ // 解析排序参数
|
|
|
+ boolean isTimeFirst = order.contains("FA_FANG_SHI_JIAN_");
|
|
|
+ boolean isBianhaoFirst = order.contains("WEN_JIAN_BIAN_HAO");
|
|
|
+ boolean isAsc = order.contains("ASC");
|
|
|
+ boolean isDesc = order.contains("DESC");
|
|
|
+
|
|
|
+ // 创建时间比较器
|
|
|
+ Comparator<String> timeComparator = isAsc
|
|
|
+ ? Comparator.nullsLast(Comparator.naturalOrder())
|
|
|
+ : Comparator.nullsLast(Comparator.reverseOrder());
|
|
|
+
|
|
|
+ // 创建文件编号比较器
|
|
|
+ Comparator<String> bianhaoComparator = isAsc
|
|
|
+ ? Comparator.nullsLast(Comparator.naturalOrder())
|
|
|
+ : Comparator.nullsLast(Comparator.reverseOrder());
|
|
|
+
|
|
|
+ // 根据 order 参数构建不同的排序规则
|
|
|
+ if (isTimeFirst) {
|
|
|
+ // 先按时间排序,再按文件编号排序
|
|
|
+ return mergedList.stream()
|
|
|
+ .sorted(Comparator.comparing(
|
|
|
+ (Map<String, Object> map) -> (String) map.get("fa_bu_shi_jian_"),
|
|
|
+ timeComparator
|
|
|
+ ).thenComparing(
|
|
|
+ (Map<String, Object> map) -> (String) map.get("wen_jian_bian_hao"), // 添加类型声明
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder()) // 次要字段默认正序
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else if (isBianhaoFirst) {
|
|
|
+ // 先按文件编号排序,再按时间排序
|
|
|
+ return mergedList.stream()
|
|
|
+ .sorted(Comparator.comparing(
|
|
|
+ (Map<String, Object> map) -> (String) map.get("wen_jian_bian_hao"), // 添加类型声明
|
|
|
+ bianhaoComparator
|
|
|
+ ).thenComparing(
|
|
|
+ (Map<String, Object> map) -> (String) map.get("fa_bu_shi_jian_"), // 添加类型声明
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder()) // 次要字段默认正序
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ // 默认排序:按时间倒序,文件编号正序
|
|
|
+ return mergedList.stream()
|
|
|
+ .sorted(Comparator.comparing(
|
|
|
+ (Map<String, Object> map) -> (String) map.get("fa_bu_shi_jian_"),
|
|
|
+ Comparator.nullsLast(Comparator.reverseOrder())
|
|
|
+ ).thenComparing(
|
|
|
+ (Map<String, Object> map) -> (String) map.get("wen_jian_bian_hao"), // 添加类型声明
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder()) // 次要字段默认正序
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public static Map<String, Object> paginate(List<Map<String, Object>> dataList, int currentPage, int pageSize) {
|
|
|
int totalCount = dataList.size();
|