|
@@ -3,6 +3,7 @@ package com.fs.hisStore.service.impl;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
@@ -1415,7 +1416,36 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
return false; // 默认返回 false
|
|
return false; // 默认返回 false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private List<AnswerVO> getAnswerVOs(List<AnswerVO> target,List<AnswerVO> source) {
|
|
|
|
|
|
|
+ private List<AnswerVO> getAnswerVOs(List<AnswerVO> target, List<AnswerVO> source) {
|
|
|
|
|
+ // 1. 先对 target 中的每个 AnswerVO,从 source 中按 title 找到对应的模板,补充 options 的 open 字段
|
|
|
|
|
+ if (target != null && source != null) {
|
|
|
|
|
+ // 构建 source 的 title -> AnswerVO 映射
|
|
|
|
|
+ Map<String, AnswerVO> sourceMap = source.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(AnswerVO::getTitle, Function.identity(), (a, b) -> a));
|
|
|
|
|
+
|
|
|
|
|
+ for (AnswerVO targetAnswer : target) {
|
|
|
|
|
+ AnswerVO sourceAnswer = sourceMap.get(targetAnswer.getTitle());
|
|
|
|
|
+ if (sourceAnswer != null) {
|
|
|
|
|
+ // 构建 source 中 options 的 value -> open 映射
|
|
|
|
|
+ Map<Integer, Boolean> openMap = sourceAnswer.getOptions().stream()
|
|
|
|
|
+ .collect(Collectors.toMap(AnswerVO.Options::getValue, AnswerVO.Options::isOpen, (a, b) -> a));
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历 target 的 options,设置 open 字段
|
|
|
|
|
+ if (targetAnswer.getOptions() != null) {
|
|
|
|
|
+ for (AnswerVO.Options opt : targetAnswer.getOptions()) {
|
|
|
|
|
+ Boolean open = openMap.get(opt.getValue());
|
|
|
|
|
+ if (open != null) {
|
|
|
|
|
+ opt.setOpen(open);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ opt.setOpen(false); // 默认 false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 合并列表并去重(保留第一个出现的,即 target 中补全后的数据优先)
|
|
|
target.addAll(source);
|
|
target.addAll(source);
|
|
|
return target.stream()
|
|
return target.stream()
|
|
|
.collect(Collectors.groupingBy(AnswerVO::getTitle))
|
|
.collect(Collectors.groupingBy(AnswerVO::getTitle))
|
|
@@ -1423,6 +1453,15 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
.map(group -> group.stream().reduce((a, b) -> a).orElse(null))
|
|
.map(group -> group.stream().reduce((a, b) -> a).orElse(null))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
+ //这个是备份方法
|
|
|
|
|
+// private List<AnswerVO> getAnswerVOs(List<AnswerVO> target,List<AnswerVO> source) {
|
|
|
|
|
+// target.addAll(source);
|
|
|
|
|
+// return target.stream()
|
|
|
|
|
+// .collect(Collectors.groupingBy(AnswerVO::getTitle))
|
|
|
|
|
+// .values().stream()
|
|
|
|
|
+// .map(group -> group.stream().reduce((a, b) -> a).orElse(null))
|
|
|
|
|
+// .collect(Collectors.toList());
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 辅助方法:组装信息采集对象
|
|
* 辅助方法:组装信息采集对象
|