QuestionInfoMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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.QuestionInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.QuestionInfo">
  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="tag_name" property="tagName" />
  13. <result column="name" property="name" />
  14. <result column="sex_type" property="sexType" />
  15. <result column="age_begin" property="ageBegin" />
  16. <result column="age_end" property="ageEnd" />
  17. <result column="tag_type" property="tagType" />
  18. <result column="control_type" property="controlType" />
  19. <result column="type" property="type" />
  20. <result column="sub_type" property="subType" />
  21. <result column="item_type" property="itemType" />
  22. <result column="label_prefix" property="labelPrefix" />
  23. <result column="label_suffix" property="labelSuffix" />
  24. <result column="min_value" property="minValue" />
  25. <result column="max_value" property="maxValue" />
  26. <result column="text_generate" property="textGenerate" />
  27. <result column="copy_type" property="copyType" />
  28. <result column="show_add" property="showAdd" />
  29. <result column="show_info" property="showInfo" />
  30. <result column="joint" property="joint" />
  31. <result column="formula_code" property="formulaCode" />
  32. <result column="remark" property="remark" />
  33. </resultMap>
  34. <delete id="deleteByIds" parameterType="java.util.Map">
  35. update `icss_question_info`
  36. set gmt_modified = #{gmtModified}, modifier = #{modifier}, is_deleted = #{delete}
  37. where is_deleted = 'N'
  38. and id in
  39. <foreach item="id" collection="ids" open="(" separator="," close=")" >
  40. #{id}
  41. </foreach>
  42. </delete>
  43. <select id="index" parameterType="java.util.Map" resultType="com.diagbot.entity.QuestionInfo">
  44. select * from `icss_question_info`
  45. where is_deleted = 'N'
  46. <if test="tagName != null and tagName != ''">
  47. and tag_name like concat("%", #{tagName}, "%")
  48. </if>
  49. <if test="existName != null and existName != ''">
  50. and tag_name = #{existName}
  51. </if>
  52. <if test="sexType != null and sexType != 3 and sexType != ''">
  53. and sex_type in (3, #{sexType})
  54. </if>
  55. <if test="age != null and age != ''">
  56. <![CDATA[ and age_begin <= #{age} ]]>
  57. <![CDATA[ and age_end >= #{age} ]]>
  58. </if>
  59. <if test="type != null and type != ''">
  60. and type = #{type}
  61. </if>
  62. <if test="controlType != null and controlType.size() > 0">
  63. and control_type in
  64. <foreach collection="controlType" item="controlType" open="(" separator="," close=")">
  65. #{controlType}
  66. </foreach>
  67. </if>
  68. <if test="tagType != null and tagType.size() > 0">
  69. and tag_type in
  70. <foreach collection="tagType" item="tagType" open="(" separator="," close=")">
  71. #{tagType}
  72. </foreach>
  73. </if>
  74. <if test="notTagType != null and notTagType.size() > 0">
  75. and tag_type not in
  76. <foreach collection="notTagType" item="notTagType" open="(" separator="," close=")">
  77. #{notTagType}
  78. </foreach>
  79. </if>
  80. <if test="notControlType != null and notControlType.size() > 0">
  81. and control_type not in
  82. <foreach collection="notControlType" item="notControlType" open="(" separator="," close=")">
  83. #{notControlType}
  84. </foreach>
  85. </if>
  86. <if test="notIds != null and notIds.size() > 0 ">
  87. and id not in
  88. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  89. #{id}
  90. </foreach>
  91. </if>
  92. order by gmt_modified desc
  93. </select>
  94. <select id="getQuestiongInfoByName" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  95. SELECT
  96. a.*
  97. FROM
  98. `icss_question_info` a
  99. WHERE
  100. a.is_deleted = 'N'
  101. AND a.sub_type = '0'
  102. AND a.type = #{type}
  103. <if test="deptId != null and deptId != ''">
  104. AND a.id NOT IN (
  105. SELECT
  106. b.question_id
  107. FROM
  108. `icss_question_usual` b
  109. WHERE
  110. b.is_deleted = 'N'
  111. AND b.dept_id = #{deptId}
  112. )
  113. </if>
  114. <if test="noIds != null and noIds.size != 0">
  115. AND a.id NOT IN
  116. <foreach collection="noIds" item="noId" open="(" separator="," close=")">
  117. #{noId}
  118. </foreach>
  119. </if>
  120. <if test="tagName != null and tagName != ''">
  121. AND a.tag_name like CONCAT('%', #{tagName}, '%')
  122. </if>
  123. </select>
  124. <select id="moduleGetQuestiongInfoByName" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  125. SELECT
  126. a.*
  127. FROM
  128. `icss_question_info` a
  129. WHERE
  130. a.is_deleted = 'N'
  131. AND a.type = #{type}
  132. <if test="moduleId != null and moduleId != ''">
  133. AND a.id NOT IN (
  134. SELECT
  135. c.question_id
  136. FROM
  137. `icss_module_detail` c
  138. WHERE
  139. c.is_deleted = 'N'
  140. AND c.module_id = #{moduleId}
  141. AND c.question_id != ''
  142. )
  143. </if>
  144. <if test="noIds != null and noIds.size != 0">
  145. AND a.id NOT IN
  146. <foreach collection="noIds" item="noId" open="(" separator="," close=")">
  147. #{noId}
  148. </foreach>
  149. </if>
  150. <if test="tagName != null and tagName != ''">
  151. AND a.tag_name like CONCAT('%', #{tagName}, '%')
  152. </if>
  153. </select>
  154. <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
  155. SELECT a.* FROM `icss_question_info` a WHERE a.is_deleted = 'N'
  156. <if test="type != null and type != ''">
  157. AND a.type = #{type}
  158. </if>
  159. <if test="tagName != null and tagName != ''">
  160. AND a.tag_name like concat ('%', #{tagName}, '%')
  161. </if>
  162. <if test="tagTypeList != null and tagTypeList.size() > 0 ">
  163. and a.tag_type in
  164. <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
  165. #{tagType}
  166. </foreach>
  167. </if>
  168. order by a.gmt_modified desc
  169. </select>
  170. <select id="getQuestionUsualsByDept" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  171. SELECT a.* FROM `icss_question_info` a
  172. LEFT JOIN icss_question_usual b ON a.id = b.question_id
  173. WHERE b.dept_id = #{deptId} AND a.type = #{type}
  174. GROUP BY a.id
  175. </select>
  176. <select id="getSpecial" parameterType="java.util.Map" resultMap="BaseResultMap">
  177. SELECT DISTINCT t1.* FROM icss_question_info t1, `icss_question_detail` t2
  178. where t1.is_deleted = 'N' and t2.is_deleted = 'N' and
  179. t1.id = t2.question_id and t2.`code` in (1,2)
  180. <if test="sexType != null and sexType != ''">
  181. and t1.sex_type in (3, #{sexType})
  182. </if>
  183. <if test="age != null and age != ''">
  184. <![CDATA[ and t1.age_begin <= #{age} ]]>
  185. <![CDATA[ and t1.age_end >= #{age} ]]>
  186. </if>
  187. <if test="type != null and type != ''">
  188. and t1.type = #{type}
  189. </if>
  190. <if test="notIds != null and notIds.size() > 0 ">
  191. and t1.id not in
  192. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  193. #{id}
  194. </foreach>
  195. </if>
  196. </select>
  197. <select id="getParent" resultMap="BaseResultMap">
  198. SELECT a.* FROM `icss_question_info` a, icss_question_mapping b
  199. where a.is_deleted = 'N' and b.is_deleted = 'N' and a.id = b.parent_question
  200. and b.son_question = #{id}
  201. </select>
  202. <select id="getByQuestionMapping" parameterType="java.util.Map" resultType="com.diagbot.entity.wrapper.QuestionInfoWrapper">
  203. select t.*, m.parent_question, m.position, m.form_position , m.exclusion_type, m.symptom_type from icss_question_info t, icss_question_mapping m
  204. where t.is_deleted = 'N' and m.is_deleted = 'N' and m.son_question = t.id
  205. <if test="id != null">
  206. and m.parent_question = #{id}
  207. </if>
  208. <if test="ids != null and ids.size > 0">
  209. <foreach item="myId" collection="ids" open="and(" separator="or" close=")" >
  210. m.parent_question = #{myId}
  211. </foreach>
  212. </if>
  213. <if test="sexType != null and sexType != 3 and sexType != ''">
  214. and t.sex_type in (3, #{sexType})
  215. </if>
  216. <if test="age != null">
  217. <![CDATA[ and t.age_begin <= #{age} ]]>
  218. <![CDATA[ and t.age_end >= #{age} ]]>
  219. </if>
  220. <if test="id != null">
  221. order by m.order_no
  222. </if>
  223. <if test="ids != null and ids.size > 0">
  224. order by m.parent_question, m.order_no
  225. </if>
  226. </select>
  227. <select id="getByParam" parameterType="java.util.Map" resultMap="BaseResultMap">
  228. select * from icss_question_info where is_deleted = 'N'
  229. and id = #{id}
  230. <if test="sexType != null and sexType != 3 and sexType != ''">
  231. and sex_type in (3, #{sexType})
  232. </if>
  233. <if test="age != null and age != ''">
  234. <![CDATA[ and age_begin <= #{age} ]]>
  235. <![CDATA[ and age_end >= #{age} ]]>
  236. </if>
  237. </select>
  238. <select id="getQuestionByModuleId" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  239. SELECT a.id,a.tag_name FROM `icss_question_info` a
  240. LEFT JOIN icss_module_detail b ON a.id = b.question_id
  241. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND b.module_id = #{moduleId}
  242. </select>
  243. </mapper>