瀏覽代碼

添加术语新增和规则维护接口

kongwz 3 年之前
父節點
當前提交
58b902e64f

+ 39 - 24
src/main/java/com/diagbot/facade/KlConceptFacade.java

@@ -383,38 +383,53 @@ public class KlConceptFacade extends KlConceptServiceImpl {
         return retType;
     }
 
+    /**
+     * 术语集合新增
+     *
+     * @param searchConceptVO
+     * @return
+     */
+    public List<GetAllForRelationDTO> addConceptClass(SearchConceptVO searchConceptVO) {
+        List<GetAllForRelationDTO> getAllForRelationDTOS = this.searchByTypeAndNameAdd(searchConceptVO);
+        return getAllForRelationDTOS;
+    }
+
+    /**
+     * 规则维护术语查询
+     *
+     * @param searchConceptVO
+     * @return
+     */
+    public List<GetAllForRelationDTO> searchConceptRuleClass(SearchConceptVO searchConceptVO) {
+        List<GetAllForRelationDTO> getAllForRelationDTOS = this.searchByTypeAndName(searchConceptVO);
+        return getAllForRelationDTOS;
+    }
+
     public List<GetAllForRelationDTO> searchConceptByNameAndLibType(SearchConceptVO searchConceptVO) {
         List<GetAllForRelationDTO> getAllForRelationDTOS = Lists.newArrayList();
         String name = searchConceptVO.getName();
         Integer libType = searchConceptVO.getLibType();
-        Integer sign = searchConceptVO.getSign();
         List<Long> excludedConceptIds = searchConceptVO.getExcludedConceptIds();
         if (StringUtils.isNotBlank(name) && libType != null) {
-            if(libType >= 308 && libType <= 328){
-                if(sign == 1){
-                    getAllForRelationDTOS = this.searchByTypeAndNameAdd(searchConceptVO);
-                }else if(sign == 2){
-                    getAllForRelationDTOS = this.searchByTypeAndName(searchConceptVO);
-                }
-            }else {
-                List<KlConcept> conceptList = this.list(new QueryWrapper<KlConcept>()
-                        .eq("is_deleted", IsDeleteEnum.N.getKey())
-                        .like(StringUtil.isNotBlank(name), "lib_name", name.trim())
-                        .eq("lib_type", libType)
-                        .eq("status", StatusEnum.Enable.getKey())
-                        .notIn(ListUtil.isNotEmpty(excludedConceptIds), "id", excludedConceptIds));
-                if (ListUtil.isNotEmpty(conceptList)) {
-                    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());
-                        return getAllForRelationDTO;
-                    }).collect(Collectors.toList());
-                }
+            List<KlConcept> conceptList = this.list(new QueryWrapper<KlConcept>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .like(StringUtil.isNotBlank(name), "lib_name", name.trim())
+                    .eq("lib_type", libType)
+                    .eq("status", StatusEnum.Enable.getKey())
+                    .notIn(ListUtil.isNotEmpty(excludedConceptIds), "id", excludedConceptIds)
+            .last("limit 100"));
+            if (ListUtil.isNotEmpty(conceptList)) {
+                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());
+                    return getAllForRelationDTO;
+                }).collect(Collectors.toList());
             }
 
+
         }
         return getAllForRelationDTOS;
     }

+ 3 - 2
src/main/java/com/diagbot/vo/SearchConceptVO.java

@@ -34,6 +34,7 @@ public class SearchConceptVO {
     /**
      * 标志(新增 -1 修改 2)
      */
-    @ApiModelProperty(value="新增修改标志")
-    private Integer sign;
+//    @ApiModelProperty(value="新增修改标志")
+//    @NotBlank(message = "请输入标志")
+//    private Integer sign;
 }

+ 23 - 2
src/main/java/com/diagbot/web/KlDiseaseController.java

@@ -37,8 +37,7 @@ public class KlDiseaseController {
     @ApiOperation(value = "查询诊断依据相关的类型术语[by:kongwz]",
             notes = "name: 查询术语的名称<br>" +
                     "libType: 查询术语的词性<br>" +
-                    "excludedConceptIds: 需要排除的概念id集合"+
-                    "sign: 新增 -1 修改 2")
+                    "excludedConceptIds: 需要排除的概念id集合")
     @PostMapping("/searchConcept")
     @SysLogger("searchConcept")
     public RespDTO<List<GetAllForRelationDTO>> searchConcept(@Valid @RequestBody SearchConceptVO searchConceptVO) {
@@ -46,4 +45,26 @@ public class KlDiseaseController {
         return RespDTO.onSuc(getAllForRelationDTOS);
     }
 
+    @ApiOperation(value = "术语集合新增[by:kongwz]",
+            notes = "name: 查询术语的名称<br>" +
+                    "libType: 查询术语的词性<br>" +
+                    "excludedConceptIds: 需要排除的概念id集合")
+    @PostMapping("/addConceptClass")
+    @SysLogger("addConceptClass")
+    public RespDTO<List<GetAllForRelationDTO>> addConceptClass(@Valid @RequestBody SearchConceptVO searchConceptVO) {
+        List<GetAllForRelationDTO> getAllForRelationDTOS = klConceptFacade.addConceptClass(searchConceptVO);
+        return RespDTO.onSuc(getAllForRelationDTOS);
+    }
+
+    @ApiOperation(value = "规则维护术语查询[by:kongwz]",
+            notes = "name: 查询术语的名称<br>" +
+                    "libType: 查询术语的词性<br>" +
+                    "excludedConceptIds: 需要排除的概念id集合")
+    @PostMapping("/searchConceptRuleClass")
+    @SysLogger("searchConceptRuleClass")
+    public RespDTO<List<GetAllForRelationDTO>> searchConceptRuleClass(@Valid @RequestBody SearchConceptVO searchConceptVO) {
+        List<GetAllForRelationDTO> getAllForRelationDTOS = klConceptFacade.searchConceptRuleClass(searchConceptVO);
+        return RespDTO.onSuc(getAllForRelationDTOS);
+    }
+
 }

+ 77 - 81
src/main/resources/mapper/KlConceptMapper.xml

@@ -692,86 +692,82 @@
 
     <select id="searchByTypeAndName" parameterType="com.diagbot.vo.SearchConceptVO"
             resultType="com.diagbot.dto.GetAllForRelationDTO">
-        SELECT
-        kc.id AS conceptId,
+        <!--        SELECT-->
+        <!--        kc.id AS conceptId,-->
+        <!--        kc.lib_name AS conceptName,-->
+        <!--        kc.lib_type AS libType,-->
+        <!--        kc.lib_name AS conceptNameType-->
+        <!--        FROM-->
+        <!--        `kl_concept` kc-->
+        <!--        WHERE-->
+        <!--        kc.`status` = 1-->
+        <!--        <if test="libType!=null">-->
+        <!--            AND kc.lib_type = #{libType}-->
+        <!--        </if>-->
+        <!--        <if test="name != null and name != ''">-->
+        <!--            AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')-->
+        <!--        </if>-->
+        <!--        <if test="excludedConceptIds != null and excludedConceptIds.size > 0">-->
+        <!--            AND kc.id not in-->
+        <!--            <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">-->
+        <!--                #{id}-->
+        <!--            </foreach>-->
+        <!--        </if>-->
+        <!--        AND kc.is_deleted = 'N'-->
+        <!--        AND kc.id NOT IN (1)-->
+        <!--        AND kc.id IN (-->
+        <!--        SELECT DISTINCT-->
+        <!--        start_id-->
+        <!--        FROM-->
+        <!--        kl_relation-->
+        <!--        WHERE-->
+        <!--        is_deleted = 'N'-->
+        <!--        AND relation_id = 600-->
+        <!--        )-->
+        select kc.id AS conceptId,
         kc.lib_name AS conceptName,
         kc.lib_type AS libType,
-        kc.lib_name AS conceptNameType,
-        kli.remark
-        FROM
-        kl_concept kc,
-        kl_library_info kli,
-        (
-        SELECT
-        distinct
-        kr.start_id
+        kc.lib_name AS conceptNameType
+        from (SELECT
+        a.*,
+        <choose>
+            <when test="libType gte 308 and libType lte 328"> b.id as tRelationId</when>
+            <otherwise>null as tRelationId</otherwise>
+        </choose>
         FROM
-        kl_relation_order kro,
-        (
-        SELECT
-        id,
-        start_id,
-        relation_id,
-        end_id
-        FROM
-        kl_relation
-        WHERE
-        start_id IN (
-        SELECT
-        id
-        FROM
-        `kl_concept`
-        WHERE
-        <if test="libType!=null">
-            lib_type = #{libType}
-        </if>
-        )
-        AND `status` = 1
-        AND is_deleted = 'N'
-        ) kr
-        WHERE
-        kr.id = kro.t_relation_id
-        AND kro.is_deleted = 'N'
-        ORDER BY
-        kro.order_no
-        ) b
-        WHERE
-        kc.id = kli.concept_id
-        AND b.start_id = kc.id
-        AND kc.is_deleted = 'N'
-        AND kli.is_deleted = 'N'
-        AND kli.is_concept = 1
-        <if test="libType!=null">
-            AND kc.lib_type = #{libType}
-        </if>
-        <if test="name != null and name != ''">
-            AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
-        </if>
-        <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
-            AND kc.id not in
-            <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
-                #{id}
-            </foreach>
-        </if>
+        kl_concept a
+        <choose>
+            <when test="libType gte 308 and libType lte 328"> LEFT JOIN kl_relation b ON a.id = b.start_id
+               AND a.lib_type = #{libType} AND b.relation_id = 600 and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</when>
+            <otherwise>where a.lib_type = #{libType} and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</otherwise>
+        </choose>
+        GROUP BY
+        a.id)kc
+        where
+        <choose>
+            <when test="libType gte 308 and libType lte 328"> kc.tRelationId is not null</when>
+            <otherwise>kc.tRelationId is null</otherwise>
+        </choose>
+        limit 100
     </select>
 
     <select id="searchByTypeAndNameAdd" parameterType="com.diagbot.vo.SearchConceptVO"
             resultType="com.diagbot.dto.GetAllForRelationDTO">
         SELECT
-	kc.id AS conceptId,
-	kc.lib_name AS conceptName,
-	kc.lib_type AS libType,
-	kc.lib_name AS conceptNameType,
-	kli.remark
-FROM
-	`kl_concept` kc,
-kl_library_info kli
-WHERE
+        kc.id AS conceptId,
+        kc.lib_name AS conceptName,
+        kc.lib_type AS libType,
+        kc.lib_name AS conceptNameType,
+        kli.remark
+        FROM
+        `kl_concept` kc,
+        kl_library_info kli
+        WHERE
         <if test="libType!=null">
             kc.lib_type = #{libType}
         </if>
-AND kc.`status` = 1
-AND kc.is_deleted = 'N'
+        AND kc.`status` = 1
+        AND kc.is_deleted = 'N'
         <if test="name != null and name != ''">
             AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
         </if>
@@ -781,18 +777,18 @@ AND kc.is_deleted = 'N'
                 #{id}
             </foreach>
         </if>
-AND kc.id NOT IN (
-	SELECT DISTINCT
-		start_id
-	FROM
-		kl_relation
-	WHERE
-		is_deleted = 'N'
-	AND relation_id = 600
-)
-AND kc.id = kli.concept_id
-AND kli.is_deleted = 'N'
-AND kli.is_concept = 1
+        AND kc.id NOT IN (
+        SELECT DISTINCT
+        start_id
+        FROM
+        kl_relation
+        WHERE
+        is_deleted = 'N'
+        AND relation_id = 600
+        )
+        AND kc.id = kli.concept_id
+        AND kli.is_deleted = 'N'
+        AND kli.is_concept = 1
     </select>
 
 </mapper>