IndexErrDataRecordMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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. DISTINCT 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. <if test="educationUserId!=null">
  265. AND deal_user_id_ = #{educationUserId}
  266. </if>
  267. </where>
  268. </sql>
  269. <select id="queryErrStrings" resultType="string">
  270. SELECT CONCAT(generate_time_, organ_id_, deal_user_id_) FROM index_err_data_record
  271. <include refid="queryErrStringsCondition"></include>
  272. GROUP BY generate_time_,organ_id_,deal_user_id_
  273. ORDER BY generate_time_ DESC,organ_id_,deal_user_id_
  274. <include refid="global.limit"></include>
  275. </select>
  276. <select id="queryErrStringsCount" resultType="int">
  277. SELECT COUNT(DISTINCT CONCAT(generate_time_,organ_id_,deal_user_id_)) FROM index_err_data_record
  278. <include refid="queryErrStringsCondition"></include>
  279. </select>
  280. <select id="getWithOrganMonthUserStr" resultMap="IndexErrDataRecord">
  281. SELECT * FROM index_err_data_record WHERE CONCAT(generate_time_, organ_id_, deal_user_id_) IN
  282. <foreach collection="omuStrings" item="omuString" open="(" close=")" separator=",">
  283. #{omuString}
  284. </foreach>
  285. </select>
  286. <select id="getAllErrDatas" resultMap="IndexErrDataRecord">
  287. SELECT * FROM index_err_data_record
  288. <include refid="queryErrStringsCondition"></include>
  289. </select>
  290. <select id="queryErrInspectionData" resultMap="com.ym.mec.biz.dal.dao.InspectionItemPlanDao.InspectionItemPlan" parameterType="map">
  291. SELECT iip.*,su.real_name_ realName,o.name_ organName,co.name_ cooperationName,mg.name_ musicGroupName,
  292. irdr.generate_time_ generateTime,irdr.deal_time_ dealTime
  293. FROM index_err_data_record irdr
  294. LEFT JOIN inspection_item_plan iip ON irdr.data_id_=iip.id_
  295. LEFT JOIN sys_user su ON su.id_ = iip.user_id_
  296. LEFT JOIN organization o ON o.id_=iip.organ_id_
  297. LEFT JOIN cooperation_organ co ON co.id_=iip.cooperation_organ_id_
  298. LEFT JOIN music_group mg ON mg.id_ = iip.music_group_id_
  299. <include refid="queryErrInspectionDataCondition"/>
  300. ORDER BY iip.plan_start_ ASC
  301. <include refid="global.limit"/>
  302. </select>
  303. <select id="errInspectionDataCount" resultType="int">
  304. SELECT COUNT(*)
  305. FROM index_err_data_record irdr
  306. LEFT JOIN inspection_item_plan iip ON irdr.data_id_=iip.id_
  307. LEFT JOIN music_group mg ON mg.id_ = iip.music_group_id_
  308. <include refid="queryErrInspectionDataCondition"/>
  309. </select>
  310. <sql id="queryErrInspectionDataCondition">
  311. <where>
  312. <if test="searchType != null and searchType != ''">
  313. <if test="searchType == 'MUSIC_PATROL_ITEM'">
  314. irdr.data_type_ = 'MUSIC_PATROL_ITEM'
  315. </if>
  316. <if test="searchType == 'INSPECTION_ITEM_PLAN'">
  317. irdr.data_type_ = 'INSPECTION_ITEM_PLAN'
  318. </if>
  319. </if>
  320. <if test="hasDealTime!=null and hasDealTime">
  321. AND irdr.deal_time_ IS NOT NULL
  322. </if>
  323. <if test="hasDealTime!=null and !hasDealTime">
  324. AND irdr.deal_time_ IS NULL
  325. </if>
  326. <if test="itemId != null">
  327. AND iip.item_id_ = #{itemId}
  328. </if>
  329. <if test="userId != null">
  330. AND iip.user_id_ = #{userId}
  331. </if>
  332. <if test="organId != null">
  333. AND FIND_IN_SET(iip.organ_id_,#{organId})
  334. </if>
  335. <if test="cooperationOrganId != null">
  336. AND iip.cooperation_organ_id_ = #{cooperationOrganId}
  337. </if>
  338. <if test="musicGroupId != null">
  339. AND iip.music_group_id_ = #{musicGroupId}
  340. </if>
  341. <if test="conclusionStatus != null">
  342. AND iip.conclusion_status_ = #{conclusionStatus}
  343. </if>
  344. <if test="status !=null">
  345. AND iip.status_ = #{status}
  346. </if>
  347. <if test='hasSubmit != null and hasSubmit.toString()=="1".toString()'>
  348. AND iip.status_ > 0
  349. </if>
  350. <if test='hasSubmit != null and hasSubmit.toString()=="0".toString()'>
  351. AND iip.status_ = 0
  352. </if>
  353. <if test="startTime != null">
  354. AND iip.plan_start_ >= #{startTime}
  355. </if>
  356. <if test="endTime != null">
  357. <![CDATA[AND iip.plan_start_ <= #{endTime}]]>
  358. </if>
  359. <if test="generateStartTime != null">
  360. AND irdr.generate_time_ >= #{generateStartTime}
  361. </if>
  362. <if test="generateEndTime != null">
  363. <![CDATA[AND irdr.generate_time_ <= #{generateEndTime}]]>
  364. </if>
  365. <if test="dealStartTime != null">
  366. AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") >= #{dealStartTime}
  367. </if>
  368. <if test="dealEndTime != null">
  369. <![CDATA[AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") <= #{dealEndTime}]]>
  370. </if>
  371. <if test="search != null">
  372. AND mg.name_ LIKE CONCAT('%', #{search}, '%')
  373. </if>
  374. <if test="ids != null and ids != ''">
  375. AND FIND_IN_SET(iip.id_,#{ids})
  376. </if>
  377. </where>
  378. </sql>
  379. <select id="queryErrStudentVisit" resultMap="com.ym.mec.biz.dal.dao.InspectionItemDao.InspectionItem" parameterType="map">
  380. SELECT ii.*,i.month_ month,o.name_ organName,su.real_name_ userName,
  381. irdr.generate_time_ generateTime,irdr.deal_time_ dealTime
  382. FROM index_err_data_record irdr
  383. LEFT JOIN inspection_item ii ON irdr.data_id_=ii.id_
  384. LEFT JOIN inspection i ON i.id_ = ii.inspection_id_
  385. LEFT JOIN organization o ON o.id_=ii.organ_id_
  386. LEFT JOIN sys_user su ON su.id_ = ii.user_id_
  387. <include refid="queryErrStudentVisitCondition"/>
  388. ORDER BY i.month_ DESC ,ii.id_ DESC
  389. <include refid="global.limit"/>
  390. </select>
  391. <!-- 查询当前表的总记录数 -->
  392. <select id="studentVisitCount" resultType="int">
  393. SELECT COUNT(*)
  394. FROM index_err_data_record irdr
  395. LEFT JOIN inspection_item ii ON irdr.data_id_=ii.id_
  396. LEFT JOIN inspection i ON i.id_ = ii.inspection_id_
  397. <include refid="queryErrStudentVisitCondition"/>
  398. </select>
  399. <sql id="queryErrStudentVisitCondition">
  400. <where>
  401. irdr.data_type_ = 'STUDENT_VISIT'
  402. <if test="hasDealTime!=null and hasDealTime">
  403. AND irdr.deal_time_ IS NOT NULL
  404. </if>
  405. <if test="hasDealTime!=null and !hasDealTime">
  406. AND irdr.deal_time_ IS NULL
  407. </if>
  408. <if test="organId != null">
  409. AND FIND_IN_SET(ii.organ_id_,#{organId})
  410. </if>
  411. <if test="userId != null">
  412. AND ii.user_id_ = #{userId}
  413. </if>
  414. <if test="operation != null">
  415. AND ii.operation_ = #{operation}
  416. </if>
  417. <if test="ids != null">
  418. AND FIND_IN_SET(ii.id_,#{ids})
  419. </if>
  420. <if test="startTime != null">
  421. AND i.month_ >= #{startTime}
  422. </if>
  423. <if test="endTime != null">
  424. <![CDATA[AND i.month_ <= #{endTime}]]>
  425. </if>
  426. <if test="generateStartTime != null">
  427. AND irdr.generate_time_ >= #{generateStartTime}
  428. </if>
  429. <if test="generateEndTime != null">
  430. <![CDATA[AND irdr.generate_time_ <= #{generateEndTime}]]>
  431. </if>
  432. <if test="dealStartTime != null">
  433. AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") >= #{dealStartTime}
  434. </if>
  435. <if test="dealEndTime != null">
  436. <![CDATA[AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") <= #{dealEndTime}]]>
  437. </if>
  438. </where>
  439. </sql>
  440. <select id="queryHistoryErrCourseData" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseScheduleEndDto">
  441. SELECT
  442. cs.id_ id_,
  443. cs.new_course_id_,
  444. cs.group_type_,
  445. cs.music_group_id_,
  446. cs.class_group_id_,
  447. cs.status_,
  448. cs.name_,
  449. cs.class_date_,
  450. CONCAT(cs.class_date_,' ',cs.start_class_time_) course_start_time_,
  451. CONCAT(cs.class_date_,' ',cs.end_class_time_) course_end_time_,
  452. cs.actual_teacher_id_,
  453. cs.teach_mode_,
  454. cs.type_,
  455. cs.schoole_id_,
  456. cs.create_time_,
  457. cs.is_lock_,
  458. cs.organ_id_,
  459. s.name_ schoole_name_,
  460. o.name_ organ_name_,
  461. irdr.generate_time_ generateTime,
  462. irdr.deal_time_ dealTime,
  463. eu.real_name_ educationTeacherName,
  464. 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,
  465. CASE WHEN COUNT(CASE WHEN ta.is_complaints_ = 1 THEN 1 ELSE NULL END) > 0 THEN '1' ELSE '0' END is_complaints_
  466. FROM index_err_data_record irdr
  467. LEFT JOIN course_schedule cs ON irdr.data_id_=cs.id_
  468. LEFT JOIN school s ON cs.schoole_id_=s.id_
  469. LEFT JOIN organization o ON cs.organ_id_=o.id_
  470. LEFT JOIN course_schedule_teacher_salary csts ON csts.course_schedule_id_ = cs.id_
  471. left join teacher_attendance ta on ta.course_schedule_id_ = cs.id_
  472. <if test="searchType == 'ERR_ATTENDANCE'">
  473. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  474. </if>
  475. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_
  476. <if test="searchType == 'ERR_ATTENDANCE'">
  477. AND cssp.user_id_ = sa.user_id_
  478. </if>
  479. LEFT JOIN sys_user eu ON irdr.deal_user_id_ = eu.id_
  480. <include refid="endFindCourseSchedulesCondition"/>
  481. GROUP BY cs.class_date_,cs.start_class_time_,cs.id_
  482. ORDER BY cs.class_date_,cs.start_class_time_,cs.id_
  483. <include refid="global.limit"/>
  484. </select>
  485. <select id="historyErrCourseDataCount" resultType="int">
  486. SELECT
  487. COUNT(DISTINCT cs.id_)
  488. FROM index_err_data_record irdr
  489. LEFT JOIN course_schedule cs ON irdr.data_id_=cs.id_
  490. <if test="searchType == 'ERR_ATTENDANCE'">
  491. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  492. </if>
  493. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_
  494. <if test="searchType == 'ERR_ATTENDANCE'">
  495. AND cssp.user_id_ = sa.user_id_
  496. </if>
  497. LEFT JOIN teacher_attendance ta on ta.course_schedule_id_ = cs.id_
  498. LEFT JOIN course_schedule_teacher_salary csts ON csts.course_schedule_id_ = cs.id_
  499. <include refid="endFindCourseSchedulesCondition"/>
  500. </select>
  501. <select id="getAllDealUserIds" resultType="int">
  502. SELECT DISTINCT deal_user_id_ FROM index_err_data_record
  503. <where>
  504. <if test="organIds!=null and organIds.size()>0">
  505. AND organ_id_ IN
  506. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  507. #{organId}
  508. </foreach>
  509. </if>
  510. </where>
  511. </select>
  512. <sql id="endFindCourseSchedulesCondition">
  513. <where>
  514. <if test="searchType == 'ERR_ATTENDANCE'">
  515. AND irdr.data_type_ = 'TEACHER_EXCEPTION_ATTENDANCE'
  516. </if>
  517. <if test="searchType == 'NO_ATTENDANCE'">
  518. AND irdr.data_type_ = 'TEACHER_NOT_A_CLASS'
  519. </if>
  520. <if test="hasDealTime!=null and hasDealTime">
  521. AND irdr.deal_time_ IS NOT NULL
  522. </if>
  523. <if test="hasDealTime!=null and !hasDealTime">
  524. AND irdr.deal_time_ IS NULL
  525. </if>
  526. <if test="educationUserId!=null">
  527. AND irdr.deal_user_id_ = #{educationUserId}
  528. </if>
  529. <if test="mergeCourseType != null and mergeCourseType != ''">
  530. <if test="mergeCourseType == 'MASTER'">
  531. AND cs.new_course_id_ = cs.id_
  532. </if>
  533. <if test="mergeCourseType == 'ASSIST'">
  534. AND cs.new_course_id_ > 0 AND cs.new_course_id_ != cs.id_
  535. </if>
  536. <if test="mergeCourseType == 'ALL'">
  537. AND cs.new_course_id_ > 0
  538. </if>
  539. </if>
  540. <if test="isCallNames != null and isCallNames == 1">
  541. AND sa.id_ IS NOT NULL
  542. </if>
  543. <if test="isCallNames != null and isCallNames == 0">
  544. AND sa.id_ IS NULL
  545. </if>
  546. <if test="startTime!=null">
  547. AND cs.class_date_ &gt;= DATE_FORMAT(#{startTime},"%Y-%m-%d")
  548. </if>
  549. <if test="endTime!=null">
  550. AND cs.class_date_ &lt;= DATE_FORMAT(#{endTime},"%Y-%m-%d")
  551. </if>
  552. <if test="generateStartTime != null">
  553. AND irdr.generate_time_ >= #{generateStartTime}
  554. </if>
  555. <if test="generateEndTime != null">
  556. <![CDATA[AND irdr.generate_time_ <= #{generateEndTime}]]>
  557. </if>
  558. <if test="dealStartTime != null">
  559. AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") >= #{dealStartTime}
  560. </if>
  561. <if test="dealEndTime != null">
  562. <![CDATA[AND DATE_FORMAT(irdr.deal_time_,"%Y-%m-%d") <= #{dealEndTime}]]>
  563. </if>
  564. <if test="courseStatus!=null">
  565. AND cs.status_ = #{courseStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  566. </if>
  567. <if test="createStartDate!=null">
  568. AND date(cs.create_time_) &gt;= date(#{createStartDate})
  569. </if>
  570. <if test="createEndDate!=null">
  571. AND date(cs.create_time_) &lt;= date(#{createEndDate})
  572. </if>
  573. <if test="courseType!=null">
  574. AND cs.type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  575. </if>
  576. <if test="groupType!=null">
  577. AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  578. </if>
  579. <if test="schoolId!=null">
  580. AND cs.schoole_id_ = #{schoolId}
  581. </if>
  582. <if test="teachMode!=null">
  583. AND cs.teach_mode_ = #{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  584. </if>
  585. <if test="teacherIdList != null">
  586. AND csts.user_id_=#{teacherIdList}
  587. </if>
  588. <if test="teachType != null">
  589. AND csts.teacher_role_ = #{teachType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  590. </if>
  591. <if test="organIdList!=null">
  592. AND FIND_IN_SET(cs.organ_id_,#{organIdList})
  593. </if>
  594. <if test="search != null and search != ''">
  595. AND (cs.music_group_id_ = #{search} OR cs.id_=#{search} OR cs.name_ LIKE CONCAT('%' ,#{search}, '%' ))
  596. </if>
  597. <if test="courseIdSearch != null">
  598. AND cs.id_ = #{courseIdSearch}
  599. </if>
  600. <if test="classGroupIds != null and classGroupIds.size() > 0">
  601. AND cs.class_group_id_ IN
  602. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  603. #{classGroupId}
  604. </foreach>
  605. </if>
  606. </where>
  607. </sql>
  608. </mapper>