浏览代码

药品搜索及展示增加分类信息

SGTY 10 月之前
父节点
当前提交
26d88496c7

+ 6 - 0
src/main/java/com/diagbot/dto/GetAllForRelationDTO.java

@@ -30,6 +30,12 @@ public class GetAllForRelationDTO {
     @ApiModelProperty(value="概念id")
     private Integer libType;
 
+    /**
+     * 药品分类
+     */
+    @ApiModelProperty(value="药品分类")
+    private String drugC;
+
     /**
      * 概念名称(类型)
      */

+ 89 - 0
src/main/java/com/diagbot/entity/KlDrug.java

@@ -0,0 +1,89 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 药品表
+ * </p>
+ * @author: SGTY
+ * @create: 2024/8/7 10:18
+ **/
+
+@Data
+public class KlDrug implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 术语概念id
+     */
+    private Long conceptId;
+
+    /**
+     * 药品类别(0:西药,1:中成药)
+     */
+    private Integer drug;
+
+    /**
+     * 药品分类
+     */
+    private String drugC;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    @Override
+    public String toString() {
+        return "KlDrug{" +
+                "id=" + id +
+                ", isDeleted=" + isDeleted +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", creator=" + creator +
+                ", modifier=" + modifier +
+                ", conceptId=" + conceptId +
+                ", drug=" + drug +
+                ", remark=" + remark +
+                "}";
+    }
+}

+ 22 - 6
src/main/java/com/diagbot/facade/KlConceptFacade.java

@@ -4,12 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.GetAllForRelationDTO;
 import com.diagbot.dto.IndexBatchDTO;
 import com.diagbot.dto.KllisDetailDTO;
-import com.diagbot.entity.KlConcept;
-import com.diagbot.entity.KlDisease;
-import com.diagbot.entity.KlLibraryInfo;
-import com.diagbot.entity.KlOperation;
-import com.diagbot.entity.TcmDisease;
-import com.diagbot.entity.TcmSyndrome;
+import com.diagbot.entity.*;
 import com.diagbot.enums.ConceptTypeEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.LexiconEnum;
@@ -55,6 +50,8 @@ public class KlConceptFacade extends KlConceptServiceImpl {
     private TcmSyndromeFacade tcmSyndromeFacade;
     @Autowired
     private KlLibraryInfoFacade klLibraryInfoFacade;
+    @Autowired
+    private KlDrugFacade klDrugFacade;
 
     /**
      * 批量校验标准术语
@@ -500,13 +497,32 @@ public class KlConceptFacade extends KlConceptServiceImpl {
                     .eq("status", StatusEnum.Enable.getKey())
                     .notIn(ListUtil.isNotEmpty(excludedConceptIds), "id", excludedConceptIds)
                     .last("limit 100"));
+
+            // 取出 is_deleted = N 且 concept_id 在 conceptList 中的所有药品
+            List<KlDrug> klDrugs = klDrugFacade.getKlDrugsByConceptIds(conceptList.stream().map(KlConcept::getId).collect(Collectors.toList()));
+
             if (ListUtil.isNotEmpty(conceptList)) {
+
+                // 构建 conceptId -> KlDrug 的映射
+                Map<Long, KlDrug> klDrugMap = new HashMap<>();
+                for (KlDrug klDrug : klDrugs) {
+                    klDrugMap.put(klDrug.getConceptId(), klDrug);
+                }
+
                 getAllForRelationDTOS = conceptList.stream().map(x -> {
                     GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
                     getAllForRelationDTO.setConceptNameType(x.getLibName());
                     getAllForRelationDTO.setConceptName(x.getLibName());
                     getAllForRelationDTO.setConceptId(x.getId());
                     getAllForRelationDTO.setLibType(x.getLibType());
+
+                    KlDrug klDrug = klDrugMap.get(x.getId());
+                    if (klDrug != null && StringUtil.isNotBlank(klDrug.getDrugC())) {
+                        getAllForRelationDTO.setDrugC(klDrug.getDrugC());
+                    } else {
+                        getAllForRelationDTO.setDrugC("其他");
+                    }
+
                     return getAllForRelationDTO;
                 }).collect(Collectors.toList());
             }

+ 24 - 0
src/main/java/com/diagbot/facade/KlDrugFacade.java

@@ -0,0 +1,24 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.entity.KlDrug;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.service.impl.KlDrugServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @description:
+ * @author: SGTY
+ * @create: 2024/8/7 11:20
+ **/
+
+@Component
+public class KlDrugFacade extends KlDrugServiceImpl {
+    public List<KlDrug> getKlDrugsByConceptIds(List<Object> collect) {
+        return this.list(new QueryWrapper<KlDrug>().eq("is_deleted", IsDeleteEnum.N.getKey())
+                .in("concept_id", collect));
+    }
+}

+ 16 - 0
src/main/java/com/diagbot/mapper/KlDrugMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.KlDrug;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 药品表 Mapper 接口
+ * </p>
+ * @author: SGTY
+ * @create: 2024/8/7 11:05
+ **/
+
+public interface KlDrugMapper extends BaseMapper<KlDrug> {
+
+}

+ 16 - 0
src/main/java/com/diagbot/service/KlDrugService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.entity.KlDrug;
+
+/**
+ * <p>
+ * 药品表 服务类
+ * </p>
+ * @author: SGTY
+ * @create: 2024/8/7 11:00
+ **/
+
+public interface KlDrugService extends IService<KlDrug> {
+
+}

+ 20 - 0
src/main/java/com/diagbot/service/impl/KlDrugServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.entity.KlDrug;
+import com.diagbot.mapper.KlDrugMapper;
+import com.diagbot.service.KlDrugService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 药品表 服务实现类
+ * </p>
+ * @author: SGTY
+ * @create: 2024/8/7 10:40
+ **/
+
+@Service
+public class KlDrugServiceImpl extends ServiceImpl<KlDrugMapper, KlDrug> implements KlDrugService {
+
+}