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)) {