PapersMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.ie.mapper.PapersMapper">
  6. <resultMap type="Papers" id="PapersResult">
  7. <result property="id" column="id" />
  8. <result property="paperName" column="paperName" />
  9. <result property="subjectName" column="subjectName" />
  10. <result property="parseName" column="parseName" />
  11. <result property="number" column="number" />
  12. <result property="tiid" column="tiid" />
  13. <result property="year" column="year" />
  14. <result property="area" column="area" />
  15. <result property="paperType" column="paperType" />
  16. <result property="gradeName" column="gradeName" />
  17. <result property="mark" column="mark" />
  18. <result property="isExist" column="isExist" />
  19. <result property="fenshu" column="fenshu" />
  20. <result property="paperSource" column="paperSource" />
  21. <result property="attachments" column="attachments" />
  22. <result property="osspath" column="osspath" />
  23. <result property="filename" column="filename" />
  24. <result property="subjectId" column="subjectId" />
  25. <result property="paperTypeId" column="paperTypeId" />
  26. <result property="examineeId" column="examineeId" />
  27. <result property="accuracy" column="accuracy" />
  28. <result property="location" column="location" />
  29. <result property="examineeType" column="examineeType" />
  30. <result property="createTime" column="createTime" />
  31. <result property="collect" column="collect" />
  32. <collection property="questions" javaType="java.util.List" resultMap="QuestionsQueryResult" />
  33. </resultMap>
  34. <resultMap type="com.ruoyi.ie.domain.Questions" id="QuestionsQueryResult">
  35. <result property="id" column="id2" />
  36. <result property="title" column="title2" />
  37. <result property="optionA" column="option_a2" />
  38. <result property="optionB" column="option_b2" />
  39. <result property="optionC" column="option_c2" />
  40. <result property="optionD" column="option_d2" />
  41. <result property="optionE" column="option_e2" />
  42. <result property="qtpye" column="qtpye2" />
  43. <result property="diff" column="diff2" />
  44. <result property="subjectId" column="subjectId2" />
  45. <result property="gradeId" column="gradeId2" />
  46. <result property="knowledges" column="knowledges2" />
  47. <result property="area" column="area2" />
  48. <result property="year" column="year2" />
  49. <result property="paperTpye" column="paperTpye2" />
  50. <result property="source" column="source2" />
  51. <result property="fromSite" column="fromSite2" />
  52. <result property="isSub" column="isSub2" />
  53. <result property="isNormal" column="isNormal2" />
  54. <result property="isKonw" column="isKonw2" />
  55. <result property="similarity" column="Similarity2" />
  56. <result property="isunique" column="isunique2" />
  57. </resultMap>
  58. <sql id="selectPapersVo">
  59. select pap.id, pap.paperName, pap.subjectId, pap.subjectName, pap.parseName, pap.number, pap.tiid, pap.year, pap.area,
  60. pap.paperType, pap.gradeName, pap.mark, pap.isExist, pap.fenshu, pap.paperSource,pap.osspath,pap.attachments,pap.filename,pap.paperTypeId
  61. from papers pap
  62. </sql>
  63. <select id="selectMyPapersList" parameterType="Map" resultMap="PapersResult">
  64. select pap.id, pap.paperName, pap.subjectId, pap.subjectName, pap.parseName, pap.number, pap.tiid, pap.year, pap.area,
  65. pap.paperType, pap.gradeName, pap.mark, pap.isExist, pap.fenshu, pap.paperSource,pap.osspath,pap.attachments,pap.filename,pap.paperTypeId,
  66. pe.`examinee_id` examineeId, pe.begin_time createTime, IF(pe.`state` = 6, round(pe.`score_rate` * 100), null) accuracy, f.refId > 0 collect
  67. from `mxjb_paper_examinee` pe join papers pap on pe.paper_id = pap.id
  68. left join b_customer_favorites f on f.type = 'paper' and f.customercode = #{creatorId} and f.status = 1 and f.refId = pap.id
  69. <where> pe.customer_code = #{creatorId} and pe.state &gt; 4
  70. <if test="subjectId != null"> and pap.subjectId = #{subjectId}</if>
  71. <choose>
  72. <when test="paperType == '所有'">and pap.paperType != '历年真题' </when>
  73. <when test="paperType == '模拟试卷'">and pap.paperType in ('历年真题', '模拟试卷') </when>
  74. <when test="paperType != null and paperType != ''"> and pap.paperType like concat('%', #{paperType},'%')</when>
  75. </choose>
  76. </where>
  77. order by pe.`end_time` DESC, pe.begin_time desc
  78. </select>
  79. <select id="selectPapersList" parameterType="Papers" resultMap="PapersResult">
  80. <include refid="selectPapersVo"/>
  81. <where>
  82. <if test="paperName != null and paperName != ''"> and pap.paperName like concat('%', #{paperName}, '%')</if>
  83. <if test="subjectId != null "> and pap.subjectId = #{subjectId}</if>
  84. <if test="subjectName != null and subjectName != ''"> and pap.subjectName like concat('%', #{subjectName}, '%')</if>
  85. <if test="parseName != null and parseName != ''"> and pap.parseName like concat('%', #{parseName}, '%')</if>
  86. <if test="number != null and number != ''"> and pap.number = #{number}</if>
  87. <if test="tiid != null and tiid != ''"> and pap.tiid = #{tiid}</if>
  88. <if test="year != null "> and pap.year = #{year}</if>
  89. <if test="area != null and area != ''"> and pap.area like concat('%', #{area},'%')</if>
  90. <if test="location != null and location != ''"> and (`location` IS NULL OR FIND_IN_SET(#{location}, `location`) &gt; 0)</if>
  91. <if test="examineeType != null and examineeType != ''"> and (`examineeType` IS NULL OR FIND_IN_SET(#{examineeType}, `examineeType`) &gt; 0)</if>
  92. <choose>
  93. <when test="paperType == '所有'">and pap.paperType != '历年真题' </when>
  94. <when test="paperType == '模拟试卷'">and pap.paperType in ('历年真题', '模拟试卷') </when>
  95. <when test="paperType != null and paperType != ''"> and pap.paperType like concat('%', #{paperType},'%')</when>
  96. </choose>
  97. <if test="gradeName != null and gradeName != ''"> and pap.gradeName like concat('%', #{gradeName}, '%')</if>
  98. <if test="mark != null "> and pap.mark = #{mark}</if>
  99. <if test="isExist != null "> and pap.isExist = #{isExist}</if>
  100. <if test="fenshu != null "> and pap.fenshu = #{fenshu}</if>
  101. </where>
  102. order by pap.id desc
  103. </select>
  104. <select id="selectPapersListFromFavorites" parameterType="Papers" resultMap="PapersResult">
  105. select p.*,0 readNum from b_customer_favorites f
  106. left join papers p on f.refId = p.id
  107. where f.type = 'paper' and f.customercode = #{examineeId} and f.course = #{subjectId} <if test="collect "> and f.status = 1</if>
  108. </select>
  109. <select id="selectPapersById" parameterType="Long" resultMap="PapersResult">
  110. <include refid="selectPapersVo"/>
  111. where pap.id = #{id}
  112. </select>
  113. <select id="getPaperInfo" parameterType="Long" resultMap="PapersResult">
  114. <include refid="selectPapersVo"/>
  115. where pap.id = #{paperId}
  116. </select>
  117. <insert id="insertPapers" parameterType="Papers" useGeneratedKeys="true" keyProperty="id">
  118. insert into papers
  119. <trim prefix="(" suffix=")" suffixOverrides=",">
  120. <if test="paperName != null">paperName,</if>
  121. <if test="subjectId != null">subjectId,</if>
  122. <if test="subjectName != null">subjectName,</if>
  123. <if test="parseName != null">parseName,</if>
  124. <if test="number != null">number,</if>
  125. <if test="tiid != null">tiid,</if>
  126. <if test="year != null">year,</if>
  127. <if test="area != null">area,</if>
  128. <if test="paperType != null">paperType,</if>
  129. <if test="gradeName != null">gradeName,</if>
  130. <if test="mark != null">mark,</if>
  131. <if test="isExist != null">isExist,</if>
  132. <if test="fenshu != null">fenshu,</if>
  133. <if test="paperSource != null">paperSource,</if>
  134. <if test="osspath != null">osspath,</if>
  135. <if test="attachments != null">attachments,</if>
  136. <if test="filename != null">filename,</if>
  137. <if test="location != null">location,</if>
  138. <if test="examineeType != null">examineeType,</if>
  139. </trim>
  140. <trim prefix="values (" suffix=")" suffixOverrides=",">
  141. <if test="paperName != null">#{paperName},</if>
  142. <if test="subjectId != null">#{subjectId},</if>
  143. <if test="subjectName != null">#{subjectName},</if>
  144. <if test="parseName != null">#{parseName},</if>
  145. <if test="number != null">#{number},</if>
  146. <if test="tiid != null">#{tiid},</if>
  147. <if test="year != null">#{year},</if>
  148. <if test="area != null">#{area},</if>
  149. <if test="paperType != null">#{paperType},</if>
  150. <if test="gradeName != null">#{gradeName},</if>
  151. <if test="mark != null">#{mark},</if>
  152. <if test="isExist != null">#{isExist},</if>
  153. <if test="fenshu != null">#{fenshu},</if>
  154. <if test="paperSource != null">#{paperSource},</if>
  155. <if test="osspath != null">#{osspath},</if>
  156. <if test="attachments != null">#{attachments},</if>
  157. <if test="filename != null">#{filename},</if>
  158. <if test="location != null">#{location},</if>
  159. <if test="examineeType != null">#{examineeType},</if>
  160. </trim>
  161. </insert>
  162. <insert id="insertMxjbPapers" parameterType="Papers" useGeneratedKeys="true" keyProperty="id">
  163. insert into mxjb_papers
  164. <trim prefix="(" suffix=")" suffixOverrides=",">
  165. <if test="paperName != null">paperName,</if>
  166. <if test="subjectId != null">subjectId,</if>
  167. <if test="subjectName != null">subjectName,</if>
  168. <if test="parseName != null">parseName,</if>
  169. <if test="number != null">number,</if>
  170. <if test="tiid != null">tiid,</if>
  171. <if test="year != null">year,</if>
  172. <if test="area != null">area,</if>
  173. <if test="paperType != null">paperType,</if>
  174. <if test="gradeName != null">gradeName,</if>
  175. <if test="mark != null">mark,</if>
  176. <if test="isExist != null">isExist,</if>
  177. <if test="fenshu != null">fenshu,</if>
  178. <if test="paperSource != null">paperSource,</if>
  179. <if test="osspath != null">osspath,</if>
  180. <if test="attachments != null">attachments,</if>
  181. <if test="filename != null">filename,</if>
  182. </trim>
  183. <trim prefix="values (" suffix=")" suffixOverrides=",">
  184. <if test="paperName != null">#{paperName},</if>
  185. <if test="subjectId != null">#{subjectId},</if>
  186. <if test="subjectName != null">#{subjectName},</if>
  187. <if test="parseName != null">#{parseName},</if>
  188. <if test="number != null">#{number},</if>
  189. <if test="tiid != null">#{tiid},</if>
  190. <if test="year != null">#{year},</if>
  191. <if test="area != null">#{area},</if>
  192. <if test="paperType != null">#{paperType},</if>
  193. <if test="gradeName != null">#{gradeName},</if>
  194. <if test="mark != null">#{mark},</if>
  195. <if test="isExist != null">#{isExist},</if>
  196. <if test="fenshu != null">#{fenshu},</if>
  197. <if test="paperSource != null">#{paperSource},</if>
  198. <if test="osspath != null">#{osspath},</if>
  199. <if test="attachments != null">#{attachments},</if>
  200. <if test="filename != null">#{filename},</if>
  201. </trim>
  202. </insert>
  203. <update id="updatePapers" parameterType="Papers">
  204. update papers
  205. <trim prefix="SET" suffixOverrides=",">
  206. <if test="paperName != null">paperName = #{paperName},</if>
  207. <if test="subjectName != null">subjectName = #{subjectName},</if>
  208. <if test="parseName != null">parseName = #{parseName},</if>
  209. <if test="number != null">number = #{number},</if>
  210. <if test="tiid != null">tiid = #{tiid},</if>
  211. <if test="year != null">year = #{year},</if>
  212. <if test="area != null">area = #{area},</if>
  213. <if test="paperType != null">paperType = #{paperType},</if>
  214. <if test="gradeName != null">gradeName = #{gradeName},</if>
  215. <if test="mark != null">mark = #{mark},</if>
  216. <if test="isExist != null">isExist = #{isExist},</if>
  217. <if test="fenshu != null">fenshu = #{fenshu},</if>
  218. <if test="paperSource != null">paperSource = #{paperSource},</if>
  219. <if test="osspath != null">osspath = #{osspath},</if>
  220. <if test="attachments != null">attachments = #{attachments},</if>
  221. <if test="filename != null">filename = #{filename},</if>
  222. </trim>
  223. where id = #{id}
  224. </update>
  225. <delete id="deletePapersById" parameterType="Long">
  226. delete from papers where id = #{id}
  227. </delete>
  228. <delete id="deletePapersByIds" parameterType="String">
  229. delete from papers where id in
  230. <foreach item="id" collection="array" open="(" separator="," close=")">
  231. #{id}
  232. </foreach>
  233. </delete>
  234. <select id="filterList" parameterType="com.ruoyi.ie.domain.Papers" resultType="String">
  235. select distinct ${column} from papers pap
  236. <where>
  237. <if test="subjectName != null and subjectName != ''"> and pap.subjectName = #{subjectName} </if>
  238. <if test="parseName != null and parseName != ''"> and pap.parseName = #{parseName} </if>
  239. <if test="number != null and number != ''"> and pap.number = #{number}</if>
  240. <if test="tiid != null and tiid != ''"> and pap.tiid = #{tiid}</if>
  241. <if test="year != null "> and pap.year = #{year}</if>
  242. <if test="area != null and area != ''"> and pap.area = #{area}</if>
  243. <choose>
  244. <when test="paperType != null and paperType != ''"> and pap.paperType = #{paperType}</when>
  245. <otherwise>and pap.paperType != '历年真题' </otherwise>
  246. </choose>
  247. <if test="gradeName != null and gradeName != ''"> and pap.gradeName = #{gradeName} </if>
  248. <if test="mark != null "> and pap.mark = #{mark}</if>
  249. <if test="isExist != null "> and pap.isExist = #{isExist}</if>
  250. <if test="fenshu != null "> and pap.fenshu = #{fenshu}</if>
  251. <choose>
  252. <when test="column=='year'"> and year &lt; 2200 and year &gt; 2014</when>
  253. <otherwise>and pap.${column} != '' </otherwise>
  254. </choose>
  255. </where>
  256. <choose>
  257. <when test="column=='paperType'">
  258. order by FIELD(paperType, '单元测试', '月考试卷', '期中考试', '期末考试', '专题练习', '同步练习', '开学考试')
  259. </when>
  260. <when test="column=='subjectName'">
  261. order by FIELD(subjectName, '语文','数学','英语','物理','化学','生物','历史','地理','政治')
  262. </when>
  263. <when test="column=='gradeName'">
  264. order by LOCATE(SUBSTRING(REPLACE(gradeName, '高', ''), 1, 1), '一1二2三3四4五5六6七7八8九9')
  265. </when>
  266. <when test="column=='year'">
  267. order by year desc
  268. </when>
  269. <when test="column=='area'">
  270. order by field(area,'全国','湖南','湖北','安徽','江西','河南','广东','广西','河北','山东','北京','四川','贵州','江苏','福建','浙江','山西','吉林','陕西','海南','内蒙古','黑龙江','重庆','甘肃','上海','云南','辽宁','青海','新疆','西藏','宁夏','天津')
  271. </when>
  272. <otherwise>
  273. order by ${column}
  274. </otherwise>
  275. </choose>
  276. </select>
  277. <select id="selectCollectInfo" parameterType="java.util.HashMap" resultMap="PapersResult">
  278. SELECT p.id from b_customer_favorites f
  279. left join papers p on f.refId = p.id
  280. where f.type = 'paper'
  281. and f.status = 1
  282. and f.customerCode = #{customerCode}
  283. and p.id in
  284. <foreach item="id" collection="ids" open="(" separator="," close=")">
  285. #{id}
  286. </foreach>
  287. </select>
  288. <select id="selectGrades" parameterType="Papers" resultMap="PapersResult">
  289. SELECT distinct gradeName
  290. from papers p
  291. where 1=1
  292. <if test="subjectName != null and subjectName != ''"> and p.subjectName = #{subjectName} </if>
  293. <if test="parseName != null and parseName != ''">
  294. and p.parseName = #{parseName}
  295. </if>
  296. <if test="parseName != null and parseName != ''">
  297. <if test="parseName == '高中'">
  298. order by FIELD(p.gradeName, '高一','高二','高三')
  299. </if>
  300. <if test="parseName == '初中'">
  301. order by FIELD(p.gradeName, '七年级','八年级','九年级')
  302. </if>
  303. </if>
  304. </select>
  305. </mapper>