供 flow-center 嵌入页「业务信息」直出中文键名,零后端改动(bizSnapshot 透传)。 通知对象:全员 ⇒「全部」;指定 ⇒ 前 3 个姓名以「、」连接,多于 3 人再追「 等N人」。 原有键(title/summary/attachmentNames 等)照旧保留。
This commit is contained in:
@@ -10,8 +10,10 @@ import com.yunhai.notice.model.flow.FlowModels;
|
|||||||
import com.yunhai.notice.repository.NoticeFlowBindingRepository;
|
import com.yunhai.notice.repository.NoticeFlowBindingRepository;
|
||||||
import com.yunhai.notice.repository.NoticeRepository;
|
import com.yunhai.notice.repository.NoticeRepository;
|
||||||
import com.yunhai.notice.repository.UpFileRepository;
|
import com.yunhai.notice.repository.UpFileRepository;
|
||||||
|
import com.yunhai.notice.utils.ReceiveParser;
|
||||||
import com.yunhai.platform.apistd.BizException;
|
import com.yunhai.platform.apistd.BizException;
|
||||||
import com.yunhai.platform.auth.spring.CurrentBoaUser;
|
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.openapi.core.JumpTarget;
|
||||||
import com.yunhai.platform.utils.exception.ErrorCode;
|
import com.yunhai.platform.utils.exception.ErrorCode;
|
||||||
import com.yunhai.platform.utils.model.BoaUser;
|
import com.yunhai.platform.utils.model.BoaUser;
|
||||||
@@ -152,7 +154,7 @@ public class NoticeFlowService {
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 业务摘要:{title, summary(纯文本截 300 字), attachmentNames[]}——富文本正文不传(概览 §十边界) */
|
/** 业务摘要:原键照旧(流程中心透传、嵌入页不展示)+ 约定键 summaryFields(嵌入页「业务信息」唯一渲染源) */
|
||||||
private Map<String, Object> buildSnapshot(Notice notice) {
|
private Map<String, Object> buildSnapshot(Notice notice) {
|
||||||
Map<String, Object> snapshot = new LinkedHashMap<>();
|
Map<String, Object> snapshot = new LinkedHashMap<>();
|
||||||
snapshot.put("title", notice.getTitle());
|
snapshot.put("title", notice.getTitle());
|
||||||
@@ -164,9 +166,60 @@ public class NoticeFlowService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
snapshot.put("attachmentNames", names);
|
snapshot.put("attachmentNames", names);
|
||||||
|
snapshot.put("summaryFields", buildSummaryFields(notice));
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 嵌入页「业务信息」三行:通知标题 / 来源部门 / 通知对象 */
|
||||||
|
private List<Map<String, Object>> buildSummaryFields(Notice notice) {
|
||||||
|
List<Map<String, Object>> fields = new ArrayList<>();
|
||||||
|
fields.add(summaryField("通知标题", notice.getTitle()));
|
||||||
|
fields.add(summaryField("来源部门", notice.getDeptName()));
|
||||||
|
fields.add(summaryField("通知对象", buildReceiveSummary(notice)));
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> summaryField(String label, Object value) {
|
||||||
|
Map<String, Object> 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<String> accounts = ReceiveParser.parse(notice.getReceiveList());
|
||||||
|
if (accounts.isEmpty()) {
|
||||||
|
return "全部";
|
||||||
|
}
|
||||||
|
int total = accounts.size();
|
||||||
|
List<String> 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 字) */
|
/** 富文本剥标签取纯文本摘要(截断 300 字) */
|
||||||
private String plainSummary(String content) {
|
private String plainSummary(String content) {
|
||||||
if (!StringUtils.hasText(content)) {
|
if (!StringUtils.hasText(content)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user