ConceptMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. WHERE
  339. t1.is_deleted = 'N'
  340. AND t2.is_deleted = 'N'
  341. AND t3.is_deleted = 'N'
  342. AND t4.is_deleted = 'N'
  343. AND t5.is_deleted = 'N'
  344. AND t6.is_deleted = 'N'
  345. <if test="detilType != null">
  346. AND t1.lib_type = #{detilType}
  347. </if>
  348. <if test="sexType == 3">
  349. and t3.sex_type in ('1','2','3')
  350. </if>
  351. <if test="sexType != 3">
  352. and t3.sex_type in ('3',#{sexType})
  353. </if>
  354. <if test="age != null and age != ''">
  355. AND <![CDATA[ t3.min_age <= #{age} ]]>
  356. AND <![CDATA[ t3.max_age >= #{age} ]]>
  357. </if>
  358. AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
  359. <if test="inputIds != null and inputIds.size > 0">
  360. and t1.id not in
  361. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  362. #{id}
  363. </foreach>
  364. </if>
  365. AND t4.relation_id = 18
  366. <if test="isStatic != null and isStatic == 1">
  367. GROUP BY t5.id
  368. </if>
  369. <if test="isStatic == null or isStatic != 1">
  370. LIMIT 100
  371. </if>)
  372. UNION
  373. (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
  374. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  375. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  376. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  377. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  378. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  379. WHERE
  380. t1.is_deleted = 'N'
  381. AND t2.is_deleted = 'N'
  382. AND t3.is_deleted = 'N'
  383. AND t4.is_deleted = 'N'
  384. AND t5.is_deleted = 'N'
  385. AND t6.is_deleted = 'N'
  386. <if test="detilType != null">
  387. AND t1.lib_type = #{detilType}
  388. </if>
  389. <if test="sexType == 3">
  390. and t3.sex_type in ('1','2','3')
  391. </if>
  392. <if test="sexType != 3">
  393. and t3.sex_type in ('3',#{sexType})
  394. </if>
  395. <if test="age != null and age != ''">
  396. AND <![CDATA[ t3.min_age <= #{age} ]]>
  397. AND <![CDATA[ t3.max_age >= #{age} ]]>
  398. </if>
  399. AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
  400. <if test="inputIds != null and inputIds.size > 0">
  401. and t1.id not in
  402. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  403. #{id}
  404. </foreach>
  405. </if>
  406. AND t4.relation_id = 18
  407. <if test="isStatic != null and isStatic == 1">
  408. GROUP BY t5.id
  409. </if>
  410. <if test="isStatic == null or isStatic != 1">
  411. LIMIT 100
  412. </if>)
  413. UNION
  414. (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
  415. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  416. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  417. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  418. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  419. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  420. WHERE
  421. t1.is_deleted = 'N'
  422. AND t2.is_deleted = 'N'
  423. AND t3.is_deleted = 'N'
  424. AND t4.is_deleted = 'N'
  425. AND t5.is_deleted = 'N'
  426. AND t6.is_deleted = 'N'
  427. <if test="detilType != null">
  428. AND t1.lib_type = #{detilType}
  429. </if>
  430. <if test="sexType == 3">
  431. and t3.sex_type in ('1','2','3')
  432. </if>
  433. <if test="sexType != 3">
  434. and t3.sex_type in ('3',#{sexType})
  435. </if>
  436. <if test="age != null and age != ''">
  437. AND <![CDATA[ t3.min_age <= #{age} ]]>
  438. AND <![CDATA[ t3.max_age >= #{age} ]]>
  439. </if>
  440. AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
  441. <if test="inputIds != null and inputIds.size > 0">
  442. and t1.id not in
  443. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  444. #{id}
  445. </foreach>
  446. </if>
  447. AND t4.relation_id = 18
  448. <if test="isStatic != null and isStatic == 1">
  449. GROUP BY t5.id
  450. </if>
  451. <if test="isStatic == null or isStatic != 1">
  452. LIMIT 100
  453. </if>)
  454. </if>
  455. ) a1
  456. <if test="isStatic == null or isStatic != 1">
  457. LIMIT 100
  458. </if>
  459. </select>
  460. <select id="getConceptConMap" resultType="com.diagbot.dto.ConceptBaseDTO" parameterType="com.diagbot.vo.ConceptFindVO">
  461. SELECT
  462. t1.id as conceptId,
  463. t1.lib_name as name
  464. FROM
  465. kl_concept t1,
  466. kl_concept_common t2
  467. WHERE
  468. t1.id = t2.concept_id
  469. AND t1.is_deleted = 'N'
  470. AND t2.is_deleted = 'N'
  471. <if test="conceptIds != null and conceptIds.size > 0">
  472. and t1.id in
  473. <foreach item="id" collection="conceptIds" open="(" separator="," close=")">
  474. #{id}
  475. </foreach>
  476. </if>
  477. <if test="sexType == 3">
  478. AND t2.sex_type IN ('1','2','3')
  479. </if>
  480. <if test="sexType != 3">
  481. AND t2.sex_type IN ('3',#{sexType})
  482. </if>
  483. <if test="age != null and age != ''">
  484. AND <![CDATA[ t2.min_age <= #{age} ]]>
  485. AND <![CDATA[ t2.max_age >= #{age} ]]>
  486. </if>
  487. </select>
  488. <select id="getStandWord" resultType="java.lang.String">
  489. SELECT lib_name FROM kl_concept WHERE is_deleted = 'N' AND lib_type = 33
  490. </select>
  491. </mapper>