|
@@ -9,13 +9,18 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.qw.param.QwExternalContactVOTime;
|
|
|
+import com.fs.qw.param.QwTagSearchParam;
|
|
|
import com.fs.qw.param.SopExternalContactInfo;
|
|
|
import com.fs.qw.service.IQwExternalContactService;
|
|
|
+import com.fs.qw.service.IQwTagService;
|
|
|
import com.fs.sop.domain.SopUserLogsInfo;
|
|
|
import com.fs.sop.params.BatchSopUserLogsInfoParam;
|
|
|
import com.fs.sop.params.SendUserLogsInfoMsgParam;
|
|
|
import com.fs.sop.service.ISopUserLogsInfoService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonSyntaxException;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -23,6 +28,8 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -41,56 +48,139 @@ public class SopUserLogsInfoController extends BaseController
|
|
|
@Autowired
|
|
|
private IQwExternalContactService iQwExternalContactService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IQwTagService iQwTagService;
|
|
|
+
|
|
|
+ private static final Gson GSON = new Gson();
|
|
|
+
|
|
|
/**
|
|
|
* 查询sopUserLogsInfo列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('qw:sop:list')")
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(SopUserLogsInfo sopUserLogsInfo)
|
|
|
- {
|
|
|
- startPage();
|
|
|
+ {startPage();
|
|
|
List<SopUserLogsInfo> list = sopUserLogsInfoService.selectSopUserLogsInfoList(sopUserLogsInfo);
|
|
|
|
|
|
- if (!list.isEmpty()){
|
|
|
-
|
|
|
- List<Long> externalIdList = list.stream()
|
|
|
- .map(SopUserLogsInfo::getExternalId) // 提取 externalId
|
|
|
- .filter(Objects::nonNull) // 过滤掉 null 值,防止 NullPointerException
|
|
|
- .collect(Collectors.toList()); // 收集到 List
|
|
|
-
|
|
|
- List<QwExternalContactVOTime> qwExternalContactVOTimes = iQwExternalContactService.selectQwExternalContactListVOByIds(externalIdList);
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ // 使用并行流提取externalId
|
|
|
+ List<Long> externalIdList = list.parallelStream()
|
|
|
+ .map(SopUserLogsInfo::getExternalId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
+ 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.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.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);
|
|
|
+// startPage();
|
|
|
+// List<SopUserLogsInfo> list = sopUserLogsInfoService.selectSopUserLogsInfoList(sopUserLogsInfo);
|
|
|
+//
|
|
|
+//
|
|
|
+// if (!list.isEmpty()){
|
|
|
+//
|
|
|
+// List<Long> externalIdList = list.stream()
|
|
|
+// .map(SopUserLogsInfo::getExternalId) // 提取 externalId
|
|
|
+// .filter(Objects::nonNull) // 过滤掉 null 值,防止 NullPointerException
|
|
|
+// .collect(Collectors.toList()); // 收集到 List
|
|
|
+//
|
|
|
+// 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.getTagIds(),item.getRemark())
|
|
|
+// ));
|
|
|
+//
|
|
|
+// // 遍历 list,赋值 inComTime 和 tagIds
|
|
|
+// list.forEach(item -> {
|
|
|
+// SopExternalContactInfo info = externalContactInfoMap.getOrDefault(item.getExternalId(), new SopExternalContactInfo("无进线时间", "无标签","无备注"));
|
|
|
+// item.setInComTime(info.getCreateTime());
|
|
|
+// item.setTagIds(info.getTagIds());
|
|
|
+// item.setRemark(info.getRemark());
|
|
|
+// });
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// if ((sopUserLogsInfo.getTagIds() != null && !sopUserLogsInfo.getTagIds().isEmpty())
|
|
|
+// || !StringUtil.strIsNullOrEmpty(sopUserLogsInfo.getRemark())) {
|
|
|
+// 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()))
|
|
|
+// )
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// list.forEach(item->{
|
|
|
+//
|
|
|
+// if (!Objects.equals(item.getTagIds(), "[]") && !Objects.equals(item.getTagIds(), "无标签") && item.getTagIds()!=null) {
|
|
|
+// QwTagSearchParam param = new QwTagSearchParam();
|
|
|
+// Gson gson = new Gson();
|
|
|
+// List<String> tagIds = gson.fromJson(
|
|
|
+// item.getTagIds(),
|
|
|
+// new TypeToken<List<String>>() {
|
|
|
+// }.getType()
|
|
|
+// );
|
|
|
+//
|
|
|
+// param.setTagIds(tagIds);
|
|
|
+//
|
|
|
+// item.setTagIdsName(iQwTagService.selectQwTagListByTagIds(param));
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// /**
|
|
|
// * 导出sopUserLogsInfo列表
|
|
|
// */
|