KlRuleMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.diagbot.mapper.KlRuleMapper">
  5. <!-- 通用查询映射结果 -->
  6. <resultMap id="BaseResultMap" type="com.diagbot.entity.KlRule">
  7. <id column="id" property="id"/>
  8. <result column="is_deleted" property="isDeleted"/>
  9. <result column="gmt_create" property="gmtCreate"/>
  10. <result column="gmt_modified" property="gmtModified"/>
  11. <result column="creator" property="creator"/>
  12. <result column="modifier" property="modifier"/>
  13. <result column="concept_id" property="conceptId"/>
  14. <result column="description" property="description"/>
  15. <result column="rule_type" property="ruleType"/>
  16. <result column="status" property="status"/>
  17. </resultMap>
  18. <resultMap id="SchemaResultMap" type="com.diagbot.dto.RuleDTO">
  19. <result column="libName" property="libName"/>
  20. <result column="libType" property="libType"/>
  21. <result column="ruleType" property="ruleType"/>
  22. <collection property="ruleConditionDTOList" ofType="com.diagbot.dto.RuleConditionDTO">
  23. <result column="hasSubCond" property="hasSubCond"/>
  24. <result column="ruleGroup" property="ruleGroup"/>
  25. <result column="msg" property="msg"/>
  26. <collection property="ruleBaseDTOList" ofType="com.diagbot.dto.RuleBaseDTO">
  27. <result column="baseLibName" property="baseLibName"/>
  28. <result column="baseLibType" property="baseLibType"/>
  29. <result column="baseType" property="baseType"/>
  30. <result column="baseMinOperator" property="baseMinOperator"/>
  31. <result column="baseMinValue" property="baseMinValue"/>
  32. <result column="baseMinUnit" property="baseMinUnit"/>
  33. <result column="baseMaxOperator" property="baseMaxOperator"/>
  34. <result column="baseMaxValue" property="baseMaxValue"/>
  35. <result column="baseMaxUnit" property="baseMaxUnit"/>
  36. <result column="baseEqOperator" property="baseEqOperator"/>
  37. <result column="baseEqValue" property="baseEqValue"/>
  38. <result column="baseEqUnit" property="baseEqUnit"/>
  39. </collection>
  40. </collection>
  41. </resultMap>
  42. <select id="getAllRule" resultMap="SchemaResultMap">
  43. SELECT
  44. t10.*
  45. FROM
  46. (
  47. SELECT
  48. t4.lib_name AS libName,
  49. t4.lib_type AS libType,
  50. t1.rule_type AS ruleType,
  51. t1.msg AS msg,
  52. t1.has_sub_cond AS hasSubCond,
  53. CONCAT_WS("-", t1.id, 1) AS ruleGroup,
  54. "" AS baseLibName,
  55. 0 AS baseLibType,
  56. 0 AS baseType,
  57. "" AS baseMinOperator,
  58. "" AS baseMinValue,
  59. "" AS baseMinUnit,
  60. "" AS baseMaxOperator,
  61. "" AS baseMaxValue,
  62. "" AS baseMaxUnit,
  63. "" AS baseEqOperator,
  64. "" AS baseEqValue,
  65. "" AS baseEqUnit
  66. FROM
  67. kl_rule t1,
  68. kl_concept t4
  69. WHERE
  70. t1.is_deleted = "N"
  71. AND t4.is_deleted = "N"
  72. AND t1.concept_id = t4.id
  73. AND t1. STATUS = 1
  74. AND t4. STATUS = 1
  75. AND t1.has_sub_cond = 0
  76. UNION ALL
  77. SELECT
  78. t4.lib_name AS libName,
  79. t4.lib_type AS libType,
  80. t1.rule_type AS ruleType,
  81. t1.msg AS msg,
  82. t1.has_sub_cond AS hasSubCond,
  83. CONCAT_WS("-", t1.id, t2.group_type) AS ruleGroup,
  84. t5.lib_name AS baseLibName,
  85. t5.lib_type AS baseLibType,
  86. t3.type AS baseType,
  87. t3.min_operator AS baseMinOperator,
  88. t3.min_value AS baseMinValue,
  89. t3.min_unit AS baseMinUnit,
  90. t3.max_operator AS baseMaxOperator,
  91. t3.max_value AS baseMaxValue,
  92. t3.max_unit AS baseMaxUnit,
  93. t3.eq_operator AS baseEqOperator,
  94. t3.eq_value AS baseEqValue,
  95. t3.eq_unit AS baseEqUnit
  96. FROM
  97. kl_rule t1,
  98. kl_rule_condition t2,
  99. kl_rule_base t3,
  100. kl_concept t4,
  101. kl_concept t5
  102. WHERE
  103. t1.is_deleted = "N"
  104. AND t2.is_deleted = "N"
  105. AND t3.is_deleted = "N"
  106. AND t4.is_deleted = "N"
  107. AND t5.is_deleted = "N"
  108. AND t1. STATUS = 1
  109. AND t3. STATUS = 1
  110. AND t4. STATUS = 1
  111. AND t5. STATUS = 1
  112. AND t1.id = t2.rule_id
  113. AND t2.rule_base_id = t3.id
  114. AND t1.concept_id = t4.id
  115. AND t3.concept_id = t5.id
  116. AND t1.has_sub_cond = 1
  117. ) t10
  118. ORDER BY
  119. t10.libType,
  120. t10.libName,
  121. t10.ruleType,
  122. t10.ruleGroup
  123. </select>
  124. <select id="getKlRuleInfoPage" resultType="com.diagbot.dto.KlRuleInfoDTO">
  125. SELECT
  126. ru.id as parId,
  127. ru.description as parDescription,
  128. ru.rule_type as parRuleType,
  129. ru.concept_id as parConceptId,
  130. co.lib_name as parConceptName,
  131. le.name as parLibTypeName,
  132. ru.has_sub_cond as parHasSub,
  133. ru.msg as parMsg,
  134. ru.status as parStatus,
  135. ru.gmt_modified as gmtModified,
  136. ru.modifier as modifier
  137. FROM
  138. kl_rule ru,
  139. kl_concept co,
  140. kl_lexicon le
  141. WHERE ru.is_deleted = 'N'
  142. AND co.is_deleted = 'N'
  143. AND le.is_deleted = 'N'
  144. AND ru.concept_id = co.`id`
  145. AND co.lib_type = le.`code`
  146. <if test="parDescription!=null and parDescription!=''">
  147. AND UPPER(ru.description) LIKE CONCAT('%', UPPER(trim(#{parDescription})), '%')
  148. </if>
  149. <if test="parRuleType !=null">
  150. AND ru.rule_type = #{parRuleType}
  151. </if>
  152. <if test="parConceptName!=null and parConceptName!=''">
  153. AND UPPER(co.lib_name) LIKE CONCAT('%', UPPER(trim(#{parConceptName})), '%')
  154. </if>
  155. <if test="parStatus!=null">
  156. AND ru.status = #{parStatus}
  157. </if>
  158. ORDER BY ru.status DESC ,ru.gmt_modified DESC,ru.id DESC
  159. </select>
  160. <select id="getByIdRuleInfo" resultType="com.diagbot.dto.KlRuleByIdDTO">
  161. SELECT
  162. par.*,
  163. CASE
  164. WHEN ISNULL(ruco.rule_id)
  165. THEN par.parId
  166. ELSE ruco.rule_id
  167. END AS ruleId,
  168. sub.*,
  169. ruco.msg AS subMsg,
  170. ruco.group_type AS groupType
  171. FROM
  172. (SELECT
  173. a.id AS parId,
  174. a.description AS parDescription,
  175. a.rule_type AS parRuleType,
  176. a.concept_id AS parconceptId,
  177. b.lib_name AS parlibName,
  178. a.has_sub_cond AS parHasSub,
  179. a.msg AS parMsg,
  180. a.status AS parStatus,
  181. c.name AS parLenName,
  182. c.code AS parLenCode
  183. FROM
  184. kl_rule a,
  185. kl_concept b,
  186. kl_lexicon c
  187. WHERE a.is_deleted = 'N'
  188. AND b.is_deleted = 'N'
  189. AND c.is_deleted = 'N'
  190. AND a.concept_id = b.id
  191. <if test="id != null">
  192. and a.id = #{id}
  193. </if>
  194. AND b.lib_type = c.code) par
  195. LEFT JOIN kl_rule_condition ruco
  196. ON par.parId = ruco.rule_id
  197. LEFT JOIN
  198. (SELECT
  199. c.id AS subId,
  200. c.description AS subDescription,
  201. c.concept_id AS subConceptId,
  202. d.lib_name AS subLibName,
  203. f.name AS subLenName,
  204. f.code AS subLenCode,
  205. c.type AS subType,
  206. c.min_operator AS subMinOperator,
  207. c.min_value AS subMinValue,
  208. c.min_unit AS subMinUnit,
  209. c.max_operator AS subMaxOperator,
  210. c.max_value AS subMaxValue,
  211. c.max_unit AS subMaxUnit,
  212. c.eq_operator AS subEqOperator,
  213. c.eq_value AS subEqValue,
  214. c.eq_unit AS subEqUnit
  215. FROM
  216. kl_rule_base c,
  217. kl_concept d,
  218. kl_lexicon f
  219. WHERE c.is_deleted = 'N'
  220. AND d.is_deleted = 'N'
  221. AND f.is_deleted = 'N'
  222. AND c.concept_id = d.id
  223. AND d.lib_type = f.code) sub
  224. ON sub.subId = ruco.rule_base_id
  225. </select>
  226. <select id="exportIndication" resultType="com.diagbot.dto.IndicationExportDTO">
  227. SELECT
  228. tt1.par_name,
  229. tt1.par_type,
  230. tt2.lib_name base_name,
  231. xx2.NAME base_type,
  232. CASE
  233. when tt1.type = '1' then '等于术语'
  234. when tt1.type = '2' then '比较'
  235. when tt1.type = '3' then '不等于术语'
  236. when tt1.type = '4' then '过敏'
  237. when tt1.type = '5' then '开单项互斥'
  238. when tt1.type = '6' then '正则'
  239. else '错误类型'
  240. end taboo_type,
  241. tt1.eq_value,
  242. tt1.min_value,
  243. tt1.min_operator,
  244. tt1.min_unit,
  245. tt1.max_value,
  246. tt1.max_operator,
  247. tt1.max_unit,
  248. tt1.description,
  249. tt1.msg,
  250. tt1.rule_id,
  251. tt1.cond_id
  252. FROM
  253. (
  254. SELECT
  255. c1.lib_name par_name,
  256. c1.id par_id,
  257. x1.`name` par_type,
  258. t1.id rule_id,
  259. t1.description,
  260. t1.rule_type,
  261. t1.has_sub_cond,
  262. t2.id cond_id,
  263. t2.msg,
  264. t3.type,
  265. t3.concept_id base_id,
  266. t3.eq_value,
  267. t3.min_value,
  268. t3.min_operator,
  269. t3.min_unit,
  270. t3.max_value,
  271. t3.max_operator,
  272. t3.max_unit
  273. FROM
  274. kl_concept c1,
  275. kl_lexicon x1,
  276. kl_rule t1,
  277. kl_rule_condition t2,
  278. kl_rule_base t3
  279. WHERE
  280. c1.is_deleted = 'N'
  281. AND t1.is_deleted = 'N'
  282. AND t2.is_deleted = 'N'
  283. AND t3.is_deleted = 'N'
  284. AND c1.`status` = 1
  285. AND t1.`status` = 1
  286. AND c1.id = t1.concept_id
  287. AND t1.id = t2.rule_id
  288. AND t2.rule_base_id = t3.id
  289. AND t1.rule_type = 1
  290. AND x1.`code` = c1.lib_type
  291. ) tt1
  292. LEFT JOIN kl_concept tt2 ON tt2.is_deleted = 'N'
  293. AND tt2.`status` = 1
  294. AND tt1.base_id = tt2.id
  295. LEFT JOIN kl_lexicon xx2 ON tt2.lib_type = xx2.CODE
  296. ORDER BY par_name, rule_id
  297. </select>
  298. <select id="exportOther" resultType="com.diagbot.dto.DefaultExportDTO">
  299. SELECT
  300. a.id rule_id,
  301. a.concept_id,
  302. f.lib_type,
  303. f.lib_name,
  304. g.name lib_type_cn,
  305. a.description rule_group,
  306. a.rule_type,
  307. a.has_sub_cond,
  308. b.group_type,
  309. b.msg,
  310. c.concept_id base_concept,
  311. d.lib_name baseName,
  312. d.lib_type baseType,
  313. e. NAME baseTypeCn,
  314. CASE
  315. WHEN c.type = '1' THEN
  316. '等于术语'
  317. WHEN c.type = '2' THEN
  318. '比较'
  319. WHEN c.type = '3' THEN
  320. '不等于术语'
  321. WHEN c.type = '4' THEN
  322. '过敏'
  323. WHEN c.type = '5' THEN
  324. '开单项互斥'
  325. WHEN c.type = '6' THEN
  326. '正则'
  327. ELSE
  328. '错误类型'
  329. END taboo_type,
  330. c.min_operator,
  331. c.min_value,
  332. c.max_operator,
  333. c.max_value,
  334. c.eq_value
  335. FROM
  336. kl_rule a,
  337. kl_rule_condition b,
  338. kl_rule_base c,
  339. kl_concept d,
  340. kl_lexicon e,
  341. kl_concept f,
  342. kl_lexicon g
  343. WHERE
  344. a.is_deleted = 'N'
  345. AND b.is_deleted = 'N'
  346. AND c.is_deleted = 'N'
  347. AND d.is_deleted = 'N'
  348. AND e.is_deleted = 'N'
  349. AND f.is_deleted = 'N'
  350. AND g.is_deleted = 'N'
  351. AND a.`status` = 1
  352. AND d.`status` = 1
  353. AND f.`status` = 1
  354. AND a.id = b.rule_id
  355. AND b.rule_base_id = c.id
  356. AND c.concept_id = d.id
  357. AND d.lib_type = e.`code`
  358. AND a.concept_id = f.id
  359. AND f.lib_type = g.`code`
  360. <if test="ruleType != null">
  361. AND a.rule_type = #{ruleType}
  362. </if>
  363. <if test="libTypeList != null and libTypeList.size() > 0">
  364. and f.lib_type in
  365. <foreach collection="libTypeList" item="item" separator="," open="(" close=")">
  366. #{item}
  367. </foreach>
  368. </if>
  369. ORDER BY
  370. a.gmt_modified DESC, b.id,c.id asc
  371. </select>
  372. <select id="getRuleInitDTO" resultType="com.diagbot.dto.RuleInitDTO">
  373. SELECT
  374. *
  375. FROM
  376. (
  377. SELECT
  378. t1.concept_id AS conceptId,
  379. CONCAT_WS(
  380. "_",
  381. t1.concept_id,
  382. t1.rule_type
  383. ) AS conceptGroup,
  384. t1.id AS ruleId,
  385. t4.lib_name AS libName,
  386. t4.lib_type AS libType,
  387. t1.rule_type AS ruleType,
  388. t1.has_sub_cond AS hasSubCond,
  389. t1.description AS description,
  390. t1.msg AS msg,
  391. t1.gmt_modified AS gmtModified
  392. FROM
  393. kl_rule t1,
  394. kl_concept t4
  395. WHERE
  396. t1.is_deleted = "N"
  397. AND t4.is_deleted = "N"
  398. AND t1.concept_id = t4.id
  399. AND t1. STATUS = 1
  400. AND t4. STATUS = 1
  401. AND t4.lib_type BETWEEN 100 AND 299
  402. UNION
  403. SELECT
  404. t11.id AS conceptId,
  405. CONCAT_WS("_", t11.id, t1.rule_type) AS conceptGroup,
  406. t1.id AS ruleId,
  407. t11.lib_name AS libName,
  408. t11.lib_type AS libType,
  409. t1.rule_type AS ruleType,
  410. t1.has_sub_cond AS hasSubCond,
  411. t1.description AS description,
  412. t1.msg AS msg,
  413. t1.gmt_modified AS gmtModified
  414. FROM
  415. kl_rule t1,
  416. kl_concept t4,
  417. kl_relation t10,
  418. kl_concept t11
  419. WHERE
  420. t1.is_deleted = "N"
  421. AND t4.is_deleted = "N"
  422. AND t1.concept_id = t4.id
  423. AND t1. STATUS = 1
  424. AND t4. STATUS = 1
  425. AND t4.lib_type BETWEEN 300 AND 399
  426. AND t10.start_id = t4.id
  427. AND t10.relation_id = 600
  428. AND t10.end_id = t11.id
  429. AND t11.lib_type BETWEEN 100 AND 299
  430. AND t10.is_deleted = "N"
  431. AND t11.is_deleted = "N"
  432. AND t10. STATUS = 1
  433. AND t11. STATUS = 1
  434. ) t12
  435. ORDER BY
  436. t12.conceptId,
  437. t12.ruleType,
  438. t12.hasSubCond,
  439. t12.gmtModified DESC,
  440. t12.ruleId DESC
  441. </select>
  442. <select id="getRuleConditionInitDTO" resultType="com.diagbot.dto.RuleConditionInitDTO">
  443. SELECT
  444. t2.rule_id AS ruleId,
  445. CONCAT_WS("-", t2.rule_id, t2.group_type) AS ruleGroup,
  446. t2.rule_base_id as ruleBaseId,
  447. t2.msg as msg
  448. FROM
  449. kl_rule_condition t2
  450. WHERE
  451. t2.is_deleted = "N"
  452. ORDER BY
  453. t2.id DESC
  454. </select>
  455. <select id="getRuleBaseInitDTO" resultType="com.diagbot.dto.RuleBaseInitDTO">
  456. SELECT
  457. t3.id as ruleBaseId,
  458. t5.lib_name AS baseLibName,
  459. t5.lib_type AS baseLibType,
  460. t3.type AS baseType,
  461. t3.min_operator AS baseMinOperator,
  462. t3.min_value AS baseMinValue,
  463. t3.min_unit AS baseMinUnit,
  464. t3.max_operator AS baseMaxOperator,
  465. t3.max_value AS baseMaxValue,
  466. t3.max_unit AS baseMaxUnit,
  467. t3.eq_operator AS baseEqOperator,
  468. t3.eq_value AS baseEqValue,
  469. t3.eq_unit AS baseEqUnit
  470. FROM
  471. kl_rule_base t3,
  472. kl_concept t5
  473. WHERE
  474. t3.is_deleted = "N"
  475. AND t5.is_deleted = "N"
  476. AND t3. STATUS = 1
  477. AND t5. STATUS = 1
  478. AND t3.concept_id = t5.id
  479. </select>
  480. <select id="getRuleInitDTONotHaveClass" resultType="com.diagbot.dto.RuleInitDTO">
  481. SELECT
  482. CONCAT_WS("_",t1.concept_id,t1.rule_type) AS conceptGroup,
  483. t1.id AS ruleId,
  484. t4.lib_name AS libName,
  485. t4.lib_type AS libType,
  486. t1.rule_type AS ruleType,
  487. t1.msg AS msg,
  488. t1.has_sub_cond AS hasSubCond
  489. FROM
  490. kl_rule t1,
  491. kl_concept t4
  492. WHERE
  493. t1.is_deleted = "N"
  494. AND t4.is_deleted = "N"
  495. AND t1.concept_id = t4.id
  496. AND t1. STATUS = 1
  497. AND t4. STATUS = 1
  498. AND t4.lib_type BETWEEN 100 AND 299
  499. </select>
  500. <select id="getRuleInitDTOHaveClass" resultType="com.diagbot.dto.RuleInitDTO">
  501. SELECT
  502. CONCAT_WS("_", t11.id, t1.rule_type) AS conceptGroup,
  503. t1.id AS ruleId,
  504. t11.lib_name AS libName,
  505. t11.lib_type AS libType,
  506. t1.rule_type AS ruleType,
  507. t1.msg AS msg,
  508. t1.has_sub_cond AS hasSubCond
  509. FROM
  510. kl_rule t1,
  511. kl_concept t4,
  512. kl_relation t10,
  513. kl_concept t11
  514. WHERE
  515. t1.is_deleted = "N"
  516. AND t4.is_deleted = "N"
  517. AND t1.concept_id = t4.id
  518. AND t1. STATUS = 1
  519. AND t4. STATUS = 1
  520. AND t4.lib_type BETWEEN 300 AND 399
  521. AND t10.start_id = t4.id
  522. AND t10.relation_id = 600
  523. AND t10.end_id = t11.id
  524. AND t11.lib_type BETWEEN 100 AND 299
  525. AND t10.is_deleted = "N"
  526. AND t11.is_deleted = "N"
  527. AND t10. STATUS = 1
  528. AND t11. STATUS = 1
  529. </select>
  530. <select id="getRuleBaseInitDTONotHaveClass" resultType="com.diagbot.dto.RuleBaseInitDTO">
  531. SELECT
  532. t3.id AS ruleBaseId,
  533. t5.lib_name AS baseLibName,
  534. t5.lib_type AS baseLibType,
  535. t3.type AS baseType,
  536. t3.min_operator AS baseMinOperator,
  537. t3.min_value AS baseMinValue,
  538. t3.min_unit AS baseMinUnit,
  539. t3.max_operator AS baseMaxOperator,
  540. t3.max_value AS baseMaxValue,
  541. t3.max_unit AS baseMaxUnit,
  542. t3.eq_operator AS baseEqOperator,
  543. t3.eq_value AS baseEqValue,
  544. t3.eq_unit AS baseEqUnit
  545. FROM
  546. kl_rule_base t3,
  547. kl_concept t5
  548. WHERE
  549. t3.is_deleted = "N"
  550. AND t5.is_deleted = "N"
  551. AND t3. STATUS = 1
  552. AND t5. STATUS = 1
  553. AND t3.concept_id = t5.id
  554. AND (t5.lib_type BETWEEN 100 AND 299
  555. OR t5.lib_type= 410)
  556. </select>
  557. <select id="getRuleBaseInitDTOHaveClass" resultType="com.diagbot.dto.RuleBaseInitDTO">
  558. SELECT
  559. t3.id AS ruleBaseId,
  560. t11.lib_name AS baseLibName,
  561. t11.lib_type AS baseLibType,
  562. t3.type AS baseType,
  563. t3.min_operator AS baseMinOperator,
  564. t3.min_value AS baseMinValue,
  565. t3.min_unit AS baseMinUnit,
  566. t3.max_operator AS baseMaxOperator,
  567. t3.max_value AS baseMaxValue,
  568. t3.max_unit AS baseMaxUnit,
  569. t3.eq_operator AS baseEqOperator,
  570. t3.eq_value AS baseEqValue,
  571. t3.eq_unit AS baseEqUnit
  572. FROM
  573. kl_rule_base t3,
  574. kl_concept t5,
  575. kl_relation t10,
  576. kl_concept t11
  577. WHERE
  578. t3.is_deleted = "N"
  579. AND t5.is_deleted = "N"
  580. AND t3. STATUS = 1
  581. AND t5. STATUS = 1
  582. AND t3.concept_id = t5.id
  583. AND t5.lib_type BETWEEN 300 AND 399
  584. AND t10.start_id = t5.id
  585. AND t10.relation_id = 600
  586. AND t10.end_id = t11.id
  587. AND (t11.lib_type BETWEEN 100 AND 299
  588. OR t11.lib_type = 410)
  589. AND t10.is_deleted = "N"
  590. AND t11.is_deleted = "N"
  591. AND t10. STATUS = 1
  592. AND t11. STATUS = 1
  593. </select>
  594. <select id="getRulePage" resultType="com.diagbot.dto.RuleQueryDTO" parameterType="com.diagbot.vo.RuleQueryVO">
  595. SELECT DISTINCT
  596. t12.libName AS libName,
  597. t12.libType AS libType,
  598. t12.ruleType AS ruleType
  599. FROM
  600. (
  601. SELECT
  602. t1.concept_id AS conceptId,
  603. t1.id AS ruleId,
  604. t4.lib_name AS libName,
  605. t4.lib_type AS libType,
  606. t1.rule_type AS ruleType,
  607. t1.has_sub_cond AS hasSubCond,
  608. t1.gmt_modified AS gmtModified
  609. FROM
  610. kl_rule t1,
  611. kl_rule_search t3,
  612. kl_concept t4
  613. WHERE
  614. t1.is_deleted = "N"
  615. AND t3.is_deleted = "N"
  616. AND t3.id = t1.id
  617. AND t4.is_deleted = "N"
  618. AND t1.concept_id = t4.id
  619. AND t1. STATUS = 1
  620. AND t4. STATUS = 1
  621. AND t4.lib_type BETWEEN 100
  622. AND 299
  623. <if test="description!=null and description!=''">
  624. AND UPPER(t1.description) LIKE CONCAT('%', UPPER(trim(#{description})), '%')
  625. </if>
  626. <if test="libName!=null and libName!=''">
  627. AND UPPER(t4.lib_name) LIKE CONCAT('%', UPPER(trim(#{libName})), '%')
  628. </if>
  629. <if test="libType !=null">
  630. AND t4.lib_type = #{libType}
  631. </if>
  632. <if test="ruleType !=null">
  633. AND t1.rule_type = #{ruleType}
  634. </if>
  635. UNION ALL
  636. SELECT
  637. t11.id AS conceptId,
  638. t1.id AS ruleId,
  639. t11.lib_name AS libName,
  640. t11.lib_type AS libType,
  641. t1.rule_type AS ruleType,
  642. t1.has_sub_cond AS hasSubCond,
  643. t1.gmt_modified AS gmtModified
  644. FROM
  645. kl_rule t1,
  646. kl_rule_search t3,
  647. kl_concept t4,
  648. kl_relation t10,
  649. kl_concept t11
  650. WHERE
  651. t1.is_deleted = "N"
  652. AND t4.is_deleted = "N"
  653. AND t3.is_deleted = "N"
  654. AND t3.id = t1.id
  655. AND t1.concept_id = t4.id
  656. AND t1. STATUS = 1
  657. AND t4. STATUS = 1
  658. AND t4.lib_type BETWEEN 300
  659. AND 399
  660. AND t10.start_id = t4.id
  661. AND t10.relation_id = 600
  662. AND t10.end_id = t11.id
  663. AND t11.lib_type BETWEEN 100
  664. AND 299
  665. AND t10.is_deleted = "N"
  666. AND t11.is_deleted = "N"
  667. AND t10. STATUS = 1
  668. AND t11. STATUS = 1
  669. <if test="description!=null and description!=''">
  670. AND UPPER(t1.description) LIKE CONCAT('%', UPPER(trim(#{description})), '%')
  671. </if>
  672. <if test="libName!=null and libName!=''">
  673. AND UPPER(t11.lib_name) LIKE CONCAT('%', UPPER(trim(#{libName})), '%')
  674. </if>
  675. <if test="libType !=null">
  676. AND t11.lib_type = #{libType}
  677. </if>
  678. <if test="ruleType !=null">
  679. AND t1.rule_type = #{ruleType}
  680. </if>
  681. ) t12
  682. <if test="(baseLibType!=null) or (baseLibName!=null and baseLibName!='')">
  683. WHERE t12.ruleId IN
  684. <foreach collection="ruleIds" open="(" close=")" separator="," item="ruleId">
  685. #{ruleId}
  686. </foreach>
  687. </if>
  688. ORDER BY
  689. t12.gmtModified DESC,
  690. t12.ruleId DESC,
  691. t12.conceptId DESC
  692. </select>
  693. <select id="getRuleNotHaveClass" resultType="com.diagbot.dto.RuleIdDTO" parameterType="com.diagbot.vo.RuleBaseQueryVO">
  694. SELECT
  695. t2.rule_id AS ruleId,
  696. t3.id AS ruleBaseId,
  697. t5.lib_name AS baseLibName,
  698. t5.lib_type AS baseLibType,
  699. t3.type AS baseType
  700. FROM
  701. kl_rule_condition t2,
  702. kl_rule_base t3,
  703. kl_concept t5
  704. WHERE
  705. t3.is_deleted = "N"
  706. AND t5.is_deleted = "N"
  707. AND t2.is_deleted = "N"
  708. AND t2.rule_base_id = t3.id
  709. AND t3. STATUS = 1
  710. AND t5. STATUS = 1
  711. AND t3.concept_id = t5.id
  712. <if test="baseLibName!=null and baseLibName!=''">
  713. AND UPPER(t5.lib_name) LIKE CONCAT('%', UPPER(trim(#{baseLibName})), '%')
  714. </if>
  715. <if test="baseLibType !=null">
  716. AND t5.lib_type = #{baseLibType}
  717. </if>
  718. AND (t5.lib_type BETWEEN 100 AND 299
  719. OR t5.lib_type= 410)
  720. </select>
  721. <select id="getRuleHaveClass" resultType="com.diagbot.dto.RuleIdDTO" parameterType="com.diagbot.vo.RuleBaseQueryVO">
  722. SELECT
  723. t2.rule_id AS ruleId,
  724. t3.id AS ruleBaseId,
  725. t11.lib_name AS baseLibName,
  726. t11.lib_type AS baseLibType,
  727. t3.type AS baseType
  728. FROM
  729. kl_rule_condition t2,
  730. kl_rule_base t3,
  731. kl_concept t5,
  732. kl_relation t10,
  733. kl_concept t11
  734. WHERE
  735. t3.is_deleted = "N"
  736. AND t5.is_deleted = "N"
  737. AND t2.is_deleted = "N"
  738. AND t2.rule_base_id = t3.id
  739. AND t3. STATUS = 1
  740. AND t5. STATUS = 1
  741. AND t3.concept_id = t5.id
  742. AND t5.lib_type BETWEEN 300 AND 399
  743. AND t10.start_id = t5.id
  744. AND t10.relation_id = 600
  745. AND t10.end_id = t11.id
  746. <if test="baseLibName!=null and baseLibName!=''">
  747. AND UPPER(t11.lib_name) LIKE CONCAT('%', UPPER(trim(#{baseLibName})), '%')
  748. </if>
  749. <if test="baseLibType !=null">
  750. AND t11.lib_type = #{baseLibType}
  751. </if>
  752. AND (t11.lib_type BETWEEN 100 AND 299
  753. OR t11.lib_type = 410)
  754. AND t10.is_deleted = "N"
  755. AND t11.is_deleted = "N"
  756. AND t10. STATUS = 1
  757. AND t11. STATUS = 1
  758. </select>
  759. </mapper>