IndexErrDataRecordMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.IndexErrDataRecordDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.IndexErrDataRecord" id="IndexErrDataRecord">
  9. <result column="id_" property="id" />
  10. <result column="organ_id_" property="organId" />
  11. <result column="data_id_" property="dataId" />
  12. <result column="data_type_" property="dataType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  13. <result column="deal_user_id_" property="dealUserId" />
  14. <result column="generate_time_" property="generateTime"/>
  15. <result column="create_time_" property="createTime" />
  16. <result column="deal_time_" property="dealTime" />
  17. </resultMap>
  18. <!-- 根据主键查询一条记录 -->
  19. <select id="get" resultMap="IndexErrDataRecord" >
  20. SELECT * FROM index_err_data_record WHERE id_ = #{id}
  21. </select>
  22. <!-- 全查询 -->
  23. <select id="findAll" resultMap="IndexErrDataRecord">
  24. SELECT * FROM index_err_data_record ORDER BY id_
  25. </select>
  26. <!-- 向数据库增加一条记录 -->
  27. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.IndexErrDataRecord" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  28. <!--
  29. <selectKey resultClass="int" keyProperty="id" >
  30. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  31. </selectKey>
  32. -->
  33. INSERT INTO index_err_data_record (organ_id_,data_id_,data_type_,deal_user_id_,generate_time_,deal_time_,create_time_)
  34. VALUES(#{organId},#{dataId},#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{dealUserId},#{generateTime},#{dealTime},NOW())
  35. </insert>
  36. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.IndexErrDataRecord" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  37. INSERT INTO index_err_data_record (organ_id_,data_id_,data_type_,deal_user_id_,generate_time_,deal_time_,create_time_)
  38. VALUE
  39. <foreach collection="datas" item="data" separator=",">
  40. (#{data.organId},#{data.dataId},#{data.dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.dealUserId},
  41. #{data.generateTime},#{data.dealTime},NOW())
  42. </foreach>
  43. </insert>
  44. <!-- 根据主键查询一条记录 -->
  45. <update id="update" parameterType="com.ym.mec.biz.dal.entity.IndexErrDataRecord">
  46. UPDATE index_err_data_record
  47. <set>
  48. <if test="organId != null">
  49. organ_id_ = #{organId},
  50. </if>
  51. <if test="dealUserId != null">
  52. deal_user_id_ = #{dealUserId},
  53. </if>
  54. <if test="dataId != null">
  55. data_id_ = #{dataId},
  56. </if>
  57. <if test="dataType != null">
  58. data_type_ = #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  59. </if>
  60. <if test="generateTime != null">
  61. generate_time_ = #{generateTime},
  62. </if>
  63. <if test="dealTime != null">
  64. deal_time_ = #{dealTime},
  65. </if>
  66. </set>
  67. WHERE id_ = #{id}
  68. </update>
  69. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.IndexErrDataRecord">
  70. <foreach collection="datas" item="data" separator=";">
  71. UPDATE index_err_data_record
  72. <set>
  73. <if test="data.organId != null">
  74. organ_id_ = #{data.organId},
  75. </if>
  76. <if test="data.dealUserId != null">
  77. deal_user_id_ = #{data.dealUserId},
  78. </if>
  79. <if test="data.dataId != null">
  80. data_id_ = #{data.dataId},
  81. </if>
  82. <if test="data.dataType != null">
  83. data_type_ = #{data.dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  84. </if>
  85. <if test="data.generateTime != null">
  86. generate_time_ = #{data.generateTime},
  87. </if>
  88. <if test="data.dealTime != null">
  89. deal_time_ = #{data.dealTime},
  90. </if>
  91. </set>
  92. WHERE id_ = #{data.id}
  93. </foreach>
  94. </update>
  95. <!-- 根据主键删除一条记录 -->
  96. <delete id="delete" >
  97. DELETE FROM index_err_data_record WHERE id_ = #{id}
  98. </delete>
  99. <delete id="deleteWithGenerateTimeAndType" >
  100. DELETE FROM index_err_data_record
  101. WHERE
  102. generate_time_ = #{generateTime}
  103. <if test="dataType!=null">
  104. AND data_type_=#{dataType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  105. </if>
  106. </delete>
  107. <!-- 分页查询 -->
  108. <select id="queryPage" resultMap="IndexErrDataRecord" parameterType="map">
  109. SELECT * FROM index_err_data_record ORDER BY id_ <include refid="global.limit"/>
  110. </select>
  111. <!-- 查询当前表的总记录数 -->
  112. <select id="queryCount" resultType="int">
  113. SELECT COUNT(*) FROM index_err_data_record
  114. </select>
  115. <select id="countWithGenerateTime" resultType="int">
  116. SELECT COUNT(id_) FROM index_err_data_record WHERE generate_time_=#{generateTime}
  117. </select>
  118. <select id="getWithGenerateTime" resultMap="IndexErrDataRecord">
  119. SELECT * FROM index_err_data_record
  120. <where>
  121. <if test="organIds!=null and organIds.size()>0">
  122. AND organ_id_ IN
  123. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  124. #{organId}
  125. </foreach>
  126. </if>
  127. <if test="generateStartTime!=null and generateStartTime!=''">
  128. AND generate_time_&gt;=#{generateStartTime}
  129. </if>
  130. <if test="generateEndTime!=null and generateEndTime!=''">
  131. AND generate_time_&lt;=#{generateEndTime}
  132. </if>
  133. </where>
  134. </select>
  135. <select id="findUntreatedRecord" resultMap="IndexErrDataRecord">
  136. SELECT * FROM index_err_data_record WHERE deal_time_ IS NULL
  137. </select>
  138. <select id="queryErrInspection" resultMap="IndexErrDataRecord">
  139. SELECT
  140. id_ data_id_,
  141. organ_id_,
  142. user_id_ deal_user_id_
  143. FROM
  144. inspection_item_plan
  145. WHERE
  146. conclusion_status_ = 1 AND memo_ = ''
  147. <if test="date!=null">
  148. AND DATE_FORMAT(plan_start_,'%Y-%m-%d') = #{date}
  149. </if>
  150. <if test="dates!=null and dates.size()>0">
  151. AND DATE_FORMAT(plan_start_,'%Y-%m-%d') IN
  152. <foreach collection="dates" item="dt" separator="," open="(" close=")">
  153. #{dt}
  154. </foreach>
  155. </if>
  156. </select>
  157. <select id="queryInspectionItemPlan" resultMap="IndexErrDataRecord">
  158. SELECT
  159. iip.id_ data_id_,
  160. iip.organ_id_,
  161. iip.user_id_ deal_user_id_
  162. FROM inspection_item_plan iip
  163. WHERE iip.status_ = 0 AND iip.memo_ = ''
  164. AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt; DATE_FORMAT(NOW(),'%Y-%m-%d')
  165. AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  166. <if test="date!=null">
  167. AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') = #{date}
  168. </if>
  169. <if test="dates!=null and dates.size()>0">
  170. AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') IN
  171. <foreach collection="dates" item="dt" separator="," open="(" close=")">
  172. #{dt}
  173. </foreach>
  174. </if>
  175. </select>
  176. <select id="queryStudentVisit" resultMap="IndexErrDataRecord">
  177. SELECT
  178. ii.id_ data_id_,
  179. ii.organ_id_,
  180. ii.user_id_ deal_user_id_
  181. FROM inspection_item ii
  182. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  183. WHERE ii.item_ = 'VISIT' AND ii.memo_ =''
  184. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  185. WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
  186. AND i.month_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  187. <if test="date!=null">
  188. AND i.month_ = #{date}
  189. </if>
  190. <if test="dates!=null and dates.size()>0">
  191. AND i.month_ IN
  192. <foreach collection="dates" item="dt" separator="," open="(" close=")">
  193. #{dt}
  194. </foreach>
  195. </if>
  196. </select>
  197. <select id="getAttendanceError" resultMap="IndexErrDataRecord">
  198. SELECT
  199. cs.id_ data_id_,
  200. cs.organ_id_,
  201. CASE cs.group_type_ WHEN 'MUSIC' THEN mg.educational_teacher_id_ WHEN 'VIP' THEN vg.educational_teacher_id_ WHEN 'PRACTICE' THEN pg.educational_teacher_id_ END deal_user_id_
  202. FROM course_schedule cs
  203. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  204. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  205. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  206. LEFT JOIN music_group mg ON cs.music_group_id_=mg.id_ AND cs.group_type_='MUSIC'
  207. LEFT JOIN vip_group vg ON cs.music_group_id_=vg.id_ AND cs.group_type_='VIP'
  208. LEFT JOIN practice_group pg ON cs.music_group_id_=pg.id_ AND cs.group_type_='PRACTICE'
  209. WHERE ta.teacher_id_ = cs.actual_teacher_id_
  210. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_ >= '2021-02-01'
  211. AND (((ta.sign_in_status_ = 0 OR ta.sign_in_status_ IS NULL OR ta.sign_out_status_ = 0 OR ta.sign_out_status_ IS NULL) AND ta.dispose_content_ IS NULL) OR (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0)))
  212. AND ((ta.sign_in_status_ IS NULL AND ta.sign_out_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NULL AND ta.sign_in_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NOT NULL AND ta.sign_in_status_ IS NOT NULL))
  213. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cssp.id_ IS NOT NULL
  214. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  215. <if test="date!=null">
  216. AND cs.class_date_=#{date}
  217. </if>
  218. <if test="dates!=null and dates.size()>0">
  219. AND cs.class_date_ IN
  220. <foreach collection="dates" item="dt" separator="," open="(" close=")">
  221. #{dt}
  222. </foreach>
  223. </if>
  224. </select>
  225. <select id="getNoAttendance" resultMap="IndexErrDataRecord">
  226. SELECT
  227. cs.id_ data_id_,
  228. cs.organ_id_,
  229. CASE cs.group_type_ WHEN 'MUSIC' THEN mg.educational_teacher_id_ WHEN 'VIP' THEN vg.educational_teacher_id_ WHEN 'PRACTICE' THEN pg.educational_teacher_id_ END deal_user_id_
  230. FROM course_schedule cs
  231. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  232. LEFT JOIN music_group mg ON cs.music_group_id_=mg.id_ AND cs.group_type_='MUSIC'
  233. LEFT JOIN vip_group vg ON cs.music_group_id_=vg.id_ AND cs.group_type_='VIP'
  234. LEFT JOIN practice_group pg ON cs.music_group_id_=pg.id_ AND cs.group_type_='PRACTICE'
  235. WHERE ta.teacher_id_ = cs.actual_teacher_id_
  236. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>='2021-02-01'
  237. AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
  238. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
  239. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  240. <if test="date!=null">
  241. AND cs.class_date_=#{date}
  242. </if>
  243. <if test="dates!=null and dates.size()>0">
  244. AND cs.class_date_ IN
  245. <foreach collection="dates" item="dt" separator="," open="(" close=")">
  246. #{dt}
  247. </foreach>
  248. </if>
  249. </select>
  250. <sql id="queryErrStringsCondition">
  251. <where>
  252. <if test="queryOrganIds!=null and queryOrganIds.size()>0">
  253. AND organ_id_ IN
  254. <foreach collection="queryOrganIds" item="organId" open="(" close=")" separator=",">
  255. #{organId}
  256. </foreach>
  257. </if>
  258. <if test="startDate!=null and startDate!=''">
  259. AND generate_time_&gt;=#{startDate}
  260. </if>
  261. <if test="endDate!=null and endDate!=''">
  262. AND generate_time_&lt;=#{endDate}
  263. </if>
  264. </where>
  265. </sql>
  266. <select id="queryErrStrings" resultType="string">
  267. SELECT CONCAT(generate_time_, organ_id_, deal_user_id_) FROM index_err_data_record
  268. <include refid="queryErrStringsCondition"></include>
  269. GROUP BY generate_time_,organ_id_,deal_user_id_
  270. ORDER BY generate_time_ DESC,organ_id_,deal_user_id_
  271. <include refid="global.limit"></include>
  272. </select>
  273. <select id="queryErrStringsCount" resultType="int">
  274. SELECT COUNT(DISTINCT CONCAT(generate_time_,organ_id_,deal_user_id_)) FROM index_err_data_record
  275. <include refid="queryErrStringsCondition"></include>
  276. </select>
  277. <select id="getWithOrganMonthUserStr" resultMap="IndexErrDataRecord">
  278. SELECT * FROM index_err_data_record WHERE CONCAT(generate_time_, organ_id_, deal_user_id_) IN
  279. <foreach collection="omuStrings" item="omuString" open="(" close=")" separator=",">
  280. #{omuString}
  281. </foreach>
  282. </select>
  283. <select id="getAllErrDatas" resultMap="IndexErrDataRecord">
  284. SELECT * FROM index_err_data_record
  285. <include refid="queryErrStringsCondition"></include>
  286. </select>
  287. <select id="queryErrInspectionData" resultMap="com.ym.mec.biz.dal.dao.InspectionItemPlanDao.InspectionItemPlan" parameterType="map">
  288. SELECT iip.*,su.real_name_ realName,o.name_ organName,co.name_ cooperationName,mg.name_ musicGroupName,
  289. irdr.generate_time_ generateTime,irdr.deal_time_ dealTime
  290. FROM index_err_data_record irdr
  291. LEFT JOIN inspection_item_plan iip ON irdr.data_id_=iip.id_
  292. LEFT JOIN sys_user su ON su.id_ = iip.user_id_
  293. LEFT JOIN organization o ON o.id_=iip.organ_id_
  294. LEFT JOIN cooperation_organ co ON co.id_=iip.cooperation_organ_id_
  295. LEFT JOIN music_group mg ON mg.id_ = iip.music_group_id_
  296. <include refid="queryErrInspectionDataCondition"/>
  297. ORDER BY iip.plan_start_ ASC
  298. <include refid="global.limit"/>
  299. </select>
  300. <select id="errInspectionDataCount" resultType="int">
  301. SELECT COUNT(*)
  302. FROM index_err_data_record irdr
  303. LEFT JOIN inspection_item_plan iip ON irdr.data_id_=iip.id_
  304. LEFT JOIN music_group mg ON mg.id_ = iip.music_group_id_
  305. <include refid="queryErrInspectionDataCondition"/>
  306. </select>
  307. <sql id="queryErrInspectionDataCondition">
  308. <where>
  309. <if test="searchType != null and searchType != ''">
  310. <if test="searchType == 'MUSIC_PATROL_ITEM'">
  311. irdr.data_type_ = 'MUSIC_PATROL_ITEM'
  312. </if>
  313. <if test="searchType == 'INSPECTION_ITEM_PLAN'">
  314. irdr.data_type_ = 'INSPECTION_ITEM_PLAN'
  315. </if>
  316. </if>
  317. <if test="itemId != null">
  318. AND iip.item_id_ = #{itemId}
  319. </if>
  320. <if test="userId != null">
  321. AND iip.user_id_ = #{userId}
  322. </if>
  323. <if test="organId != null">
  324. AND FIND_IN_SET(iip.organ_id_,#{organId})
  325. </if>
  326. <if test="cooperationOrganId != null">
  327. AND iip.cooperation_organ_id_ = #{cooperationOrganId}
  328. </if>
  329. <if test="musicGroupId != null">
  330. AND iip.music_group_id_ = #{musicGroupId}
  331. </if>
  332. <if test="conclusionStatus != null">
  333. AND iip.conclusion_status_ = #{conclusionStatus}
  334. </if>
  335. <if test="status !=null">
  336. AND iip.status_ = #{status}
  337. </if>
  338. <if test='hasSubmit != null and hasSubmit.toString()=="1".toString()'>
  339. AND iip.status_ > 0
  340. </if>
  341. <if test='hasSubmit != null and hasSubmit.toString()=="0".toString()'>
  342. AND iip.status_ = 0
  343. </if>
  344. <if test="startTime != null">
  345. AND iip.plan_start_ >= #{startTime}
  346. </if>
  347. <if test="endTime != null">
  348. <![CDATA[AND iip.plan_start_ <= #{endTime}]]>
  349. </if>
  350. <if test="generateStartTime != null">
  351. AND irdr.generate_time_ >= #{generateStartTime}
  352. </if>
  353. <if test="generateEndTime != null">
  354. <![CDATA[AND irdr.generate_time_ <= #{generateEndTime}]]>
  355. </if>
  356. <if test="dealStartTime != null">
  357. AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") >= #{dealStartTime}
  358. </if>
  359. <if test="dealEndTime != null">
  360. <![CDATA[AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") <= #{dealEndTime}]]>
  361. </if>
  362. <if test="search != null">
  363. AND mg.name_ LIKE CONCAT('%', #{search}, '%')
  364. </if>
  365. <if test="ids != null and ids != ''">
  366. AND FIND_IN_SET(iip.id_,#{ids})
  367. </if>
  368. </where>
  369. </sql>
  370. <select id="queryErrStudentVisit" resultMap="com.ym.mec.biz.dal.dao.InspectionItemDao.InspectionItem" parameterType="map">
  371. SELECT ii.*,i.month_ month,o.name_ organName,su.real_name_ userName,
  372. irdr.generate_time_ generateTime,irdr.deal_time_ dealTime
  373. FROM index_err_data_record irdr
  374. LEFT JOIN inspection_item ii ON irdr.data_id_=ii.id_
  375. LEFT JOIN inspection i ON i.id_ = ii.inspection_id_
  376. LEFT JOIN organization o ON o.id_=ii.organ_id_
  377. LEFT JOIN sys_user su ON su.id_ = ii.user_id_
  378. <include refid="queryErrStudentVisitCondition"/>
  379. ORDER BY i.month_ DESC ,ii.id_ DESC
  380. <include refid="global.limit"/>
  381. </select>
  382. <!-- 查询当前表的总记录数 -->
  383. <select id="studentVisitCount" resultType="int">
  384. SELECT COUNT(*)
  385. FROM index_err_data_record irdr
  386. LEFT JOIN inspection_item ii ON irdr.data_id_=ii.id_
  387. LEFT JOIN inspection i ON i.id_ = ii.inspection_id_
  388. <include refid="queryErrStudentVisitCondition"/>
  389. </select>
  390. <sql id="queryErrStudentVisitCondition">
  391. <where>
  392. irdr.data_type_ = 'STUDENT_VISIT'
  393. <if test="organId != null">
  394. AND FIND_IN_SET(ii.organ_id_,#{organId})
  395. </if>
  396. <if test="userId != null">
  397. AND ii.user_id_ = #{userId}
  398. </if>
  399. <if test="operation != null">
  400. AND ii.operation_ = #{operation}
  401. </if>
  402. <if test="ids != null">
  403. AND FIND_IN_SET(ii.id_,#{ids})
  404. </if>
  405. <if test="startTime != null">
  406. AND i.month_ >= #{startTime}
  407. </if>
  408. <if test="endTime != null">
  409. <![CDATA[AND i.month_ <= #{endTime}]]>
  410. </if>
  411. <if test="generateStartTime != null">
  412. AND irdr.generate_time_ >= #{generateStartTime}
  413. </if>
  414. <if test="generateEndTime != null">
  415. <![CDATA[AND irdr.generate_time_ <= #{generateEndTime}]]>
  416. </if>
  417. <if test="dealStartTime != null">
  418. AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") >= #{dealStartTime}
  419. </if>
  420. <if test="dealEndTime != null">
  421. <![CDATA[AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") <= #{dealEndTime}]]>
  422. </if>
  423. </where>
  424. </sql>
  425. <select id="queryHistoryErrCourseData" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseScheduleEndDto">
  426. SELECT
  427. cs.id_ id_,
  428. cs.new_course_id_,
  429. cs.group_type_,
  430. cs.music_group_id_,
  431. cs.class_group_id_,
  432. cs.status_,
  433. cs.name_,
  434. cs.class_date_,
  435. CONCAT(cs.class_date_,' ',cs.start_class_time_) course_start_time_,
  436. CONCAT(cs.class_date_,' ',cs.end_class_time_) course_end_time_,
  437. cs.actual_teacher_id_,
  438. cs.teach_mode_,
  439. cs.type_,
  440. cs.schoole_id_,
  441. cs.create_time_,
  442. cs.is_lock_,
  443. cs.organ_id_,
  444. s.name_ schoole_name_,
  445. o.name_ organ_name_,
  446. irdr.generate_time_ generateTime,
  447. irdr.deal_time_ dealTime,
  448. eu.real_name_ educationTeacherName,
  449. CASE WHEN COUNT(CASE WHEN sa.id_ IS NULL OR (sa.status_ = 'LEAVE' AND sa.remark_ IS NOT NULL) THEN NULL ELSE 1 END) > 0 THEN 1 ELSE 0 END isCallNames,
  450. CASE WHEN COUNT(CASE WHEN ta.is_complaints_ = 1 THEN 1 ELSE NULL END) > 0 THEN '1' ELSE '0' END is_complaints_
  451. FROM index_err_data_record irdr
  452. LEFT JOIN course_schedule cs ON irdr.data_id_=cs.id_
  453. LEFT JOIN school s ON cs.schoole_id_=s.id_
  454. LEFT JOIN organization o ON cs.organ_id_=o.id_
  455. LEFT JOIN course_schedule_teacher_salary csts ON csts.course_schedule_id_ = cs.id_
  456. left join teacher_attendance ta on ta.course_schedule_id_ = cs.id_
  457. <if test="searchType == 'ERR_ATTENDANCE'">
  458. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  459. </if>
  460. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_
  461. <if test="searchType == 'ERR_ATTENDANCE'">
  462. AND cssp.user_id_ = sa.user_id_
  463. </if>
  464. LEFT JOIN sys_user eu ON irdr.deal_user_id_ = eu.id_
  465. <include refid="endFindCourseSchedulesCondition"/>
  466. GROUP BY cs.class_date_,cs.start_class_time_,cs.id_
  467. ORDER BY cs.class_date_,cs.start_class_time_,cs.id_
  468. <include refid="global.limit"/>
  469. </select>
  470. <select id="historyErrCourseDataCount" resultType="int">
  471. SELECT
  472. COUNT(DISTINCT cs.id_)
  473. FROM index_err_data_record irdr
  474. LEFT JOIN course_schedule cs ON irdr.data_id_=cs.id_
  475. <if test="searchType == 'ERR_ATTENDANCE'">
  476. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  477. </if>
  478. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_
  479. <if test="searchType == 'ERR_ATTENDANCE'">
  480. AND cssp.user_id_ = sa.user_id_
  481. </if>
  482. LEFT JOIN teacher_attendance ta on ta.course_schedule_id_ = cs.id_
  483. LEFT JOIN course_schedule_teacher_salary csts ON csts.course_schedule_id_ = cs.id_
  484. <include refid="endFindCourseSchedulesCondition"/>
  485. </select>
  486. <select id="getAllDealUserIds" resultType="int">
  487. SELECT DISTINCT deal_user_id_ FROM index_err_data_record
  488. <where>
  489. <if test="organIds!=null and organIds.size()>0">
  490. AND organ_id_ IN
  491. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  492. #{organId}
  493. </foreach>
  494. </if>
  495. </where>
  496. </select>
  497. <sql id="endFindCourseSchedulesCondition">
  498. <where>
  499. cs.del_flag_ = 0
  500. <if test="searchType == 'ERR_ATTENDANCE'">
  501. AND irdr.data_type_ = 'TEACHER_EXCEPTION_ATTENDANCE'
  502. </if>
  503. <if test="searchType == 'NO_ATTENDANCE'">
  504. AND irdr.data_type_ = 'TEACHER_NOT_A_CLASS'
  505. </if>
  506. <if test="mergeCourseType != null and mergeCourseType != ''">
  507. <if test="mergeCourseType == 'MASTER'">
  508. AND cs.new_course_id_ = cs.id_
  509. </if>
  510. <if test="mergeCourseType == 'ASSIST'">
  511. AND cs.new_course_id_ > 0 AND cs.new_course_id_ != cs.id_
  512. </if>
  513. <if test="mergeCourseType == 'ALL'">
  514. AND cs.new_course_id_ > 0
  515. </if>
  516. </if>
  517. <if test="isCallNames != null and isCallNames == 1">
  518. AND sa.id_ IS NOT NULL
  519. </if>
  520. <if test="isCallNames != null and isCallNames == 0">
  521. AND sa.id_ IS NULL
  522. </if>
  523. <if test="startTime!=null">
  524. AND cs.class_date_ &gt;= DATE_FORMAT(#{startTime},"%Y-%m-%d")
  525. </if>
  526. <if test="endTime!=null">
  527. AND cs.class_date_ &lt;= DATE_FORMAT(#{endTime},"%Y-%m-%d")
  528. </if>
  529. <if test="generateStartTime != null">
  530. AND irdr.generate_time_ >= #{generateStartTime}
  531. </if>
  532. <if test="generateEndTime != null">
  533. <![CDATA[AND irdr.generate_time_ <= #{generateEndTime}]]>
  534. </if>
  535. <if test="dealStartTime != null">
  536. AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") >= #{dealStartTime}
  537. </if>
  538. <if test="dealEndTime != null">
  539. <![CDATA[AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") <= #{dealEndTime}]]>
  540. </if>
  541. <if test="courseStatus!=null">
  542. AND cs.status_ = #{courseStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  543. </if>
  544. <if test="createStartDate!=null">
  545. AND date(cs.create_time_) &gt;= date(#{createStartDate})
  546. </if>
  547. <if test="createEndDate!=null">
  548. AND date(cs.create_time_) &lt;= date(#{createEndDate})
  549. </if>
  550. <if test="courseType!=null">
  551. AND cs.type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  552. </if>
  553. <if test="groupType!=null">
  554. AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  555. </if>
  556. <if test="schoolId!=null">
  557. AND cs.schoole_id_ = #{schoolId}
  558. </if>
  559. <if test="teachMode!=null">
  560. AND cs.teach_mode_ = #{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  561. </if>
  562. <if test="teacherIdList != null">
  563. AND csts.user_id_=#{teacherIdList}
  564. </if>
  565. <if test="teachType != null">
  566. AND csts.teacher_role_ = #{teachType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  567. </if>
  568. <if test="organIdList!=null">
  569. AND FIND_IN_SET(cs.organ_id_,#{organIdList})
  570. </if>
  571. <if test="search != null and search != ''">
  572. AND (cs.music_group_id_ = #{search} OR cs.id_=#{search} OR cs.name_ LIKE CONCAT('%' ,#{search}, '%' ))
  573. </if>
  574. <if test="courseIdSearch != null">
  575. AND cs.id_ = #{courseIdSearch}
  576. </if>
  577. <if test="classGroupIds != null and classGroupIds.size() > 0">
  578. AND cs.class_group_id_ IN
  579. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  580. #{classGroupId}
  581. </foreach>
  582. </if>
  583. </where>
  584. </sql>
  585. </mapper>