|
@@ -54,6 +54,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.*;
|
|
|
import java.util.function.Function;
|
|
|
+import java.util.stream.Collector;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -744,12 +745,44 @@ public class QwSopLogsServiceImpl implements IQwSopLogsService
|
|
|
List<QwSopLogsDoSendListTVO> logsByJsApi = qwSopLogsMapper.getQwSopLogsByJsApiAll(param);
|
|
|
|
|
|
|
|
|
+// // 优先返回 sendType == 8 的第一条记录
|
|
|
+// List<QwSopLogsDoSendListTVO> result = logsByJsApi.stream()
|
|
|
+// .filter(log -> log.getSendType() == 8)
|
|
|
+// .findFirst()
|
|
|
+// .map(Collections::singletonList) // 单元素不可变 List
|
|
|
+// .orElse(logsByJsApi); // 如果没有匹配项,返回原列表
|
|
|
// 优先返回 sendType == 8 的第一条记录
|
|
|
List<QwSopLogsDoSendListTVO> result = logsByJsApi.stream()
|
|
|
- .filter(log -> log.getSendType() == 8)
|
|
|
- .findFirst()
|
|
|
- .map(Collections::singletonList) // 单元素不可变 List
|
|
|
- .orElse(logsByJsApi); // 如果没有匹配项,返回原列表
|
|
|
+ .collect(Collector.of(
|
|
|
+ () -> new Object() {
|
|
|
+ QwSopLogsDoSendListTVO type8 = null;
|
|
|
+ List<QwSopLogsDoSendListTVO> type9List = new ArrayList<>();
|
|
|
+ List<QwSopLogsDoSendListTVO> otherList = new ArrayList<>();
|
|
|
+ },
|
|
|
+ (acc, log) -> {
|
|
|
+ if (acc.type8 == null && log.getSendType() == 8) {
|
|
|
+ acc.type8 = log;
|
|
|
+ } else if (acc.type8 == null) {
|
|
|
+ if (log.getSendType() == 9) {
|
|
|
+ acc.type9List.add(log);
|
|
|
+ } else {
|
|
|
+ acc.otherList.add(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (acc1, acc2) -> { throw new UnsupportedOperationException(); },
|
|
|
+ acc -> {
|
|
|
+ if (acc.type8 != null) {
|
|
|
+ return Collections.singletonList(acc.type8);
|
|
|
+ } else if (!acc.type9List.isEmpty()) {
|
|
|
+ List<QwSopLogsDoSendListTVO> combined = new ArrayList<>(acc.type9List.size() + acc.otherList.size());
|
|
|
+ combined.addAll(acc.type9List);
|
|
|
+ combined.addAll(acc.otherList);
|
|
|
+ return combined;
|
|
|
+ }
|
|
|
+ return logsByJsApi;
|
|
|
+ }
|
|
|
+ ));
|
|
|
|
|
|
// 查询员工信息的id
|
|
|
QwUser qwUser = qwExternalContactService.getQwUserByRedis(param.getCorpId().trim(),param.getQwUserId().trim());
|