通知修订

This commit is contained in:
chenxing
2026-09-01 19:55:12 +08:00
parent c387f8eb76
commit 41849defc9
8 changed files with 35 additions and 119 deletions
@@ -70,12 +70,4 @@ public class DictController {
public void sort(@RequestParam("ids") String ids) {
dictService.ordbyDicIds(ids);
}
/**
* 发文单位同步。
*/
@GetMapping("Sync")
public void sync() {
dictService.getDeptSync();
}
}
@@ -47,6 +47,9 @@ public class NoticeVo {
/** 接收人列表(JSON) */
private String receiveList;
/** 附件ID串("1,2,3",列表页下载入口使用;对齐旧 .NET UpFile 字段) */
private String UpFile;
private String createBy;
private LocalDateTime createTime;
private String updateBy;
@@ -56,11 +56,6 @@ public interface IDictService {
*/
void ordbyDicIds(String ids);
/**
* 发文单位同步(从用户中心组织架构同步部门到字典)。
*/
void getDeptSync();
/**
* 是否发送短信(查询当前学校模块短信开关)。
*
@@ -201,17 +201,6 @@ public class DictService implements IDictService {
}
}
// ============================ GetDeptSync ============================
@Override
@Transactional
public void getDeptSync() {
// C# 从用户中心 OpenAPI 获取学校部门树并同步到字典。
// Java 版暂不接入外部 OpenAPI,预留空实现。
// 后续接入平台用户中心 API 后补全同步逻辑。
log.info("[getDeptSync] 部门同步暂未接入用户中心API,跳过");
}
// ============================ GetSchModuleIsSms ============================
@Override
@@ -333,6 +333,15 @@ entity.setIsPulled(0);
List<NoticeVo> content = page.getContent().stream()
.map(n -> toVo(n, false))
.collect(Collectors.toList());
// 批量填充附件ID串("1,2,3"):列表页"附件下载"入口依赖 UpFile 字段
if (!content.isEmpty()) {
Map<Integer, List<Integer>> fileMap = batchFileIds(
content.stream().map(NoticeVo::getId).collect(Collectors.toList()));
for (NoticeVo vo : content) {
List<Integer> fids = fileMap.getOrDefault(vo.getId(), Collections.emptyList());
vo.setUpFile(fids.stream().map(String::valueOf).collect(Collectors.joining(",")));
}
}
return PageUtils.toResult(new PageImpl<>(content, pageable, page.getTotalElements()));
}
@@ -578,31 +587,43 @@ entity.setIsPulled(0);
}
}
// 逐账号查用户中心(姓名+组织链)。量级为校内接收人(几十),串行可接受
// 逐接收人查用户中心(姓名+组织链)。接收明细可能存登录名,也可能存历史数字ID
// (如 10012):先按登录名查,查不到且为纯数字再按 userId 查,保证未读人也能取到组
Map<String, BoaUser> userMap = new LinkedHashMap<>();
Map<String, String> canonicalAccount = new HashMap<>(); // 原始串 -> 规范登录名
for (String account : receivers) {
BoaUser user = null;
try {
BoaUser user = YschBaseOpenApi.getUserInfo(account);
if (user != null) {
userMap.put(account, user);
user = YschBaseOpenApi.getUserInfo(account);
if (user == null && account.chars().allMatch(Character::isDigit)) {
user = YschBaseOpenApi.getUserInfo(Integer.parseInt(account));
}
} catch (Exception e) {
log.warn("[readDetailGrouped] 查询用户中心失败, account={}", account, e);
}
if (user != null) {
userMap.put(account, user);
if (StringUtils.hasText(user.getAccount())) {
canonicalAccount.put(account, user.getAccount());
}
}
}
// 组名=用户组织链最近端(主组),跨校/查不到归「其他」(对齐旧版逻辑)
Map<String, List<Map<String, Object>>> groupUsers = new LinkedHashMap<>();
for (String account : receivers) {
BoaUser user = userMap.get(account);
// 已读比对/姓名兜底统一使用规范登录名(接收明细可能存的是历史数字ID)
String canonical = canonicalAccount.getOrDefault(account, account);
boolean read = readAccounts.contains(canonical) || readAccounts.contains(account);
String groupName = resolveReadGroupName(user, notice.getSchId());
String teaName = user != null && StringUtils.hasText(user.getName())
? user.getName()
: readNameMap.getOrDefault(account, account);
: readNameMap.getOrDefault(canonical, canonical);
Map<String, Object> item = new LinkedHashMap<>();
item.put("account", account);
item.put("account", canonical);
item.put("teaname", teaName);
item.put("states", readAccounts.contains(account) ? "read" : "unread");
item.put("states", read ? "read" : "unread");
groupUsers.computeIfAbsent(groupName, k -> new ArrayList<>()).add(item);
}
@@ -262,19 +262,7 @@ public class UserCenterService implements IUserCenterService {
}
}
// 全树按 orderNumber 排序
sortTree(roots);
// 保持 SDK(用户中心)返回顺序,不再按 orderNumber 重排
return roots;
}
@SuppressWarnings("unchecked")
private void sortTree(List<Map<String, Object>> nodes) {
nodes.sort(Comparator.comparingInt(n -> (Integer) n.get("orderNumber")));
for (Map<String, Object> node : nodes) {
List<Map<String, Object>> children = (List<Map<String, Object>>) node.get("children");
if (!children.isEmpty()) {
sortTree(children);
}
}
}
}