|
@@ -66,46 +66,63 @@ public class SopUserLogsInfoController extends BaseController
|
|
|
public TableDataInfo list(SopUserLogsInfo sopUserLogsInfo) {
|
|
|
startPage();
|
|
|
if (sopUserLogsInfo.getFilterMode() == 1) {
|
|
|
+ startPage();
|
|
|
List<SopUserLogsInfo> list = sopUserLogsInfoService.selectSopUserLogsInfoList(sopUserLogsInfo);
|
|
|
|
|
|
if (!list.isEmpty()) {
|
|
|
+ // 使用并行流提取externalId
|
|
|
+ List<Long> externalIdList = list.parallelStream()
|
|
|
+ .map(SopUserLogsInfo::getExternalId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- List<Long> externalIdList = list.stream()
|
|
|
- .map(SopUserLogsInfo::getExternalId) // 提取 externalId
|
|
|
- .filter(Objects::nonNull) // 过滤掉 null 值,防止 NullPointerException
|
|
|
- .collect(Collectors.toList()); // 收集到 List
|
|
|
-
|
|
|
- List<QwExternalContactVOTime> qwExternalContactVOTimes = iQwExternalContactService.selectQwExternalContactListVOByIds(externalIdList);
|
|
|
-
|
|
|
+ List<QwExternalContactVOTime> qwExternalContactVOTimes =
|
|
|
+ iQwExternalContactService.selectQwExternalContactListVOByIds(externalIdList);
|
|
|
|
|
|
- // 先将 qwExternalContactVOTimes 转换为 Map,key 为 id,value 为 ExternalContactInfo(包含 createTime 和 tagIds)
|
|
|
+ // 构建联系人信息映射
|
|
|
Map<Long, SopExternalContactInfo> externalContactInfoMap = qwExternalContactVOTimes.stream()
|
|
|
.collect(Collectors.toMap(
|
|
|
QwExternalContactVOTime::getId,
|
|
|
- item -> new SopExternalContactInfo(item.getCreateTime(), item.getTagIdsName(), item.getTagIds(), item.getRemark())
|
|
|
+ item -> new SopExternalContactInfo(item.getCreateTime(), item.getTagIds(), item.getRemark())
|
|
|
));
|
|
|
|
|
|
- // 遍历 list,赋值 inComTime 和 tagIds
|
|
|
+ // 设置联系信息
|
|
|
list.forEach(item -> {
|
|
|
- SopExternalContactInfo info = externalContactInfoMap.getOrDefault(item.getExternalId(), new SopExternalContactInfo("无进线时间", "无标签", "无备注"));
|
|
|
+ SopExternalContactInfo info = externalContactInfoMap.getOrDefault(
|
|
|
+ item.getExternalId(),
|
|
|
+ new SopExternalContactInfo("无进线时间", "无标签", "无备注"));
|
|
|
item.setInComTime(info.getCreateTime());
|
|
|
item.setTagIds(info.getTagIds());
|
|
|
- item.setTagNames(info.getTagNames());
|
|
|
item.setRemark(info.getRemark());
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- if ((sopUserLogsInfo.getTagIds() != null && !sopUserLogsInfo.getTagIds().isEmpty())
|
|
|
- || !StringUtil.strIsNullOrEmpty(sopUserLogsInfo.getRemark())) {
|
|
|
+ // 优化过滤条件
|
|
|
+ boolean isRemarkEmpty = StringUtil.strIsNullOrEmpty(sopUserLogsInfo.getRemark());
|
|
|
+ Predicate<SopUserLogsInfo> tagFilter = item ->
|
|
|
+ sopUserLogsInfo.getTagIds() == null ||
|
|
|
+ sopUserLogsInfo.getTagIds().isEmpty() ||
|
|
|
+ item.getTagIds().contains(sopUserLogsInfo.getTagIds());
|
|
|
+
|
|
|
+ Predicate<SopUserLogsInfo> remarkFilter = item ->
|
|
|
+ isRemarkEmpty ||
|
|
|
+ item.getRemark().contains(sopUserLogsInfo.getRemark());
|
|
|
+
|
|
|
+ if (sopUserLogsInfo.getTagIds() != null || !isRemarkEmpty) {
|
|
|
list = list.stream()
|
|
|
- .filter(item ->
|
|
|
- (sopUserLogsInfo.getTagIds() == null || sopUserLogsInfo.getTagIds().isEmpty() || item.getTagIds().contains(sopUserLogsInfo.getTagIds()))
|
|
|
- && (StringUtil.strIsNullOrEmpty(sopUserLogsInfo.getRemark()) || item.getRemark().contains(sopUserLogsInfo.getRemark()))
|
|
|
- )
|
|
|
+ .filter(tagFilter.and(remarkFilter))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ // 处理标签名称
|
|
|
+ list.parallelStream().forEach(item -> {
|
|
|
+ if (item.getTagIds() != null && !item.getTagIds().equals("[]") && !item.getTagIds().equals("无标签")) {
|
|
|
+ List<String> tagIds = GSON.fromJson(item.getTagIds(), new TypeToken<List<String>>() {}.getType());
|
|
|
+ QwTagSearchParam param = new QwTagSearchParam();
|
|
|
+ param.setTagIds(tagIds);
|
|
|
+ item.setTagIdsName(iQwTagService.selectQwTagListByTagIds(param));
|
|
|
+ }
|
|
|
+ });
|
|
|
return getDataTable(list);
|
|
|
} else {
|
|
|
List<QwGroupChatUser> list = qwGroupChatUserService.selectByChatId(sopUserLogsInfo);
|