修复存款失败用户不能正常发送消息的问题
This commit is contained in:
parent
8326e316fb
commit
daa6b29579
@ -89,12 +89,12 @@ public class DailyReport {
|
|||||||
deptWithUsersAndAccounts.forEach(dept -> {
|
deptWithUsersAndAccounts.forEach(dept -> {
|
||||||
//根据用户角色对部门用户进行分组
|
//根据用户角色对部门用户进行分组
|
||||||
Map<String, List<UserWithRolesAndAccountsResp>> usersByRole = dept.getUsers()
|
Map<String, List<UserWithRolesAndAccountsResp>> usersByRole = dept.getUsers()
|
||||||
|
.stream()
|
||||||
|
.flatMap(user -> user.getRoles()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(user -> user.getRoles()
|
.map(role -> new AbstractMap.SimpleEntry<>(role.getCode(), user)))
|
||||||
.stream()
|
.collect(Collectors.groupingByConcurrent(Map.Entry::getKey, Collectors
|
||||||
.map(role -> new AbstractMap.SimpleEntry<>(role.getCode(), user)))
|
.mapping(Map.Entry::getValue, Collectors.toList())));
|
||||||
.collect(Collectors.groupingByConcurrent(Map.Entry::getKey, Collectors
|
|
||||||
.mapping(Map.Entry::getValue, Collectors.toList())));
|
|
||||||
|
|
||||||
var ministerUser = usersByRole.get(MINISTER_ROLE_CODE).get(0);
|
var ministerUser = usersByRole.get(MINISTER_ROLE_CODE).get(0);
|
||||||
//获取账号不为空的用户
|
//获取账号不为空的用户
|
||||||
@ -114,19 +114,19 @@ public class DailyReport {
|
|||||||
deptWithUsersAndAccounts.forEach(dept -> {
|
deptWithUsersAndAccounts.forEach(dept -> {
|
||||||
//根据用户角色对部门用户进行分组
|
//根据用户角色对部门用户进行分组
|
||||||
Map<String, List<UserWithRolesAndAccountsResp>> usersByRole = dept.getUsers()
|
Map<String, List<UserWithRolesAndAccountsResp>> usersByRole = dept.getUsers()
|
||||||
|
.stream()
|
||||||
|
.flatMap(user -> user.getRoles()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(user -> user.getRoles()
|
.map(role -> new AbstractMap.SimpleEntry<>(role.getCode(), user)))
|
||||||
.stream()
|
.collect(Collectors.groupingByConcurrent(Map.Entry::getKey, Collectors
|
||||||
.map(role -> new AbstractMap.SimpleEntry<>(role.getCode(), user)))
|
.mapping(Map.Entry::getValue, Collectors.toList())));
|
||||||
.collect(Collectors.groupingByConcurrent(Map.Entry::getKey, Collectors
|
|
||||||
.mapping(Map.Entry::getValue, Collectors.toList())));
|
|
||||||
// 获取所有账号的username与用户的映射
|
// 获取所有账号的username与用户的映射
|
||||||
Map<String, UserWithRolesAndAccountsResp> accountUsernameToUserMap = dept.getUsers()
|
Map<String, UserWithRolesAndAccountsResp> accountUsernameToUserMap = dept.getUsers()
|
||||||
|
.stream()
|
||||||
|
.flatMap(user -> user.getAccounts()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(user -> user.getAccounts()
|
.map(account -> new AbstractMap.SimpleEntry<>(account.getUsername(), user)))
|
||||||
.stream()
|
.collect(Collectors.toConcurrentMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
.map(account -> new AbstractMap.SimpleEntry<>(account.getUsername(), user)))
|
|
||||||
.collect(Collectors.toConcurrentMap(Map.Entry::getKey, Map.Entry::getValue));
|
|
||||||
|
|
||||||
var ministerUser = usersByRole.get(MINISTER_ROLE_CODE).get(0);
|
var ministerUser = usersByRole.get(MINISTER_ROLE_CODE).get(0);
|
||||||
//获取账号不为空的用户
|
//获取账号不为空的用户
|
||||||
@ -151,16 +151,16 @@ public class DailyReport {
|
|||||||
deptWithUsersAndAccounts.forEach(dept -> {
|
deptWithUsersAndAccounts.forEach(dept -> {
|
||||||
//根据用户角色对部门用户进行分组
|
//根据用户角色对部门用户进行分组
|
||||||
Map<String, List<UserWithRolesAndAccountsResp>> usersByRole = dept.getUsers()
|
Map<String, List<UserWithRolesAndAccountsResp>> usersByRole = dept.getUsers()
|
||||||
|
.stream()
|
||||||
|
.flatMap(user -> user.getRoles()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(user -> user.getRoles()
|
.map(role -> new AbstractMap.SimpleEntry<>(role.getCode(), user)))
|
||||||
.stream()
|
.collect(Collectors.groupingByConcurrent(Map.Entry::getKey, Collectors
|
||||||
.map(role -> new AbstractMap.SimpleEntry<>(role.getCode(), user)))
|
.mapping(Map.Entry::getValue, Collectors.toList())));
|
||||||
.collect(Collectors.groupingByConcurrent(Map.Entry::getKey, Collectors
|
|
||||||
.mapping(Map.Entry::getValue, Collectors.toList())));
|
|
||||||
|
|
||||||
var userWithRolesAndAccountsResps = usersByRole.get(MINISTER_ROLE_CODE);
|
var userWithRolesAndAccountsResps = usersByRole.get(MINISTER_ROLE_CODE);
|
||||||
userWithRolesAndAccountsResps.forEach(ministerUser -> generateAndSendTeamReport(ministerUser, nowDate
|
userWithRolesAndAccountsResps.forEach(ministerUser -> generateAndSendTeamReport(ministerUser, nowDate
|
||||||
.atStartOfDay(), nowDateTime, null));
|
.atStartOfDay(), nowDateTime, null));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,76 +174,76 @@ public class DailyReport {
|
|||||||
LocalDate date) {
|
LocalDate date) {
|
||||||
|
|
||||||
TeamMemberReq memberListReq = TeamMemberReq.builder()
|
TeamMemberReq memberListReq = TeamMemberReq.builder()
|
||||||
.registerStartDate(date)
|
.registerStartDate(date)
|
||||||
.registerEndDate(date)
|
.registerEndDate(date)
|
||||||
.startDate(date)
|
.startDate(date)
|
||||||
.endDate(date)
|
.endDate(date)
|
||||||
.registerSort(1)
|
.registerSort(1)
|
||||||
.status(1)
|
.status(1)
|
||||||
.pageSize(100)
|
.pageSize(100)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<CompletableFuture<List<TeamMember>>> futureList = new ArrayList<>();
|
List<CompletableFuture<List<TeamMember>>> futureList = new ArrayList<>();
|
||||||
ministerUser.getAccounts().forEach(account -> {
|
ministerUser.getAccounts().forEach(account -> {
|
||||||
CompletableFuture<MemberPagination<List<TeamMember>>> memberPaginationCompletableFuture = completableFutureWebClientService
|
CompletableFuture<MemberPagination<List<TeamMember>>> memberPaginationCompletableFuture = completableFutureWebClientService
|
||||||
.fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() {
|
.fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
CompletableFuture<List<TeamMember>> teamMembersFuture = memberPaginationCompletableFuture
|
CompletableFuture<List<TeamMember>> teamMembersFuture = memberPaginationCompletableFuture
|
||||||
.thenApply(MemberPagination::getList)
|
.thenApply(MemberPagination::getList)
|
||||||
.thenApplyAsync(members -> members.stream()
|
.thenApplyAsync(members -> members.stream()
|
||||||
.filter(member -> member.getDeposit() != null && member.getDeposit()
|
.filter(member -> member.getDeposit() != null && member.getDeposit()
|
||||||
.compareTo(BigDecimal.ZERO) == 0)
|
.compareTo(BigDecimal.ZERO) == 0)
|
||||||
.collect(Collectors.toList()), asyncTaskExecutor)
|
.collect(Collectors.toList()), asyncTaskExecutor)
|
||||||
.thenComposeAsync(membersWithoutDep -> {
|
.thenComposeAsync(membersWithoutDep -> {
|
||||||
List<CompletableFuture<TeamMember>> memberFutures = membersWithoutDep.stream()
|
List<CompletableFuture<TeamMember>> memberFutures = membersWithoutDep.stream()
|
||||||
.map(memberWithoutDep -> {
|
.map(memberWithoutDep -> {
|
||||||
PayRecordListReq req = PayRecordListReq.builder()
|
PayRecordListReq req = PayRecordListReq.builder()
|
||||||
.startDate(date)
|
.startDate(date)
|
||||||
.endDate(date)
|
.endDate(date)
|
||||||
.pageSize(100)
|
.pageSize(100)
|
||||||
.id(memberWithoutDep.getId())
|
.id(memberWithoutDep.getId())
|
||||||
.build();
|
.build();
|
||||||
CompletableFuture<PayRecordList<List<PayRecord>>> completableFuture = completableFutureWebClientService
|
CompletableFuture<PayRecordList<List<PayRecord>>> completableFuture = completableFutureWebClientService
|
||||||
.fetchDataForAccount(account, ApiPathConstants.PAY_RECORD_LIST_URL, req, new ParameterizedTypeReference<>() {
|
.fetchDataForAccount(account, ApiPathConstants.PAY_RECORD_LIST_URL, req, new ParameterizedTypeReference<>() {
|
||||||
});
|
});
|
||||||
return completableFuture.thenApplyAsync(pagination -> {
|
return completableFuture.thenApplyAsync(pagination -> {
|
||||||
if (pagination.getOrderAmountTotal().compareTo(BigDecimal.ZERO) > 0 && pagination
|
if (pagination.getOrderAmountTotal().compareTo(BigDecimal.ZERO) > 0 && pagination
|
||||||
.getScoreAmountTotal()
|
.getScoreAmountTotal()
|
||||||
.compareTo(BigDecimal.ZERO) == 0) {
|
.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
return memberWithoutDep;
|
return memberWithoutDep;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
}, asyncTaskExecutor);
|
|
||||||
})
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
return CompletableFuture.allOf(memberFutures.toArray(new CompletableFuture[0]))
|
|
||||||
.thenApply(v -> memberFutures.stream()
|
|
||||||
.map(CompletableFuture::join)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}, asyncTaskExecutor)
|
|
||||||
.thenApplyAsync(membersWithoutDep -> {
|
|
||||||
// 发送给每个account关联的user用户
|
|
||||||
if (!membersWithoutDep.isEmpty()) {
|
|
||||||
Map<String, List<TeamMember>> groupByTopAgentName = membersWithoutDep.stream()
|
|
||||||
.collect(Collectors.groupingBy(TeamMember::getTopAgentName));
|
|
||||||
groupByTopAgentName.forEach((accountName, accountMembers) -> {
|
|
||||||
String notification = telegramMessageService
|
|
||||||
.buildFailedPayMessage(accountName, accountMembers);
|
|
||||||
UserWithRolesAndAccountsResp currUser = accountUsernameToUserMap.get(accountName);
|
|
||||||
if (currUser != null && DisEnableStatusEnum.ENABLE.equals(currUser.getNeedNotify())) {
|
|
||||||
String botToken = StrUtil.isEmpty(currUser.getBotToken())
|
|
||||||
? ministerUser.getBotToken()
|
|
||||||
: currUser.getBotToken();
|
|
||||||
telegramMessageService.sendMessage(botToken, currUser.getRegAndDepIds(), notification);
|
|
||||||
}
|
}
|
||||||
});
|
}, asyncTaskExecutor);
|
||||||
}
|
})
|
||||||
return membersWithoutDep;
|
.toList();
|
||||||
}, asyncTaskExecutor);
|
|
||||||
|
return CompletableFuture.allOf(memberFutures.toArray(new CompletableFuture[0]))
|
||||||
|
.thenApply(v -> memberFutures.stream()
|
||||||
|
.map(CompletableFuture::join)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}, asyncTaskExecutor)
|
||||||
|
.thenApplyAsync(membersWithoutDep -> {
|
||||||
|
// 发送给每个account关联的user用户
|
||||||
|
if (!membersWithoutDep.isEmpty()) {
|
||||||
|
Map<String, List<TeamMember>> groupByTopAgentName = membersWithoutDep.stream()
|
||||||
|
.collect(Collectors.groupingBy(TeamMember::getTopAgentName));
|
||||||
|
groupByTopAgentName.forEach((accountName, accountMembers) -> {
|
||||||
|
String notification = telegramMessageService
|
||||||
|
.buildFailedPayMessage(accountName, accountMembers);
|
||||||
|
UserWithRolesAndAccountsResp currUser = accountUsernameToUserMap.get(accountName);
|
||||||
|
if (currUser != null && DisEnableStatusEnum.ENABLE.equals(currUser.getNeedNotify())) {
|
||||||
|
String botToken = StrUtil.isEmpty(currUser.getBotToken())
|
||||||
|
? ministerUser.getBotToken()
|
||||||
|
: currUser.getBotToken();
|
||||||
|
telegramMessageService.sendMessage(botToken, currUser.getRegAndDepIds(), notification);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return membersWithoutDep;
|
||||||
|
}, asyncTaskExecutor);
|
||||||
|
|
||||||
futureList.add(teamMembersFuture);
|
futureList.add(teamMembersFuture);
|
||||||
});
|
});
|
||||||
@ -252,22 +252,22 @@ public class DailyReport {
|
|||||||
allFutures.thenRunAsync(() -> {
|
allFutures.thenRunAsync(() -> {
|
||||||
// 主线下的所有的存款失败用户
|
// 主线下的所有的存款失败用户
|
||||||
List<TeamMember> allTeamMembers = futureList.stream()
|
List<TeamMember> allTeamMembers = futureList.stream()
|
||||||
.map(CompletableFuture::join)
|
.map(CompletableFuture::join)
|
||||||
.flatMap(List::stream)
|
.flatMap(List::stream)
|
||||||
.toList();
|
.toList();
|
||||||
Map<String, List<TeamMember>> groupByTopAgentName = new TreeMap<>(allTeamMembers.stream()
|
Map<String, List<TeamMember>> groupByTopAgentName = new TreeMap<>(allTeamMembers.stream()
|
||||||
.collect(Collectors.groupingBy(TeamMember::getTopAgentName)));
|
.collect(Collectors.groupingBy(TeamMember::getTopAgentName)));
|
||||||
StringBuilder combinedNotification = new StringBuilder();
|
StringBuilder combinedNotification = new StringBuilder();
|
||||||
groupByTopAgentName.forEach((accountName, accountMembers) -> {
|
groupByTopAgentName.forEach((accountName, accountMembers) -> {
|
||||||
String notification = telegramMessageService.buildFailedPayMessage(accountName, accountMembers);
|
String notification = telegramMessageService.buildFailedPayMessage(accountName, accountMembers);
|
||||||
combinedNotification.append(notification).append("\n");
|
combinedNotification.append(notification).append("\n");
|
||||||
});
|
});
|
||||||
telegramMessageService
|
telegramMessageService
|
||||||
.sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, combinedNotification
|
.sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, combinedNotification
|
||||||
.toString());
|
.toString());
|
||||||
if (DisEnableStatusEnum.ENABLE.equals(ministerUser.getNeedNotify())) {
|
if (DisEnableStatusEnum.ENABLE.equals(ministerUser.getNeedNotify())) {
|
||||||
telegramMessageService.sendMessage(ministerUser.getBotToken(), ministerUser
|
telegramMessageService.sendMessage(ministerUser.getBotToken(), ministerUser
|
||||||
.getReportIds(), combinedNotification.toString());
|
.getReportIds(), combinedNotification.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}, asyncTaskExecutor).exceptionally(ex -> {
|
}, asyncTaskExecutor).exceptionally(ex -> {
|
||||||
@ -290,7 +290,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, 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();
|
||||||
@ -317,32 +317,32 @@ public class DailyReport {
|
|||||||
TeamInfoReq teamInfoReq = TeamInfoReq.builder().startDate(startDateTime).endDate(endDateTime).build();
|
TeamInfoReq teamInfoReq = TeamInfoReq.builder().startDate(startDateTime).endDate(endDateTime).build();
|
||||||
|
|
||||||
List<CompletableFuture<Void>> futures = accounts.stream()
|
List<CompletableFuture<Void>> futures = accounts.stream()
|
||||||
.map(accountResp -> teamService.getLatestTeamInfoAsync(accountResp, teamInfoReq)
|
.map(accountResp -> teamService.getLatestTeamInfoAsync(accountResp, teamInfoReq)
|
||||||
.thenAcceptAsync(team -> {
|
.thenAcceptAsync(team -> {
|
||||||
int totalNewMember = team.getList().stream().mapToInt(TeamAccount::getSubMemberNum).sum();
|
int totalNewMember = team.getList().stream().mapToInt(TeamAccount::getSubMemberNum).sum();
|
||||||
int totalNewFirstDeposit = team.getList()
|
int totalNewFirstDeposit = team.getList()
|
||||||
.stream()
|
.stream()
|
||||||
.mapToInt(TeamAccount::getFirstDepositNum)
|
.mapToInt(TeamAccount::getFirstDepositNum)
|
||||||
.sum();
|
.sum();
|
||||||
synchronized (totals) {
|
synchronized (totals) {
|
||||||
totals[0] += totalNewMember;
|
totals[0] += totalNewMember;
|
||||||
totals[1] += totalNewFirstDeposit;
|
totals[1] += totalNewFirstDeposit;
|
||||||
}
|
}
|
||||||
String percent = getPercent(totalNewFirstDeposit, totalNewMember);
|
String percent = getPercent(totalNewFirstDeposit, totalNewMember);
|
||||||
synchronized (rows) {
|
synchronized (rows) {
|
||||||
rows.add(new String[]{accountResp.getPlatformName(), String.valueOf(totalNewMember), String
|
rows.add(new String[] {accountResp.getPlatformName(), String.valueOf(totalNewMember), String
|
||||||
.valueOf(totalNewFirstDeposit), percent});
|
.valueOf(totalNewFirstDeposit), percent});
|
||||||
}
|
}
|
||||||
}, asyncTaskExecutor))
|
}, asyncTaskExecutor))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
CompletableFuture<Void> allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
CompletableFuture<Void> allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||||
allFutures.join();
|
allFutures.join();
|
||||||
// 对 rows 列表进行排序
|
// 对 rows 列表进行排序
|
||||||
rows.sort(Comparator.comparing((String[] row) -> row[0].length()).thenComparing(row -> row[0]));
|
rows.sort(Comparator.comparing((String[] row) -> row[0].length()).thenComparing(row -> row[0]));
|
||||||
|
|
||||||
rows.add(new String[]{"总计", String.valueOf(totals[0]), String.valueOf(totals[1]),
|
rows.add(new String[] {"总计", String.valueOf(totals[0]), String.valueOf(totals[1]),
|
||||||
getPercent(totals[1], totals[0])});
|
getPercent(totals[1], totals[0])});
|
||||||
String message = TableFormatter.formatTableAsHtml(rows);
|
String message = TableFormatter.formatTableAsHtml(rows);
|
||||||
if (ministerUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
|
if (ministerUser.getNeedNotify() == DisEnableStatusEnum.ENABLE) {
|
||||||
telegramMessageService.sendMessage(ministerUser.getBotToken(), ministerUser.getReportIds(), message);
|
telegramMessageService.sendMessage(ministerUser.getBotToken(), ministerUser.getReportIds(), message);
|
||||||
@ -379,21 +379,21 @@ public class DailyReport {
|
|||||||
List<AccountResp> currUserAccounts = deptUser.getAccounts();
|
List<AccountResp> currUserAccounts = deptUser.getAccounts();
|
||||||
|
|
||||||
List<CompletableFuture<Statics>> futures = currUserAccounts.stream()
|
List<CompletableFuture<Statics>> futures = currUserAccounts.stream()
|
||||||
.map(currAccount -> agentDataVisualListService
|
.map(currAccount -> agentDataVisualListService
|
||||||
.getAgentDataVisualList(currAccount, agentDataVisualListReq)
|
.getAgentDataVisualList(currAccount, agentDataVisualListReq)
|
||||||
.thenApplyAsync(agentData -> agentData.getCurData()
|
.thenApplyAsync(agentData -> agentData.getCurData()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(data -> data.getStaticsDate().equals(reportDate))
|
.filter(data -> data.getStaticsDate().equals(reportDate))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow(() -> new BusinessException("No data found for report date")))
|
.orElseThrow(() -> new BusinessException("No data found for report date")))
|
||||||
.exceptionally(ex -> {
|
.exceptionally(ex -> {
|
||||||
log.error("Error fetching data for account {}: {}", currAccount.getId(), ex.getMessage());
|
log.error("Error fetching data for account {}: {}", currAccount.getId(), ex.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}))
|
}))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
CompletableFuture<Void> userStaticsFuture = CompletableFuture.allOf(futures
|
CompletableFuture<Void> userStaticsFuture = CompletableFuture.allOf(futures
|
||||||
.toArray(new CompletableFuture[0]));
|
.toArray(new CompletableFuture[0]));
|
||||||
userStaticsFuture.thenRunAsync(() -> {
|
userStaticsFuture.thenRunAsync(() -> {
|
||||||
List<Statics> agentDataList = futures.stream().map(future -> {
|
List<Statics> agentDataList = futures.stream().map(future -> {
|
||||||
try {
|
try {
|
||||||
@ -409,8 +409,8 @@ public class DailyReport {
|
|||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}, asyncTaskExecutor).exceptionally(ex -> {
|
}, asyncTaskExecutor).exceptionally(ex -> {
|
||||||
@ -437,33 +437,33 @@ public class DailyReport {
|
|||||||
List<CompletableFuture<Void>> tasks = new ArrayList<>();
|
List<CompletableFuture<Void>> tasks = new ArrayList<>();
|
||||||
|
|
||||||
TeamFinanceReq teamFinanceReq = TeamFinanceReq.builder()
|
TeamFinanceReq teamFinanceReq = TeamFinanceReq.builder()
|
||||||
.pageNum(1)
|
.pageNum(1)
|
||||||
.pageSize(999)
|
.pageSize(999)
|
||||||
.commissionDate(reportDate)
|
.commissionDate(reportDate)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 异步处理 ministerUserAccounts
|
// 异步处理 ministerUserAccounts
|
||||||
CompletableFuture<Void> ministerAccountsFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> ministerAccountsFuture = CompletableFuture.runAsync(() -> {
|
||||||
List<CompletableFuture<Void>> accountFutures = ministerUser.getAccounts()
|
List<CompletableFuture<Void>> accountFutures = ministerUser.getAccounts()
|
||||||
.stream()
|
.stream()
|
||||||
.map(accountResp -> completableFutureFinanceService.getTeamFinance(accountResp, teamFinanceReq)
|
.map(accountResp -> completableFutureFinanceService.getTeamFinance(accountResp, teamFinanceReq)
|
||||||
.thenAcceptAsync(financePagination -> {
|
.thenAcceptAsync(financePagination -> {
|
||||||
List<FinanceDO> financeReqList = financePagination.getList().stream().map(finance -> {
|
List<FinanceDO> financeReqList = financePagination.getList().stream().map(finance -> {
|
||||||
FinanceDO financeDO = new FinanceDO();
|
FinanceDO financeDO = new FinanceDO();
|
||||||
BeanUtil.copyProperties(finance, financeDO);
|
BeanUtil.copyProperties(finance, financeDO);
|
||||||
return financeDO;
|
return financeDO;
|
||||||
}).toList();
|
}).toList();
|
||||||
financeService.addAll(financeReqList);
|
financeService.addAll(financeReqList);
|
||||||
FinanceSumReq financeSumReq = new FinanceSumReq();
|
FinanceSumReq financeSumReq = new FinanceSumReq();
|
||||||
BeanUtil.copyProperties(financePagination.getTotalSumVo(), financeSumReq);
|
BeanUtil.copyProperties(financePagination.getTotalSumVo(), financeSumReq);
|
||||||
financeSumService.add(financeSumReq);
|
financeSumService.add(financeSumReq);
|
||||||
}, asyncTaskExecutor)
|
}, asyncTaskExecutor)
|
||||||
.exceptionally(ex -> {
|
.exceptionally(ex -> {
|
||||||
log.error("Error processing minister accounts for account {}", accountResp
|
log.error("Error processing minister accounts for account {}", accountResp
|
||||||
.getUsername(), ex);
|
.getUsername(), ex);
|
||||||
return null;
|
return null;
|
||||||
}))
|
}))
|
||||||
.toList();
|
.toList();
|
||||||
CompletableFuture.allOf(accountFutures.toArray(new CompletableFuture[0])).join();
|
CompletableFuture.allOf(accountFutures.toArray(new CompletableFuture[0])).join();
|
||||||
}, asyncTaskExecutor).exceptionally(ex -> {
|
}, asyncTaskExecutor).exceptionally(ex -> {
|
||||||
log.error("Error processing minister accounts", ex);
|
log.error("Error processing minister accounts", ex);
|
||||||
@ -473,36 +473,36 @@ public class DailyReport {
|
|||||||
|
|
||||||
// 异步处理 deptUsers
|
// 异步处理 deptUsers
|
||||||
AgentDataVisualListReq agentDataVisualListReq = AgentDataVisualListReq.builder()
|
AgentDataVisualListReq agentDataVisualListReq = AgentDataVisualListReq.builder()
|
||||||
.monthDate(reportDate)
|
.monthDate(reportDate)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
deptUsers.forEach(deptUser -> {
|
deptUsers.forEach(deptUser -> {
|
||||||
CompletableFuture<Void> deptUserFuture = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> deptUserFuture = CompletableFuture.runAsync(() -> {
|
||||||
List<AccountResp> currUserAccounts = deptUser.getAccounts();
|
List<AccountResp> currUserAccounts = deptUser.getAccounts();
|
||||||
List<CompletableFuture<StatsDO>> futures = currUserAccounts.stream()
|
List<CompletableFuture<StatsDO>> futures = currUserAccounts.stream()
|
||||||
.map(currAccount -> agentDataVisualListService
|
.map(currAccount -> agentDataVisualListService
|
||||||
.getAgentDataVisualList(currAccount, agentDataVisualListReq)
|
.getAgentDataVisualList(currAccount, agentDataVisualListReq)
|
||||||
.thenApplyAsync(agentData -> {
|
.thenApplyAsync(agentData -> {
|
||||||
Statics statics = agentData.getCurData()
|
Statics statics = agentData.getCurData()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(data -> data.getStaticsDate().equals(reportDate))
|
.filter(data -> data.getStaticsDate().equals(reportDate))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow(() -> new BusinessException("No data found for report date"));
|
.orElseThrow(() -> new BusinessException("No data found for report date"));
|
||||||
StatsDO statsDO = new StatsDO();
|
StatsDO statsDO = new StatsDO();
|
||||||
BeanUtil.copyProperties(statics, statsDO);
|
BeanUtil.copyProperties(statics, statsDO);
|
||||||
return statsDO;
|
return statsDO;
|
||||||
}, asyncTaskExecutor)
|
}, asyncTaskExecutor)
|
||||||
.exceptionally(ex -> {
|
.exceptionally(ex -> {
|
||||||
log.error("Error fetching data for account {}: {}", currAccount.getId(), ex
|
log.error("Error fetching data for account {}: {}", currAccount.getId(), ex
|
||||||
.getMessage());
|
.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}))
|
}))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
List<StatsDO> list = futures.stream()
|
List<StatsDO> list = futures.stream()
|
||||||
.map(CompletableFuture::join)
|
.map(CompletableFuture::join)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
statsService.addAll(list);
|
statsService.addAll(list);
|
||||||
}, asyncTaskExecutor).exceptionally(ex -> {
|
}, asyncTaskExecutor).exceptionally(ex -> {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.zayac.admin.webapi.system;
|
package com.zayac.admin.webapi.system;
|
||||||
|
|
||||||
import cn.hutool.core.util.ReUtil;
|
|
||||||
import com.xkcoding.justauth.AuthRequestFactory;
|
import com.xkcoding.justauth.AuthRequestFactory;
|
||||||
import com.zayac.admin.system.model.entity.UserSocialDO;
|
import com.zayac.admin.system.model.entity.UserSocialDO;
|
||||||
import com.zayac.admin.system.model.req.UserBasicInfoUpdateReq;
|
import com.zayac.admin.system.model.req.UserBasicInfoUpdateReq;
|
||||||
@ -41,7 +40,6 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.zayac.admin.common.constant.CacheConstants;
|
import com.zayac.admin.common.constant.CacheConstants;
|
||||||
import com.zayac.admin.common.constant.RegexConstants;
|
|
||||||
import com.zayac.admin.common.enums.SocialSourceEnum;
|
import com.zayac.admin.common.enums.SocialSourceEnum;
|
||||||
import com.zayac.admin.common.util.SecureUtils;
|
import com.zayac.admin.common.util.SecureUtils;
|
||||||
import com.zayac.admin.common.util.helper.LoginHelper;
|
import com.zayac.admin.common.util.helper.LoginHelper;
|
||||||
|
Loading…
Reference in New Issue
Block a user