|
@@ -12,6 +12,7 @@ import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.vo.QuestionIds2VO;
|
|
|
import com.diagbot.vo.QuestionNameVO;
|
|
|
+import com.diagbot.vo.QuestionNamesVO;
|
|
|
import com.diagbot.vo.QuestionVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -19,7 +20,9 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.LinkedHashMap;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -123,6 +126,8 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
|
|
|
questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
.in(ListUtil.isNotEmpty(sexTypeList), "sex_type", sexTypeList)
|
|
|
.apply("({0} between age_begin and age_end)", questionNameVO.getAge())
|
|
|
+ .eq("type", questionNameVO.getType())
|
|
|
+ .eq("tag_type", 4)
|
|
|
.eq("tag_name", questionNameVO.getName());
|
|
|
QuestionInfo questionInfo = this.getOne(questionInfoQueryWrapper);
|
|
|
if (questionInfo != null) {
|
|
@@ -137,6 +142,59 @@ public class QuestionFacade extends QuestionInfoServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据名称批量获取标签
|
|
|
+ *
|
|
|
+ * @param questionNamesVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> getByNames(QuestionNamesVO questionNamesVO) {
|
|
|
+ Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
+ QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ List<Integer> sexTypeList = Lists.newArrayList();
|
|
|
+ sexTypeList.add(questionNamesVO.getSexType());
|
|
|
+ if (!questionNamesVO.getSexType().equals(3)) {
|
|
|
+ sexTypeList.add(3);
|
|
|
+ }
|
|
|
+ questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in(ListUtil.isNotEmpty(sexTypeList), "sex_type", sexTypeList)
|
|
|
+ .apply("({0} between age_begin and age_end)", questionNamesVO.getAge())
|
|
|
+ .eq("type", questionNamesVO.getType())
|
|
|
+ .eq("tag_type", 4)
|
|
|
+ .in(ListUtil.isNotEmpty(questionNamesVO.getNames()), "tag_name", questionNamesVO.getNames());
|
|
|
+ List<QuestionInfo> questionInfoList = this.list(questionInfoQueryWrapper);
|
|
|
+
|
|
|
+ //同名的只保留第一个
|
|
|
+ Map<String, Long> nameMap = new LinkedHashMap<>();
|
|
|
+ Iterator<QuestionInfo> iterator = questionInfoList.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ QuestionInfo next = iterator.next();
|
|
|
+ if (nameMap.containsKey(next.getTagName())) {
|
|
|
+ iterator.remove();
|
|
|
+ } else {
|
|
|
+ nameMap.put(next.getTagName(), next.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null == nameMap) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ QuestionIds2VO questionIds2VO = new QuestionIds2VO();
|
|
|
+ questionIds2VO.setIds(new LinkedList<>(nameMap.values()));
|
|
|
+ questionIds2VO.setSexType(questionNamesVO.getSexType());
|
|
|
+ questionIds2VO.setAge(questionNamesVO.getAge());
|
|
|
+
|
|
|
+ Map<Long, Object> questionMap = this.getByIds(questionIds2VO);
|
|
|
+
|
|
|
+ if (questionMap != null) {
|
|
|
+ nameMap.entrySet().forEach(entry -> {
|
|
|
+ if (questionMap.containsKey(entry.getValue())) {
|
|
|
+ retMap.put(entry.getKey(), questionMap.get(entry.getValue()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询多个id返回标签内容
|