ConceptMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  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="getConcept" resultType="com.diagbot.dto.ConceptRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  17. SELECT
  18. t1.id AS startId,
  19. t1.lib_name AS startName,
  20. t3.id AS endId,
  21. t3.lib_name AS endName
  22. FROM
  23. `kl_concept` t1,
  24. `kl_relation` t2,
  25. <if test="startSex != null or startAge != null">
  26. kl_concept_common c1,
  27. </if>
  28. <if test="endSex != null or endAge != null">
  29. kl_concept_common c2,
  30. </if>
  31. `kl_concept` t3
  32. WHERE
  33. t1.is_deleted = 'N'
  34. AND t2.is_deleted = 'N'
  35. AND t3.is_deleted = 'N'
  36. AND t1.id = t2.start_id
  37. AND t3.id = t2.end_id
  38. <if test="startId != null">
  39. AND t2.start_id = #{startId}
  40. </if>
  41. <if test="startName != null and startName != ''">
  42. AND t1.lib_name = #{startName}
  43. </if>
  44. <if test="startSex != null or startAge != null">
  45. AND c1.is_deleted = 'N'
  46. <if test="startSex != null">
  47. <if test="startSex == 3">
  48. and c1.sex_type in ('1','2','3')
  49. </if>
  50. <if test="startSex != 3">
  51. and c1.sex_type in ('3',#{startSex})
  52. </if>
  53. </if>
  54. <if test="startAge != null">
  55. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  56. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  57. </if>
  58. AND t2.start_id = c1.concept_id
  59. </if>
  60. <if test="startType != null">
  61. AND t1.lib_type = #{startType}
  62. </if>
  63. <if test="relationType != null">
  64. AND t2.relation_id = #{relationType}
  65. </if>
  66. <if test="endId != null">
  67. AND t2.end_id = #{endId}
  68. </if>
  69. <if test="endName != null and endName != ''">
  70. AND t3.lib_name = #{endName}
  71. </if>
  72. <if test="endSex != null or endAge != null">
  73. AND c2.is_deleted = 'N'
  74. <if test="endSex != null">
  75. <if test="endSex == 3">
  76. and c2.sex_type in ('1','2','3')
  77. </if>
  78. <if test="endSex != 3">
  79. and c2.sex_type in ('3',#{endSex})
  80. </if>
  81. </if>
  82. <if test="endAge != null">
  83. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  84. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  85. </if>
  86. AND t2.end_id = c2.concept_id
  87. </if>
  88. <if test="endType != null">
  89. AND t3.lib_type = #{endType}
  90. </if>
  91. </select>
  92. <select id="getConceptWithOrder" resultType="com.diagbot.dto.ConceptWithOrderRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  93. SELECT
  94. t1.id AS startId,
  95. t1.lib_name AS startName,
  96. t3.id AS endId,
  97. t3.lib_name AS endName,
  98. t4.order_no AS orderNo
  99. FROM
  100. `kl_concept` t1,
  101. `kl_relation` t2,
  102. <if test="startSex != null or startAge != null">
  103. kl_concept_common c1,
  104. </if>
  105. <if test="endSex != null or endAge != null">
  106. kl_concept_common c2,
  107. </if>
  108. `kl_concept` t3,
  109. `kl_relation_order` t4
  110. WHERE
  111. t1.is_deleted = 'N'
  112. AND t2.is_deleted = 'N'
  113. AND t3.is_deleted = 'N'
  114. AND t4.is_deleted = 'N'
  115. AND t1.id = t2.start_id
  116. AND t3.id = t2.end_id
  117. AND t2.id = t4.t_relation_id
  118. <if test="startId != null">
  119. AND t2.start_id = #{startId}
  120. </if>
  121. <if test="startName != null and startName != ''">
  122. AND t1.lib_name = #{startName}
  123. </if>
  124. <if test="startSex != null or startAge != null">
  125. AND c1.is_deleted = 'N'
  126. <if test="startSex != null">
  127. <if test="startSex == 3">
  128. and c1.sex_type in ('1','2','3')
  129. </if>
  130. <if test="startSex != 3">
  131. and c1.sex_type in ('3',#{startSex})
  132. </if>
  133. </if>
  134. <if test="startAge != null">
  135. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  136. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  137. </if>
  138. AND t2.start_id = c1.concept_id
  139. </if>
  140. <if test="startNameList != null and startNameList.size() > 0">
  141. AND t1.lib_name in
  142. <foreach collection="startNameList" item="item" open="(" close=")" separator=",">
  143. #{item}
  144. </foreach>
  145. </if>
  146. <if test="startType != null">
  147. AND t1.lib_type = #{startType}
  148. </if>
  149. <if test="relationType != null">
  150. AND t2.relation_id = #{relationType}
  151. </if>
  152. <if test="endId != null">
  153. AND t2.end_id = #{endId}
  154. </if>
  155. <if test="endName != null and endName != ''">
  156. AND t3.lib_name = #{endName}
  157. </if>
  158. <if test="endSex != null or endAge != null">
  159. AND c2.is_deleted = 'N'
  160. <if test="endSex != null">
  161. <if test="endSex == 3">
  162. and c2.sex_type in ('1','2','3')
  163. </if>
  164. <if test="endSex != 3">
  165. and c2.sex_type in ('3',#{endSex})
  166. </if>
  167. </if>
  168. <if test="endAge != null">
  169. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  170. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  171. </if>
  172. AND t2.end_id = c2.concept_id
  173. </if>
  174. <if test="endNameList != null and endNameList.size() > 0">
  175. AND t3.lib_name in
  176. <foreach collection="endNameList" item="item" open="(" close=")" separator=",">
  177. #{item}
  178. </foreach>
  179. </if>
  180. <if test="endType != null">
  181. AND t3.lib_type = #{endType}
  182. </if>
  183. ORDER BY t4.order_no
  184. </select>
  185. <select id="retrievalConcept" resultType="com.diagbot.dto.ConceptRetrievalDTO">
  186. SELECT a1.* from (
  187. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  188. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  189. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  190. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  191. <if test="isStatic != null and isStatic == 1">
  192. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
  193. </if>
  194. WHERE
  195. t1.is_deleted = 'N'
  196. AND t2.is_deleted = 'N'
  197. AND t3.is_deleted = 'N'
  198. AND t6.is_deleted = 'N'
  199. <if test="isStatic != null and isStatic == 1">
  200. AND t7.is_deleted = 'N'
  201. </if>
  202. <if test="type != null">
  203. AND t1.lib_type = #{type}
  204. </if>
  205. <if test="otherType != null and otherType.size > 0">
  206. and t1.lib_type in
  207. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  208. #{type}
  209. </foreach>
  210. </if>
  211. <if test="sexType == 3">
  212. and t3.sex_type in ('1','2','3')
  213. </if>
  214. <if test="sexType != 3">
  215. and t3.sex_type in ('3',#{sexType})
  216. </if>
  217. <if test="age != null and age != ''">
  218. AND <![CDATA[ t3.min_age <= #{age} ]]>
  219. AND <![CDATA[ t3.max_age >= #{age} ]]>
  220. </if>
  221. <if test="inputIds != null and inputIds.size > 0">
  222. and t1.id not in
  223. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  224. #{id}
  225. </foreach>
  226. </if>
  227. AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
  228. <if test="isStatic != null and isStatic == 1">
  229. GROUP BY t1.id
  230. </if>
  231. <if test="isStatic == null or isStatic != 1">
  232. LIMIT 100
  233. </if>)
  234. UNION
  235. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  236. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  237. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  238. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  239. <if test="isStatic != null and isStatic == 1">
  240. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
  241. </if>
  242. WHERE
  243. t1.is_deleted = 'N'
  244. AND t2.is_deleted = 'N'
  245. AND t3.is_deleted = 'N'
  246. AND t6.is_deleted = 'N'
  247. <if test="isStatic != null and isStatic == 1">
  248. AND t7.is_deleted = 'N'
  249. </if>
  250. <if test="type != null">
  251. AND t1.lib_type = #{type}
  252. </if>
  253. <if test="otherType != null and otherType.size > 0">
  254. and t1.lib_type in
  255. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  256. #{type}
  257. </foreach>
  258. </if>
  259. <if test="sexType == 3">
  260. and t3.sex_type in ('1','2','3')
  261. </if>
  262. <if test="sexType != 3">
  263. and t3.sex_type in ('3',#{sexType})
  264. </if>
  265. <if test="age != null and age != ''">
  266. AND <![CDATA[ t3.min_age <= #{age} ]]>
  267. AND <![CDATA[ t3.max_age >= #{age} ]]>
  268. </if>
  269. <if test="inputIds != null and inputIds.size > 0">
  270. and t1.id not in
  271. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  272. #{id}
  273. </foreach>
  274. </if>
  275. AND (t2.spell LIKE CONCAT( UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
  276. <if test="isStatic != null and isStatic == 1">
  277. GROUP BY t1.id
  278. </if>
  279. <if test="isStatic == null or isStatic != 1">
  280. LIMIT 100
  281. </if>)
  282. UNION
  283. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  284. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  285. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  286. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  287. <if test="isStatic != null and isStatic == 1">
  288. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
  289. </if>
  290. WHERE
  291. t1.is_deleted = 'N'
  292. AND t2.is_deleted = 'N'
  293. AND t3.is_deleted = 'N'
  294. AND t6.is_deleted = 'N'
  295. <if test="isStatic != null and isStatic == 1">
  296. AND t7.is_deleted = 'N'
  297. </if>
  298. <if test="type != null">
  299. AND t1.lib_type = #{type}
  300. </if>
  301. <if test="otherType != null and otherType.size > 0">
  302. and t1.lib_type in
  303. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  304. #{type}
  305. </foreach>
  306. </if>
  307. <if test="sexType == 3">
  308. and t3.sex_type in ('1','2','3')
  309. </if>
  310. <if test="sexType != 3">
  311. and t3.sex_type in ('3',#{sexType})
  312. </if>
  313. <if test="age != null and age != ''">
  314. AND <![CDATA[ t3.min_age <= #{age} ]]>
  315. AND <![CDATA[ t3.max_age >= #{age} ]]>
  316. </if>
  317. <if test="inputIds != null and inputIds.size > 0">
  318. and t1.id not in
  319. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  320. #{id}
  321. </foreach>
  322. </if>
  323. AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
  324. <if test="isStatic != null and isStatic == 1">
  325. GROUP BY t1.id
  326. </if>
  327. <if test="isStatic == null or isStatic != 1">
  328. LIMIT 100
  329. </if>)
  330. <if test="detilType != null and detilType != ''">
  331. UNION
  332. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  333. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  334. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  335. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  336. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  337. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  338. <if test="isStatic != null and isStatic == 1">
  339. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t5.id
  340. </if>
  341. WHERE
  342. t1.is_deleted = 'N'
  343. AND t2.is_deleted = 'N'
  344. AND t3.is_deleted = 'N'
  345. AND t4.is_deleted = 'N'
  346. AND t5.is_deleted = 'N'
  347. AND t6.is_deleted = 'N'
  348. <if test="isStatic != null and isStatic == 1">
  349. AND t7.is_deleted = 'N'
  350. </if>
  351. <if test="detilType != null">
  352. AND t1.lib_type = #{detilType}
  353. </if>
  354. <if test="sexType == 3">
  355. and t3.sex_type in ('1','2','3')
  356. </if>
  357. <if test="sexType != 3">
  358. and t3.sex_type in ('3',#{sexType})
  359. </if>
  360. <if test="age != null and age != ''">
  361. AND <![CDATA[ t3.min_age <= #{age} ]]>
  362. AND <![CDATA[ t3.max_age >= #{age} ]]>
  363. </if>
  364. AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
  365. <if test="inputIds != null and inputIds.size > 0">
  366. and t1.id not in
  367. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  368. #{id}
  369. </foreach>
  370. </if>
  371. AND t4.relation_id = 18
  372. <if test="isStatic != null and isStatic == 1">
  373. GROUP BY t5.id
  374. </if>
  375. <if test="isStatic == null or isStatic != 1">
  376. LIMIT 100
  377. </if>)
  378. UNION
  379. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  380. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  381. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  382. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  383. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  384. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  385. <if test="isStatic != null and isStatic == 1">
  386. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t5.id
  387. </if>
  388. WHERE
  389. t1.is_deleted = 'N'
  390. AND t2.is_deleted = 'N'
  391. AND t3.is_deleted = 'N'
  392. AND t4.is_deleted = 'N'
  393. AND t5.is_deleted = 'N'
  394. AND t6.is_deleted = 'N'
  395. <if test="isStatic != null and isStatic == 1">
  396. AND t7.is_deleted = 'N'
  397. </if>
  398. <if test="detilType != null">
  399. AND t1.lib_type = #{detilType}
  400. </if>
  401. <if test="sexType == 3">
  402. and t3.sex_type in ('1','2','3')
  403. </if>
  404. <if test="sexType != 3">
  405. and t3.sex_type in ('3',#{sexType})
  406. </if>
  407. <if test="age != null and age != ''">
  408. AND <![CDATA[ t3.min_age <= #{age} ]]>
  409. AND <![CDATA[ t3.max_age >= #{age} ]]>
  410. </if>
  411. AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
  412. <if test="inputIds != null and inputIds.size > 0">
  413. and t1.id not in
  414. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  415. #{id}
  416. </foreach>
  417. </if>
  418. <if test="isStatic != null and isStatic == 1">
  419. GROUP BY t5.id
  420. </if>
  421. AND t4.relation_id = 18
  422. <if test="isStatic == null or isStatic != 1">
  423. LIMIT 100
  424. </if>)
  425. UNION
  426. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  427. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  428. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  429. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  430. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  431. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  432. <if test="isStatic != null and isStatic == 1">
  433. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t5.id
  434. </if>
  435. WHERE
  436. t1.is_deleted = 'N'
  437. AND t2.is_deleted = 'N'
  438. AND t3.is_deleted = 'N'
  439. AND t4.is_deleted = 'N'
  440. AND t5.is_deleted = 'N'
  441. AND t6.is_deleted = 'N'
  442. <if test="isStatic != null and isStatic == 1">
  443. AND t7.is_deleted = 'N'
  444. </if>
  445. <if test="detilType != null">
  446. AND t1.lib_type = #{detilType}
  447. </if>
  448. <if test="sexType == 3">
  449. and t3.sex_type in ('1','2','3')
  450. </if>
  451. <if test="sexType != 3">
  452. and t3.sex_type in ('3',#{sexType})
  453. </if>
  454. <if test="age != null and age != ''">
  455. AND <![CDATA[ t3.min_age <= #{age} ]]>
  456. AND <![CDATA[ t3.max_age >= #{age} ]]>
  457. </if>
  458. AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
  459. <if test="inputIds != null and inputIds.size > 0">
  460. and t1.id not in
  461. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  462. #{id}
  463. </foreach>
  464. </if>
  465. <if test="isStatic != null and isStatic == 1">
  466. GROUP BY t5.id
  467. </if>
  468. AND t4.relation_id = 18
  469. <if test="isStatic == null or isStatic != 1">
  470. LIMIT 100
  471. </if>)
  472. </if>
  473. ) a1
  474. <if test="isStatic == null or isStatic != 1">
  475. LIMIT 100
  476. </if>
  477. </select>
  478. <select id="staticKnowledge" resultType="com.diagbot.dto.ConceptRetrievalDTO">
  479. SELECT a1.* from (
  480. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  481. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  482. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  483. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  484. WHERE
  485. t1.is_deleted = 'N'
  486. AND t2.is_deleted = 'N'
  487. AND t3.is_deleted = 'N'
  488. AND t6.is_deleted = 'N'
  489. <if test="type != null">
  490. AND t1.lib_type = #{type}
  491. </if>
  492. <if test="otherType != null and otherType.size > 0">
  493. and t1.lib_type in
  494. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  495. #{type}
  496. </foreach>
  497. </if>
  498. <if test="sexType == 3">
  499. and t3.sex_type in ('1','2','3')
  500. </if>
  501. <if test="sexType != 3">
  502. and t3.sex_type in ('3',#{sexType})
  503. </if>
  504. <if test="age != null and age != ''">
  505. AND <![CDATA[ t3.min_age <= #{age} ]]>
  506. AND <![CDATA[ t3.max_age >= #{age} ]]>
  507. </if>
  508. <if test="inputIds != null and inputIds.size > 0">
  509. and t1.id not in
  510. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  511. #{id}
  512. </foreach>
  513. </if>
  514. AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
  515. <if test="isStatic != null and isStatic == 1">
  516. GROUP BY t1.id
  517. </if>
  518. <if test="isStatic == null or isStatic != 1">
  519. LIMIT 100
  520. </if>)
  521. UNION
  522. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  523. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  524. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  525. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  526. WHERE
  527. t1.is_deleted = 'N'
  528. AND t2.is_deleted = 'N'
  529. AND t3.is_deleted = 'N'
  530. AND t6.is_deleted = 'N'
  531. <if test="type != null">
  532. AND t1.lib_type = #{type}
  533. </if>
  534. <if test="otherType != null and otherType.size > 0">
  535. and t1.lib_type in
  536. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  537. #{type}
  538. </foreach>
  539. </if>
  540. <if test="sexType == 3">
  541. and t3.sex_type in ('1','2','3')
  542. </if>
  543. <if test="sexType != 3">
  544. and t3.sex_type in ('3',#{sexType})
  545. </if>
  546. <if test="age != null and age != ''">
  547. AND <![CDATA[ t3.min_age <= #{age} ]]>
  548. AND <![CDATA[ t3.max_age >= #{age} ]]>
  549. </if>
  550. <if test="inputIds != null and inputIds.size > 0">
  551. and t1.id not in
  552. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  553. #{id}
  554. </foreach>
  555. </if>
  556. AND (t2.spell LIKE CONCAT( UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
  557. <if test="isStatic != null and isStatic == 1">
  558. GROUP BY t1.id
  559. </if>
  560. <if test="isStatic == null or isStatic != 1">
  561. LIMIT 100
  562. </if>)
  563. UNION
  564. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  565. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  566. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  567. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  568. WHERE
  569. t1.is_deleted = 'N'
  570. AND t2.is_deleted = 'N'
  571. AND t3.is_deleted = 'N'
  572. AND t6.is_deleted = 'N'
  573. <if test="type != null">
  574. AND t1.lib_type = #{type}
  575. </if>
  576. <if test="otherType != null and otherType.size > 0">
  577. and t1.lib_type in
  578. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  579. #{type}
  580. </foreach>
  581. </if>
  582. <if test="sexType == 3">
  583. and t3.sex_type in ('1','2','3')
  584. </if>
  585. <if test="sexType != 3">
  586. and t3.sex_type in ('3',#{sexType})
  587. </if>
  588. <if test="age != null and age != ''">
  589. AND <![CDATA[ t3.min_age <= #{age} ]]>
  590. AND <![CDATA[ t3.max_age >= #{age} ]]>
  591. </if>
  592. <if test="inputIds != null and inputIds.size > 0">
  593. and t1.id not in
  594. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  595. #{id}
  596. </foreach>
  597. </if>
  598. AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
  599. <if test="isStatic != null and isStatic == 1">
  600. GROUP BY t1.id
  601. </if>
  602. <if test="isStatic == null or isStatic != 1">
  603. LIMIT 100
  604. </if>)
  605. <if test="detilType != null and detilType != ''">
  606. UNION
  607. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType
  608. <if test="isStatic != null and isStatic == 1">
  609. ,t1.lib_type libTypeId
  610. </if>
  611. <if test="isStatic == null or isStatic != 1">
  612. ,t5.lib_type libTypeId
  613. </if> ,t6.`name` libTypeName FROM kl_concept t1
  614. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  615. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  616. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  617. LEFT JOIN kl_lexicon t6 ON
  618. <if test="isStatic != null and isStatic == 1">
  619. t6.id = t1.lib_type
  620. </if>
  621. <if test="isStatic == null or isStatic != 1">
  622. t6.id = t5.lib_type
  623. </if>
  624. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  625. WHERE
  626. t1.is_deleted = 'N'
  627. AND t2.is_deleted = 'N'
  628. AND t3.is_deleted = 'N'
  629. AND t4.is_deleted = 'N'
  630. AND t5.is_deleted = 'N'
  631. AND t6.is_deleted = 'N'
  632. <if test="detilType != null">
  633. AND t1.lib_type = #{detilType}
  634. </if>
  635. <if test="sexType == 3">
  636. and t3.sex_type in ('1','2','3')
  637. </if>
  638. <if test="sexType != 3">
  639. and t3.sex_type in ('3',#{sexType})
  640. </if>
  641. <if test="age != null and age != ''">
  642. AND <![CDATA[ t3.min_age <= #{age} ]]>
  643. AND <![CDATA[ t3.max_age >= #{age} ]]>
  644. </if>
  645. AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
  646. <if test="inputIds != null and inputIds.size > 0">
  647. and t1.id not in
  648. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  649. #{id}
  650. </foreach>
  651. </if>
  652. AND t4.relation_id = 18
  653. <if test="isStatic != null and isStatic == 1">
  654. GROUP BY t5.id
  655. </if>
  656. <if test="isStatic == null or isStatic != 1">
  657. LIMIT 100
  658. </if>)
  659. UNION
  660. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType
  661. <if test="isStatic != null and isStatic == 1">
  662. ,t1.lib_type libTypeId
  663. </if>
  664. <if test="isStatic == null or isStatic != 1">
  665. ,t5.lib_type libTypeId
  666. </if> ,t6.`name` libTypeName FROM kl_concept t1
  667. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  668. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  669. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  670. LEFT JOIN kl_lexicon t6 ON
  671. <if test="isStatic != null and isStatic == 1">
  672. t6.id = t1.lib_type
  673. </if>
  674. <if test="isStatic == null or isStatic != 1">
  675. t6.id = t5.lib_type
  676. </if>
  677. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  678. WHERE
  679. t1.is_deleted = 'N'
  680. AND t2.is_deleted = 'N'
  681. AND t3.is_deleted = 'N'
  682. AND t4.is_deleted = 'N'
  683. AND t5.is_deleted = 'N'
  684. AND t6.is_deleted = 'N'
  685. <if test="detilType != null">
  686. AND t1.lib_type = #{detilType}
  687. </if>
  688. <if test="sexType == 3">
  689. and t3.sex_type in ('1','2','3')
  690. </if>
  691. <if test="sexType != 3">
  692. and t3.sex_type in ('3',#{sexType})
  693. </if>
  694. <if test="age != null and age != ''">
  695. AND <![CDATA[ t3.min_age <= #{age} ]]>
  696. AND <![CDATA[ t3.max_age >= #{age} ]]>
  697. </if>
  698. AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
  699. <if test="inputIds != null and inputIds.size > 0">
  700. and t1.id not in
  701. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  702. #{id}
  703. </foreach>
  704. </if>
  705. AND t4.relation_id = 18
  706. <if test="isStatic != null and isStatic == 1">
  707. GROUP BY t5.id
  708. </if>
  709. <if test="isStatic == null or isStatic != 1">
  710. LIMIT 100
  711. </if>)
  712. UNION
  713. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType
  714. <if test="isStatic != null and isStatic == 1">
  715. ,t1.lib_type libTypeId
  716. </if>
  717. <if test="isStatic == null or isStatic != 1">
  718. ,t5.lib_type libTypeId
  719. </if> ,t6.`name` libTypeName FROM kl_concept t1
  720. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  721. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  722. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  723. LEFT JOIN kl_lexicon t6 ON
  724. <if test="isStatic != null and isStatic == 1">
  725. t6.id = t1.lib_type
  726. </if>
  727. <if test="isStatic == null or isStatic != 1">
  728. t6.id = t5.lib_type
  729. </if>
  730. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  731. WHERE
  732. t1.is_deleted = 'N'
  733. AND t2.is_deleted = 'N'
  734. AND t3.is_deleted = 'N'
  735. AND t4.is_deleted = 'N'
  736. AND t5.is_deleted = 'N'
  737. AND t6.is_deleted = 'N'
  738. <if test="detilType != null">
  739. AND t1.lib_type = #{detilType}
  740. </if>
  741. <if test="sexType == 3">
  742. and t3.sex_type in ('1','2','3')
  743. </if>
  744. <if test="sexType != 3">
  745. and t3.sex_type in ('3',#{sexType})
  746. </if>
  747. <if test="age != null and age != ''">
  748. AND <![CDATA[ t3.min_age <= #{age} ]]>
  749. AND <![CDATA[ t3.max_age >= #{age} ]]>
  750. </if>
  751. AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
  752. <if test="inputIds != null and inputIds.size > 0">
  753. and t1.id not in
  754. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  755. #{id}
  756. </foreach>
  757. </if>
  758. AND t4.relation_id = 18
  759. <if test="isStatic != null and isStatic == 1">
  760. GROUP BY t5.id
  761. </if>
  762. <if test="isStatic == null or isStatic != 1">
  763. LIMIT 100
  764. </if>)
  765. </if>
  766. <if test="isStatic != null and isStatic == 1">
  767. UNION
  768. (SELECT 0 selfId,null selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  769. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  770. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  771. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  772. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  773. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  774. WHERE
  775. t1.is_deleted = 'N'
  776. AND t2.is_deleted = 'N'
  777. AND t3.is_deleted = 'N'
  778. AND t4.is_deleted = 'N'
  779. AND t5.is_deleted = 'N'
  780. AND t6.is_deleted = 'N'
  781. <if test="detilType != null">
  782. AND t1.lib_type = #{detilType}
  783. </if>
  784. <if test="sexType == 3">
  785. and t3.sex_type in ('1','2','3')
  786. </if>
  787. <if test="sexType != 3">
  788. and t3.sex_type in ('3',#{sexType})
  789. </if>
  790. <if test="age != null and age != ''">
  791. AND <![CDATA[ t3.min_age <= #{age} ]]>
  792. AND <![CDATA[ t3.max_age >= #{age} ]]>
  793. </if>
  794. AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
  795. <if test="inputIds != null and inputIds.size > 0">
  796. and t1.id not in
  797. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  798. #{id}
  799. </foreach>
  800. </if>
  801. AND t4.relation_id = 18
  802. <if test="isStatic != null and isStatic == 1">
  803. GROUP BY t5.id
  804. </if>
  805. <if test="isStatic == null or isStatic != 1">
  806. LIMIT 100
  807. </if>)
  808. UNION
  809. (SELECT 0 selfId,null selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  810. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  811. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  812. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  813. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  814. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  815. WHERE
  816. t1.is_deleted = 'N'
  817. AND t2.is_deleted = 'N'
  818. AND t3.is_deleted = 'N'
  819. AND t4.is_deleted = 'N'
  820. AND t5.is_deleted = 'N'
  821. AND t6.is_deleted = 'N'
  822. <if test="detilType != null">
  823. AND t1.lib_type = #{detilType}
  824. </if>
  825. <if test="sexType == 3">
  826. and t3.sex_type in ('1','2','3')
  827. </if>
  828. <if test="sexType != 3">
  829. and t3.sex_type in ('3',#{sexType})
  830. </if>
  831. <if test="age != null and age != ''">
  832. AND <![CDATA[ t3.min_age <= #{age} ]]>
  833. AND <![CDATA[ t3.max_age >= #{age} ]]>
  834. </if>
  835. AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
  836. <if test="inputIds != null and inputIds.size > 0">
  837. and t1.id not in
  838. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  839. #{id}
  840. </foreach>
  841. </if>
  842. AND t4.relation_id = 18
  843. <if test="isStatic != null and isStatic == 1">
  844. GROUP BY t5.id
  845. </if>
  846. <if test="isStatic == null or isStatic != 1">
  847. LIMIT 100
  848. </if>)
  849. UNION
  850. (SELECT 0 selfId,null selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  851. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  852. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  853. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  854. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  855. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  856. WHERE
  857. t1.is_deleted = 'N'
  858. AND t2.is_deleted = 'N'
  859. AND t3.is_deleted = 'N'
  860. AND t4.is_deleted = 'N'
  861. AND t5.is_deleted = 'N'
  862. AND t6.is_deleted = 'N'
  863. <if test="detilType != null">
  864. AND t1.lib_type = #{detilType}
  865. </if>
  866. <if test="sexType == 3">
  867. and t3.sex_type in ('1','2','3')
  868. </if>
  869. <if test="sexType != 3">
  870. and t3.sex_type in ('3',#{sexType})
  871. </if>
  872. <if test="age != null and age != ''">
  873. AND <![CDATA[ t3.min_age <= #{age} ]]>
  874. AND <![CDATA[ t3.max_age >= #{age} ]]>
  875. </if>
  876. AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
  877. <if test="inputIds != null and inputIds.size > 0">
  878. and t1.id not in
  879. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  880. #{id}
  881. </foreach>
  882. </if>
  883. AND t4.relation_id = 18
  884. <if test="isStatic != null and isStatic == 1">
  885. GROUP BY t5.id
  886. </if>
  887. <if test="isStatic == null or isStatic != 1">
  888. LIMIT 100
  889. </if>)
  890. </if>
  891. ) a1
  892. <if test="isStatic == null or isStatic != 1">
  893. LIMIT 100
  894. </if>
  895. </select>
  896. <select id="getConceptConMap" resultType="com.diagbot.dto.ConceptBaseDTO" parameterType="com.diagbot.vo.ConceptFindVO">
  897. SELECT
  898. t1.id as conceptId,
  899. t1.lib_name as name
  900. FROM
  901. kl_concept t1,
  902. kl_concept_common t2
  903. WHERE
  904. t1.id = t2.concept_id
  905. AND t1.is_deleted = 'N'
  906. AND t2.is_deleted = 'N'
  907. <if test="conceptIds != null and conceptIds.size > 0">
  908. and t1.id in
  909. <foreach item="id" collection="conceptIds" open="(" separator="," close=")">
  910. #{id}
  911. </foreach>
  912. </if>
  913. <if test="sexType == 3">
  914. AND t2.sex_type IN ('1','2','3')
  915. </if>
  916. <if test="sexType != 3">
  917. AND t2.sex_type IN ('3',#{sexType})
  918. </if>
  919. <if test="age != null and age != ''">
  920. AND <![CDATA[ t2.min_age <= #{age} ]]>
  921. AND <![CDATA[ t2.max_age >= #{age} ]]>
  922. </if>
  923. </select>
  924. <select id="getStandWord" resultType="java.lang.String">
  925. SELECT lib_name FROM kl_concept WHERE is_deleted = 'N' AND lib_type = 33
  926. </select>
  927. </mapper>