From cc3bde94c47d832120698b53e667491ededb8002 Mon Sep 17 00:00:00 2001 From: ccsens_zhengzhichuan Date: Tue, 27 Jan 2026 18:53:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=BC=E5=87=BA=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E8=80=85=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/ExportServiceImpl.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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<>();