IndexErrDataRecordMapper.xml 24 KB

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