新增了一些特殊功能

This commit is contained in:
zayac 2024-09-01 18:11:46 +08:00
parent 2828161cfa
commit b33eac431f

View File

@ -450,7 +450,7 @@ public class DailyReport {
AgentDataVisualListReq agentDataVisualListReq = AgentDataVisualListReq.builder().monthDate(reportDate).build(); AgentDataVisualListReq agentDataVisualListReq = AgentDataVisualListReq.builder().monthDate(reportDate).build();
deptUsers.forEach(deptUser -> tasks deptUsers.forEach(deptUser -> tasks
.add(processDeptUser(deptUser, ministerUser, agentDataVisualListReq, reportDate))); .add(processDeptUser(deptUser, ministerUser, assistants, agentDataVisualListReq, reportDate)));
CompletableFuture<Void> allTasks = CompletableFuture.allOf(tasks.toArray(new CompletableFuture[0])); CompletableFuture<Void> allTasks = CompletableFuture.allOf(tasks.toArray(new CompletableFuture[0]));
allTasks.join(); allTasks.join();
@ -525,6 +525,8 @@ public class DailyReport {
assistants.forEach(assistant -> { assistants.forEach(assistant -> {
if (assistant.getNeedNotify() == DisEnableStatusEnum.ENABLE) { if (assistant.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
telegramMessageService.sendMessage(assistant.getBotToken(), assistant.getReportIds(), message); telegramMessageService.sendMessage(assistant.getBotToken(), assistant.getReportIds(), message);
telegramMessageService.sendMessage(assistant.getBotToken(), assistant.getReportIds(), String
.format("1组新增%s\n在岗人数", totals.get(1)));
log.info("Sent report to assistant: {}", assistant.getUsername()); log.info("Sent report to assistant: {}", assistant.getUsername());
} }
}); });
@ -546,6 +548,7 @@ public class DailyReport {
*/ */
private CompletableFuture<Void> processDeptUser(UserWithRolesAndAccountsResp deptUser, private CompletableFuture<Void> processDeptUser(UserWithRolesAndAccountsResp deptUser,
UserWithRolesAndAccountsResp ministerUser, UserWithRolesAndAccountsResp ministerUser,
List<UserWithRolesAndAccountsResp> assistants,
AgentDataVisualListReq agentDataVisualListReq, AgentDataVisualListReq agentDataVisualListReq,
LocalDate reportDate) { LocalDate reportDate) {
return CompletableFuture.runAsync(() -> { return CompletableFuture.runAsync(() -> {
@ -578,16 +581,32 @@ public class DailyReport {
return null; return null;
} }
}).filter(Objects::nonNull).collect(Collectors.toList()); }).filter(Objects::nonNull).collect(Collectors.toList());
// 构造消息体 // 构造消息体
String message = telegramMessageService.buildDailyReportMessage(agentDataList); String message = telegramMessageService.buildDailyReportMessage(agentDataList);
if (StrUtil.isNotBlank(message) && deptUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) { if (StrUtil.isNotBlank(message) && deptUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
String botToken = StrUtil.isEmpty(deptUser.getBotToken()) String botToken = StrUtil.isEmpty(deptUser.getBotToken())
? ministerUser.getBotToken() ? ministerUser.getBotToken()
: deptUser.getBotToken(); : deptUser.getBotToken();
telegramMessageService.sendMessage(botToken, deptUser.getReportIds(), message); telegramMessageService.sendMessage(botToken, deptUser.getReportIds(), message);
} }
// 发送消息给助理
if (!CollUtil.isEmpty(assistants)) {
assistants.forEach(assistant -> {
if (assistant.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
if (message.contains("ky3tg107101")) {
var assistantMsg = message.replace("ky3tg107101", "心食谱\nky3tg107101");
assistantMsg = assistantMsg.replace("ky3tg107105", "信息网\nky3tg107105");
int index = assistantMsg.indexOf("ky3tg107108");
if (index != -1) {
assistantMsg = assistantMsg.substring(0, index + 1);
}
telegramMessageService.sendMessage(assistant.getBotToken(), assistant
.getReportIds(), assistantMsg);
}
}
});
}
}, asyncTaskExecutor).exceptionally(ex -> { }, asyncTaskExecutor).exceptionally(ex -> {
log.error("Error collecting and processing data", ex); log.error("Error collecting and processing data", ex);
return null; return null;