IndexBaseMonthDataMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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.IndexBaseMonthDataDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.IndexBaseMonthData" id="IndexBaseMonthData">
  9. <result column="id_" property="id" />
  10. <result column="month_" property="month" />
  11. <result column="organ_id_" property="organId" />
  12. <result column="total_num_" property="totalNum" />
  13. <result column="activate_num_" property="activateNum" />
  14. <result column="percent_" property="percent" />
  15. <result column="data_type_" property="dataType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  16. <result column="create_time_" property="createTime" />
  17. <result column="update_time_" property="updateTime" />
  18. </resultMap>
  19. <!-- 根据主键查询一条记录 -->
  20. <select id="get" resultMap="IndexBaseMonthData" >
  21. SELECT * FROM index_base_month_data WHERE id_ = #{id}
  22. </select>
  23. <!-- 全查询 -->
  24. <select id="findAll" resultMap="IndexBaseMonthData">
  25. SELECT * FROM index_base_month_data ORDER BY id_
  26. </select>
  27. <!-- 向数据库增加一条记录 -->
  28. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" 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_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,create_time_,update_time_)
  35. VALUES(#{month},#{organId},#{totalNum},#{activateNum},#{percent},#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},NOW(),NOW())
  36. </insert>
  37. <insert id="batchInsertWithDataType" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  38. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,create_time_,update_time_)
  39. VALUES
  40. <foreach collection="datas" item="data" separator=",">
  41. (#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
  42. #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},NOW(),NOW())
  43. </foreach>
  44. </insert>
  45. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  46. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,create_time_,update_time_)
  47. VALUES
  48. <foreach collection="datas" item="data" separator=",">
  49. (#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
  50. #{data.dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},NOW(),NOW())
  51. </foreach>
  52. </insert>
  53. <!-- 根据主键查询一条记录 -->
  54. <update id="update" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
  55. UPDATE index_base_month_data <set>
  56. <if test="organId != null">
  57. organ_id_ = #{organId},
  58. </if>
  59. <if test="id != null">
  60. id_ = #{id},
  61. </if>
  62. <if test="activateNum != null">
  63. activate_num_ = #{activateNum},
  64. </if>
  65. <if test="totalNum != null">
  66. total_num_ = #{totalNum},
  67. </if>
  68. <if test="percent != null">
  69. percent_ = #{percent},
  70. </if>
  71. <if test="month != null">
  72. month_ = #{month},
  73. </if>
  74. <if test="dataType != null">
  75. data_type_ = #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  76. </if>
  77. update_time_ = NOW()
  78. </set> WHERE id_ = #{id}
  79. </update>
  80. <!-- 根据主键删除一条记录 -->
  81. <delete id="delete" >
  82. DELETE FROM index_base_month_data WHERE id_ = #{id}
  83. </delete>
  84. <delete id="deleteWithMonthAndType">
  85. DELETE FROM index_base_month_data
  86. WHERE DATE_FORMAT(month_, '%Y-%m-%d') IN
  87. <foreach collection="months" item="month" open="(" close=")" separator=",">
  88. #{month}
  89. </foreach>
  90. <if test="dataType!=null">
  91. AND data_type_=#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  92. </if>
  93. </delete>
  94. <!-- 分页查询 -->
  95. <select id="queryPage" resultMap="IndexBaseMonthData" parameterType="map">
  96. SELECT * FROM index_base_month_data ORDER BY id_ <include refid="global.limit"/>
  97. </select>
  98. <!-- 查询当前表的总记录数 -->
  99. <select id="queryCount" resultType="int">
  100. SELECT COUNT(*) FROM index_base_month_data
  101. </select>
  102. <select id="getIndexBaseData" resultMap="IndexBaseMonthData">
  103. SELECT
  104. month_,data_type_,SUM(total_num_) total_num_,SUM(activate_num_) activate_num_,SUM(percent_) percent_
  105. FROM index_base_month_data
  106. <where>
  107. <if test="dataTypes!=null and dataTypes.size()>0">
  108. AND data_type_ IN
  109. <foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
  110. #{dataType}
  111. </foreach>
  112. </if>
  113. <if test="organIds!=null and organIds.size()>0">
  114. AND organ_id_ IN
  115. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  116. #{organId}
  117. </foreach>
  118. </if>
  119. <if test="startMonth!=null and startMonth!=''">
  120. AND DATE_FORMAT(month_, '%Y-%m')&gt;=#{startMonth}
  121. </if>
  122. <if test="endMonth!=null and endMonth!=''">
  123. AND DATE_FORMAT(month_, '%Y-%m')&lt;=#{endMonth}
  124. </if>
  125. </where>
  126. GROUP BY month_,data_type_
  127. </select>
  128. <select id="getStudentSignUpData" resultMap="IndexBaseMonthData">
  129. SELECT
  130. organ_id_,
  131. CONCAT(#{month}, '-01') month_,
  132. COUNT( id_ ) total_num_,
  133. COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END) activate_num_,
  134. TRUNCATE(COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END)/COUNT( id_ )*100, 2) percent_
  135. FROM sys_user
  136. WHERE
  137. del_flag_=0
  138. AND organ_id_ IS NOT NULL
  139. AND user_type_ LIKE '%STUDENT%'
  140. AND DATE_FORMAT(create_time_, '%Y-%m')&lt;=#{month}
  141. GROUP BY organ_id_
  142. ORDER BY organ_id_;
  143. </select>
  144. <select id="getHomeworkData" resultMap="IndexBaseMonthData">
  145. SELECT
  146. su.organ_id_,
  147. CONCAT(#{month}, '-01') month_,
  148. <choose>
  149. <when test="type == 'submit'">
  150. SUM(sees.actual_exercises_num_) total_num_,
  151. SUM(sees.exercises_reply_num_) activate_num_,
  152. TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.actual_exercises_num_)*100, 2) percent_
  153. </when>
  154. <when test="type == 'comment'">
  155. SUM(sees.exercises_reply_num_) total_num_,
  156. SUM(sees.exercises_message_num_) activate_num_,
  157. TRUNCATE(SUM(sees.exercises_message_num_)/SUM(sees.exercises_reply_num_)*100, 2) percent_
  158. </when>
  159. <otherwise>
  160. SUM(sees.expect_exercises_num_) total_num_,
  161. SUM(sees.actual_exercises_num_) activate_num_,
  162. TRUNCATE(SUM(sees.actual_exercises_num_)/SUM(sees.expect_exercises_num_)*100, 2) percent_
  163. </otherwise>
  164. </choose>
  165. FROM student_extracurricular_exercises_situation_ sees
  166. LEFT JOIN sys_user su ON sees.student_id_=su.id_
  167. WHERE su.del_flag_=0
  168. AND su.organ_id_ IS NOT NULL
  169. AND YEAR(sees.monday_)=YEAR(CONCAT(#{month}, '-01'))
  170. AND MONTH(sees.monday_)=MONTH(CONCAT(#{month}, '-01'))
  171. GROUP BY su.organ_id_
  172. ORDER BY su.organ_id_
  173. </select>
  174. <select id="getSchoolData" resultMap="IndexBaseMonthData">
  175. SELECT
  176. mg.organ_id_,
  177. CONCAT(#{month}, '-01') month_,
  178. COUNT( DISTINCT mg.cooperation_organ_id_ ) total_num_,
  179. COUNT( DISTINCT mg.cooperation_organ_id_ ) activate_num_,
  180. COUNT( DISTINCT mg.cooperation_organ_id_ ) percent_
  181. FROM
  182. music_group mg
  183. WHERE
  184. mg.del_flag_ = 0
  185. AND mg.organ_id_ IS NOT NULL
  186. AND mg.status_ = 'PROGRESS'
  187. GROUP BY
  188. mg.organ_id_
  189. ORDER BY
  190. mg.organ_id_;
  191. </select>
  192. <select id="getMusicData" resultMap="IndexBaseMonthData">
  193. SELECT
  194. organ_id_,
  195. CONCAT(#{month}, '-01') month_,
  196. COUNT( id_ ) total_num_,
  197. COUNT( id_ ) activate_num_,
  198. COUNT( id_ ) percent_
  199. FROM
  200. music_group
  201. WHERE
  202. del_flag_ = 0
  203. AND status_ = 'PROGRESS'
  204. AND organ_id_ IS NOT NULL
  205. <if test="month!=null and month!=''">
  206. AND DATE_FORMAT(create_time_, '%Y-%m') &lt;= #{month}
  207. </if>
  208. GROUP BY
  209. organ_id_
  210. ORDER BY
  211. organ_id_;
  212. </select>
  213. <select id="getMusicStudentData" resultMap="IndexBaseMonthData">
  214. SELECT
  215. mg.organ_id_,
  216. CONCAT(#{month}, '-01') month_,
  217. COUNT( DISTINCT sr.user_id_ ) total_num_,
  218. COUNT( DISTINCT sr.user_id_ ) activate_num_,
  219. COUNT( DISTINCT sr.user_id_ ) percent_
  220. FROM student_registration sr
  221. LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
  222. WHERE
  223. mg.del_flag_ = 0
  224. AND mg.organ_id_ IS NOT NULL
  225. AND mg.status_ = 'PROGRESS'
  226. <if test="type==null">
  227. AND sr.music_group_status_='NORMAL'
  228. </if>
  229. <if test="type!=null and type=='QUIT'">
  230. AND sr.music_group_status_='QUIT'
  231. AND DATE_FORMAT(sr.create_time_, '%Y-%m') &gt;= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
  232. </if>
  233. <if test="type!=null and type=='ADD'">
  234. AND sr.music_group_status_='NORMAL'
  235. AND DATE_FORMAT(sr.create_time_, '%Y-%m') &gt;= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
  236. </if>
  237. <if test="month!=null and month!=''">
  238. AND DATE_FORMAT(sr.create_time_, '%Y-%m') &lt;= #{month}
  239. </if>
  240. GROUP BY
  241. mg.organ_id_
  242. ORDER BY
  243. mg.organ_id_;
  244. </select>
  245. <select id="getTeacherData" resultMap="IndexBaseMonthData">
  246. SELECT
  247. t.organ_id_,
  248. CONCAT(#{month}, '-01') month_,
  249. COUNT( t.id_ ) total_num_,
  250. COUNT( t.id_ ) activate_num_,
  251. COUNT( t.id_ ) percent_
  252. FROM
  253. teacher t
  254. LEFT JOIN sys_user su ON su.id_ = t.id_
  255. WHERE
  256. su.del_flag_ = 0
  257. <if test="isDemission==null">
  258. AND su.lock_flag_ = 0
  259. </if>
  260. <if test="isDemission!=null">
  261. AND (su.lock_flag_ = 1 OR t.demission_date_&lt;NOW())
  262. </if>
  263. AND t.organ_id_ IS NOT NULL
  264. <if test="jobNature!=null">
  265. AND t.job_nature_ = #{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  266. </if>
  267. GROUP BY
  268. t.organ_id_
  269. ORDER BY
  270. t.organ_id_;
  271. </select>
  272. <select id="getGroupCourseData" resultMap="IndexBaseMonthData">
  273. SELECT
  274. m.organ_id_,
  275. CONCAT(#{month}, '-01') month_,
  276. COUNT( m.id_ ) total_num_,
  277. COUNT( m.id_ ) activate_num_,
  278. COUNT( m.id_ ) percent_
  279. FROM
  280. course_schedule m
  281. WHERE
  282. m.del_flag_ = 0
  283. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  284. AND m.status_ = 'OVER'
  285. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  286. AND m.organ_id_ IS NOT NULL
  287. <if test="groupType!=null">
  288. AND m.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  289. </if>
  290. <if test="month!=null and month!=''">
  291. AND DATE_FORMAT(m.class_date_, '%Y-%m') &lt;= #{month}
  292. </if>
  293. GROUP BY
  294. m.organ_id_
  295. ORDER BY
  296. m.organ_id_;
  297. </select>
  298. <select id="getOtherStudentData" resultMap="IndexBaseMonthData">
  299. SELECT
  300. su.organ_id_,
  301. CONCAT(#{month}, '-01') month_,
  302. COUNT( DISTINCT s.user_id_ ) total_num_,
  303. COUNT( DISTINCT s.user_id_ ) activate_num_,
  304. COUNT( DISTINCT s.user_id_ ) percent_
  305. FROM
  306. sys_user su
  307. LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
  308. LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
  309. WHERE
  310. m.del_flag_ = 0
  311. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  312. AND su.organ_id_ IS NOT NULL
  313. AND m.group_type_ IN ('VIP', 'PRACTICE')
  314. AND m.status_ = 'NOT_START'
  315. <if test="month!=null and month!=''">
  316. AND (DATE_FORMAT(m.create_time_, '%Y-%m') &lt;= #{month} OR YEAR(m.create_time_)=3000)
  317. </if>
  318. GROUP BY
  319. su.organ_id_
  320. ORDER BY
  321. su.organ_id_;
  322. </select>
  323. <select id="getStudentConversionData" resultMap="IndexBaseMonthData">
  324. SELECT
  325. cs.organ_id_,
  326. CONCAT( #{month}, '-01' ) month_,
  327. COUNT( DISTINCT m.user_id_ ) total_num_,
  328. COUNT( DISTINCT m.user_id_ ) activate_num_,
  329. COUNT( DISTINCT m.user_id_ ) percent_
  330. FROM
  331. course_schedule_student_payment m
  332. LEFT JOIN course_schedule cs ON m.course_schedule_id_=cs.id_
  333. LEFT JOIN practice_group pg ON m.music_group_id_=pg.id_ AND m.group_type_='PRACTICE'
  334. WHERE
  335. (cs.del_flag_ IS NULL OR cs.del_flag_=0)
  336. AND cs.organ_id_ IS NOT NULL
  337. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
  338. AND m.group_type_ IN ('VIP', 'PRACTICE')
  339. AND (pg.id_ IS NULL OR pg.type_='CHARGE')
  340. AND m.user_id_ IN
  341. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  342. #{studentId}
  343. </foreach>
  344. GROUP BY
  345. cs.organ_id_
  346. ORDER BY
  347. cs.organ_id_;
  348. </select>
  349. <select id="getMusicGroupPreRegistrationStudentData" resultMap="IndexBaseMonthData">
  350. SELECT
  351. mg.organ_id_,
  352. CONCAT( #{month}, '-01' ) month_,
  353. COUNT( DISTINCT spr.user_id_ ) total_num_,
  354. COUNT( DISTINCT spr.user_id_ ) activate_num_,
  355. COUNT( DISTINCT spr.user_id_ ) percent_
  356. FROM
  357. student_pre_registration spr
  358. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  359. WHERE
  360. mg.del_flag_ = 0
  361. AND mg.organ_id_ IS NOT NULL
  362. AND mg.status_ = 'PROGRESS'
  363. AND DATE_FORMAT( spr.create_time_, '%Y-%m' ) &lt;= #{month}
  364. GROUP BY
  365. mg.organ_id_
  366. ORDER BY
  367. mg.organ_id_;
  368. </select>
  369. <select id="getMusicGroupStudentFromPreData" resultMap="IndexBaseMonthData">
  370. SELECT
  371. mg.organ_id_,
  372. CONCAT( #{month}, '-01' ) month_,
  373. COUNT( DISTINCT sr.user_id_ ) total_num_,
  374. COUNT( DISTINCT sr.user_id_ ) activate_num_,
  375. COUNT( DISTINCT sr.user_id_ ) percent_
  376. FROM
  377. student_registration sr
  378. LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
  379. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  380. WHERE
  381. mg.del_flag_ = 0
  382. AND mg.organ_id_ IS NOT NULL
  383. AND mg.status_ = 'PROGRESS'
  384. <if test="paymentStatus==null">
  385. AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
  386. </if>
  387. <if test="paymentStatus!=null">
  388. AND sr.music_group_status_ IN ('NORMAL')
  389. AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  390. </if>
  391. AND DATE_FORMAT( sr.create_time_, '%Y-%m' ) &lt;= #{month}
  392. GROUP BY
  393. mg.organ_id_
  394. ORDER BY
  395. mg.organ_id_;
  396. </select>
  397. <select id="getMusicGroupStudentIdFromPre" resultType="int">
  398. SELECT
  399. sr.user_id_
  400. FROM
  401. student_registration sr
  402. LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
  403. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  404. WHERE
  405. mg.del_flag_ = 0
  406. AND mg.organ_id_ IS NOT NULL
  407. AND mg.status_ = 'PROGRESS'
  408. <if test="paymentStatus==null">
  409. AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
  410. </if>
  411. <if test="paymentStatus!=null">
  412. AND sr.music_group_status_ IN ('NORMAL')
  413. AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  414. </if>
  415. AND DATE_FORMAT( sr.create_time_, '%Y-%m' ) &lt;= #{month}
  416. </select>
  417. <select id="countLessThenThreeClassGroupNum" resultType="int">
  418. SELECT COUNT(t.id_) FROM (
  419. SELECT cg.id_ FROM
  420. class_group cg
  421. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  422. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  423. WHERE
  424. cg.type_ IN ('HIGH','HIGH_ONLINE')
  425. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
  426. <if test="organIds!=null and organIds.size()>0">
  427. AND mg.organ_id_ IN
  428. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  429. #{organId}
  430. </foreach>
  431. </if>
  432. GROUP BY cg.id_
  433. HAVING
  434. COUNT(CASE WHEN cgsm.status_ = 'NORMAL' THEN 1 ELSE NULL END) &lt; 3
  435. ) t
  436. </select>
  437. <select id="getLessThenThreeMusicGroup" resultType="java.lang.String">
  438. SELECT cg.music_group_id_ FROM
  439. class_group cg
  440. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  441. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  442. WHERE
  443. cg.type_ IN ('HIGH','HIGH_ONLINE')
  444. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
  445. <if test="organIds!=null and organIds.size()>0">
  446. AND mg.organ_id_ IN
  447. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  448. #{organId}
  449. </foreach>
  450. </if>
  451. GROUP BY cg.id_
  452. HAVING
  453. COUNT(CASE WHEN cgsm.status_ = 'NORMAL' THEN 1 ELSE NULL END) &lt; 3
  454. </select>
  455. <select id="countNoPaymentStudentNum" resultType="int">
  456. SELECT
  457. COUNT(DISTINCT mgpcd.user_id_)
  458. FROM
  459. music_group_payment_calender_detail mgpcd
  460. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  461. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  462. WHERE
  463. mg.status_ = 'PROGRESS'
  464. AND mgpc.payment_valid_end_date_ &lt; NOW()
  465. AND mgpcd.payment_status_ = 'NON_PAYMENT'
  466. <if test="organIds!=null and organIds.size()>0">
  467. AND mg.organ_id_ IN
  468. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  469. #{organId}
  470. </foreach>
  471. </if>
  472. </select>
  473. <select id="getNoPaymentMusicGroup" resultType="java.lang.String">
  474. SELECT
  475. DISTINCT mg.id_
  476. FROM
  477. music_group_payment_calender_detail mgpcd
  478. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  479. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  480. WHERE
  481. mg.status_ = 'PROGRESS'
  482. AND mgpc.payment_valid_end_date_ &lt; NOW()
  483. AND mgpcd.payment_status_ = 'NON_PAYMENT'
  484. <if test="organIds!=null and organIds.size()>0">
  485. AND mg.organ_id_ IN
  486. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  487. #{organId}
  488. </foreach>
  489. </if>
  490. </select>
  491. <select id="queryApplyForQuitGroupNum" resultType="java.lang.Long">
  492. SELECT mgq.id_ FROM music_group_quit mgq
  493. LEFT JOIN music_group mg ON mgq.music_group_id_=mg.id_
  494. WHERE mg.status_='PROGRESS'
  495. AND mgq.status_='PROCESSING'
  496. <if test="organIds!=null and organIds.size()>0">
  497. AND mg.organ_id_ IN
  498. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  499. #{organId}
  500. </foreach>
  501. </if>
  502. </select>
  503. <select id="queryStudentAttendanceInfo" resultType="java.lang.Long">
  504. SELECT
  505. DISTINCT cssp.user_id_
  506. FROM
  507. course_schedule_student_payment cssp
  508. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  509. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND sa.user_id_ = cssp.user_id_
  510. LEFT JOIN student_visit sv ON cssp.id_=sv.object_id_
  511. WHERE
  512. <if test="type!=null and type=='LEAVE'">
  513. (sa.status_ = 'LEAVE' AND sa.remark_ IS NOT NULL AND sv.id_ IS NULL)
  514. </if>
  515. <if test="type!=null and type=='TRUANT'">
  516. (sa.status_ = 'TRUANT' OR sa.id_ IS NULL)
  517. </if>
  518. <if test="firstDayOfMonth != null">
  519. AND cs.class_date_ >= DATE_FORMAT(#{firstDayOfMonth},'%Y-%m-%d')
  520. </if>
  521. <if test="organIds!=null and organIds.size()>0">
  522. AND cs.organ_id_ IN
  523. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  524. #{organId}
  525. </foreach>
  526. </if>
  527. </select>
  528. <select id="getAttendanceError" resultType="java.lang.Long">
  529. SELECT DISTINCT ta.id_ FROM teacher_attendance ta
  530. LEFT JOIN course_schedule cs ON ta.course_schedule_id_ = cs.id_
  531. WHERE (ta.sign_in_status_ = 0 OR ta.sign_out_status_ = 0)
  532. AND (ta.sign_in_time_ IS NOT NULL OR ta.sign_out_time_ IS NOT NULL) AND ta.dispose_content_ IS NULL
  533. <if test="organIds != null and organIds != ''">
  534. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  535. </if>
  536. <if test="firstDayOfMonth != null">
  537. AND cs.class_date_ >= DATE_FORMAT(#{firstDayOfMonth},'%Y-%m-%d')
  538. </if>
  539. </select>
  540. <select id="getNoAttendance" resultType="java.lang.Long">
  541. SELECT DISTINCT ta.id_ FROM teacher_attendance ta
  542. LEFT JOIN course_schedule cs ON ta.course_schedule_id_ = cs.id_
  543. WHERE ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
  544. <if test="organIds != null and organIds != ''">
  545. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  546. </if>
  547. <if test="firstDayOfMonth != null">
  548. AND cs.class_date_ >= DATE_FORMAT(#{firstDayOfMonth},'%Y-%m-%d')
  549. </if>
  550. </select>
  551. <select id="queryTeacherLeave" resultType="java.lang.Long">
  552. SELECT DISTINCT tlr.id_ FROM teacher_leave_record tlr
  553. LEFT JOIN teacher t ON t.id_ = tlr.user_id_
  554. WHERE tlr.status_ = 'ING'
  555. <if test="organIdsStr != null and organIdsStr != ''">
  556. AND FIND_IN_SET(t.organ_id_,#{organIdsStr})
  557. </if>
  558. </select>
  559. <select id="queryLowTeacherSalary" resultType="java.lang.Long">
  560. SELECT DISTINCT tcs.user_id_ FROM teacher_course_statistics tcs
  561. WHERE DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
  562. <if test="organIdsStr != null and organIdsStr != ''">
  563. AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
  564. </if>
  565. </select>
  566. <select id="queryInspectionItem" resultType="java.lang.Long">
  567. SELECT DISTINCT ii.id_ FROM inspection_item ii
  568. WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ IS NULL
  569. <if test="organIdsStr != null and organIdsStr != ''">
  570. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  571. </if>
  572. </select>
  573. <select id="queryInspectionItemPlan" resultType="java.lang.Long">
  574. SELECT DISTINCT iip.id_ FROM inspection_item_plan iip
  575. WHERE iip.status_ = 0 AND iip.memo_ IS NULL
  576. <if test="organIdsStr != null and organIdsStr != ''">
  577. AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
  578. </if>
  579. </select>
  580. <select id="queryStudentVisit" resultType="java.lang.Long">
  581. SELECT DISTINCT ii.id_ FROM inspection_item ii
  582. WHERE ii.item_ = 'VISIT' AND ii.memo_ IS NULL
  583. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  584. WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(ii.create_time_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
  585. <if test="organIdsStr != null and organIdsStr != ''">
  586. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  587. </if>
  588. </select>
  589. <select id="queryErrInspection" resultType="java.lang.Long">
  590. SELECT
  591. id_
  592. FROM
  593. inspection_item_plan
  594. WHERE
  595. conclusion_status_ = 1
  596. <if test="organIds!=null and organIds.size()>0">
  597. AND organ_id_ IN
  598. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  599. #{organId}
  600. </foreach>
  601. </if>
  602. </select>
  603. <select id="getFinancePayData" resultMap="IndexBaseMonthData">
  604. </select>
  605. <select id="getFinanceBalanceData" resultMap="IndexBaseMonthData">
  606. </select>
  607. <select id="getFinanceActualData" resultMap="IndexBaseMonthData">
  608. </select>
  609. </mapper>