|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.diagbot.dto.ConceptWithOrderRes;
|
|
|
import com.diagbot.dto.PartDTO;
|
|
|
import com.diagbot.dto.PartSymptomDTO;
|
|
|
+import com.diagbot.entity.Concept;
|
|
|
import com.diagbot.entity.ConceptDetail;
|
|
|
import com.diagbot.entity.Symptom;
|
|
|
import com.diagbot.entity.wrapper.ConceptWrapper;
|
|
@@ -62,99 +63,99 @@ public class PartFacade {
|
|
|
}
|
|
|
List<PartSymptomDTO> res = new ArrayList<>();
|
|
|
|
|
|
+ // 获取部位区域
|
|
|
+ List<Concept> conceptList = conceptFacade.list(new QueryWrapper<Concept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("lib_type", LexiconTypeEnum.PART_AREA.getKey())
|
|
|
+ .in("lib_name", partList)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 设置部位区域
|
|
|
+ for (Concept c : conceptList) {
|
|
|
+ PartSymptomDTO partSymptomDTO = new PartSymptomDTO();
|
|
|
+ partSymptomDTO.setConceptId(c.getId());
|
|
|
+ partSymptomDTO.setName(c.getLibName());
|
|
|
+ res.add(partSymptomDTO);
|
|
|
+ }
|
|
|
+
|
|
|
// 获取部位信息
|
|
|
ConceptWrapper conceptWrapper = new ConceptWrapper();
|
|
|
conceptWrapper.setStartNameList(partList);
|
|
|
- conceptWrapper.setStartType(LexiconTypeEnum.BODYPART.getKey());
|
|
|
+ conceptWrapper.setStartType(LexiconTypeEnum.PART_AREA.getKey());
|
|
|
conceptWrapper.setRelationType(LexiconRSTypeEnum.ORDER_BY.getKey());
|
|
|
conceptWrapper.setEndType(LexiconTypeEnum.BODYPART.getKey());
|
|
|
conceptWrapper.setEndSex(partSymptomVO.getSexType());
|
|
|
conceptWrapper.setEndAge(partSymptomVO.getAge());
|
|
|
List<ConceptWithOrderRes> list = conceptFacade.getConceptWithOrder(conceptWrapper);
|
|
|
- // 设置一级部位
|
|
|
- for (ConceptWithOrderRes concept : list) {
|
|
|
- if (concept.getStartId().equals(concept.getEndId())) { //startId 和 endId相同标识一级部位
|
|
|
- PartSymptomDTO dto = new PartSymptomDTO();
|
|
|
- dto.setName(concept.getStartName());
|
|
|
- dto.setConceptId(concept.getStartId());
|
|
|
- res.add(dto);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // 设置二级部位
|
|
|
- List<String> secPart = new ArrayList<>();
|
|
|
- for (PartSymptomDTO dto : res) {
|
|
|
- List<PartDTO> partDTO = new ArrayList<>();
|
|
|
- for (ConceptWithOrderRes concept : list) {
|
|
|
- if (dto.getName().equals(concept.getStartName())
|
|
|
- && !concept.getStartName().equals(concept.getEndName())) {
|
|
|
- PartDTO dto1 = new PartDTO();
|
|
|
- dto1.setName(concept.getEndName());
|
|
|
- dto1.setConceptId(concept.getEndId());
|
|
|
- secPart.add(concept.getEndName());
|
|
|
- partDTO.add(dto1);
|
|
|
+ Map<Long, List<ConceptWithOrderRes>> partMap = EntityUtil.makeEntityListMap(list, "startId");
|
|
|
+ // 设置部位区域下的部位
|
|
|
+ for (PartSymptomDTO partSymptomDTO : res) {
|
|
|
+ List<ConceptWithOrderRes> part = partMap.get(partSymptomDTO.getConceptId());
|
|
|
+ if (ListUtil.isNotEmpty(part)) {
|
|
|
+ List<PartDTO> partDTOS = new ArrayList<>();
|
|
|
+ for (ConceptWithOrderRes conceptWithOrderRes : part) {
|
|
|
+ PartDTO partDTO = new PartDTO();
|
|
|
+ partDTO.setName(conceptWithOrderRes.getEndName());
|
|
|
+ partDTO.setConceptId(conceptWithOrderRes.getEndId());
|
|
|
+ partDTOS.add(partDTO);
|
|
|
}
|
|
|
+ partSymptomDTO.setPartDTO(partDTOS);
|
|
|
}
|
|
|
- dto.setPartDTO(partDTO);
|
|
|
}
|
|
|
|
|
|
- // 获取二级部位下症状信息
|
|
|
+ // 获取部位下的症状
|
|
|
ConceptWrapper wrapper = new ConceptWrapper();
|
|
|
- wrapper.setStartNameList(secPart);
|
|
|
+ wrapper.setStartNameList(list.stream().map(r -> r.getEndName()).distinct().collect(Collectors.toList()));
|
|
|
wrapper.setStartType(LexiconTypeEnum.BODYPART.getKey());
|
|
|
wrapper.setRelationType(LexiconRSTypeEnum.ORDER_BY.getKey());
|
|
|
wrapper.setEndType(LexiconTypeEnum.SYMPTOM.getKey());
|
|
|
wrapper.setEndSex(partSymptomVO.getSexType());
|
|
|
wrapper.setEndAge(partSymptomVO.getAge());
|
|
|
- List<ConceptWithOrderRes> sympton = conceptFacade.getConceptWithOrder(wrapper);
|
|
|
-
|
|
|
- // 出参转化
|
|
|
- List<Symptom> symptomList = new ArrayList<>();
|
|
|
- for (ConceptWithOrderRes conceptWithOrderRes : sympton) {
|
|
|
- Symptom bean = new Symptom();
|
|
|
- bean.setName(conceptWithOrderRes.getEndName());
|
|
|
- bean.setConceptId(conceptWithOrderRes.getEndId());
|
|
|
- bean.setPartConceptId(conceptWithOrderRes.getStartId());
|
|
|
- symptomList.add(bean);
|
|
|
- }
|
|
|
+ List<ConceptWithOrderRes> symptomList = conceptFacade.getConceptWithOrder(wrapper);
|
|
|
+ Map<Long, List<ConceptWithOrderRes>> symptomMap = EntityUtil.makeEntityListMap(symptomList, "startId");
|
|
|
|
|
|
- // 添加症状的简述信息
|
|
|
+ // 获取症状的简述信息
|
|
|
List<ConceptDetail> conceptDetailList = conceptDetailFacade.list(
|
|
|
new QueryWrapper<ConceptDetail>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("concept_id", symptomList.stream().map(row -> row.getConceptId()).distinct().collect(Collectors.toList()))
|
|
|
+ .in("concept_id", symptomList.stream().map(row -> row.getEndId()).distinct().collect(Collectors.toList()))
|
|
|
.apply("find_in_set({0},position)", 7));
|
|
|
- Map<Long, String> map = conceptDetailList.stream().collect(Collectors.toMap(row->row.getConceptId(), row->row.getText()));
|
|
|
- System.out.println(list);
|
|
|
- for (Symptom symptom : symptomList) {
|
|
|
- if (map.get(symptom.getConceptId()) != null) {
|
|
|
- symptom.setDesc(map.get(symptom.getConceptId()));
|
|
|
- }
|
|
|
- }
|
|
|
+ Map<Long, String> descMap = conceptDetailList.stream().collect(Collectors.toMap(row->row.getConceptId(), row->row.getText()));
|
|
|
|
|
|
- Map<Long, List<Symptom>> keyMap = EntityUtil.makeEntityListMap(symptomList, "partConceptId");
|
|
|
|
|
|
- // 设置二级部位对应的症状
|
|
|
- for (PartSymptomDTO dto : res) {
|
|
|
- for (PartDTO partDTO : dto.getPartDTO()) {
|
|
|
- if (keyMap.get(partDTO.getConceptId()) != null) { // 去除null数据
|
|
|
- partDTO.setSymptomList(keyMap.get(partDTO.getConceptId()));
|
|
|
+ // 设置部位下的症状
|
|
|
+ for (PartSymptomDTO partSymptomDTO : res) {
|
|
|
+ List<PartDTO> partDTOS = partSymptomDTO.getPartDTO();
|
|
|
+ for (PartDTO partDTO : partDTOS) {
|
|
|
+ List<ConceptWithOrderRes> symptom = symptomMap.get(partDTO.getConceptId());
|
|
|
+ if (ListUtil.isNotEmpty(symptom)) {
|
|
|
+ List<Symptom> symptoms = new ArrayList<>();
|
|
|
+ for (ConceptWithOrderRes conceptWithOrderRes : symptom) {
|
|
|
+ Symptom bean = new Symptom();
|
|
|
+ bean.setConceptId(conceptWithOrderRes.getEndId());
|
|
|
+ bean.setName(conceptWithOrderRes.getEndName());
|
|
|
+ bean.setPartConceptId(conceptWithOrderRes.getStartId());
|
|
|
+ if (descMap.get(conceptWithOrderRes.getEndId()) != null) {
|
|
|
+ bean.setDesc(descMap.get(conceptWithOrderRes.getEndId()));
|
|
|
+ }
|
|
|
+ symptoms.add(bean);
|
|
|
+ }
|
|
|
+ partDTO.setSymptomList(symptoms);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 如二级部位无关联的症状,则删除二级部位
|
|
|
+ // 如部位无关联的症状,则删除部位
|
|
|
for (PartSymptomDTO dto : res) {
|
|
|
for (int i = 0; i < dto.getPartDTO().size(); i++) {
|
|
|
PartDTO partDTO = dto.getPartDTO().get(i);
|
|
|
- if (keyMap.get(partDTO.getConceptId()) != null) { // 去除null数据
|
|
|
- partDTO.setSymptomList(keyMap.get(partDTO.getConceptId()));
|
|
|
- }
|
|
|
if (ListUtil.isEmpty(partDTO.getSymptomList())) {
|
|
|
dto.getPartDTO().remove(i--);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return res;
|
|
|
}
|
|
|
|