ConceptMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.diagbot.mapper.ConceptMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.Concept">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="lib_id" property="libId" />
  13. <result column="lib_name" property="libName" />
  14. <result column="lib_type" property="libType" />
  15. </resultMap>
  16. <select id="getAllLisConcept" parameterType="com.diagbot.vo.GetAllLisConceptVO" resultType="com.diagbot.dto.GetAllLisConceptDTO">
  17. SELECT
  18. conceptName
  19. FROM
  20. ((SELECT
  21. lib_name as conceptName
  22. FROM kl_concept
  23. WHERE is_deleted='N' AND lib_type=12
  24. ORDER BY gmt_modified DESC)
  25. UNION
  26. (SELECT
  27. CONCAT(t1.conceptName,'-',t3.conceptName) as conceptName
  28. FROM
  29. (SELECT
  30. id as conceptId,
  31. lib_name as conceptName
  32. FROM kl_concept
  33. WHERE is_deleted='N' AND lib_type=12) t1
  34. JOIN
  35. kl_relation t2
  36. ON t1.conceptId=t2.end_id
  37. JOIN
  38. (SELECT
  39. id as conceptId,
  40. lib_name as conceptName
  41. FROM kl_concept
  42. WHERE is_deleted='N' AND lib_type=13) t3
  43. ON t2.start_id=t3.conceptId
  44. LEFT JOIN kl_relation_order t4
  45. ON t2.id=t4.t_relation_id
  46. WHERE t2.is_deleted='N' AND t2.relation_id=3
  47. ORDER BY t4.order_no DESC)) t
  48. WHERE 1=1
  49. <if test="conceptName!=null and conceptName!=''">
  50. and (conceptName LIKE CONCAT('%',#{conceptName},'%'))
  51. </if>
  52. <if test="excludedConceptNames!=null and excludedConceptNames.size>0">
  53. and (conceptName not in
  54. <foreach collection="excludedConceptNames" open="(" close=")" separator="," item="excludedConceptName">
  55. #{excludedConceptName}
  56. </foreach>
  57. )
  58. </if>
  59. </select>
  60. <select id="getConcept" resultType="com.diagbot.dto.ConceptRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  61. SELECT
  62. t1.id AS startId,
  63. t1.lib_name AS startName,
  64. t3.id AS endId,
  65. t3.lib_name AS endName
  66. FROM
  67. `kl_concept` t1,
  68. `kl_relation` t2,
  69. <if test="startSex != null or startAge != null">
  70. kl_concept_common c1,
  71. </if>
  72. <if test="endSex != null or endAge != null">
  73. kl_concept_common c2,
  74. </if>
  75. `kl_concept` t3
  76. WHERE
  77. t1.is_deleted = 'N'
  78. AND t2.is_deleted = 'N'
  79. AND t3.is_deleted = 'N'
  80. AND t1.id = t2.start_id
  81. AND t3.id = t2.end_id
  82. <if test="startId != null">
  83. AND t2.start_id = #{startId}
  84. </if>
  85. <if test="startName != null and startName != ''">
  86. AND t1.lib_name = #{startName}
  87. </if>
  88. <if test="startSex != null or startAge != null">
  89. AND c1.is_deleted = 'N'
  90. <if test="startSex != null">
  91. <if test="startSex == 3">
  92. and c1.sex_type in ('1','2','3')
  93. </if>
  94. <if test="startSex != 3">
  95. and c1.sex_type in ('3',#{startSex})
  96. </if>
  97. </if>
  98. <if test="startAge != null">
  99. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  100. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  101. </if>
  102. AND t2.start_id = c1.concept_id
  103. </if>
  104. <if test="startType != null">
  105. AND t1.lib_type = #{startType}
  106. </if>
  107. <if test="relationType != null">
  108. AND t2.relation_id = #{relationType}
  109. </if>
  110. <if test="endId != null">
  111. AND t2.end_id = #{endId}
  112. </if>
  113. <if test="endName != null and endName != ''">
  114. AND t3.lib_name = #{endName}
  115. </if>
  116. <if test="endSex != null or endAge != null">
  117. AND c2.is_deleted = 'N'
  118. <if test="endSex != null">
  119. <if test="endSex == 3">
  120. and c2.sex_type in ('1','2','3')
  121. </if>
  122. <if test="endSex != 3">
  123. and c2.sex_type in ('3',#{endSex})
  124. </if>
  125. </if>
  126. <if test="endAge != null">
  127. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  128. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  129. </if>
  130. AND t2.end_id = c2.concept_id
  131. </if>
  132. <if test="endType != null">
  133. AND t3.lib_type = #{endType}
  134. </if>
  135. </select>
  136. <select id="getConceptWithOrder" resultType="com.diagbot.dto.ConceptWithOrderRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  137. SELECT
  138. t1.id AS startId,
  139. t1.lib_name AS startName,
  140. t3.id AS endId,
  141. t3.lib_name AS endName,
  142. t4.order_no AS orderNo
  143. FROM
  144. `kl_concept` t1,
  145. `kl_relation` t2,
  146. <if test="startSex != null or startAge != null">
  147. kl_concept_common c1,
  148. </if>
  149. <if test="endSex != null or endAge != null">
  150. kl_concept_common c2,
  151. </if>
  152. `kl_concept` t3,
  153. `kl_relation_order` t4
  154. WHERE
  155. t1.is_deleted = 'N'
  156. AND t2.is_deleted = 'N'
  157. AND t3.is_deleted = 'N'
  158. AND t4.is_deleted = 'N'
  159. AND t1.id = t2.start_id
  160. AND t3.id = t2.end_id
  161. AND t2.id = t4.t_relation_id
  162. <if test="startId != null">
  163. AND t2.start_id = #{startId}
  164. </if>
  165. <if test="startName != null and startName != ''">
  166. AND t1.lib_name = #{startName}
  167. </if>
  168. <if test="startSex != null or startAge != null">
  169. AND c1.is_deleted = 'N'
  170. <if test="startSex != null">
  171. <if test="startSex == 3">
  172. and c1.sex_type in ('1','2','3')
  173. </if>
  174. <if test="startSex != 3">
  175. and c1.sex_type in ('3',#{startSex})
  176. </if>
  177. </if>
  178. <if test="startAge != null">
  179. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  180. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  181. </if>
  182. AND t2.start_id = c1.concept_id
  183. </if>
  184. <if test="startNameList != null and startNameList.size() > 0">
  185. AND t1.lib_name in
  186. <foreach collection="startNameList" item="item" open="(" close=")" separator=",">
  187. #{item}
  188. </foreach>
  189. </if>
  190. <if test="startType != null">
  191. AND t1.lib_type = #{startType}
  192. </if>
  193. <if test="relationType != null">
  194. AND t2.relation_id = #{relationType}
  195. </if>
  196. <if test="endId != null">
  197. AND t2.end_id = #{endId}
  198. </if>
  199. <if test="endName != null and endName != ''">
  200. AND t3.lib_name = #{endName}
  201. </if>
  202. <if test="endSex != null or endAge != null">
  203. AND c2.is_deleted = 'N'
  204. <if test="endSex != null">
  205. <if test="endSex == 3">
  206. and c2.sex_type in ('1','2','3')
  207. </if>
  208. <if test="endSex != 3">
  209. and c2.sex_type in ('3',#{endSex})
  210. </if>
  211. </if>
  212. <if test="endAge != null">
  213. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  214. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  215. </if>
  216. AND t2.end_id = c2.concept_id
  217. </if>
  218. <if test="endNameList != null and endNameList.size() > 0">
  219. AND t3.lib_name in
  220. <foreach collection="endNameList" item="item" open="(" close=")" separator=",">
  221. #{item}
  222. </foreach>
  223. </if>
  224. <if test="endType != null">
  225. AND t3.lib_type = #{endType}
  226. </if>
  227. ORDER BY t4.order_no
  228. </select>
  229. <select id="index" resultType="com.diagbot.dto.ConceptBaseDTO">
  230. SELECT b.id conceptId, b.lib_name name
  231. FROM `kl_library_info` a, kl_concept b
  232. where b.is_deleted = 'N' and a.is_deleted = 'N' and a.concept_id = b.id and a.is_concept = 1
  233. <if test="libType != null">
  234. and b.lib_type = #{libType}
  235. </if>
  236. and (a.name like concat('%',#{name},'%')
  237. or a.spell like concat('%',#{name},'%'))
  238. </select>
  239. </mapper>