|
@@ -186,4 +186,179 @@
|
|
|
ORDER BY t4.order_no
|
|
|
</select>
|
|
|
|
|
|
+ <select id="retrievalConcept" resultType="com.diagbot.dto.RetrievalDTO">
|
|
|
+ SELECT a1.* from (
|
|
|
+ SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType FROM kl_concept t1
|
|
|
+ LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_concept_common t3 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
|
|
|
+ LEFT JOIN kl_concept t5 on t5.id = t4.start_id
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'N'
|
|
|
+ AND t4.is_deleted = 'N'
|
|
|
+ AND t5.is_deleted = 'N'
|
|
|
+ AND t1.lib_type = #{type}
|
|
|
+ <if test="sexType == 3">
|
|
|
+ and t3.sex_type in ('1','2','3')
|
|
|
+ </if>
|
|
|
+ <if test="sexType != 3">
|
|
|
+ and t3.sex_type in ('3',#{sexType})
|
|
|
+ </if>
|
|
|
+ <if test="age != null and age != ''">
|
|
|
+ AND <![CDATA[ t3.min_age <= #{age} ]]>
|
|
|
+ AND <![CDATA[ t3.max_age >= #{age} ]]>
|
|
|
+ </if>
|
|
|
+ AND (t2.spell = #{InputStr} OR t2.name = #{InputStr})
|
|
|
+ <if test="inputIds != null and inputIds.size > 0">
|
|
|
+ and t1.id not in
|
|
|
+ <foreach item="id" collection="inputIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND t4.relation_id = 18
|
|
|
+ UNION
|
|
|
+ SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType FROM kl_concept t1
|
|
|
+ LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_concept_common t3 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
|
|
|
+ LEFT JOIN kl_concept t5 on t5.id = t4.start_id
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'N'
|
|
|
+ AND t4.is_deleted = 'N'
|
|
|
+ AND t5.is_deleted = 'N'
|
|
|
+ AND t1.lib_type = #{type}
|
|
|
+ <if test="sexType == 3">
|
|
|
+ and t3.sex_type in ('1','2','3')
|
|
|
+ </if>
|
|
|
+ <if test="sexType != 3">
|
|
|
+ and t3.sex_type in ('3',#{sexType})
|
|
|
+ </if>
|
|
|
+ <if test="age != null and age != ''">
|
|
|
+ AND <![CDATA[ t3.min_age <= #{age} ]]>
|
|
|
+ AND <![CDATA[ t3.max_age >= #{age} ]]>
|
|
|
+ </if>
|
|
|
+ AND (t2.spell LIKE CONCAT( #{InputStr},'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
|
|
|
+ <if test="inputIds != null and inputIds.size > 0">
|
|
|
+ and t1.id not in
|
|
|
+ <foreach item="id" collection="inputIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND t4.relation_id = 18
|
|
|
+ UNION
|
|
|
+ SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType FROM kl_concept t1
|
|
|
+ LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_concept_common t3 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
|
|
|
+ LEFT JOIN kl_concept t5 on t5.id = t4.start_id
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'N'
|
|
|
+ AND t4.is_deleted = 'N'
|
|
|
+ AND t5.is_deleted = 'N'
|
|
|
+ AND t1.lib_type = #{type}
|
|
|
+ <if test="sexType == 3">
|
|
|
+ and t3.sex_type in ('1','2','3')
|
|
|
+ </if>
|
|
|
+ <if test="sexType != 3">
|
|
|
+ and t3.sex_type in ('3',#{sexType})
|
|
|
+ </if>
|
|
|
+ <if test="age != null and age != ''">
|
|
|
+ AND <![CDATA[ t3.min_age <= #{age} ]]>
|
|
|
+ AND <![CDATA[ t3.max_age >= #{age} ]]>
|
|
|
+ </if>
|
|
|
+ AND (t2.spell LIKE CONCAT('%',#{InputStr},'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
|
|
|
+ <if test="inputIds != null and inputIds.size > 0">
|
|
|
+ and t1.id not in
|
|
|
+ <foreach item="id" collection="inputIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND t4.relation_id = 18
|
|
|
+ UNION
|
|
|
+ SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType FROM kl_concept t1
|
|
|
+ LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_concept_common t3 ON t1.id = t2.concept_id
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'N'
|
|
|
+ AND t1.lib_type = #{type}
|
|
|
+ <if test="sexType == 3">
|
|
|
+ and t3.sex_type in ('1','2','3')
|
|
|
+ </if>
|
|
|
+ <if test="sexType != 3">
|
|
|
+ and t3.sex_type in ('3',#{sexType})
|
|
|
+ </if>
|
|
|
+ <if test="age != null and age != ''">
|
|
|
+ AND <![CDATA[ t3.min_age <= #{age} ]]>
|
|
|
+ AND <![CDATA[ t3.max_age >= #{age} ]]>
|
|
|
+ </if>
|
|
|
+ <if test="inputIds != null and inputIds.size > 0">
|
|
|
+ and t1.id not in
|
|
|
+ <foreach item="id" collection="inputIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND (t2.spell = #{InputStr} OR t2.name = #{InputStr})
|
|
|
+ UNION
|
|
|
+ SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType FROM kl_concept t1
|
|
|
+ LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_concept_common t3 ON t1.id = t2.concept_id
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'N'
|
|
|
+ AND t1.lib_type = #{type}
|
|
|
+ <if test="sexType == 3">
|
|
|
+ and t3.sex_type in ('1','2','3')
|
|
|
+ </if>
|
|
|
+ <if test="sexType != 3">
|
|
|
+ and t3.sex_type in ('3',#{sexType})
|
|
|
+ </if>
|
|
|
+ <if test="age != null and age != ''">
|
|
|
+ AND <![CDATA[ t3.min_age <= #{age} ]]>
|
|
|
+ AND <![CDATA[ t3.max_age >= #{age} ]]>
|
|
|
+ </if>
|
|
|
+ <if test="inputIds != null and inputIds.size > 0">
|
|
|
+ and t1.id not in
|
|
|
+ <foreach item="id" collection="inputIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND (t2.spell LIKE CONCAT( #{InputStr},'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
|
|
|
+ UNION
|
|
|
+ SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType FROM kl_concept t1
|
|
|
+ LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
|
|
|
+ LEFT JOIN kl_concept_common t3 ON t1.id = t2.concept_id
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'N'
|
|
|
+ AND t1.lib_type = #{type}
|
|
|
+ <if test="sexType == 3">
|
|
|
+ and t3.sex_type in ('1','2','3')
|
|
|
+ </if>
|
|
|
+ <if test="sexType != 3">
|
|
|
+ and t3.sex_type in ('3',#{sexType})
|
|
|
+ </if>
|
|
|
+ <if test="age != null and age != ''">
|
|
|
+ AND <![CDATA[ t3.min_age <= #{age} ]]>
|
|
|
+ AND <![CDATA[ t3.max_age >= #{age} ]]>
|
|
|
+ </if>
|
|
|
+ <if test="inputIds != null and inputIds.size > 0">
|
|
|
+ and t1.id not in
|
|
|
+ <foreach item="id" collection="inputIds" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ AND (t2.spell LIKE CONCAT('%',#{InputStr},'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
|
|
|
+ ) a1
|
|
|
+ GROUP BY a1.selfId,a1.showType
|
|
|
+ </select>
|
|
|
</mapper>
|