diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java b/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java index 7556581c..229e981c 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/controller/diseasemanage/DiseasePhysicalManageController.java @@ -2,8 +2,10 @@ package com.supervision.manage.controller.diseasemanage; import com.supervision.manage.service.DiseasePhysicalManageService; +import com.supervision.vo.manage.DiseasePhysicalLocationNodeVo; import com.supervision.vo.manage.DiseasePhysicalResVo; import com.supervision.model.DiseasePhysical; +import com.supervision.vo.manage.PhysicalLocationNode; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -52,4 +54,12 @@ public class DiseasePhysicalManageController { } + @ApiOperation("查询疾病身体部位树") + @GetMapping("/queryTree") + public List<DiseasePhysicalLocationNodeVo> queryTree(@RequestParam String diseaseId) { + + return diseasePhysicalManageService.queryTree(diseaseId); + + } + } diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/DiseasePhysicalManageService.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/DiseasePhysicalManageService.java index 765d5250..68001cc8 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/DiseasePhysicalManageService.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/DiseasePhysicalManageService.java @@ -1,7 +1,9 @@ package com.supervision.manage.service; import com.supervision.model.DiseasePhysical; +import com.supervision.vo.manage.DiseasePhysicalLocationNodeVo; import com.supervision.vo.manage.DiseasePhysicalResVo; +import com.supervision.vo.manage.PhysicalLocationNode; import java.util.List; @@ -16,4 +18,6 @@ public interface DiseasePhysicalManageService { boolean updatePhysical(DiseasePhysical diseasePhysical); boolean deleteByDiseaseId(String diseaseId); + + List<DiseasePhysicalLocationNodeVo> queryTree(String diseaseId); } diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java index d17703fc..f0dbba07 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/DiseasePhysicalManageServiceImpl.java @@ -1,22 +1,34 @@ package com.supervision.manage.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import com.supervision.manage.service.DiseasePhysicalManageService; +import com.supervision.manage.service.PhysicalLocationManageService; +import com.supervision.manage.service.PhysicalToolManageService; +import com.supervision.model.ConfigPhysicalLocation; import com.supervision.model.DiseaseAncillary; import com.supervision.model.DiseasePhysical; +import com.supervision.service.ConfigPhysicalLocationService; import com.supervision.service.DiseasePhysicalService; +import com.supervision.vo.manage.DiseasePhysicalLocationNodeVo; import com.supervision.vo.manage.DiseasePhysicalResVo; +import com.supervision.vo.manage.PhysicalLocationNode; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.List; +import java.util.stream.Collectors; + @Service @RequiredArgsConstructor public class DiseasePhysicalManageServiceImpl implements DiseasePhysicalManageService { private final DiseasePhysicalService diseasePhysicalService; + private final PhysicalLocationManageService physicalToolManageService; + @Override public List<DiseasePhysicalResVo> queryListByDiseaseId(String diseaseId) { @@ -57,6 +69,40 @@ public class DiseasePhysicalManageServiceImpl implements DiseasePhysicalManageSe return diseasePhysicalService.lambdaUpdate().eq(DiseasePhysical::getDiseaseId,diseaseId).remove(); } + @Override + public List<DiseasePhysicalLocationNodeVo> queryTree(String diseaseId) { + + List<PhysicalLocationNode> physicalLocationNodes = physicalToolManageService.queryTree(); + if (CollectionUtil.isEmpty(physicalLocationNodes)){ + return CollectionUtil.newArrayList(); + } + + PhysicalLocationNode physicalLocationNode = new PhysicalLocationNode(); + physicalLocationNode.setChild(physicalLocationNodes); + DiseasePhysicalLocationNodeVo bean = BeanUtil.toBean(physicalLocationNode, DiseasePhysicalLocationNodeVo.class); + + List<DiseasePhysicalResVo> diseasePhysicalResVos = diseasePhysicalService.queryListByDiseaseId(diseaseId); + if (CollectionUtil.isEmpty(diseasePhysicalResVos)){ + return bean.getChild(); + } + + List<String> toolIds = diseasePhysicalResVos.stream().map(DiseasePhysical::getToolId).distinct().collect(Collectors.toList()); + + populateDiseasePhysicalLocationNodeFlag(bean,toolIds); + return bean.getChild(); + } + + + private void populateDiseasePhysicalLocationNodeFlag(DiseasePhysicalLocationNodeVo node,List<String> toolIds) { + if (StrUtil.isNotEmpty(node.getId())){ + node.setFlag(toolIds.stream().anyMatch(id->node.getId().equals(id))); + } + if (CollectionUtil.isNotEmpty(node.getChild())){ + for (DiseasePhysicalLocationNodeVo childNode : node.getChild()) { + populateDiseasePhysicalLocationNodeFlag(childNode,toolIds); + } + } + } private void assertDiseasePhysical(DiseasePhysical diseasePhysical){ diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/PhysicalLocationManageServiceImpl.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/PhysicalLocationManageServiceImpl.java index e4ff5433..e719cc52 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/PhysicalLocationManageServiceImpl.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/PhysicalLocationManageServiceImpl.java @@ -36,7 +36,7 @@ public class PhysicalLocationManageServiceImpl implements PhysicalLocationManage if (StrUtil.isNotEmpty(value.getParentId())) { PhysicalLocationNode physicalLocationNode = map.get(value.getParentId()); if (!Objects.isNull(physicalLocationNode)) { - List<ConfigPhysicalLocation> child = physicalLocationNode.getChild(); + List<PhysicalLocationNode> child = physicalLocationNode.getChild(); if (null == child) { child = new ArrayList<>(); physicalLocationNode.setChild(child); diff --git a/virtual-patient-model/src/main/java/com/supervision/vo/manage/DiseasePhysicalLocationNodeVo.java b/virtual-patient-model/src/main/java/com/supervision/vo/manage/DiseasePhysicalLocationNodeVo.java new file mode 100644 index 00000000..c8de7930 --- /dev/null +++ b/virtual-patient-model/src/main/java/com/supervision/vo/manage/DiseasePhysicalLocationNodeVo.java @@ -0,0 +1,44 @@ +package com.supervision.vo.manage; + +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class DiseasePhysicalLocationNodeVo { + + @TableId + private String id; + + /** + * 编码 + */ + @ApiModelProperty("编码") + private String code; + + /** + * 位置分类 + */ + @ApiModelProperty("位置分类") + private String locationClass; + + /** + * 位置名称 + */ + @ApiModelProperty("位置名称") + private String locationName; + + + @ApiModelProperty("部位层级") + private String level; + + @ApiModelProperty("父级Id") + private String parentId; + + @ApiModelProperty("标识 true:已选择 false:未选择") + private boolean flag; + + private List<DiseasePhysicalLocationNodeVo> child; +} diff --git a/virtual-patient-model/src/main/java/com/supervision/vo/manage/PhysicalLocationNode.java b/virtual-patient-model/src/main/java/com/supervision/vo/manage/PhysicalLocationNode.java index 4e489942..2b9d64eb 100644 --- a/virtual-patient-model/src/main/java/com/supervision/vo/manage/PhysicalLocationNode.java +++ b/virtual-patient-model/src/main/java/com/supervision/vo/manage/PhysicalLocationNode.java @@ -10,6 +10,6 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) public class PhysicalLocationNode extends ConfigPhysicalLocation{ - private List<ConfigPhysicalLocation> child; + private List<PhysicalLocationNode> child; }