From b33eac431f8c22cc525468fcc2311b5f49d305f5 Mon Sep 17 00:00:00 2001 From: zayac Date: Sun, 1 Sep 2024 18:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zayac/admin/schedule/DailyReport.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/DailyReport.java b/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/DailyReport.java index a20e3e3d..c8986f75 100644 --- a/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/DailyReport.java +++ b/zayac-admin-agent/src/main/java/com/zayac/admin/schedule/DailyReport.java @@ -450,7 +450,7 @@ public class DailyReport { AgentDataVisualListReq agentDataVisualListReq = AgentDataVisualListReq.builder().monthDate(reportDate).build(); deptUsers.forEach(deptUser -> tasks - .add(processDeptUser(deptUser, ministerUser, agentDataVisualListReq, reportDate))); + .add(processDeptUser(deptUser, ministerUser, assistants, agentDataVisualListReq, reportDate))); CompletableFuture allTasks = CompletableFuture.allOf(tasks.toArray(new CompletableFuture[0])); allTasks.join(); @@ -525,6 +525,8 @@ public class DailyReport { assistants.forEach(assistant -> { if (assistant.getNeedNotify() == DisEnableStatusEnum.ENABLE) { 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()); } }); @@ -546,6 +548,7 @@ public class DailyReport { */ private CompletableFuture processDeptUser(UserWithRolesAndAccountsResp deptUser, UserWithRolesAndAccountsResp ministerUser, + List assistants, AgentDataVisualListReq agentDataVisualListReq, LocalDate reportDate) { return CompletableFuture.runAsync(() -> { @@ -578,16 +581,32 @@ public class DailyReport { return null; } }).filter(Objects::nonNull).collect(Collectors.toList()); - // 构造消息体 String message = telegramMessageService.buildDailyReportMessage(agentDataList); - if (StrUtil.isNotBlank(message) && deptUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) { String botToken = StrUtil.isEmpty(deptUser.getBotToken()) ? ministerUser.getBotToken() : deptUser.getBotToken(); 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 -> { log.error("Error collecting and processing data", ex); return null;