diff --git a/research-system/src/main/java/com/research/system/service/impl/ExportServiceImpl.java b/research-system/src/main/java/com/research/system/service/impl/ExportServiceImpl.java index 873b1461..028dee3f 100644 --- a/research-system/src/main/java/com/research/system/service/impl/ExportServiceImpl.java +++ b/research-system/src/main/java/com/research/system/service/impl/ExportServiceImpl.java @@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.FileOutputStream; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -313,8 +314,23 @@ public class ExportServiceImpl implements ExportService { try { // 使用@SuppressWarnings注解抑制警告,因为运行时类型是正确的 + @SuppressWarnings("unchecked") List authorList = JSONUtil.toList(authorsJson, Map.class); + // 按type值排序:type=0优先,type=2其次,type=1最后 + authorList.sort( + Comparator.comparing((Map m) -> { + Integer type = (Integer) m.get("type"); + if (type == null) return 999; // null值放最后 + switch (type) { + case 0: return 0; // 最高优先级 + case 2: return 1; // 中等优先级 + case 1: return 2; // 最低优先级 + default: return 3; // 其他情况 + } + }) + ); + StringBuilder result = new StringBuilder(); for (int i = 0; i < authorList.size(); i++) { Map author = authorList.get(i); @@ -348,7 +364,6 @@ public class ExportServiceImpl implements ExportService { return authorsJson; } } - public void exportGr(HttpServletResponse response, ExportDto.Query dto) { XWPFTemplate template = XWPFTemplate.compile(reportGrTemplate); HashMap map = new HashMap<>();