From 81a988f96a24e92bcb62d9d79d102851f4653dbe Mon Sep 17 00:00:00 2001 From: chenxing Date: Sat, 10 Oct 2026 14:56:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(notice):=20=E6=B5=81=E7=A8=8B=E5=BF=AB?= =?UTF-8?q?=E7=85=A7=E5=A2=9E=E7=BA=A6=E5=AE=9A=E9=94=AE=20summaryFields?= =?UTF-8?q?=EF=BC=88=E9=80=9A=E7=9F=A5=E6=A0=87=E9=A2=98/=E6=9D=A5?= =?UTF-8?q?=E6=BA=90=E9=83=A8=E9=97=A8/=E9=80=9A=E7=9F=A5=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 供 flow-center 嵌入页「业务信息」直出中文键名,零后端改动(bizSnapshot 透传)。 通知对象:全员 ⇒「全部」;指定 ⇒ 前 3 个姓名以「、」连接,多于 3 人再追「 等N人」。 原有键(title/summary/attachmentNames 等)照旧保留。 --- .../service/flow/NoticeFlowService.java | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/yunhai/notice/service/flow/NoticeFlowService.java b/src/main/java/com/yunhai/notice/service/flow/NoticeFlowService.java index 62922e6..60e181b 100644 --- a/src/main/java/com/yunhai/notice/service/flow/NoticeFlowService.java +++ b/src/main/java/com/yunhai/notice/service/flow/NoticeFlowService.java @@ -10,8 +10,10 @@ import com.yunhai.notice.model.flow.FlowModels; import com.yunhai.notice.repository.NoticeFlowBindingRepository; import com.yunhai.notice.repository.NoticeRepository; import com.yunhai.notice.repository.UpFileRepository; +import com.yunhai.notice.utils.ReceiveParser; import com.yunhai.platform.apistd.BizException; import com.yunhai.platform.auth.spring.CurrentBoaUser; +import com.yunhai.platform.openapi.base.YschBaseOpenApi; import com.yunhai.platform.openapi.core.JumpTarget; import com.yunhai.platform.utils.exception.ErrorCode; import com.yunhai.platform.utils.model.BoaUser; @@ -152,7 +154,7 @@ public class NoticeFlowService { return body; } - /** 业务摘要:{title, summary(纯文本截 300 字), attachmentNames[]}——富文本正文不传(概览 §十边界) */ + /** 业务摘要:原键照旧(流程中心透传、嵌入页不展示)+ 约定键 summaryFields(嵌入页「业务信息」唯一渲染源) */ private Map buildSnapshot(Notice notice) { Map snapshot = new LinkedHashMap<>(); snapshot.put("title", notice.getTitle()); @@ -164,9 +166,60 @@ public class NoticeFlowService { } } snapshot.put("attachmentNames", names); + snapshot.put("summaryFields", buildSummaryFields(notice)); return snapshot; } + /** 嵌入页「业务信息」三行:通知标题 / 来源部门 / 通知对象 */ + private List> buildSummaryFields(Notice notice) { + List> fields = new ArrayList<>(); + fields.add(summaryField("通知标题", notice.getTitle())); + fields.add(summaryField("来源部门", notice.getDeptName())); + fields.add(summaryField("通知对象", buildReceiveSummary(notice))); + return fields; + } + + private Map summaryField(String label, Object value) { + Map field = new LinkedHashMap<>(); + field.put("label", label); + field.put("value", value == null ? "" : value); + return field; + } + + /** + * 通知对象展示串:全员(receive_list 空 / ALL / UserAll)⇒ "全部";指定 ⇒ 前 3 个姓名以「、」连接, + * 多于 3 人再追 " 等N人"(如 "张三、李四、王五 等11人")。 + * 姓名经用户中心解析(手法同 NoticeService.getReadDetailGrouped),失败回落原 id/账号; + * 只解析前 3 个——本方法在 apply 提交时执行,避免 N 次远程调用。 + */ + private String buildReceiveSummary(Notice notice) { + List accounts = ReceiveParser.parse(notice.getReceiveList()); + if (accounts.isEmpty()) { + return "全部"; + } + int total = accounts.size(); + List shown = new ArrayList<>(); + for (String account : accounts.subList(0, Math.min(3, total))) { + shown.add(resolveReceiverName(account)); + } + String joined = String.join("、", shown); + return total > 3 ? joined + " 等" + total + "人" : joined; + } + + /** 接收明细可能存登录名,也可能是历史数字 userId:先按登录名查,查不到且纯数字再按 id 查 */ + private String resolveReceiverName(String account) { + try { + BoaUser user = YschBaseOpenApi.getUserInfo(account); + if (user == null && StringUtils.hasText(account) && account.chars().allMatch(Character::isDigit)) { + user = YschBaseOpenApi.getUserInfo(Integer.parseInt(account)); + } + return user != null && StringUtils.hasText(user.getName()) ? user.getName() : account; + } catch (Exception e) { + log.warn("[notice-flow] 通知对象姓名解析失败 account={}", account, e); + return account; + } + } + /** 富文本剥标签取纯文本摘要(截断 300 字) */ private String plainSummary(String content) { if (!StringUtils.hasText(content)) {