KmtExerciseMapper.xml 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488
  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.aijia.kmt.mapper.KmtExerciseMapper">
  4. <resultMap id="DistributionExerciseBookDTOResultMap" type="com.aijia.kmt.dto.DistributionExerciseBookDTO">
  5. <id column="exerciseBookId" property="exerciseBookId"/>
  6. <result column="importDate" property="importDate"/>
  7. <result column="subject" property="subject"/>
  8. <result column="grade" property="grade"/>
  9. <result column="version_name" property="versionName"/>
  10. <result column="semester" property="semester"/>
  11. <result column="book_name" property="bookName"/>
  12. <result column="book_type" property="bookType"/>
  13. <result column="unitNum" property="unitNum"/>
  14. <result column="courseNum" property="courseNum"/>
  15. <result column="intHandleAccuracy" property="intHandleAccuracy"/>
  16. <result column="intHandleAuditAccuracy" property="intHandleAuditAccuracy"/>
  17. <result column="intAnalysisAccuracy" property="intAnalysisAccuracy"/>
  18. <result column="assigned_batch" property="assignedBatch"/>
  19. <collection property="handleUserList" ofType="com.aijia.kmt.dto.DistributionTeacherDTO">
  20. <result column="handlerTeacherId" property="teacherId"/>
  21. <result column="handlerSalaryGiven" property="salaryGiven"/>
  22. <result column="handlerSalaryGivenTime" property="salaryGivenTime"/>
  23. <result column="handlerName" property="teacherName"/>
  24. <result column="handlerDistributeTime" property="createTime"/>
  25. </collection>
  26. <collection property="auditingUserList" ofType="com.aijia.kmt.dto.DistributionTeacherDTO">
  27. <result column="handlerAuditUserTeacherId" property="teacherId"/>
  28. <result column="handlerAuditUserSalaryGiven" property="salaryGiven"/>
  29. <result column="handlerAuditUserSalaryGivenTime" property="salaryGivenTime"/>
  30. <result column="handlerAuditUserName" property="teacherName"/>
  31. <result column="handlerAuditUserDistributeTime" property="createTime"/>
  32. </collection>
  33. <collection property="analysisUserList" ofType="com.aijia.kmt.dto.DistributionTeacherDTO">
  34. <result column="analyserTeacherId" property="teacherId"/>
  35. <result column="analyserSalaryGiven" property="salaryGiven"/>
  36. <result column="analyserSalaryGivenTime" property="salaryGivenTime"/>
  37. <result column="analyserName" property="teacherName"/>
  38. <result column="analyserDistributeTime" property="createTime"/>
  39. </collection>
  40. <collection property="analysisAuditerList" ofType="com.aijia.kmt.dto.DistributionTeacherDTO">
  41. <result column="analysisAuditUserTeacherId" property="teacherId"/>
  42. <result column="analysisAuditUserSalaryGiven" property="salaryGiven"/>
  43. <result column="analysisAuditUserSalaryGivenTime" property="salaryGivenTime"/>
  44. <result column="analysisAuditUserName" property="teacherName"/>
  45. <result column="analysisAuditUserDistributeTime" property="createTime"/>
  46. </collection>
  47. </resultMap>
  48. <resultMap id="ExportDistributionExerciseBookDTOResultMap" type="com.aijia.kmt.dto.ExportDistributionExerciseBookDTO">
  49. <id column="exercise_book_id" property="exerciseBookId"/>
  50. <result column="import_date" property="importDate"/>
  51. <result column="subject" property="subject"/>
  52. <result column="grade" property="grade"/>
  53. <result column="version_name" property="version"/>
  54. <result column="semester" property="semester"/>
  55. <result column="book_name" property="bookName"/>
  56. <result column="book_type" property="bookType"/>
  57. <result column="unit_count" property="unitCount"/>
  58. <result column="course_count" property="courseCount"/>
  59. </resultMap>
  60. <select id="findWrongQuestionKnowHowDetailIdList" resultType="java.lang.String">
  61. select kmt_exercise_question_know.how_details_id
  62. from kmt_exercise_question_know
  63. where kmt_exercise_question_know.question_id = #{questionId}
  64. union all
  65. select kmt_exercise_question_know.how_details_id
  66. from kmt_exercise_question_know,
  67. kmt_exercise_questions brother,
  68. kmt_exercise_questions
  69. where kmt_exercise_question_know.question_id = brother.id
  70. and brother.parent_id = kmt_exercise_questions.parent_id
  71. and kmt_exercise_questions.id = #{questionId}
  72. and ifnull(length(kmt_exercise_questions.parent_id), 0) > 0
  73. </select>
  74. <!-- 查询题目列表 -->
  75. <!-- 条件 :,eq.concise_id-->
  76. <select id="findKmtExerciseQuestionsByIdIn" resultType="com.aijia.kmt.po.KmtExerciseQuestion" >
  77. select eq.id, eq.book_id, eq.unit_id, eq.book_course_id,
  78. eb.auditing_user_id, eb.handle_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eb.answer_correcter_id,
  79. eq.question_type, eq.source, eq.big_question_index, eq.analysis_submit_time, eq.page_index,
  80. eq.image, eq.precision_percent, eq.create_time, eq.deal_status, eq.remark, eq.analysis_submit_type,
  81. eq.answer_image, eq.num, eq.small_question_name, eq.parent_id, eq.big_name, eq.real_exam_type, eq.publish_time,
  82. eq.update_type, eq.difficulty_level, eq.training_skill, eq.course_name, eq.is_common_flag, eq.question_year, eq.exercise_book_id, eq.es_loaded,
  83. eq.analysis_handler_submit_time, eq.question_class_type, eq.repulse_time,
  84. eq.proofread_status, eq.question_path, eq.handler_submit_time,eq.enumerate
  85. from kmt_exercise_questions eq
  86. left join kmt_exercise_book eb on eq.exercise_book_id=eb.id where eq.id in
  87. <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
  88. #{id}
  89. </foreach>
  90. limit 0, 5000
  91. </select>
  92. <!-- 查询打回题目列表 -->
  93. <select id="findKmtExerciseQuestionRollbacks" resultType="com.aijia.kmt.po.KmtExerciseQuestionRollback">
  94. SELECT * FROM kmt_exercise_question_rollback where question_id in
  95. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  96. #{id}
  97. </foreach>
  98. and type=#{dealType}
  99. </select>
  100. <!-- 查询待加工审核的题目 -->
  101. <select id="findQuestionByBookCourseIdAndUserId" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  102. select eq.id question_id, eq.course_name, eb.handle_user_id, eb.auditing_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eq.book_course_id course_id,
  103. eq.big_question_index, eq.small_question_name small_question_index, eq.is_common_flag,
  104. eq.deal_status question_status, eq.create_time, eq.remark reason, eq.from_user_id, eq.to_user_id,
  105. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  106. eq.training_skill training_skills, eq.parent_id, eq.proofread_status, eq.question_path, eq.num, eq.page_index,
  107. eq.image question_image, eq.concise_id start_X, eq.analysis_submit_type start_Y, eq.update_type end_X, eq.es_loaded end_Y,eq.enumerate
  108. from kmt_exercise_questions eq left join kmt_exercise_book eb on eq.exercise_book_id=eb.id
  109. where eq.book_course_id = #{bookCourseId} and (eq.exercise_book_id=#{exerciseBookId} or eq.is_common_flag = 0)
  110. <if test = "dealType == 2">
  111. and eq.deal_status in (3, 7) and eb.auditing_user_id=#{userId}
  112. </if>
  113. <if test = "dealType == 1">
  114. and eq.deal_status &lt; 2 and eb.handle_user_id=#{userId}
  115. </if>
  116. <if test = "dealType == 4">
  117. and eq.deal_status in (5, 8) and eb.analysis_user_id=#{userId}
  118. </if>
  119. <if test = "dealType == 5">
  120. and eq.deal_status in (9, 10) and eb.analysis_auditer_id = #{userId}
  121. </if>
  122. <if test = "dealType == 6">
  123. and eq.deal_status >= 4 and eq.deal_status != 7 and eb.answer_correcter_id=#{userId} and eq.proofread_status = 0
  124. </if>
  125. <if test = "dealType == 7">
  126. and eq.proofread_status > 0 and eb.answer_correcter_id=#{userId}
  127. </if>
  128. <if test="dealType == 3 and rollbackType > 0 ">
  129. <if test="rollbackType == 1">
  130. and eq.deal_status != 2
  131. </if>
  132. <if test="rollbackType == 2">
  133. and eq.deal_status > 2
  134. </if>
  135. <if test="rollbackType == 3">
  136. and eq.deal_status > 3 and eq.deal_status != 7
  137. </if>
  138. <if test="rollbackType == 4">
  139. and eq.deal_status > 8
  140. </if>
  141. <if test="rollbackType == 5">
  142. and eq.deal_status > 10
  143. </if>
  144. </if>
  145. order by eq.num, eq.create_time
  146. </select>
  147. <!-- 查询不同的题目 -->
  148. <select id="findPartQuestionByBookCourseId" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  149. select eq.id question_id, eq.course_name, eb.handle_user_id, eb.auditing_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eq.book_course_id course_id,
  150. eq.big_question_index, eq.small_question_name small_question_index,
  151. eq.deal_status question_status, eq.create_time, eq.remark reason, eq.from_user_id, eq.to_user_id,
  152. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  153. eq.training_skill training_skills, eq.parent_id, eq.proofread_status, eq.question_path, eq.num, eq.page_index,
  154. eq.image question_image, eq.concise_id start_X, eq.analysis_submit_type start_Y, eq.update_type end_X, eq.es_loaded end_Y,eq.enumerate
  155. from kmt_exercise_questions eq left join kmt_exercise_book eb on eq.exercise_book_id=eb.id
  156. where eq.book_course_id = #{bookCourseId} and eq.exercise_book_id=#{exerciseBookId}
  157. order by eq.num, eq.create_time
  158. </select>
  159. <select id="findPartQuestionByBookCourseIdNew" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  160. SELECT
  161. eq.id question_id,
  162. eq.course_name,
  163. eb.handle_user_id,
  164. eb.auditing_user_id,
  165. eb.analysis_user_id,
  166. eb.analysis_auditer_id,
  167. eq.book_course_id course_id,
  168. eq.big_question_index,
  169. eq.small_question_name small_question_index,
  170. eq.deal_status question_status,
  171. eq.create_time,
  172. eq.remark reason,
  173. eq.from_user_id,
  174. eq.to_user_id,
  175. eq.question_type question_types,
  176. eq.difficulty_level difficulty_levels,
  177. eq.real_exam_type real_exam_types,
  178. eq.training_skill training_skills,
  179. eq.parent_id,
  180. eq.proofread_status,
  181. eq.question_path,
  182. t.number num,
  183. t.page_index,
  184. eq.image question_image,
  185. eq.concise_id start_X,
  186. eq.analysis_submit_type start_Y,
  187. eq.update_type end_X,
  188. eq.es_loaded end_Y,
  189. eq.enumerate,
  190. eq.exercise_book_id
  191. FROM
  192. q_question_workbook t
  193. LEFT JOIN kmt_exercise_questions eq ON t.question_id=eq.id
  194. LEFT JOIN kmt_exercise_book eb ON t.sub_book_id = eb.id
  195. <if test="req.publishStatus==3">
  196. LEFT JOIN q_question_info qi on t.question_id=qi.id
  197. </if>
  198. WHERE
  199. eq.exercise_book_id=#{req.exerciseBookId} and t.course_name=#{req.periodId} and t.unit_name=#{req.unitId}
  200. <if test="req.questionType > 0">
  201. and eq.question_type = #{req.questionType}
  202. </if>
  203. <if test="req.publishStatus == 1">
  204. and eq.deal_status in (0, 1, 3, 7)
  205. </if>
  206. <if test="req.publishStatus == 2">
  207. and eq.deal_status in (4, 5, 8, 9, 10, 11)
  208. </if>
  209. <if test="req.publishStatus==3">
  210. and (qi.answer_text='略' or qi.answer='略')
  211. </if>
  212. ORDER BY
  213. t.page_index,
  214. t.number
  215. </select>
  216. <!-- 查询待加工审核的题目 -->
  217. <select id="findQuestionByBookCourseId" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  218. select eq.id question_id, eq.course_name, eb.handle_user_id, eb.auditing_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eq.book_course_id course_id,
  219. eq.big_question_index, eq.small_question_name small_question_index,
  220. eq.deal_status question_status, eq.create_time, eq.remark reason,
  221. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  222. eq.training_skill training_skills, eq.parent_id, eq.question_path
  223. from kmt_exercise_questions eq
  224. left join kmt_exercise_book eb on eq.exercise_book_id=eb.id
  225. where eq.book_course_id = #{bookCourseId}
  226. order by eq.num, eq.create_time
  227. limit 0, 5000
  228. </select>
  229. <!-- 查询打回理由记录 -->
  230. <select id="findQuestionRollbackRecord" resultType="com.aijia.kmt.dto.exercise.KmtExerciseQuestionRollBackInfo">
  231. select eqr.id, eqr.create_time, eqr.reason,eqr.user_id userId,eqr.to_user_id toUserId,user1.user_id tbUserId,user2.user_id tbToUserId, user1.name from_user, eqr.from_user_type from_type,user2.name to_user,
  232. eqr.to_user_type to_type from kmt_exercise_question_rollback eqr left join tb_lib_manager user1 on eqr.user_id = user1.user_id and user1.type in (17, 18)
  233. left join tb_lib_manager user2 on eqr.to_user_id = user2.user_id and user2.type in (17, 18)
  234. where eqr.question_id = #{questionId}
  235. order by eqr.create_time desc limit 20;
  236. </select>
  237. <!-- 查询打回理由记录老 -->
  238. <select id="findQuestionRollbackRecordOld" resultType="com.aijia.kmt.dto.exercise.ExerciseQuestionRollbacks">
  239. select eqr.id,eqr.create_time, eqr.reason, user1.name from_user, user1.type from_type, user2.name to_user,
  240. user2.type to_type from kmt_exercise_question_rollback eqr left join kmt_sys_user user1 on eqr.user_id = user1.id
  241. left join kmt_sys_user user2 on eqr.to_user_id = user2.id
  242. where eqr.question_id = #{questionId} order by eqr.create_time desc limit 20;
  243. </select>
  244. <select id="countWrongAndTotal" resultType="java.util.Map">
  245. select sum(ifnull(scon_homework_how_details.detail_count, 0)) wrong_count,
  246. sum(ifnull(scon_homework_how_details.total_count, 1)) total_count
  247. from scon_homework_how_details,
  248. scon_homework
  249. where scon_homework_how_details.homework_id = scon_homework.id
  250. and scon_homework.vip_id = #{vipId}
  251. <if test="subject != null and subject != ''">
  252. and scon_homework.subject = #{subject}
  253. </if>
  254. and scon_homework.create_time >= #{beginDateTime}
  255. and #{endDateTime} >= scon_homework.create_time
  256. and scon_homework_how_details.wrong_question_id is null
  257. union all
  258. select sum(if(kmt_homework_wrong_question.type = 1, 1, 0)) wrong_count, count(*) total_count
  259. from kmt_homework_wrong_question,
  260. scon_homework
  261. where kmt_homework_wrong_question.homework_id = scon_homework.id
  262. and scon_homework.vip_id = #{vipId}
  263. <if test="subject != null and subject != ''">
  264. and scon_homework.subject = #{subject}
  265. </if>
  266. and scon_homework.create_time >= #{beginDateTime}
  267. and #{endDateTime} >= scon_homework.create_time
  268. and kmt_homework_wrong_question.is_delete = 0
  269. </select>
  270. <select id="countPlatformCorrectionKnowledgeTimes" resultType="java.util.Map">
  271. select zyb_know_how_details_sort.alias, count(*) count_num
  272. from scon_homework_how_details,
  273. scon_homework,
  274. zyb_know_how_details_sort
  275. where scon_homework_how_details.homework_id = scon_homework.id
  276. and scon_homework_how_details.how_detail_id = zyb_know_how_details_sort.how_details_id
  277. and scon_homework_how_details.knowledge_version = zyb_know_how_details_sort.type
  278. and zyb_know_how_details_sort.stat = 2
  279. and scon_homework.vip_id = #{vipId}
  280. <if test="subject != null and subject != ''">
  281. and scon_homework.subject = #{subject}
  282. </if>
  283. and scon_homework.create_time > #{beginDateTimeStr}
  284. and #{endDateTimeStr} > scon_homework.create_time
  285. and scon_homework_how_details.wrong_question_id is null
  286. group by zyb_know_how_details_sort.alias
  287. </select>
  288. <select id="findWrongQuestion" resultType="java.util.Map">
  289. select kmt_homework_wrong_question.homework_id, kmt_homework_wrong_question.question_id
  290. from kmt_homework_wrong_question,
  291. scon_homework
  292. where kmt_homework_wrong_question.homework_id = scon_homework.id
  293. and scon_homework.vip_id = #{vipId}
  294. and scon_homework.subject = #{subject}
  295. and scon_homework.create_time > #{beginDateTimeStr}
  296. and #{endDateTimeStr} > scon_homework.create_time
  297. and kmt_homework_wrong_question.is_delete = 0
  298. </select>
  299. <select id="countCampusCorrectionKnowledgeTimesByQuestionIds" resultType="java.util.Map">
  300. select khds.alias, count(distinct eqk.question_id) count_num
  301. from (select question_id, how_detail_sort_id
  302. from kmt_exercise_question_know
  303. where question_id in
  304. <foreach collection="questionIdList" open="(" item="questionId" separator="," close=")">
  305. #{questionId}
  306. </foreach>
  307. ) eqk, zyb_know_how_details_sort khds
  308. where eqk.how_detail_sort_id = khds.id
  309. group by khds.alias
  310. </select>
  311. <select id="countKnowledgeMastery" resultType="java.util.Map">
  312. (select details_sort.alias,
  313. <if test="subject != null and subject != ''">
  314. <if test="subject == '语文' || subject == '数学'">
  315. details_sort.two_module module,
  316. </if>
  317. <if test="subject == '英语'">
  318. details_sort.module module,
  319. </if>
  320. </if>
  321. group_concat(how_sort.alias) how_name,
  322. sum(ifnull(scon_homework_how_details.detail_count, 0)) wrong_count,
  323. sum(ifnull(scon_homework_how_details.total_count, 1)) total_count,
  324. group_concat(details_sort.how_details_id) know_how_detail_id_str,
  325. group_concat(details_sort.type) knowledge_version_str
  326. from scon_homework_how_details,
  327. scon_homework,
  328. zyb_know_how_details_sort details_sort,
  329. zyb_know_how_details_sort how_sort
  330. where scon_homework_how_details.homework_id = scon_homework.id
  331. and scon_homework_how_details.how_detail_id = details_sort.how_details_id
  332. and scon_homework_how_details.knowledge_version = details_sort.type
  333. and details_sort.stat = 2
  334. and how_sort.how_id = details_sort.how_id
  335. and how_sort.stat = 1
  336. and how_sort.grade_num = details_sort.grade_num
  337. and how_sort.semester = details_sort.semester
  338. and scon_homework.vip_id = #{vipId}
  339. <if test="subject != null and subject != ''">
  340. and scon_homework.subject = #{subject}
  341. </if>
  342. and scon_homework.create_time > #{beginDateTimeStr}
  343. and #{endDateTimeStr} > scon_homework.create_time
  344. and scon_homework_how_details.wrong_question_id is null
  345. group by details_sort.alias)
  346. union all
  347. (select details_sort.alias,
  348. <if test="subject != null and subject != ''">
  349. <if test="subject == '语文' || subject == '数学'">
  350. details_sort.two_module module,
  351. </if>
  352. <if test="subject == '英语'">
  353. details_sort.module module,
  354. </if>
  355. </if>
  356. group_concat(how_sort.alias) how_name,
  357. sum(if(kmt_homework_wrong_question.type = 1, 1, 0)) wrong_count,
  358. count(*) total_count,
  359. group_concat(details_sort.how_details_id) know_how_detail_id_str,
  360. group_concat(details_sort.type) knowledge_version_str
  361. from kmt_homework_wrong_question,
  362. scon_homework,
  363. kmt_exercise_questions,
  364. kmt_exercise_book_course,
  365. kmt_exercise_question_know,
  366. zyb_know_how_details_sort details_sort,
  367. zyb_know_how_details_sort how_sort
  368. where kmt_homework_wrong_question.homework_id = scon_homework.id
  369. and kmt_homework_wrong_question.question_id = kmt_exercise_questions.id
  370. and kmt_exercise_questions.book_course_id = kmt_exercise_book_course.id
  371. and kmt_homework_wrong_question.question_id = kmt_exercise_question_know.question_id
  372. and kmt_exercise_question_know.how_details_id = details_sort.how_details_id
  373. and details_sort.type = kmt_exercise_book_course.version
  374. and details_sort.stat = 2
  375. and how_sort.how_id = details_sort.how_id
  376. and how_sort.stat = 1
  377. and how_sort.grade_num = details_sort.grade_num
  378. and how_sort.semester = details_sort.semester
  379. and scon_homework.vip_id = #{vipId}
  380. <if test="subject != null and subject != ''">
  381. and scon_homework.subject = #{subject}
  382. </if>
  383. and scon_homework.create_time > #{beginDateTimeStr}
  384. and #{endDateTimeStr} > scon_homework.create_time
  385. and kmt_homework_wrong_question.is_delete = 0
  386. group by details_sort.alias)
  387. </select>
  388. <!--查询题目列表关联的知识点id列表-->
  389. <select id="findHowDetailIdsByQuestionIds" resultType="java.lang.String">
  390. select how_details_id from kmt_exercise_question_know where question_id in
  391. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  392. #{id}
  393. </foreach>
  394. group by how_details_id
  395. </select>
  396. <select id="countPlatformCorrectionKnowledgeMastery" resultType="java.util.Map">
  397. select scon_homework_how_details.how_detail_id,
  398. scon_homework_how_details.knowledge_version version,
  399. scon_homework_how_details.grade,
  400. scon_homework_how_details.semester,
  401. sum(ifnull(scon_homework_how_details.detail_count, 0)) wrong_count,
  402. sum(ifnull(scon_homework_how_details.total_count, 1)) total_count
  403. from scon_homework_how_details,
  404. scon_homework,
  405. zyb_know_how_details_sort
  406. where scon_homework_how_details.homework_id = scon_homework.id
  407. and scon_homework_how_details.how_detail_id = zyb_know_how_details_sort.how_details_id
  408. and scon_homework_how_details.grade = zyb_know_how_details_sort.grade
  409. and scon_homework_how_details.semester = zyb_know_how_details_sort.semester
  410. and scon_homework_how_details.knowledge_version = zyb_know_how_details_sort.type
  411. and scon_homework.vip_id = #{vipId}
  412. <if test="subject != null and subject != ''">
  413. and scon_homework.subject = #{subject}
  414. </if>
  415. and scon_homework.create_time > #{beginDateTimeStr}
  416. and #{endDateTimeStr} > scon_homework.create_time
  417. and scon_homework_how_details.wrong_question_id is null
  418. group by zyb_know_how_details_sort.alias
  419. </select>
  420. <select id="findWrongQuestion4Mastery" resultType="java.util.Map">
  421. select kmt_homework_wrong_question.question_id, kmt_homework_wrong_question.type
  422. from kmt_homework_wrong_question,
  423. scon_homework
  424. where kmt_homework_wrong_question.homework_id = scon_homework.id
  425. and scon_homework.vip_id = #{vipId}
  426. and scon_homework.subject = #{subject}
  427. and scon_homework.create_time > #{beginDateTimeStr}
  428. and #{endDateTimeStr} > scon_homework.create_time
  429. and kmt_homework_wrong_question.is_delete = 0
  430. </select>
  431. <select id="findKnowledgeByQuestionId" resultType="java.util.Map">
  432. select khds.how_details_id how_detail_id, khds.type version, khds.grade, khds.semester, khds.alias
  433. from (select how_detail_sort_id from kmt_exercise_question_know where question_id = #{questionId}) eqk,
  434. zyb_know_how_details_sort khds
  435. where eqk.how_detail_sort_id = khds.id
  436. </select>
  437. <!--查询未解析的题目-->
  438. <select id="findUnAnalysisBookCourse" resultType="com.aijia.kmt.po.KmtExerciseBookCourse">
  439. select distinct t1.id, t1.book_id, t1.course_name, t1.version, t1.grade,
  440. t1.semester, t1.book_name, t1.unit, t1.period, t1.unit_id,
  441. t1.period_sort, t1.unit_sort from kmt_exercise_book_course t1 left join kmt_exercise_questions t2
  442. on t1.id = t2.book_course_id where t1.analysis_user_id=#{analysisUserId} and t2.analysis_submit_type=0
  443. order by t1.unit_sort, t1.period_sort limit 0, #{maxCount}
  444. </select>
  445. <select id="findData2EsByQuestionList" resultType="java.util.Map">
  446. select k.id,
  447. k.question_id,
  448. k.how_details_id,
  449. k.how_details_kd_id,
  450. k.how_detail_sort_id,
  451. k.how_detail_kd_sort_id,
  452. k.version,
  453. date_format(k.create_time, '%Y-%m-%dT%H:%i:%s.000Z') create_time,
  454. book_id,
  455. unit_id,
  456. book_course_id,
  457. question_type,
  458. source,
  459. big_question_index,
  460. date_format(analysis_submit_time, '%Y-%m-%dT%H:%i:%s.000Z') analysis_submit_time,
  461. page_index,
  462. image,
  463. precision_percent,
  464. auditing_user_id,
  465. handle_user_id,
  466. deal_status,
  467. remark,
  468. analysis_submit_type,
  469. answer_image,
  470. t.num,
  471. small_question_name,
  472. ifnull(parent_id, '') parent_id,
  473. big_name,
  474. real_exam_type,
  475. date_format(publish_time, '%Y-%m-%dT%H:%i:%s.000Z') publish_time,
  476. update_type,
  477. analysis_user_id,
  478. ifnull(difficulty_level, 0) difficulty_level,
  479. t.course_name,
  480. training_skill,
  481. concise_id,
  482. analysis_auditer_id,
  483. date_format(handler_submit_time, '%Y-%m-%dT%H:%i:%s.000Z') handler_submit_time,
  484. date_format(analysis_handler_submit_time, '%Y-%m-%dT%H:%i:%s.000Z') analysis_handler_submit_time,
  485. question_class_type,
  486. ifnull(khds.alias, '') knowledge_name,
  487. khds.course_name,
  488. khds.semester,
  489. khds.grade,
  490. date_format(t.repulse_time, '%Y-%m-%dT%H:%i:%s.000Z') repulse_time,
  491. t.exercise_book_id,
  492. t.question_path
  493. from (select *
  494. from kmt_exercise_question_know
  495. where question_id in
  496. <foreach collection="questionIdList" open="(" item="questionId" separator="," close=")">
  497. #{questionId}
  498. </foreach>
  499. limit 1000) k join kmt_exercise_questions t on k.question_id = t.id
  500. left join zyb_know_how_details_sort khds on k.how_detail_sort_id = khds.id
  501. </select>
  502. <select id="findAll2Es" resultType="java.util.Map">
  503. select k.id,
  504. k.question_id,
  505. k.how_details_id,
  506. k.how_details_kd_id,
  507. k.how_detail_sort_id,
  508. k.how_detail_kd_sort_id,
  509. k.version,
  510. date_format(k.create_time, '%Y-%m-%dT%H:%i:%s.000Z') create_time,
  511. book_id,
  512. unit_id,
  513. book_course_id,
  514. question_type,
  515. source,
  516. big_question_index,
  517. date_format(analysis_submit_time, '%Y-%m-%dT%H:%i:%s.000Z') analysis_submit_time,
  518. page_index,
  519. image,
  520. precision_percent,
  521. auditing_user_id,
  522. handle_user_id,
  523. deal_status,
  524. remark,
  525. analysis_submit_type,
  526. answer_image,
  527. t.num,
  528. small_question_name,
  529. ifnull(parent_id, '') parent_id,
  530. big_name,
  531. real_exam_type,
  532. date_format(publish_time, '%Y-%m-%dT%H:%i:%s.000Z') publish_time,
  533. update_type,
  534. analysis_user_id,
  535. ifnull(difficulty_level, 0) difficulty_level,
  536. t.course_name,
  537. training_skill,
  538. concise_id,
  539. analysis_auditer_id,
  540. date_format(handler_submit_time, '%Y-%m-%dT%H:%i:%s.000Z') handler_submit_time,
  541. date_format(analysis_handler_submit_time, '%Y-%m-%dT%H:%i:%s.000Z') analysis_handler_submit_time,
  542. question_class_type,
  543. ifnull(khds.alias, '') knowledge_name,
  544. khds.course_name,
  545. khds.semester,
  546. khds.grade,
  547. date_format(t.repulse_time, '%Y-%m-%dT%H:%i:%s.000Z') repulse_time,
  548. t.exercise_book_id,
  549. t.question_path
  550. from (select * from kmt_exercise_question_know where kmt_exercise_question_know.loaded = 0 limit #{pageSize}) k
  551. join kmt_exercise_questions t on k.question_id = t.id
  552. left join zyb_know_how_details_sort khds on k.how_detail_sort_id = khds.id
  553. </select>
  554. <select id="countQuestionByKnowledgeAndVersion" resultType="java.lang.Integer">
  555. select count(distinct question_id)
  556. from kmt_exercise_question_know
  557. where how_details_id in
  558. <foreach collection="knowledgeIdList" open="(" item="knowledgeId" separator="," close=")">
  559. #{knowledgeId}
  560. </foreach>
  561. and kmt_exercise_question_know.version = #{version}
  562. </select>
  563. <!--查询未加工练习册 where eb.had_handle = 0 and eb.handle_user_id=#{handleUserId}
  564. left join kmt_exercise_questions eq on eb.id=eq.book_id
  565. where eq.deal_status in (0, 1) and eb.handle_user_id=#{handleUserId}
  566. group by eb.id
  567. -->
  568. <select id="findUnHandleBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  569. select eb.id exercise_book_id, eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  570. from kmt_exercise_book eb
  571. where eb.part_flag != 3 and eb.had_handle=0 and eb.handle_user_id=#{handleUserId}
  572. <if test="bookName != null and bookName != ''">
  573. <choose>
  574. <when test="searchType == 1">
  575. and eb.book_name = #{bookName}
  576. </when>
  577. <otherwise>
  578. and eb.book_name like concat('%',#{bookName},'%')
  579. </otherwise>
  580. </choose>
  581. </if>
  582. order by eb.book_name
  583. </select>
  584. <!--查询未分配加工人练习册-->
  585. <select id="findUndistributedHandlerBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  586. select eb.book_id id, group_concat(distinct eb.book_year order by eb.book_year asc) book_year_list, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.part_flag
  587. from kmt_exercise_book eb
  588. where eb.course_name=#{subject} and eb.semester=#{semester} and eb.version=#{versionType} and eb.grade=#{grade}
  589. and eb.handle_user_id is null
  590. group by eb.book_id
  591. </select>
  592. <!--查询未审核练习册 where eb.had_auditing=0 and eb.auditing_user_id=#{auditingUserId}
  593. left join kmt_exercise_questions eq on eb.id=eq.book_id
  594. where eq.deal_status in (3, 7) and eb.auditing_user_id=#{auditingUserId}
  595. group by eb.id
  596. -->
  597. <select id="findUnAuditingBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  598. select eb.id exercise_book_id, eb.book_id id,eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  599. from kmt_exercise_book eb
  600. where eb.part_flag != 3 and eb.had_auditing=0 and eb.auditing_user_id=#{auditingUserId}
  601. <if test="bookName != null and bookName != ''">
  602. <choose>
  603. <when test="searchType == 1">
  604. and eb.book_name = #{bookName}
  605. </when>
  606. <otherwise>
  607. and eb.book_name like concat('%',#{bookName},'%')
  608. </otherwise>
  609. </choose>
  610. </if>
  611. order by eb.book_name
  612. </select>
  613. <!--查询未分配审核练习册-->
  614. <select id="findUndistributedAuditerBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  615. select eb.book_id id, group_concat(distinct eb.book_year order by eb.book_year asc) book_year_list, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.part_flag
  616. from kmt_exercise_book eb
  617. where eb.course_name=#{subject} and eb.semester=#{semester} and eb.version=#{versionType} and eb.grade=#{grade}
  618. and eb.auditing_user_id is null
  619. group by eb.book_id
  620. </select>
  621. <!--查询未加工解析的练习册-->
  622. <select id="findUnAnalysisHandleBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  623. select eb.id exercise_book_id, eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  624. from kmt_exercise_book eb
  625. where eb.part_flag != 3 and eb.analysis_handled=0 and eb.analysis_user_id=#{analysisUserId}
  626. <if test="bookName != null and bookName != ''">
  627. <choose>
  628. <when test="searchType == 1">
  629. and eb.book_name = #{bookName}
  630. </when>
  631. <otherwise>
  632. and eb.book_name like concat('%',#{bookName},'%')
  633. </otherwise>
  634. </choose>
  635. </if>
  636. order by eb.book_name
  637. </select>
  638. <!--查询未审核解析的练习册-->
  639. <select id="findUnAnalysisAuditingBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  640. select eb.id exercise_book_id, eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  641. from kmt_exercise_book eb
  642. where eb.part_flag != 3 and eb.analysis_audited=0 and eb.analysis_auditer_id=#{analysisAuditerId}
  643. <if test="bookName != null and bookName != ''">
  644. <choose>
  645. <when test="searchType == 1">
  646. and eb.book_name = #{bookName}
  647. </when>
  648. <otherwise>
  649. and eb.book_name like concat('%',#{bookName},'%')
  650. </otherwise>
  651. </choose>
  652. </if>
  653. order by eb.book_name
  654. </select>
  655. <select id="findUnCorrectAnswerBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  656. select eb.id exerciseBookId, eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  657. from kmt_exercise_book eb
  658. where eb.part_flag !=3 and eb.answer_correcter_id=#{userId} and eb.answer_corrected_status = 0
  659. <if test="bookName != null and bookName != ''">
  660. <choose>
  661. <when test="searchType == 1">
  662. and eb.book_name = #{bookName}
  663. </when>
  664. <otherwise>
  665. and eb.book_name like concat('%',#{bookName},'%')
  666. </otherwise>
  667. </choose>
  668. </if>
  669. order by eb.book_name
  670. </select>
  671. <select id="findCorrectedAnswerBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  672. select eb.id exerciseBookId, eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  673. from kmt_exercise_book eb
  674. where eb.part_flag !=3 and eb.answer_correcter_id=#{userId} and eb.proofread_status > 0
  675. <if test="bookName != null and bookName != ''">
  676. <choose>
  677. <when test="searchType == 1">
  678. and eb.book_name = #{bookName}
  679. </when>
  680. <otherwise>
  681. and eb.book_name like concat('%',#{bookName},'%')
  682. </otherwise>
  683. </choose>
  684. </if>
  685. order by eb.book_name
  686. </select>
  687. <!--查询未校对的练习册-->
  688. <select id="findExerciseBookListByIds" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  689. select eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type
  690. from kmt_exercise_book eb
  691. where id in
  692. <foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
  693. #{id}
  694. </foreach>
  695. </select>
  696. <!--查询所有练习册练习册-->
  697. <select id="findAllExerciseBooks" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  698. select eb.id exercise_book_id, eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type, eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  699. from kmt_exercise_book eb
  700. where eb.part_flag != 3 and eb.course_name=#{subject} and eb.semester=#{semester} and eb.version=#{versionType} and eb.grade=#{grade}
  701. <if test="bookName != null and bookName != ''">
  702. <choose>
  703. <when test="searchType == 1">
  704. and eb.book_name = #{bookName}
  705. </when>
  706. <otherwise>
  707. and eb.book_name like concat('%',#{bookName},'%')
  708. </otherwise>
  709. </choose>
  710. </if>
  711. order by eb.book_name
  712. </select>
  713. <!--查询待加工审核的练习册单元 -->
  714. <select id="findUnHandleExerciseBookCourse" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  715. select ebc.unit_id id, ebc.unit name, ebc.id book_course_id, ebc.period book_course, ebc.period_sort from kmt_exercise_book_course ebc
  716. left join kmt_exercise_questions eq on ebc.id=eq.book_course_id
  717. left join kmt_exercise_book eb on eq.exercise_book_id = eb.id
  718. where eq.exercise_book_id=#{bookId}
  719. <choose>
  720. <when test = "dealType == 1">
  721. and eq.deal_status in (0, 1) and eb.handle_user_id=#{userId}
  722. <if test="questionId != null and questionId != ''">
  723. and eq.id=#{questionId}
  724. </if>
  725. </when>
  726. <when test = "dealType == 2">
  727. and eq.deal_status in (3, 7) and eb.auditing_user_id=#{userId}
  728. <if test="questionId != null and questionId != ''">
  729. and eq.id=#{questionId}
  730. </if>
  731. </when>
  732. <when test = "dealType == 4">
  733. and eq.deal_status in (5, 8) and eb.analysis_user_id=#{userId}
  734. <if test="questionId != null and questionId != ''">
  735. and eq.id=#{questionId}
  736. </if>
  737. </when>
  738. <when test = "dealType == 5">
  739. and eq.deal_status in (9, 10) and eb.analysis_auditer_id=#{userId}
  740. <if test="questionId != null and questionId != ''">
  741. and eq.id=#{questionId}
  742. </if>
  743. </when>
  744. <when test = "dealType == 6">
  745. and eq.deal_status >= 4 and eq.deal_status != 7 and eb.answer_correcter_id=#{userId} and eq.proofread_status = 0
  746. <if test="questionId != null and questionId != ''">
  747. and eq.id=#{questionId}
  748. </if>
  749. </when>
  750. <when test = "dealType == 7">
  751. and eq.proofread_status > 0 and eb.answer_correcter_id=#{userId}
  752. <if test="questionId != null and questionId != ''">
  753. and eq.id=#{questionId}
  754. </if>
  755. </when>
  756. <otherwise>
  757. <if test="questionId != null and questionId != ''">
  758. and eq.id=#{questionId}
  759. </if>
  760. </otherwise>
  761. </choose>
  762. group by ebc.id
  763. order by ebc.period_sort
  764. </select>
  765. <!--查询不同的练习册单元 -->
  766. <select id="findPartExerciseBookCourse" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  767. select ebc.unit_id id, ebc.unit name, ebc.id book_course_id, ebc.period book_course, ebc.period_sort from kmt_exercise_book_course ebc
  768. left join kmt_exercise_questions eq on ebc.id=eq.book_course_id
  769. where eq.exercise_book_id=#{exerciseBookId}
  770. group by ebc.id
  771. order by ebc.period_sort
  772. </select>
  773. <!--查询待解析加工审核的练习册单元-->
  774. <select id="findAnalysisUnHandleExerciseBookCourse" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  775. select ebu.id, ebu.unit name, ebc.id book_course_id, ebc.period book_course from kmt_exercise_book_unit ebu
  776. left join kmt_exercise_book_course ebc on ebu.id=ebc.unit_id
  777. left join kmt_exercise_questions eq on ebc.id=eq.book_course_id
  778. where ebu.book_id=#{bookId}
  779. <if test = "dealType == 2">
  780. and ebc.had_handle = 0
  781. </if>
  782. <if test = "dealType == 1">
  783. and ebc.had_auditing = 0
  784. </if>
  785. <if test = "dealType == 4">
  786. and eq.deal_status in (5, 8)
  787. </if>
  788. <if test = "dealType == 5">
  789. and eq.deal_status in (9, 10)
  790. </if>
  791. group by ebc.id
  792. order by ebu.num, ebc.period_sort
  793. </select>
  794. <!--查询练习册下所有单元课时-->
  795. <select id="findAllExerciseBookCourse" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  796. select ebc.unit_id id, ebc.unit name, ebc.id book_course_id, ebc.period book_course, ebc.period_sort from kmt_exercise_book_course ebc
  797. where (ebc.book_id = #{bookId} and ebc.is_common_flag = 0) or (ebc.exercise_book_id=#{exerciseBookId} and ebc.is_common_flag = 1)
  798. order by ebc.period_sort
  799. </select>
  800. <!--查询练习册下所有单元课时-->
  801. <select id="findAllExerciseBookCourseByExerciseBookId" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  802. select ebc.unit_id id, ebc.unit name, ebc.id book_course_id, ebc.period book_course, ebc.period_sort from kmt_exercise_book_course ebc
  803. where ebc.exercise_book_id=#{exerciseBookId}
  804. order by ebc.period_sort
  805. </select>
  806. <!--查询未加工/未审核的题目数量-->
  807. <select id ="findUnHandleQuestionCount" resultType="java.lang.Integer">
  808. select count(1) from kmt_exercise_questions where book_course_id=#{bookCourseId}
  809. and id not in
  810. <foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
  811. #{id}
  812. </foreach>
  813. <if test = "dealType == 2">
  814. and deal_status in (3, 7)
  815. </if>
  816. <if test = "dealType == 1">
  817. and deal_status &lt; 2
  818. </if>
  819. </select>
  820. <!--查询未加工/未审核的课时数量-->
  821. <select id="findUnHandleBookCourseCount" resultType="java.lang.Integer">
  822. select count(1) from kmt_exercise_book_course where unit_id=#{unitId}
  823. and id != #{bookCourseId}
  824. <if test = "dealType == 2">
  825. and had_auditing = 0
  826. </if>
  827. <if test = "dealType == 1">
  828. and had_handle = 0
  829. </if>
  830. </select>
  831. <!--查询未加工/未审核的单元数量-->
  832. <select id="findUnHandleUnitCount" resultType="java.lang.Integer">
  833. select count(1) from kmt_exercise_book_unit where book_id=#{bookId}
  834. and id != #{unitId}
  835. <if test = "dealType == 2">
  836. and had_auditing = 0
  837. </if>
  838. <if test = "dealType == 1">
  839. and had_handle = 0
  840. </if>
  841. </select>
  842. <!--查询搜索的题目-->
  843. <select id="findKmtQuestionsById" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  844. select eq.id question_id, eq.course_name, eq.handle_user_id, eq.auditing_user_id, eq.analysis_user_id, eq.analysis_auditer_id, eq.book_course_id course_id,
  845. eq.big_question_index, eq.num small_question_index,
  846. eq.deal_status question_status, eq.create_time, eq.remark reason,
  847. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  848. eq.training_skill training_skills, parent_id, image question_image, eq.update_type
  849. from kmt_exercise_questions eq
  850. where (eq.id=#{questionId} or eq.parent_id=#{questionId}) and eq.question_class_type in (0, 2) and eq.book_id is null
  851. <choose>
  852. <when test="dealType == 1">
  853. and eq.handle_user_id = #{userId} and eq.deal_status &lt; 2
  854. </when>
  855. <when test="dealType == 2">
  856. and eq.auditing_user_id = #{userId} and eq.deal_status in (3, 7)
  857. </when>
  858. <otherwise>
  859. and eq.deal_status != 6
  860. </otherwise>
  861. </choose>
  862. order by eq.num
  863. </select>
  864. <!--根据知识点分页查询题目-->
  865. <select id="findKmtQuestionByDetailId" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  866. select eq.id question_id, eq.course_name, eq.handle_user_id, eq.auditing_user_id, eq.analysis_user_id, eq.analysis_auditer_id, eq.book_course_id course_id,
  867. eq.big_question_index, eq.small_question_name small_question_index,
  868. eq.deal_status question_status, eq.create_time, eq.remark reason,
  869. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  870. eq.training_skill training_skills, parent_id, image question_image
  871. from kmt_exercise_questions eq
  872. left join kmt_exercise_question_know eqk on eq.id = eqk.question_id
  873. where eqk.how_detail_sort_id = #{howDetailsId}
  874. <if test = "howDetailsKdId != null and howDetailsKdId != ''">
  875. and eqk.how_detail_kd_sort_id= #{howDetailsKdId}
  876. </if>
  877. and eq.book_id is null and (((eq.parent_id is null or eq.parent_id='') and not exists (select 1 from kmt_exercise_questions tmpeq where tmpeq.parent_id = eq.id))
  878. or (eq.parent_id is not null and eq.parent_id != ''))
  879. <choose>
  880. <when test="dealType == 1">
  881. and eq.handle_user_id = #{userId} and eq.deal_status &lt; 2
  882. </when>
  883. <when test="dealType == 2">
  884. and eq.auditing_user_id = #{userId} and eq.deal_status in (3, 7)
  885. </when>
  886. <otherwise>
  887. and eq.deal_status != 6
  888. </otherwise>
  889. </choose>
  890. <if test="userIdList.size() > 0">
  891. and (
  892. eq.handle_user_id in
  893. <foreach collection="userIdList" index="i" item="userId" open="(" close=")" separator=",">
  894. #{userId}
  895. </foreach>
  896. OR
  897. eq.auditing_user_id in
  898. <foreach collection="userIdList" index="i" item="userId" open="(" close=")" separator=",">
  899. #{userId}
  900. </foreach>
  901. )
  902. </if>
  903. group by eq.id
  904. order by eq.handler_submit_time, eq.parent_id, eq.num, eq.id
  905. </select>
  906. <!--根据年级,科目,版本,上下册分页查询题目-->
  907. <select id="findKmtQuestionByGradeSubjectVersionSemester" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  908. select eq.id question_id, eq.course_name, eq.handle_user_id, eq.auditing_user_id, eq.analysis_user_id, eq.analysis_auditer_id, eq.book_course_id course_id,
  909. eq.big_question_index, eq.small_question_name small_question_index,
  910. eq.deal_status question_status, eq.create_time, eq.remark reason,
  911. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  912. eq.training_skill training_skills, parent_id, image question_image
  913. from kmt_exercise_questions eq
  914. left join zyb_know_how_details_sort khds on eq.concise_id=khds.id
  915. where eq.book_id is null and eq.question_class_type in (0, 2)
  916. <if test = "grade != null and grade != ''">
  917. and khds.grade = #{grade}
  918. </if>
  919. <if test = "courseName != null and courseName != ''">
  920. and khds.course_name = #{courseName}
  921. </if>
  922. <if test = "type > 0">
  923. and khds.type = #{type}
  924. </if>
  925. <if test = "semester > 0">
  926. and khds.semester = #{semester}
  927. </if>
  928. <choose>
  929. <when test="dealType == 1">
  930. and eq.handle_user_id = #{userId} and eq.deal_status &lt; 2
  931. </when>
  932. <when test="dealType == 2">
  933. and eq.auditing_user_id = #{userId} and eq.deal_status in (3, 7)
  934. </when>
  935. <otherwise>
  936. and eq.deal_status != 6
  937. </otherwise>
  938. </choose>
  939. <if test="userIdList.size() > 0">
  940. and (
  941. eq.handle_user_id in
  942. <foreach collection="userIdList" index="i" item="userId" open="(" close=")" separator=",">
  943. #{userId}
  944. </foreach>
  945. OR
  946. eq.auditing_user_id in
  947. <foreach collection="userIdList" index="i" item="userId" open="(" close=")" separator=",">
  948. #{userId}
  949. </foreach>
  950. )
  951. </if>
  952. group by eq.id
  953. order by eq.handler_submit_time, eq.parent_id, eq.num, eq.id
  954. </select>
  955. <!--分页查询所有题目-->
  956. <select id="findAllKmtQuestions" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  957. select eq.id question_id, eq.course_name, eq.handle_user_id, eq.auditing_user_id, eq.analysis_user_id, eq.analysis_auditer_id, eq.book_course_id course_id,
  958. eq.big_question_index, eq.small_question_name small_question_index,
  959. eq.deal_status question_status, eq.create_time, eq.remark reason,
  960. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  961. eq.training_skill training_skills, eq.parent_id, image question_image
  962. from kmt_exercise_questions eq
  963. where eq.book_id is null and (((eq.parent_id is null or eq.parent_id='') and not exists (select 1 from kmt_exercise_questions tmpeq where tmpeq.parent_id = eq.id))
  964. or (eq.parent_id is not null and eq.parent_id != ''))
  965. <choose>
  966. <when test="dealType == 1">
  967. and eq.handle_user_id = #{userId} and eq.deal_status &lt; 2
  968. </when>
  969. <when test="dealType == 2">
  970. and eq.auditing_user_id = #{userId} and eq.deal_status in (3, 7)
  971. </when>
  972. <otherwise>
  973. and eq.deal_status != 6
  974. </otherwise>
  975. </choose>
  976. <if test="userIdList.size() > 0">
  977. and (
  978. eq.handle_user_id in
  979. <foreach collection="userIdList" index="i" item="userId" open="(" close=")" separator=",">
  980. #{userId}
  981. </foreach>
  982. OR
  983. eq.auditing_user_id in
  984. <foreach collection="userIdList" index="i" item="userId" open="(" close=")" separator=",">
  985. #{userId}
  986. </foreach>
  987. )
  988. </if>
  989. group by eq.id
  990. order by eq.handler_submit_time, eq.parent_id, eq.num, eq.id
  991. </select>
  992. <!--查询小题-->
  993. <select id="findSmallQuestionByParentIds" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  994. select eq.id question_id, eq.course_name, eq.handle_user_id, eq.auditing_user_id, eq.analysis_user_id, eq.analysis_auditer_id, eq.book_course_id course_id,
  995. eq.big_question_index, eq.small_question_name small_question_index,
  996. eq.deal_status question_status, eq.create_time, eq.remark reason,
  997. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  998. eq.training_skill training_skills, eq.parent_id, image question_image
  999. from kmt_exercise_questions eq
  1000. where eq.parent_id in
  1001. <foreach collection="parentIds" item="id" index="index" open="(" close=")" separator=",">
  1002. #{id}
  1003. </foreach>
  1004. and eq.deal_status != 6
  1005. order by eq.parent_id, eq.num
  1006. </select>
  1007. <!--查询大题-->
  1008. <select id="findBigQuestionById" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  1009. select eq.id question_id, eq.course_name, eq.handle_user_id, eq.auditing_user_id, eq.analysis_user_id, eq.analysis_auditer_id, eq.book_course_id course_id,
  1010. eq.big_question_index, eq.small_question_name small_question_index,
  1011. eq.deal_status question_status, eq.create_time, eq.remark reason,
  1012. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  1013. eq.training_skill training_skills, eq.parent_id, image question_image,eq.update_type
  1014. from kmt_exercise_questions eq
  1015. where eq.id = #{id}
  1016. </select>
  1017. <!--查询题目的知识点-->
  1018. <select id="findQuestionKnowByQuestionIds" resultType="com.aijia.kmt.dto.QuestionListKnowModel">
  1019. SELECT * from (
  1020. select eqk.question_id, hds.id how_details_id, hds.alias detail_name, hdks.id how_details_kd_id, hdks.alias
  1021. kd_name,
  1022. hds.grade, hds.course_name, hds.type version_type, hds.semester, khd.is_zt module_type, hs.alias how_name,
  1023. hds.num, hdks.num as num2
  1024. from tr_train_user_question_know eqk
  1025. left join zyb_know_how_details_sort hds on eqk.how_detail_sort_id=hds.id
  1026. left join zyb_know_how_details_sort hs on hds.how_id=hs.how_id and hds.type=hs.type and hds.semester=hs.semester
  1027. and hds.grade=hs.grade and hs.stat=1
  1028. left join zyb_know_how_details_sort hdks on eqk.how_detail_kd_sort_id=hdks.id
  1029. left join zyb_know_how_details khd on hds.how_details_id=khd.id
  1030. where question_id in
  1031. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  1032. #{id}
  1033. </foreach>
  1034. and eqk.user_id = #{userId}
  1035. union all
  1036. select eqk1.question_id, hds1.id how_details_id, hds1.alias detail_name, hdks1.id how_details_kd_id, hdks1.alias
  1037. kd_name,
  1038. hds1.grade, hds1.course_name, hds1.type version_type, hds1.semester, khd1.is_zt module_type, hs1.alias how_name,
  1039. hds1.num, hdks1.num as num2
  1040. from kmt_exercise_question_know eqk1
  1041. left join zyb_know_how_details_sort hds1 on eqk1.how_detail_sort_id=hds1.id
  1042. left join zyb_know_how_details_sort hs1 on hds1.how_id=hs1.how_id and hds1.type=hs1.type and
  1043. hds1.semester=hs1.semester and hds1.grade=hs1.grade and hs1.stat=1
  1044. left join zyb_know_how_details_sort hdks1 on eqk1.how_detail_kd_sort_id=hdks1.id
  1045. left join zyb_know_how_details khd1 on hds1.how_details_id=khd1.id
  1046. where question_id in
  1047. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  1048. #{id}
  1049. </foreach>and question_id not in (
  1050. select question_id from tr_train_user_question_know where user_id = #{userId}
  1051. )
  1052. )t order by t.question_id, t.num, t.num2
  1053. </select>
  1054. <!--查询kmt题目的知识点-->
  1055. <select id="findKmtQuestionKnowByQuestionIds" resultType="com.aijia.kmt.dto.QuestionListKnowModel">
  1056. select eqk.question_id, hds.id how_details_id, hds.alias detail_name, hdks.id how_details_kd_id, hdks.alias kd_name,
  1057. hds.grade, hds.course_name, hds.type version_type, hds.semester, khd.is_zt module_type, hs.alias how_name
  1058. from kmt_quality_question_know eqk
  1059. left join zyb_know_how_details_sort hds on eqk.how_detail_sort_id=hds.id
  1060. left join zyb_know_how_details_sort hs on hds.how_id=hs.how_id and hds.type=hs.type and hds.semester=hs.semester and hds.grade=hs.grade and hs.stat=1
  1061. left join zyb_know_how_details_sort hdks on eqk.how_detail_kd_sort_id=hdks.id
  1062. left join zyb_know_how_details khd on hds.how_details_id=khd.id
  1063. where question_id in
  1064. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  1065. #{id}
  1066. </foreach>
  1067. order by eqk.question_id, hds.num, hdks.num
  1068. </select>
  1069. <!--通过子题目id查询父题目-->
  1070. <select id="findPrentQuestionByChildQuestionId" resultType="com.aijia.kmt.po.KmtExerciseQuestion">
  1071. select parent.* from kmt_exercise_questions child left join kmt_exercise_questions parent on child.parent_id=parent.id
  1072. where child.id=#{questionId} and parent.id is not null
  1073. </select>
  1074. <!-- 查询练习册记录-->
  1075. <select id="findExerciseBookById" resultType="com.aijia.kmt.po.KmtExerciseBook">
  1076. select * from kmt_exercise_book where id=#{bookId}
  1077. </select>
  1078. <select id="findExerciseBookByBookIdAndYearAndType" resultType="com.aijia.kmt.po.KmtExerciseBook">
  1079. select id, book_id from kmt_exercise_book where book_id=#{bookId} and book_year=#{bookYear}
  1080. and book_type=#{bookType}
  1081. limit 1
  1082. </select>
  1083. <!-- 查询练习册单元课时-->
  1084. <select id="findByBookIds" resultType="com.aijia.kmt.po.KmtExerciseBookCourse">
  1085. select eb.id book_id, ebc.book_name, ebc.unit_id, ebc.unit, ebc.id, ebc.period, ebc.grade,
  1086. ebc.course_name, ebc.version, ebc.semester, eb.part_flag remark from kmt_exercise_book_course ebc
  1087. left join kmt_exercise_book eb on ebc.book_id=eb.book_id where eb.id in
  1088. <foreach collection="bookIds" item="id" index="index" open="(" close=")" separator=",">
  1089. #{id}
  1090. </foreach>
  1091. order by eb.id,ebc.unit_sort,ebc.period_sort limit 5000
  1092. </select>
  1093. <!-- 删除加工的知识点 -->
  1094. <delete id="deleteKmtExerciseQuestionKnowByQuestionIds">
  1095. delete from tr_train_user_question_know where question_id in
  1096. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  1097. #{id}
  1098. </foreach>
  1099. and user_id = #{userId}
  1100. </delete>
  1101. <delete id="deleteKmtExerciseBookStatusCountByExerciseBookIds">
  1102. delete from kmt_exercise_book_status_count where exercise_book_id in
  1103. <foreach collection="exerciseBookIdSet" item="id" index="index" open="(" close=")" separator=",">
  1104. #{id}
  1105. </foreach>
  1106. </delete>
  1107. <!-- 题目提交审核 -->
  1108. <update id="updateKmtExerciseQuestion2Review">
  1109. UPDATE kmt_exercise_questions set deal_status=3 WHERE id in
  1110. <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
  1111. #{id}
  1112. </foreach>
  1113. </update>
  1114. <update id="updateLoadStatus">
  1115. update kmt_exercise_question_know set loaded = 1 where loaded = 0 and id in
  1116. <foreach collection="kmtExerciseQuestionKnowIdList" open="(" item="id" separator="," close=")">
  1117. #{id}
  1118. </foreach>
  1119. </update>
  1120. <!--更新练习册为未加工-->
  1121. <update id="updateKmtExerciseBookNotHandle">
  1122. update kmt_exercise_book set had_handle=0 where id=#{id}
  1123. </update>
  1124. <!--更新练习册为未审核-->
  1125. <update id="updateKmtExerciseBookNotAuditing">
  1126. update kmt_exercise_book set had_auditing=0 where id=#{id}
  1127. </update>
  1128. <!--更新练习册为解析未加工-->
  1129. <update id="updateKmtExerciseBookAnalysisNotHandle">
  1130. update kmt_exercise_book set analysis_handled=0 where id=#{id}
  1131. </update>
  1132. <!--更新练习册为解析未审核-->
  1133. <update id="updateKmtExerciseBookAnalysisNotAuditing">
  1134. update kmt_exercise_book set analysis_audited=0 where id=#{id}
  1135. </update>
  1136. <!--更新练习册课时为未加工-->
  1137. <update id="updateKmtExerciseBookCourseNotHandle">
  1138. update kmt_exercise_book_course set had_handle=0, had_auditing=0 where id=#{id}
  1139. </update>
  1140. <!--更新练习册课时为未审核-->
  1141. <update id="updateKmtExerciseBookCourseNotAuditing">
  1142. update kmt_exercise_book_course set had_auditing=0 where id=#{id}
  1143. </update>
  1144. <update id="updateExerciseQuestionKnowEsLoadStatus">
  1145. update kmt_exercise_question_know set loaded = #{newLoaded}
  1146. where id in
  1147. <foreach collection="kmtExerciseQuestionKnowIdList" open="(" item="kmtExerciseQuestionKnowId" separator="," close=")">
  1148. #{kmtExerciseQuestionKnowId}
  1149. </foreach>
  1150. </update>
  1151. <select id="getBookId" resultType="String" parameterType="java.util.Map">
  1152. select id
  1153. from kmt_exercise_book eb
  1154. where eb.course_name = #{map.subject}
  1155. and eb.grade = #{map.grade}
  1156. and eb.semester = #{map.semester}
  1157. and eb.book_type in (0, 1, 3)
  1158. and not exists (
  1159. select 1 from scon_homework_exercise_except t1
  1160. where t1.school = #{map.school}
  1161. and t1.grade = #{map.grade}
  1162. and t1.course_name = #{map.subject}
  1163. and eb.book_id = t1.except_book_id
  1164. )
  1165. <if test='map.version != null and map.version > 0'>
  1166. and version = #{map.version}
  1167. </if>
  1168. </select>
  1169. <sql id="exercisePublic" >
  1170. t.id exerciseBookId,
  1171. t.url1,
  1172. t.url2,
  1173. t.book_name bookName,
  1174. t.press,
  1175. t.course_name subject,
  1176. t.grade,
  1177. t.version,
  1178. t.version_name versionName,
  1179. t.semester,
  1180. t.print_year printYear,
  1181. t.book_year bookYear,
  1182. t.book_year useYear,
  1183. t.status,
  1184. t.org_nums orgNums,
  1185. t.progress,
  1186. if(t.progress = '已发布', date(t.publish_time), '') publishDate,
  1187. t.total_grade_priority priority,
  1188. t.identified_nums identifiedNums,
  1189. t.answer_correcter_id answerCorrecterId,
  1190. t.book_type,
  1191. t.check_time checkTime,
  1192. t.ai_rollback_import aiRollbackImport,
  1193. t.updated_time,
  1194. t.assigned_batch,
  1195. date(t.allot_check_time) allotCheckTime
  1196. </sql>
  1197. <select id="findExerciseList" resultType="com.aijia.kmt.dto.Exercise1Dto" parameterType="java.util.Map">
  1198. select
  1199. <include refid="exercisePublic" />
  1200. ,wb.book_question_pdf,
  1201. wb.book_answer_pdf
  1202. from kmt_exercise_book t
  1203. left join q_workbook wb on t.parent_book_id=wb.id
  1204. where 1=1
  1205. <!--未校对-->
  1206. <if test='map.proofreadStatus == "0" '>
  1207. and not exists (
  1208. select 1 from kmt_exercise_book_status_count t1
  1209. where t.id = t1.exercise_book_id
  1210. and t1.data_status = 1
  1211. and t1.status > 0
  1212. and t1.status &lt; 5
  1213. )
  1214. and t.status is not null
  1215. and t.proofread_status = 0
  1216. and t.answer_correcter_id is null
  1217. and t.part_flag != 3
  1218. </if>
  1219. <if test="map.bookType != null and map.bookType != '' ">
  1220. and t.book_type = ${map.bookType}
  1221. </if>
  1222. <if test="map.progress != null and map.progress != '' ">
  1223. and t.progress = #{map.progress}
  1224. </if>
  1225. <if test="map.subject != null and map.subject != '' ">
  1226. and t.course_name = #{map.subject}
  1227. </if>
  1228. <if test="map.grade != null and map.grade != '' ">
  1229. and t.grade = #{map.grade}
  1230. </if>
  1231. <if test="map.bookName != null and map.bookName != '' ">
  1232. <choose>
  1233. <when test="map.searchType == 1">
  1234. and t.book_name = #{map.bookName}
  1235. </when>
  1236. <otherwise>
  1237. and t.book_name like concat('%',#{map.bookName},'%')
  1238. </otherwise>
  1239. </choose>
  1240. </if>
  1241. <if test="map.semester != null and map.semester != ''">
  1242. and t.semester = #{map.semester}
  1243. </if>
  1244. <if test="map.versionName != null and map.versionName != '' ">
  1245. and t.version_name = #{map.versionName}
  1246. </if>
  1247. <if test="map.bookYear != null and map.bookYear != '' ">
  1248. and t.book_year = #{map.bookYear}
  1249. </if>
  1250. <if test="map.assignedBatch != null and map.assignedBatch != '' ">
  1251. and t.assigned_batch like concat('%',#{map.assignedBatch},'%')
  1252. </if>
  1253. <if test="map.versionType != null and map.versionType != ''">
  1254. and t.version =#{map.versionType}
  1255. </if>
  1256. order by t.updated_time desc,t.book_name
  1257. </select>
  1258. <select id="findTeacherExerciseList" resultType="com.aijia.kmt.dto.Exercise1Dto" parameterType="java.util.Map">
  1259. select
  1260. <include refid="exercisePublic" />
  1261. ,t1.name teacherName, t1.user_id, t.create_time
  1262. from kmt_exercise_book t
  1263. left join tb_lib_manager t1 on t.answer_correcter_id = t1.user_id
  1264. and t1.type = 17
  1265. and t1.authority = 8
  1266. and t1.state = 1
  1267. where 1=1
  1268. <if test="map.teacherName != null and map.teacherName != '' ">
  1269. and t1.name regexp #{map.teacherName}
  1270. </if>
  1271. <if test="map.exerciseName != null and map.exerciseName != '' ">
  1272. and t.book_name regexp #{map.exerciseName}
  1273. </if>
  1274. <if test="map.beginTime != null and map.beginTime != '' ">
  1275. and t.check_time >= #{map.beginTime}
  1276. </if>
  1277. <if test="map.endTime != null and map.endTime != '' ">
  1278. and t.check_time &lt;= #{map.endTime}
  1279. </if>
  1280. <if test="map.versionType != null and map.versionType != ''">
  1281. and t.version =#{map.versionType}
  1282. </if>
  1283. <if test="map.bookType != null and map.bookType != ''">
  1284. and t.book_type =#{map.bookType}
  1285. </if>
  1286. <if test="map.grade != null and map.grade != ''">
  1287. and t.grade =#{map.grade}
  1288. </if>
  1289. <if test="map.subject != null and map.subject != ''">
  1290. and t.course_name =#{map.subject}
  1291. </if>
  1292. <if test="map.semester != null and map.semester != ''">
  1293. and t.semester =#{map.semester}
  1294. </if>
  1295. <if test="map.allotCheckTime != null and map.allotCheckTime != ''">
  1296. and t.allot_check_time BETWEEN concat(#{map.allotCheckTime},' 00:00:00') AND concat(#{map.allotCheckTime},' 23:59:59')
  1297. </if>
  1298. <!--校对中-->
  1299. <if test='map.type == "1" '>
  1300. and t.part_flag != 3
  1301. and t.answer_corrected_status = 0
  1302. and t.answer_correcter_id is not null
  1303. order by t1.name,t1.user_id,t.book_name
  1304. </if>
  1305. <!--已校对-->
  1306. <if test='map.type == "2" '>
  1307. and t.part_flag != 3
  1308. and t.answer_corrected_status = 1
  1309. order by t1.name,t1.user_id,t.book_name,t.create_time asc
  1310. </if>
  1311. </select>
  1312. <select id="findLastExerciseRollbackByQuestionId" resultType="com.aijia.kmt.po.KmtExerciseQuestionRollback">
  1313. select * from kmt_exercise_question_rollback where question_id=#{questionId} order by create_time desc limit 1
  1314. </select>
  1315. <select id="findLibList" resultType="com.aijia.kmt.po.TbLibJoin" parameterType="java.util.Map">
  1316. select t1.*
  1317. from tb_lib_join t1
  1318. where 1=1
  1319. and t1.type = 1
  1320. <if test="map.name != null and map.name != '' ">
  1321. and t1.league_name regexp #{map.name}
  1322. </if>
  1323. and exists (
  1324. select 1 from fx_merchant t2 where t1.id = t2.lib_id and t2.sign_service > 0
  1325. )
  1326. order by t1.league_name
  1327. </select>
  1328. <select id="findExerciseBookCount" resultType="com.aijia.kmt.dto.ExerciseBookCountDTO">
  1329. select status,
  1330. count(*) totalCount,
  1331. sum(if(course_name = '语文', 1, 0)) chineseCount,
  1332. sum(if(course_name = '数学', 1, 0)) mathCount,
  1333. sum(if(course_name = '英语', 1, 0)) englishCount
  1334. from kmt_exercise_book_status_count
  1335. where data_status = 1
  1336. group by status
  1337. </select>
  1338. <select id="findAllLib" resultType="java.util.Map">
  1339. select t1.lib_id libId,t3.league_lat leagueLet,t3.league_lng leagueLng,t3.league_name leagueName, ifNull(t4.sign_service,0) signService
  1340. from kmt_exercise_book_lib t1
  1341. left join kmt_exercise_book t2 on t1.exercise_book_id =t2.id and t1.is_delete=0
  1342. left join tb_lib_join t3 on t1.lib_id=t3.id
  1343. left join fx_merchant t4 on t1.lib_id=t4.lib_id
  1344. where t1.lib_id is not null and t1.lib_id !=''
  1345. <if test="subject != null and subject != '' ">
  1346. and t2.course_name=#{subject}
  1347. </if>
  1348. and t1.is_delete=0
  1349. and t4.sign_service!=0
  1350. and t4.sign_service is not null
  1351. group by libId
  1352. </select>
  1353. <select id="findAllExerciseBook" resultType="com.aijia.kmt.dto.exercise.KmtExerciseBookLibDto">
  1354. select distinct t1.book_id bookId, t1.book_name exerciseName,t1.version_name version,t1.total_grade_priority priority,t1.semester,t1.grade,t1.progress progress,t1.total_grade_priority totalPriority,t1.create_time createTime
  1355. from kmt_exercise_book_lib t
  1356. left join kmt_exercise_book t1 on t.exercise_book_id =t1.id
  1357. where t.lib_id=#{libId}
  1358. and t1.course_name=#{subject}
  1359. and t.is_delete=0
  1360. </select>
  1361. <select id="findAllExportLib" resultType="java.util.Map">
  1362. select distinct t1.exercise_book_id bookId, t1.lib_id libId,t3.league_lat leagueLet,t3.league_lng leagueLng,t3.league_name leagueName,ifNull(t4.sign_service,0)signService
  1363. from kmt_exercise_book_lib t1
  1364. left join kmt_exercise_book t2 on t1.exercise_book_id =t2.id
  1365. left join tb_lib_join t3 on t1.lib_id=t3.id
  1366. left join fx_merchant t4 on t1.lib_id=t4.lib_id
  1367. where t1.lib_id is not null
  1368. <if test="subject != null and subject != '' ">
  1369. and t2.course_name=#{subject}
  1370. </if>
  1371. and t1.is_delete=0
  1372. </select>
  1373. <select id="findQuestionByParentId" resultType="com.aijia.kmt.po.KmtExerciseQuestion">
  1374. select * from kmt_exercise_questions where (id in
  1375. <foreach collection="parentIds" open="(" item="id" separator="," close=")">
  1376. #{id}
  1377. </foreach>or parent_id in
  1378. <foreach collection="parentIds" open="(" item="id" separator="," close=")">
  1379. #{id}
  1380. </foreach>
  1381. ) and deal_status != 6
  1382. order by num
  1383. limit 2000
  1384. </select>
  1385. <select id="findKmtExerciseQuestionRollbackListByQuestionId" resultType="com.aijia.kmt.po.KmtExerciseQuestionRollback">
  1386. select * from kmt_exercise_question_rollback where question_id= #{questionId} order by create_time desc
  1387. </select>
  1388. <select id="findByUserIdAndTypeIn" resultType="com.aijia.kmt.po.user.TbLibManager">
  1389. select * from tb_lib_manager where user_id= #{userId}
  1390. and type in(17,18) order by state, is_cancelled limit 1
  1391. </select>
  1392. <select id="findLibSignCount" resultType="com.aijia.kmt.dto.ExercisePriorityDto">
  1393. select t1.id id,t1.exercise_book_id exerciseBookId,t1.lib_id libId,t2.sign_service signService from kmt_exercise_book_lib t1 left join fx_merchant t2
  1394. on t1.lib_id=t2.lib_id
  1395. where t1.exercise_book_id is not null
  1396. and t1.is_delete=0
  1397. limit 10000
  1398. </select>
  1399. <select id="findExerciseQuestionByExerciseBookId" resultType="com.aijia.kmt.po.KmtExerciseQuestion">
  1400. select eq.id, eq.book_id, eq.unit_id, eq.book_course_id,
  1401. eb.auditing_user_id, eb.handle_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eb.answer_correcter_id,
  1402. eq.question_type, eq.source, eq.big_question_index, eq.analysis_submit_time, eq.page_index,
  1403. eq.image, eq.precision_percent, eq.create_time, eq.deal_status, eq.remark, eq.analysis_submit_type,
  1404. eq.answer_image, eq.num, eq.small_question_name, eq.parent_id, eq.big_name, eq.real_exam_type, eq.publish_time,
  1405. eq.update_type, eq.difficulty_level, eq.training_skill, eq.course_name, eq.is_common_flag, eq.question_year, eq.exercise_book_id, eq.es_loaded,
  1406. eq.analysis_handler_submit_time, eq.question_class_type, eq.repulse_time, eq.handler_submit_time,
  1407. eq.proofread_status, eq.question_path
  1408. from kmt_exercise_questions eq
  1409. left join kmt_exercise_book eb on eq.exercise_book_id=eb.id where eq.exercise_book_id=#{exerciseBookId} limit 10000
  1410. </select>
  1411. <select id="findExerciseQuestionByIds" resultType="com.aijia.kmt.po.KmtExerciseQuestion">
  1412. select eq.id, eq.book_id, eq.unit_id, eq.book_course_id,
  1413. eb.auditing_user_id, eb.handle_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eb.answer_correcter_id,
  1414. eq.question_type, eq.source, eq.big_question_index, eq.analysis_submit_time, eq.page_index,
  1415. eq.image, eq.precision_percent, eq.create_time, eq.deal_status, eq.remark, eq.analysis_submit_type,
  1416. eq.answer_image, eq.num, eq.small_question_name, eq.parent_id, eq.big_name, eq.real_exam_type, eq.publish_time,
  1417. eq.update_type, eq.difficulty_level, eq.training_skill, eq.course_name, eq.is_common_flag, eq.question_year, eq.exercise_book_id, eq.es_loaded,
  1418. eq.analysis_handler_submit_time, eq.question_class_type, eq.repulse_time, eq.handler_submit_time,
  1419. eq.proofread_status, eq.question_path, eq.concise_id
  1420. from kmt_exercise_questions eq
  1421. left join kmt_exercise_book eb on eq.exercise_book_id=eb.id where eq.id in
  1422. <foreach collection="ids" open="(" item="id" separator="," close=")">
  1423. #{id}
  1424. </foreach>
  1425. limit 10000
  1426. </select>
  1427. <!--更新练习册涉及到的机构签约数-->
  1428. <update id="updateKmtExerciseBookByExerciseBookId">
  1429. update kmt_exercise_book set exercise_relevancy_num=#{exerciseRelevancyNum} where id=#{exerciseBooId}
  1430. </update>
  1431. <select id="findAllExerciseBookBySignNum" resultType="com.aijia.kmt.po.KmtExerciseBook">
  1432. select * from kmt_exercise_book
  1433. where
  1434. exercise_relevancy_num !=0
  1435. and exercise_relevancy_num is not null
  1436. order by exercise_relevancy_num desc
  1437. limit 10000
  1438. </select>
  1439. <select id="findAnswerProofreadExerciseBookList"
  1440. resultType="com.aijia.kmt.dto.AnswerProofreadExerciseBookDTO">
  1441. select distinct t1.id exerciseBookId,
  1442. t1.book_name,
  1443. t1.course_name subject,
  1444. t1.grade,
  1445. t1.version,
  1446. t1.semester,
  1447. t1.proofread_status,
  1448. t1.book_type,
  1449. t1.latest_answer_wrong_date_time proofreadDate,
  1450. t3.name
  1451. from kmt_exercise_book t1 left join tb_lib_manager t3
  1452. on t1.answer_correcter_id=t3.user_id
  1453. and t3.type=17 and t3.authority=8 and t3.state=1
  1454. where t1.proofread_status in (2, 3)
  1455. <if test="req.subject != null and req.subject != ''">
  1456. and t1.course_name = #{req.subject}
  1457. </if>
  1458. <if test="req.grade != null and req.grade != ''">
  1459. and t1.grade = #{req.grade}
  1460. </if>
  1461. <if test="req.bookName != null and req.bookName != ''">
  1462. and t1.book_name like concat('%',#{req.bookName},'%')
  1463. </if>
  1464. <if test="req.proofreadDate != null and req.proofreadDate != ''">
  1465. and date(t1.latest_answer_wrong_date_time) = #{req.proofreadDate}
  1466. </if>
  1467. order by t1.proofread_status,t1.latest_answer_wrong_date_time desc
  1468. </select>
  1469. <select id="findQuestionListAnswerWrong" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  1470. select eq.id question_id, eq.course_name, eq.handle_user_id, eq.auditing_user_id, eq.analysis_user_id,
  1471. eq.analysis_auditer_id, eq.book_course_id course_id, eq.big_question_index,
  1472. eq.small_question_name small_question_index,
  1473. eq.deal_status question_status, eq.create_time, eq.remark reason, eq.question_type question_types,
  1474. eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  1475. eq.training_skill training_skills, eq.parent_id, eq.question_path,eq.num, eq.image question_image
  1476. from kmt_exercise_questions eq
  1477. where eq.exercise_book_id = #{req.exerciseBookId}
  1478. and eq.book_course_id = #{req.periodId}
  1479. and eq.proofread_status = 2
  1480. order by eq.num, eq.create_time
  1481. </select>
  1482. <select id="findRepulsedQuestion" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  1483. select eq.id question_id,
  1484. eq.course_name,
  1485. eb.handle_user_id,
  1486. eb.auditing_user_id,
  1487. eb.analysis_user_id,
  1488. eb.analysis_auditer_id,
  1489. eq.book_course_id course_id,
  1490. eq.big_question_index,
  1491. eq.small_question_name small_question_index,
  1492. eq.deal_status question_status,
  1493. eq.create_time,
  1494. eq.remark reason,
  1495. eq.from_user_id,
  1496. eq.to_user_id,
  1497. eq.question_type question_types,
  1498. eq.difficulty_level difficulty_levels,
  1499. eq.real_exam_type real_exam_types,
  1500. eq.training_skill training_skills,
  1501. eq.parent_id,
  1502. eq.question_path,
  1503. eq.num
  1504. from kmt_exercise_questions eq
  1505. left join kmt_exercise_book eb on eq.exercise_book_id=eb.id
  1506. where eq.exercise_book_id = #{req.exerciseBookId}
  1507. and eq.deal_status in
  1508. <foreach collection="dealStatusList" open="(" item="dealStatus" separator="," close=")">
  1509. #{dealStatus}
  1510. </foreach>
  1511. order by eq.num, eq.create_time, eq.deal_status
  1512. limit 0, 5000
  1513. </select>
  1514. <update id="updateKmtExerciseBookById">
  1515. update kmt_exercise_book set priority=#{priority} where id=#{id}
  1516. </update>
  1517. <update id="updateKmtExerciseBookByPriority">
  1518. update kmt_exercise_book set total_grade_priority=#{totalGradePriority} where id=#{id}
  1519. </update>
  1520. <select id="findUnproofreadExerciseId" resultType="java.util.Map">
  1521. select id from kmt_exercise_book eb where eb.answer_correcter_id is not null
  1522. </select>
  1523. <select id="findExerciseStatusByBookId" resultType="com.aijia.kmt.po.KmtExerciseQuestion">
  1524. select eq.* from kmt_exercise_questions eq left join kmt_exercise_book eb on eq.exercise_book_id=eb.id where eb.answer_correcter_id is not null and eq.book_id=#{bookId}
  1525. </select>
  1526. <update id="updateExerciseBookStatusByIdAndStatus">
  1527. update kmt_exercise_book set proofread_status=#{proofreadStatus} where id=#{id}
  1528. </update>
  1529. <update id="updateExerciseBookProofreadResult">
  1530. update kmt_exercise_book set proofread_status=#{type}, latest_answer_wrong_date_time = now() where id=#{exerciseBookId}
  1531. </update>
  1532. <select id="countAnswerWrongQuestion" resultType="java.lang.Integer">
  1533. select count(*) from kmt_exercise_questions where exercise_book_id = #{exerciseBookId} and proofread_status = 2 and deal_status not in (2, 6)
  1534. and id not in
  1535. <foreach collection="excludeQuestionIdSet" open="(" item="id" close=")" separator=",">
  1536. #{id}
  1537. </foreach>
  1538. </select>
  1539. <select id="teacherAnswerProofreadDetail" resultType="java.util.Map">
  1540. select count(1) total,sum(answer_corrected_status) finishedNums
  1541. from kmt_exercise_book
  1542. where answer_correcter_id = #{userId}
  1543. </select>
  1544. <select id="findUnitAndPeriodList" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  1545. select ebc.unit_id id, ebc.unit name, ebc.id book_course_id, ebc.period book_course
  1546. from kmt_exercise_book_course ebc
  1547. where ebc.id in (select distinct book_course_id
  1548. from kmt_exercise_questions
  1549. where exercise_book_id = #{request.exerciseBookId} and proofread_status = 2)
  1550. </select>
  1551. <select id="findKmtExerciseQuestionErrorsByQuestionIds" resultType="com.aijia.kmt.po.KmtExerciseQuestionErrors">
  1552. select * from kmt_exercise_question_errors where question_id in
  1553. <foreach collection="questionIds" open="(" item="id" close=")" separator=",">
  1554. #{id}
  1555. </foreach>
  1556. and error_user_auth=#{beType}
  1557. </select>
  1558. <select id="findKmtExerciseQuestionByErrorUserId" resultType="com.aijia.kmt.po.KmtExerciseQuestionErrors">
  1559. select * from kmt_exercise_question_errors where error_user_id=#{userId}
  1560. and exercise_book_id=#{exerciseBookId}
  1561. order by create_time desc
  1562. </select>
  1563. <select id="countQuestionErrorCountByExerciseBookId" resultType="java.lang.Integer">
  1564. select count(1) from kmt_exercise_question_errors where exercise_book_id=#{exerciseBookId}
  1565. and error_user_id=#{userId} and error_user_auth=#{type}
  1566. </select>
  1567. <select id="findSameExerciseBookList" resultType="com.aijia.kmt.po.KmtExerciseBook">
  1568. SELECT t.*
  1569. FROM kmt_exercise_book t,
  1570. (select book_name,
  1571. course_name,
  1572. grade,
  1573. version_name,
  1574. semester,
  1575. book_type,
  1576. book_year,
  1577. COUNT(book_name) c1,
  1578. COUNT(course_name) c2,
  1579. COUNT(grade) c3,
  1580. COUNT(version_name) c4,
  1581. COUNT(semester) c5,
  1582. COUNT(book_type) c6,
  1583. COUNT(book_year) c7
  1584. from kmt_exercise_book
  1585. group by book_name, course_name, grade, version_name, semester, book_type, book_year
  1586. HAVING c1 > 1
  1587. and c2 > 1
  1588. and c3 > 1
  1589. and c4 > 1
  1590. and c5 > 1
  1591. and c6 > 1
  1592. and c7 > 1) t1
  1593. where t.book_name = t1.book_name
  1594. and t.course_name = t1.course_name
  1595. and t.grade = t1.grade
  1596. and t.version_name = t1.version_name
  1597. and t.semester = t1.semester
  1598. and t.book_type = t1.book_type
  1599. and t.book_year = t1.book_year
  1600. order by t.book_name, t.course_name, t.grade, t.version_name, t.semester, t.book_type, t.book_year, t.part_flag
  1601. </select>
  1602. <select id="countUnFinishQuestionsByExerciseBookId" resultType="java.lang.Integer">
  1603. select count(1) from kmt_exercise_questions where exercise_book_id=#{exerciseBookId}
  1604. <if test="type == 1">
  1605. and deal_status in (0, 1)
  1606. </if>
  1607. <if test="type == 2">
  1608. and deal_status in (3, 7)
  1609. </if>
  1610. <if test="type == 3">
  1611. and deal_status in (5, 8)
  1612. </if>
  1613. <if test="type == 4">
  1614. and deal_status in (9, 10)
  1615. </if>
  1616. </select>
  1617. <select id="findDistributionCount"
  1618. resultType="com.aijia.kmt.dto.ExerciseDistributionCountDTO">
  1619. select sum(if(handle_user_id is null or auditing_user_id is null or analysis_user_id is null or
  1620. analysis_auditer_id is null, 1, 0)) notDistributedExerciseBookCount,
  1621. count(*) totalExerciseBookCount
  1622. from kmt_exercise_book
  1623. where part_flag &lt;> 3
  1624. </select>
  1625. <select id="findDistributionExerciseBookList" resultMap="DistributionExerciseBookDTOResultMap">
  1626. select eb.exerciseBookId,
  1627. eb.importDate,
  1628. eb.subject,
  1629. eb.grade,
  1630. eb.version_name,
  1631. eb.semester,
  1632. eb.book_name,
  1633. eb.book_type,
  1634. eb.assigned_batch,
  1635. (select count(distinct unit_name) from q_question_workbook where sub_book_id = eb.exerciseBookId) unitNum,
  1636. (select count(distinct unit_name, course_name) from q_question_workbook where sub_book_id = eb.exerciseBookId) courseNum,
  1637. ebcHandle.accuracy intHandleAccuracy,
  1638. ebcHandleAudit.accuracy intHandleAuditAccuracy,
  1639. ebcAnalysis.accuracy intAnalysisAccuracy,
  1640. ebtrHandle.teacher_id handlerTeacherId,
  1641. ebtrHandle.teacher_name handlerName,
  1642. ebtrHandle.salary_given handlerSalaryGiven,
  1643. ebtrHandle.salary_given_time handlerSalaryGivenTime,
  1644. ebtrHandle.create_time handlerDistributeTime,
  1645. ebtrHandleAudit.teacher_id handlerAuditUserTeacherId,
  1646. ebtrHandleAudit.teacher_name handlerAuditUserName,
  1647. ebtrHandleAudit.salary_given handlerAuditUserSalaryGiven,
  1648. ebtrHandleAudit.salary_given_time handlerAuditUserSalaryGivenTime,
  1649. ebtrHandleAudit.create_time handlerAuditUserDistributeTime,
  1650. ebtrAnalysis.teacher_id analyserTeacherId,
  1651. ebtrAnalysis.teacher_name analyserName,
  1652. ebtrAnalysis.salary_given analyserSalaryGiven,
  1653. ebtrAnalysis.salary_given_time analyserSalaryGivenTime,
  1654. ebtrAnalysis.create_time analyserDistributeTime,
  1655. ebtrAnalysisAudit.teacher_id analysisAuditUserTeacherId,
  1656. ebtrAnalysisAudit.teacher_name analysisAuditUserName,
  1657. ebtrAnalysisAudit.salary_given analysisAuditUserSalaryGiven,
  1658. ebtrAnalysisAudit.salary_given_time analysisAuditUserSalaryGivenTime,
  1659. ebtrAnalysisAudit.create_time analysisAuditUserDistributeTime
  1660. from (select id exerciseBookId,
  1661. create_time importDate,
  1662. course_name subject,
  1663. grade,
  1664. version_name,
  1665. semester,
  1666. book_name,
  1667. book_type,
  1668. handle_user_id,
  1669. auditing_user_id,
  1670. analysis_user_id,
  1671. analysis_auditer_id,
  1672. assigned_batch
  1673. from kmt_exercise_book
  1674. where (3 > part_flag or part_flag > 3)
  1675. <if test="req.type == 1">
  1676. and (
  1677. <choose>
  1678. <when test="(req.handler != null and req.handler > 0) or
  1679. (req.handleAuditUser != null and req.handleAuditUser > 0) or
  1680. (req.analyser != null and req.analyser > 0) or
  1681. (req.analysisAuditUser != null and req.analysisAuditUser > 0)">
  1682. <trim suffixOverrides="and">
  1683. <if test="req.handler != null and req.handler > 0">
  1684. handle_user_id is null and
  1685. </if>
  1686. <if test="req.handleAuditUser != null and req.handleAuditUser > 0">
  1687. auditing_user_id is null and
  1688. </if>
  1689. <if test="req.analyser != null and req.analyser > 0">
  1690. analysis_user_id is null and
  1691. </if>
  1692. <if test="req.analysisAuditUser != null and req.analysisAuditUser > 0">
  1693. analysis_auditer_id is null and
  1694. </if>
  1695. </trim>
  1696. </when>
  1697. <otherwise>
  1698. handle_user_id is null
  1699. or auditing_user_id is null
  1700. or analysis_user_id is null
  1701. or analysis_auditer_id is null
  1702. </otherwise>
  1703. </choose>
  1704. )
  1705. </if>
  1706. <if test="req.type == 2">
  1707. and (handle_user_id is not null
  1708. and auditing_user_id is not null
  1709. and analysis_user_id is not null
  1710. and analysis_auditer_id is not null)
  1711. </if>
  1712. <if test="req.bookName != null and req.bookName != ''">
  1713. <choose>
  1714. <when test="req.searchType == 1">
  1715. and book_name = #{req.bookName}
  1716. </when>
  1717. <otherwise>
  1718. and book_name like '%${req.bookName}%'
  1719. </otherwise>
  1720. </choose>
  1721. </if>
  1722. <if test="req.subject != null and req.subject != ''">
  1723. and course_name = #{req.subject}
  1724. </if>
  1725. <if test="req.grade != null and req.grade != ''">
  1726. and grade = #{req.grade}
  1727. </if>
  1728. <if test="req.version != null and req.version > 0">
  1729. and version = #{req.version}
  1730. </if>
  1731. <if test="req.semester != null and req.semester > 0">
  1732. and semester = #{req.semester}
  1733. </if>
  1734. <if test="req.bookType != null and req.bookType > -1">
  1735. and book_type = #{req.bookType}
  1736. </if>
  1737. <if test="req.startTime != null and req.startTime != ''">
  1738. and create_time > #{req.startTime}
  1739. </if>
  1740. <if test="req.endTime != null and req.endTime != ''">
  1741. and '${req.endTime} 23:59:59' > create_time
  1742. </if>
  1743. <if test="req.assignedBatch != null and req.assignedBatch != ''">
  1744. and assigned_batch like '%${req.assignedBatch}%'
  1745. </if>
  1746. order by create_time desc
  1747. limit #{offset}, #{pageSize}) eb
  1748. left join kmt_exercise_book_teacher_record ebtrHandle
  1749. on eb.exerciseBookId = ebtrHandle.exercise_book_id and ebtrHandle.authority_type = 1
  1750. left join kmt_exercise_book_count ebcHandle
  1751. on eb.exerciseBookId = ebcHandle.exercise_book_id and ebcHandle.type = 1
  1752. left join kmt_exercise_book_teacher_record ebtrHandleAudit
  1753. on eb.exerciseBookId = ebtrHandleAudit.exercise_book_id and ebtrHandleAudit.authority_type = 2
  1754. left join kmt_exercise_book_count ebcHandleAudit
  1755. on eb.exerciseBookId = ebcHandleAudit.exercise_book_id and ebcHandleAudit.type = 2
  1756. left join kmt_exercise_book_teacher_record ebtrAnalysis
  1757. on eb.exerciseBookId = ebtrAnalysis.exercise_book_id and ebtrAnalysis.authority_type = 3
  1758. left join kmt_exercise_book_count ebcAnalysis
  1759. on eb.exerciseBookId = ebcAnalysis.exercise_book_id and ebcAnalysis.type = 3
  1760. left join kmt_exercise_book_teacher_record ebtrAnalysisAudit
  1761. on eb.exerciseBookId = ebtrAnalysisAudit.exercise_book_id and ebtrAnalysisAudit.authority_type = 4
  1762. left join kmt_exercise_book_count ebcAnalysisAudit
  1763. on eb.exerciseBookId = ebcAnalysisAudit.exercise_book_id and ebcAnalysisAudit.type = 4
  1764. order by eb.importDate desc
  1765. </select>
  1766. <select id="countDistributionExerciseBook" resultType="java.lang.Integer">
  1767. select count(1)
  1768. from kmt_exercise_book
  1769. where part_flag &lt;> 3
  1770. <if test="req.type == 1">
  1771. and (
  1772. <choose>
  1773. <when test="(req.handler != null and req.handler > 0) or
  1774. (req.handleAuditUser != null and req.handleAuditUser > 0) or
  1775. (req.analyser != null and req.analyser > 0) or
  1776. (req.analysisAuditUser != null and req.analysisAuditUser > 0)">
  1777. <trim suffixOverrides="and">
  1778. <if test="req.handler != null and req.handler > 0">
  1779. handle_user_id is null and
  1780. </if>
  1781. <if test="req.handleAuditUser != null and req.handleAuditUser > 0">
  1782. auditing_user_id is null and
  1783. </if>
  1784. <if test="req.analyser != null and req.analyser > 0">
  1785. analysis_user_id is null and
  1786. </if>
  1787. <if test="req.analysisAuditUser != null and req.analysisAuditUser > 0">
  1788. analysis_auditer_id is null and
  1789. </if>
  1790. </trim>
  1791. </when>
  1792. <otherwise>
  1793. handle_user_id is null
  1794. or auditing_user_id is null
  1795. or analysis_user_id is null
  1796. or analysis_auditer_id is null
  1797. </otherwise>
  1798. </choose>
  1799. )
  1800. </if>
  1801. <if test="req.type == 2">
  1802. and (handle_user_id is not null
  1803. and auditing_user_id is not null
  1804. and analysis_user_id is not null
  1805. and analysis_auditer_id is not null)
  1806. </if>
  1807. <if test="req.bookName != null and req.bookName != ''">
  1808. and book_name like '%${req.bookName}%'
  1809. </if>
  1810. <if test="req.subject != null and req.subject != ''">
  1811. and course_name = #{req.subject}
  1812. </if>
  1813. <if test="req.grade != null and req.grade != ''">
  1814. and grade = #{req.grade}
  1815. </if>
  1816. <if test="req.version != null and req.version > 0">
  1817. and version = #{req.version}
  1818. </if>
  1819. <if test="req.semester != null and req.semester > 0">
  1820. and semester = #{req.semester}
  1821. </if>
  1822. <if test="req.bookType != null and req.bookType > -1">
  1823. and book_type = #{req.bookType}
  1824. </if>
  1825. <if test="req.startTime != null and req.startTime != ''">
  1826. and create_time > #{req.startTime}
  1827. </if>
  1828. <if test="req.endTime != null and req.endTime != ''">
  1829. and '${req.endTime} 23:59:59' > create_time
  1830. </if>
  1831. <if test="req.assignedBatch != null and req.assignedBatch != ''">
  1832. and assigned_batch like '%${req.assignedBatch}%'
  1833. </if>
  1834. </select>
  1835. <update id="updateAnswerCorrecterIdByIds">
  1836. update kmt_exercise_book set answer_correcter_id = #{teacherId},allot_check_time = now()
  1837. where id in
  1838. <foreach collection="exerciseBookIds" open="(" item="exerciseBookId" separator="," close=")">
  1839. #{exerciseBookId}
  1840. </foreach>
  1841. </update>
  1842. <update id="updateAnswerCorrecterIdByExerciseBookIds">
  1843. update kmt_exercise_questions set answer_correcter_id = #{teacherId}
  1844. where exercise_book_id in
  1845. <foreach collection="exerciseBookIds" open="(" item="exerciseBookId" separator="," close=")">
  1846. #{exerciseBookId}
  1847. </foreach>
  1848. </update>
  1849. <select id="findExportDistributionExerciseBookList" resultType="com.aijia.kmt.dto.ExportDistributionExerciseBookDTO">
  1850. select ebdc.*, eb.assigned_batch, count(eq.id) question_num
  1851. from kmt_exercise_book_distribution_count ebdc join kmt_exercise_book eb on ebdc.exercise_book_id=eb.id
  1852. join kmt_exercise_questions eq on eb.id=eq.exercise_book_id
  1853. <where>
  1854. <if test="req.startTime != null and req.startTime != ''">
  1855. and ebdc.import_date > #{req.startTime}
  1856. </if>
  1857. <if test="req.endTime != null and req.endTime != ''">
  1858. and '${req.endTime} 23:59:59' > ebdc.import_date
  1859. </if>
  1860. </where>
  1861. group by ebdc.exercise_book_id
  1862. order by ebdc.import_date desc
  1863. limit #{offset}
  1864. </select>
  1865. <select id="findDistributionTeacher"
  1866. resultType="com.aijia.kmt.dto.DistributionTeacherDTO">
  1867. select teacher_id,
  1868. teacher_name,
  1869. salary_given,
  1870. salary_given_time
  1871. <if test="authorityType == 1">
  1872. , (select max(handler_submit_time)
  1873. from kmt_exercise_questions eq
  1874. where eq.exercise_book_id = #{exerciseBookId} and eq.deal_status > 0) lastSubmitTime
  1875. </if>
  1876. <if test="authorityType == 2">
  1877. , (select max(publish_time)
  1878. from kmt_exercise_questions eq
  1879. where eq.exercise_book_id = #{exerciseBookId} and eq.deal_status > 3) lastSubmitTime
  1880. </if>
  1881. <if test="authorityType == 3">
  1882. , (select max(analysis_handler_submit_time)
  1883. from kmt_exercise_questions eq
  1884. where eq.exercise_book_id = #{exerciseBookId} and eq.deal_status > 5) lastSubmitTime
  1885. </if>
  1886. <if test="authorityType == 4">
  1887. , (select max(analysis_submit_time)
  1888. from kmt_exercise_questions eq
  1889. where eq.exercise_book_id = #{exerciseBookId} and eq.deal_status = 11) lastSubmitTime
  1890. </if>
  1891. from kmt_exercise_book_teacher_record
  1892. where exercise_book_id = #{exerciseBookId}
  1893. and teacher_id = #{userId}
  1894. and authority_type = #{authorityType}
  1895. order by create_time desc
  1896. limit 1
  1897. </select>
  1898. <select id="findAllExerciseBookPage" resultType="com.aijia.kmt.po.KmtExerciseBook">
  1899. select * from kmt_exercise_book
  1900. where part_flag &lt;> 3
  1901. <if test="selectedExerciseBookIdList != null and selectedExerciseBookIdList.size > 0">
  1902. and id in
  1903. <foreach collection="selectedExerciseBookIdList" open="(" item="selectedExerciseBookId" separator="," close=")">
  1904. #{selectedExerciseBookId}
  1905. </foreach>
  1906. </if>
  1907. limit #{offset}, #{pageSize}
  1908. </select>
  1909. <select id="countNotCheckAnswerCount" resultType="java.lang.Integer">
  1910. select count(1) from kmt_exercise_questions where exercise_book_id=#{exerciseBookId}
  1911. and deal_status not in (2, 6) and proofread_status = 0
  1912. </select>
  1913. <select id="countAllNotCheckAnswerCount" resultType="java.lang.Integer">
  1914. select count(1) from kmt_exercise_questions where exercise_book_id=#{exerciseBookId}
  1915. and proofread_status = 0
  1916. </select>
  1917. <select id="findExerciseBooksByBookId" resultType="com.aijia.kmt.po.KmtExerciseBook">
  1918. select * from kmt_exercise_book where book_id=#{bookId}
  1919. </select>
  1920. <select id="findExerciseTeacherByExerciseBookIdsAndAuthType" resultType="com.aijia.kmt.po.KmtExerciseBookTeacherRecord">
  1921. select * from kmt_exercise_book_teacher_record where exercise_book_id in
  1922. <foreach collection="exerciseBookIds" open="(" item="id" separator="," close=")">
  1923. #{id}
  1924. </foreach>
  1925. and authority_type = #{authType}
  1926. </select>
  1927. <select id="findBookCountByExerciseBookIdAndType" resultType="com.aijia.kmt.po.KmtExerciseBookCount">
  1928. select * from kmt_exercise_book_count where exercise_book_id=#{exerciseBookId} and type=#{type} limit 1
  1929. </select>
  1930. <update id="updateKmtExerciseBookCountById">
  1931. UPDATE kmt_exercise_book_count set accuracy=#{accuracy} WHERE id = #{bookCountId}
  1932. </update>
  1933. <select id="findAllDistinctLibBySubject" resultType="java.util.Map">
  1934. SELECT DISTINCT lib_id FROM
  1935. kmt_exercise_book_lib t
  1936. LEFT JOIN kmt_exercise_book t1 ON t.exercise_book_id = t1.id
  1937. WHERE
  1938. t.is_delete = 0
  1939. and t.lib_id is not null
  1940. AND t1.course_name = #{subjct}
  1941. </select>
  1942. <select id="findExerciseBookByQuestionId" resultType="com.aijia.kmt.dto.ExerciseBookDto">
  1943. select DISTINCT eb.id exercise_book_id, eb.book_id id, eb.book_year, eb.book_name name, eb.grade, eb.course_name subject, eb.version version_type,
  1944. eb.semester, eb.book_type,eb.ai_rollback_import aiRollbackImport
  1945. from kmt_exercise_book eb, kmt_exercise_questions eq,tr_train_exercise_role er
  1946. where eb.id=eq.exercise_book_id and eb.part_flag != 3 and eb.book_id = er.exercise_id
  1947. <if test="questionId != null and questionId != ''">
  1948. and eb.id=#{questionId}
  1949. </if>
  1950. and er.role_type=#{roleType}
  1951. <if test="subject != null and subject != ''">
  1952. and er.subject=#{subject}
  1953. </if>
  1954. </select>
  1955. <select id="findExerciseBookCourseByQuestionId" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  1956. select ebc.unit_id id, ebc.unit name, ebc.id book_course_id, ebc.period book_course, ebc.period_sort from kmt_exercise_book_course ebc
  1957. left join kmt_exercise_questions eq on ebc.id=eq.book_course_id
  1958. where eq.id=#{questionId}
  1959. </select>
  1960. <select id="findExerciseQuestionByQuestionId" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  1961. select eq.id question_id, eq.course_name, eb.handle_user_id, eb.auditing_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eq.book_course_id course_id,
  1962. eq.big_question_index, eq.small_question_name small_question_index, eq.is_common_flag,
  1963. eq.deal_status question_status, eq.create_time, eq.remark reason, eq.from_user_id, eq.to_user_id,
  1964. eq.question_type question_types, eq.difficulty_level difficulty_levels, eq.real_exam_type real_exam_types,
  1965. eq.training_skill training_skills, eq.parent_id, eq.proofread_status, eq.question_path, eq.num,eq.page_index,
  1966. eq.image question_image, eq.concise_id start_X, eq.analysis_submit_type start_Y, eq.update_type end_X, eq.es_loaded end_Y,eq.enumerate
  1967. from kmt_exercise_questions eq
  1968. left join q_question_workbook qw on eq.id=qw.question_id
  1969. left join kmt_exercise_book eb on eq.exercise_book_id=eb.id
  1970. where eq.id=#{questionId} and eq.deal_status !=6
  1971. </select>
  1972. <select id="findExerciseQuestionByQuestionIdAndBookId" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  1973. select eq.id question_id, eq.course_name, eb.handle_user_id, eb.auditing_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eq.book_course_id course_id,
  1974. eq.big_question_index, eq.small_question_name small_question_index, qw.is_diff is_common_flag,
  1975. eq.deal_status question_status, eq.create_time, eq.remark reason, eq.from_user_id, eq.to_user_id,
  1976. ifnull(ue.question_type,eq.question_type) question_types,
  1977. ifnull(ue.difficulty_level,eq.difficulty_level) difficulty_levels,
  1978. ifnull(ue.real_exam_type,eq.real_exam_type) real_exam_types,
  1979. ifnull(ue.training_skill,eq.training_skill) training_skills,
  1980. eq.parent_id, eq.proofread_status,
  1981. ifnull(ue.question_path,eq.question_path) as question_path,
  1982. qw.number num, eq.page_index,
  1983. ifnull(ue.question_path,eq.image) question_image,
  1984. ifnull(ue.concise_id,eq.concise_id) start_X,
  1985. ifnull(ue.analysis_submit_type,eq.analysis_submit_type) start_Y,
  1986. ifnull(ue.update_type,eq.update_type) end_X,
  1987. ifnull(ue.es_loaded,eq.es_loaded) end_Y,
  1988. ifnull(ue.enumerate,eq.enumerate) as enumerate,
  1989. eq.exercise_book_id
  1990. from kmt_exercise_questions eq
  1991. left join q_question_workbook qw on eq.id=qw.question_id
  1992. left join kmt_exercise_book eb on eq.exercise_book_id=eb.id
  1993. left join tr_train_user_exercise ue on eq.id = ue.question_id and ue.user_id=#{userId}
  1994. where eq.id=#{questionId}
  1995. and qw.sub_book_id=#{bookId} and eq.deal_status !=6
  1996. </select>
  1997. <update id="updateQuestionMinusNumByQuestionIds">
  1998. UPDATE kmt_exercise_questions set num= num - #{size} WHERE id in
  1999. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  2000. #{id}
  2001. </foreach>
  2002. </update>
  2003. <update id="updateQuestionAddNumByQuestionIds">
  2004. UPDATE kmt_exercise_questions set num= num + #{size} WHERE id in
  2005. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  2006. #{id}
  2007. </foreach>
  2008. </update>
  2009. <select id="findEditExerciseBooks" resultType="com.aijia.kmt.dto.exercise.ExerciseBookEditDto">
  2010. select distinct eb.id exercise_book_id, eb.book_name exercise_book_name from kmt_exercise_question_rollback rb, kmt_exercise_questions eq, kmt_exercise_book eb
  2011. where rb.question_id=eq.id and eq.exercise_book_id=eb.id and rb.type=2
  2012. <choose>
  2013. <when test="request.questionId != null and request.questionId != ''">
  2014. and eq.id=#{request.questionId}
  2015. </when>
  2016. <otherwise>
  2017. and eb.grade=#{request.grade}
  2018. and eb.course_name=#{request.subject}
  2019. and eb.version=#{request.versionType} and eb.semester=#{request.semester}
  2020. <if test="request.bookName != null and request.bookName != ''">
  2021. and eb.book_name like concat('%',#{request.bookName},'%')
  2022. </if>
  2023. </otherwise>
  2024. </choose>
  2025. order by eb.book_name
  2026. </select>
  2027. <select id="findEditExerciseQuestions" resultType="com.aijia.kmt.dto.exercise.ExerciseQuestionEditDto">
  2028. select eq.id question_id, eb.book_name exercise_book_name, eb.course_name subject, eb.grade, eb.version version_type, eb.semester,
  2029. eq.deal_status, eb.book_type type, rb.create_time, rb.user_id, eq.book_id, eq.exercise_book_id, eb.book_year,
  2030. eq.book_course_id period_id, unit_id from kmt_exercise_question_rollback rb,
  2031. kmt_exercise_questions eq, kmt_exercise_book eb
  2032. where rb.question_id=eq.id and eq.exercise_book_id=eb.id and rb.type=2
  2033. <choose>
  2034. <when test="request.questionId != null and request.questionId != ''">
  2035. and eq.id=#{request.questionId}
  2036. </when>
  2037. <otherwise>
  2038. and eb.id=#{request.exerciseBookId}
  2039. </otherwise>
  2040. </choose>
  2041. order by rb.create_time desc
  2042. </select>
  2043. <select id="findErrorExerciseBooks" resultType="com.aijia.kmt.dto.exercise.ExerciseBookEditDto">
  2044. select distinct eb.id exercise_book_id, eb.book_name exercise_book_name from kmt_exercise_question_errors qe, kmt_exercise_book eb
  2045. where qe.exercise_book_id = eb.id and error_user_id=#{userId}
  2046. <if test="bookName != null and bookName != ''">
  2047. and eb.book_name like concat('%',#{bookName},'%')
  2048. </if>
  2049. order by eb.book_name
  2050. </select>
  2051. <select id="findExerciseQuestionNum" resultType="com.aijia.kmt.dto.ExerciseQuestionNumberDto">
  2052. select exercise_book_id, count(1) question_num from kmt_exercise_questions where exercise_book_id in
  2053. <foreach collection="exerciseBookIds" item="id" index="index" open="(" close=")" separator=",">
  2054. #{id}
  2055. </foreach>
  2056. and deal_status != 6
  2057. group by exercise_book_id
  2058. </select>
  2059. <delete id="deleteKnowByQuestionId">
  2060. delete from kmt_exercise_question_know where question_id in
  2061. <foreach collection="questionIds" item="id" index="index" open="(" close=")" separator=",">
  2062. #{id}
  2063. </foreach>
  2064. </delete>
  2065. <!-- 查询待加工审核的题目New-->
  2066. <select id="findQuestionByBookCourseIdAndUserIdNew" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  2067. SELECT
  2068. eq.id question_id,
  2069. eq.course_name,
  2070. eb.handle_user_id,
  2071. eb.auditing_user_id,
  2072. eb.analysis_user_id,
  2073. eb.analysis_auditer_id,
  2074. eq.book_course_id course_id,
  2075. eq.big_question_index,
  2076. eq.small_question_name small_question_index,
  2077. eq.is_common_flag,
  2078. eq.deal_status question_status,
  2079. eq.create_time,
  2080. eq.remark reason,
  2081. eq.from_user_id,
  2082. eq.to_user_id,
  2083. <if test="roleType == 1 or roleType ==2 ">
  2084. ue.question_type as question_types,
  2085. ue.difficulty_level as difficulty_levels,
  2086. ue.real_exam_type as real_exam_types,
  2087. ue.training_skill as training_skills,
  2088. </if>
  2089. <!-- 解析或者管理员-->
  2090. <if test="roleType ==3 or roleType ==0 ">
  2091. ifnull(ue.question_type,eq.question_type) question_types,
  2092. ifnull(ue.difficulty_level,eq.difficulty_level) difficulty_levels,
  2093. ifnull(ue.real_exam_type,eq.real_exam_type) real_exam_types,
  2094. ifnull(ue.training_skill,eq.training_skill) training_skills,
  2095. </if>
  2096. eq.parent_id,
  2097. eq.proofread_status,
  2098. ifnull(ue.question_path,eq.question_path) as question_path,
  2099. t.number as num,
  2100. t.page_index,
  2101. ifnull(ue.question_path,eq.image) question_image,
  2102. ifnull(ue.concise_id,eq.concise_id) start_X,
  2103. ifnull(ue.analysis_submit_type,eq.analysis_submit_type) start_Y,
  2104. ifnull(ue.update_type,eq.update_type) end_X,
  2105. ifnull(ue.es_loaded,eq.es_loaded) end_Y,
  2106. ifnull(ue.enumerate,eq.enumerate) as enumerate,
  2107. eq.exercise_book_id
  2108. FROM
  2109. q_question_workbook t
  2110. LEFT JOIN kmt_exercise_questions eq ON t.question_id=eq.id
  2111. LEFT JOIN kmt_exercise_book eb ON eq.exercise_book_id = eb.id
  2112. left join tr_train_user_exercise ue on t.question_id = ue.question_id and ue.user_id=#{userId}
  2113. <if test="req.publishStatus==3">
  2114. LEFT JOIN q_question_info qi on t.question_id=qi.id
  2115. </if>
  2116. <if test="searchType==1">
  2117. inner JOIN tr_train_question_check tk on tk.question_id=t.question_id and tk.status = 1
  2118. </if>
  2119. WHERE eq.deal_status != 6
  2120. and t.sub_book_id=#{req.exerciseBookId}
  2121. <if test="req.periodId !=null and req.periodId !=''">
  2122. and t.course_name=#{req.periodId}
  2123. </if>
  2124. <if test="req.unitId !=null and req.unitId !=''">
  2125. and t.unit_name=#{req.unitId}
  2126. </if>
  2127. <if test="req.questionId !=null and req.questionId !=''">
  2128. and eq.id=#{req.questionId}
  2129. </if>
  2130. <if test="type == 0">
  2131. and (ue.id is null or ue.status = 2)
  2132. </if>
  2133. order by t.number
  2134. </select>
  2135. <!-- 查询待加工审核的题目New-->
  2136. <select id="findAllQuestionByGradeDetail" resultType="com.aijia.kmt.dto.ExerciseQuetionDto">
  2137. SELECT
  2138. eq.id question_id,
  2139. eq.course_name,
  2140. eb.handle_user_id,
  2141. eb.auditing_user_id,
  2142. eb.analysis_user_id,
  2143. eb.analysis_auditer_id,
  2144. eq.book_course_id course_id,
  2145. eq.big_question_index,
  2146. eq.small_question_name small_question_index,
  2147. eq.is_common_flag,
  2148. eq.deal_status question_status,
  2149. eq.create_time,
  2150. eq.remark reason,
  2151. eq.from_user_id,
  2152. eq.to_user_id,
  2153. eq.question_type question_types,
  2154. eq.difficulty_level difficulty_levels,
  2155. eq.real_exam_type real_exam_types,
  2156. eq.training_skill training_skills,
  2157. eq.parent_id,
  2158. eq.proofread_status,
  2159. eq.question_path,
  2160. t.number as num,
  2161. t.page_index,
  2162. eq.image question_image,
  2163. eq.concise_id start_X,
  2164. eq.analysis_submit_type start_Y,
  2165. eq.update_type end_X,
  2166. eq.es_loaded end_Y,
  2167. eq.enumerate,
  2168. eq.exercise_book_id
  2169. FROM
  2170. q_question_workbook t
  2171. LEFT JOIN kmt_exercise_questions eq ON t.question_id=eq.id
  2172. LEFT JOIN kmt_exercise_book eb ON eq.exercise_book_id = eb.id
  2173. <if test="req.publishStatus==3">
  2174. LEFT JOIN q_question_info qi on t.question_id=qi.id
  2175. </if>
  2176. WHERE eb.grade=#{req.grade} and eb.course_name=#{req.subject} and eb.version=#{req.versionType} and eb.semester=#{req.semester} and eq.deal_status != 6
  2177. <if test="req.questionType > 0">
  2178. and eq.question_type=#{req.questionType}
  2179. </if>
  2180. <if test="req.publishStatus == 1">
  2181. and eq.deal_status in (0, 1, 3, 7)
  2182. </if>
  2183. <if test="req.publishStatus == 2">
  2184. and eq.deal_status in (4, 5, 8, 9, 10, 11)
  2185. </if>
  2186. <if test="req.rollbackType == 1">
  2187. and eq.deal_status != 2
  2188. </if>
  2189. <if test="req.rollbackType == 2">
  2190. and eq.deal_status > 2
  2191. </if>
  2192. <if test="req.rollbackType == 3">
  2193. and eq.deal_status > 3 and eq.deal_status != 7
  2194. </if>
  2195. <if test="req.rollbackType == 4">
  2196. and eq.deal_status > 8
  2197. </if>
  2198. <if test="req.rollbackType == 5">
  2199. and eq.deal_status > 10
  2200. </if>
  2201. <if test="req.publishStatus==3">
  2202. and (qi.answer_text='略' or qi.answer='略')
  2203. </if>
  2204. order by t.sub_book_id, t.number
  2205. </select>
  2206. <!--查询待加工审核的练习册单元 -->
  2207. <select id="findUnHandleExerciseBookCourseNew" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  2208. select a.id,
  2209. a.NAME,
  2210. a.book_course_id,
  2211. a.book_course,
  2212. @i:=@i+1 as period_sort from (
  2213. SELECT
  2214. DISTINCT
  2215. t.unit_name as id,
  2216. t.unit_name as NAME,
  2217. t.course_name as book_course_id,
  2218. t.course_name as book_course
  2219. FROM
  2220. (
  2221. SELECT
  2222. t.unit_name,
  2223. t.course_name,
  2224. @group_row :=
  2225. CASE
  2226. WHEN @parent_code = t.course_name COLLATE utf8mb4_0900_ai_ci THEN
  2227. @group_row + 1 ELSE 1
  2228. END AS groupRow,
  2229. @group_row2 :=
  2230. CASE
  2231. WHEN @parent_code = t.course_name COLLATE utf8mb4_0900_ai_ci
  2232. AND eb.id IS NOT NULL THEN
  2233. @group_row2 + 1 ELSE 1
  2234. END AS groupRow2,
  2235. @parent_code := t.course_name AS parent_code
  2236. FROM
  2237. q_question_workbook t
  2238. INNER JOIN kmt_exercise_questions eq ON t.question_id = eq.id
  2239. INNER JOIN tr_train_question_check ec ON t.question_id = ec.question_id and ec.status = 1
  2240. LEFT JOIN tr_train_user_exercise eb ON eq.id = eb.question_id and eb.user_id ='a919d6d3-1e99-11ec-aea2-00163e02e90a'
  2241. LEFT JOIN ( SELECT @group_row := 1, @group_row2 := 1, @parent_code := '' ) AS b ON 1 = 1
  2242. WHERE
  2243. eq.exercise_book_id =#{bookId}
  2244. <if test="questionId != null and questionId != ''">
  2245. and eq.id=#{questionId}
  2246. </if>
  2247. ORDER BY
  2248. t.number
  2249. ) t
  2250. where t.groupRow <![CDATA[ <> ]]> t.groupRow2
  2251. ) a,(select @i:=0) num
  2252. </select>
  2253. <select id="findExerciseBookCourseByQuestionIdNew" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  2254. select a.id,
  2255. a.NAME,
  2256. a.book_course_id,
  2257. a.book_course,
  2258. @i:=@i+1 as period_sort from (
  2259. SELECT
  2260. DISTINCT
  2261. t.unit_name as id,
  2262. t.unit_name as NAME,
  2263. t.course_name as book_course_id,
  2264. t.course_name as book_course
  2265. FROM
  2266. q_question_workbook t
  2267. WHERE
  2268. t.question_id=#{questionId}
  2269. ) a,(select @i:=0) num
  2270. </select>
  2271. <!--查询练习册下所有单元课时-->
  2272. <select id="findAllExerciseBookCourseByExerciseBookIdNew" resultType="com.aijia.kmt.dto.exercise.ExerciseUnitBookcourseDto">
  2273. select a.id,
  2274. a.NAME,
  2275. a.book_course_id,
  2276. a.book_course,
  2277. @i:=@i+1 as period_sort from (
  2278. SELECT
  2279. DISTINCT
  2280. t.unit_name as id,
  2281. t.unit_name as NAME,
  2282. t.course_name as book_course_id,
  2283. t.course_name as book_course
  2284. FROM
  2285. q_question_workbook t
  2286. <if test="type == 2">
  2287. INNER JOIN tr_train_question_check ec ON t.question_id = ec.question_id and ec.status = 1
  2288. </if>
  2289. WHERE
  2290. 1=1
  2291. <if test="exerciseBookId != null and exerciseBookId != ''">
  2292. and t.sub_book_id=#{exerciseBookId}
  2293. </if>
  2294. <if test="bookId != null and bookId != ''">
  2295. and t.book_id=#{bookId}
  2296. </if>
  2297. <if test="isDiff != null and isDiff != ''">
  2298. and t.is_diff=#{isDiff}
  2299. </if>
  2300. ORDER BY t.number
  2301. ) a,(select @i:=0) num
  2302. </select>
  2303. <select id="findMaxSmallQuestionNumber" resultType="java.util.Map">
  2304. select qw.number, qw.sort_number from kmt_exercise_questions eq, q_question_workbook qw
  2305. where eq.id=qw.question_id and eq.exercise_book_id=qw.sub_book_id
  2306. and eq.parent_id=#{parentId}
  2307. and eq.question_class_type=2
  2308. and eq.deal_status !=6
  2309. order by qw.number desc limit 1
  2310. </select>
  2311. <select id="findIsNotFinishTask" resultType="java.lang.Integer">
  2312. select 1
  2313. from kmt_exercise_book eb,
  2314. kmt_exercise_questions eq
  2315. where eb.id = eq.exercise_book_id
  2316. and ((eb.handle_user_id = #{userId} and eq.deal_status in (0, 1)) or
  2317. (eb.auditing_user_id = #{userId} and eq.deal_status in (3, 7))
  2318. or (eb.analysis_user_id = #{userId} and eq.deal_status in (5, 8)) or
  2319. (eb.analysis_auditer_id = #{userId} and eq.deal_status in (9, 10))
  2320. or (eb.answer_correcter_id=#{userId} and eq.proofread_status = 0))
  2321. limit 1
  2322. </select>
  2323. <select id="findAllKmtExerciseQuestionsByIdIn" resultType="com.aijia.kmt.po.KmtExerciseQuestion">
  2324. select eq.id, eq.book_id, eq.unit_id, eq.book_course_id,
  2325. eb.auditing_user_id, eb.handle_user_id, eb.analysis_user_id, eb.analysis_auditer_id, eb.answer_correcter_id,
  2326. eq.question_type, eq.source, eq.big_question_index, eq.analysis_submit_time, eq.page_index,
  2327. eq.image, eq.precision_percent, eq.create_time, eq.deal_status, eq.remark, eq.analysis_submit_type,
  2328. eq.answer_image, eq.num, eq.small_question_name, eq.parent_id, eq.big_name, eq.real_exam_type, eq.publish_time,
  2329. eq.update_type, eq.difficulty_level, eq.training_skill, eq.course_name, eq.is_common_flag, eq.question_year, eb.id exercise_book_id, eq.es_loaded,
  2330. eq.analysis_handler_submit_time, eq.question_class_type, eq.repulse_time,
  2331. eq.proofread_status, eq.question_path, eq.handler_submit_time,eq.enumerate
  2332. FROM
  2333. q_question_workbook t
  2334. LEFT JOIN kmt_exercise_questions eq ON t.question_id=eq.id
  2335. LEFT JOIN kmt_exercise_book eb ON t.sub_book_id = eb.id WHERE eq.id in
  2336. <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
  2337. #{id}
  2338. </foreach>
  2339. limit 0, 5000
  2340. </select>
  2341. </mapper>