StudentRepairMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ym.mec.biz.dal.dao.StudentRepairDao">
  4. <resultMap id="StudentRepair" type="com.ym.mec.biz.dal.entity.StudentRepair">
  5. <result column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
  7. <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
  8. <result column="name_" jdbcType="INTEGER" property="organName"/>
  9. <result column="student_id_" jdbcType="INTEGER" property="studentId"/>
  10. <result column="student_name_" jdbcType="VARCHAR" property="studentName"/>
  11. <result column="student_school_" jdbcType="VARCHAR" property="studentSchool"/>
  12. <result column="employee_id_" jdbcType="INTEGER" property="employeeId"/>
  13. <result column="employee_name_" jdbcType="VARCHAR" property="employeeName"/>
  14. <result column="employee_phone_" jdbcType="VARCHAR" property="employeePhone"/>
  15. <result column="employee_address_" jdbcType="VARCHAR" property="employeeAddress"/>
  16. <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>
  17. <result column="subject_name_" jdbcType="VARCHAR" property="subjectName"/>
  18. <result column="type_" jdbcType="INTEGER" property="type"/>
  19. <result column="instrument_no_" jdbcType="VARCHAR" property="instrumentNo"/>
  20. <result column="description_" jdbcType="VARCHAR" property="description"/>
  21. <result column="amount_" jdbcType="DECIMAL" property="amount"/>
  22. <result column="finish_time_" jdbcType="TIMESTAMP" property="finishTime"/>
  23. <result column="send_type_" jdbcType="INTEGER" property="sendType"/>
  24. <result column="contact_name_" jdbcType="VARCHAR" property="contactName"/>
  25. <result column="contact_mobile_" jdbcType="VARCHAR" property="contactMobile"/>
  26. <result column="address_" jdbcType="VARCHAR" property="address"/>
  27. <result column="pay_status_" jdbcType="INTEGER" property="payStatus"/>
  28. <result column="repair_status_" jdbcType="INTEGER" property="repairStatus"/>
  29. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  30. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  31. </resultMap>
  32. <!-- 根据主键查询一条记录 -->
  33. <select id="get" resultMap="StudentRepair">
  34. SELECT *
  35. FROM student_repair
  36. WHERE id_ = #{id}
  37. </select>
  38. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentRepair" useGeneratedKeys="true" keyColumn="id"
  39. keyProperty="id">
  40. <!--@mbg.generated-->
  41. insert into student_repair (id_, trans_no_, organ_id_,
  42. student_id_, student_name_, student_school_,
  43. employee_id_, employee_name_, subject_id_,
  44. subject_name_, type_, instrument_no_,
  45. description_, amount_, finish_time_,
  46. send_type_, contact_name_, contact_mobile_,
  47. address_, pay_status_, create_time_,
  48. update_time_,repair_status_)
  49. values (#{id,jdbcType=INTEGER}, #{transNo,jdbcType=VARCHAR}, #{organId,jdbcType=INTEGER},
  50. #{studentId,jdbcType=INTEGER}, #{studentName,jdbcType=VARCHAR}, #{studentSchool,jdbcType=VARCHAR},
  51. #{employeeId,jdbcType=INTEGER}, #{employeeName,jdbcType=VARCHAR}, #{subjectId,jdbcType=INTEGER},
  52. #{subjectName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{instrumentNo,jdbcType=VARCHAR},
  53. #{description,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{finishTime,jdbcType=TIMESTAMP},
  54. #{sendType,jdbcType=INTEGER}, #{contactName,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR},
  55. #{address,jdbcType=VARCHAR}, #{payStatus,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
  56. #{updateTime,jdbcType=TIMESTAMP},#{repairStatus})
  57. </insert>
  58. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentRepair">
  59. UPDATE student_repair
  60. <set>
  61. <if test="transNo != null">
  62. trans_no_ = #{transNo},
  63. </if>
  64. <if test="repairStatus != null">
  65. repair_status_ = #{repairStatus},
  66. </if>
  67. <if test="organId != null">
  68. organ_id_ = #{organId},
  69. </if>
  70. <if test="studentId != null">
  71. student_id_ = #{studentId},
  72. </if>
  73. <if test="studentName != null">
  74. student_name_ = #{studentName},
  75. </if>
  76. <if test="studentSchool != null">
  77. student_school_ = #{studentSchool},
  78. </if>
  79. <if test="employeeId != null">
  80. employee_id_ = #{employeeId},
  81. </if>
  82. <if test="employeeName != null">
  83. employee_name_ = #{employeeName},
  84. </if>
  85. <if test="subjectId != null">
  86. subject_id_ = #{subjectId},
  87. </if>
  88. <if test="subjectName != null">
  89. subject_name_ = #{subjectName},
  90. </if>
  91. <if test="type != null">
  92. type_ = #{type},
  93. </if>
  94. <if test="instrumentNo != null">
  95. instrument_no_ = #{instrumentNo},
  96. </if>
  97. <if test="description != null">
  98. description_ = #{description},
  99. </if>
  100. <if test="amount != null">
  101. amount_ = #{amount},
  102. </if>
  103. <if test="finishTime != null">
  104. finish_time_ = #{finishTime},
  105. </if>
  106. <if test="sendType != null">
  107. send_type_ = #{sendType},
  108. </if>
  109. <if test="contactName != null">
  110. contact_name_ = #{contactName},
  111. </if>
  112. <if test="contactMobile != null">
  113. contact_mobile_ = #{contactMobile},
  114. </if>
  115. <if test="address != null">
  116. address_ = #{address},
  117. </if>
  118. <if test="payStatus != null">
  119. pay_status_ = #{payStatus},
  120. </if>
  121. <if test="updateTime != null">
  122. update_time_ = #{updateTime},
  123. </if>
  124. </set>
  125. WHERE id_ = #{id}
  126. </update>
  127. <select id="getStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  128. SELECT username_ ,id_ user_id_,avatar_ head_url_,gender_,phone_
  129. FROM sys_user
  130. WHERE FIND_IN_SET(organ_id_,#{organIdList})
  131. AND user_type_ LIKE '%STUDENT%'
  132. <if test="search">
  133. AND (username_ LIKE CONCAT(#{search},'%') OR phone_ LIKE CONCAT(#{search},'%'))
  134. </if>
  135. AND id_ NOT IN (
  136. SELECT cssp.user_id_
  137. FROM music_group mg
  138. LEFT JOIN course_schedule_student_payment cssp ON mg.id_ = cssp.music_group_id_
  139. WHERE cssp.group_type_ = 'MUSIC'
  140. AND mg.repair_user_id_ != #{employeeId})
  141. <include refid="global.limit"/>
  142. </select>
  143. <select id="getStudentsCount" resultType="java.lang.Integer">
  144. SELECT COUNT(*) FROM sys_user
  145. WHERE FIND_IN_SET(organ_id_,#{organIdList})
  146. AND user_type_ LIKE '%STUDENT%'
  147. <if test="search">
  148. AND (username_ LIKE CONCAT(#{search},'%') OR phone_ LIKE CONCAT(#{search},'%'))
  149. </if>
  150. AND id_ NOT IN (
  151. SELECT cssp.user_id_
  152. FROM music_group mg
  153. LEFT JOIN course_schedule_student_payment cssp ON mg.id_ = cssp.music_group_id_
  154. WHERE cssp.group_type_ = 'MUSIC'
  155. AND mg.repair_user_id_ != #{employeeId}
  156. )
  157. </select>
  158. <select id="queryPage" resultMap="StudentRepair">
  159. SELECT sr.*,o.name_ FROM student_repair sr
  160. LEFT JOIN organization o ON o.id_ = sr.organ_id_
  161. <include refid="queryPageSql"/>
  162. <include refid="global.limit"/>
  163. </select>
  164. <sql id="queryPageSql">
  165. <where>
  166. <if test="search != null and search != ''">
  167. AND (sr.trans_no_ LIKE CONCAT('%',#{search},'%') OR sr.student_id_ = #{search} OR sr.student_name_ LIKE
  168. CONCAT('%',#{search},'%'))
  169. </if>
  170. <if test="employeeId != null">
  171. AND sr.employee_id_ = #{employeeId}
  172. </if>
  173. <if test="studentId != null">
  174. AND sr.student_id_ = #{studentId}
  175. </if>
  176. <if test="organIdList != null and organIdList != ''">
  177. AND FIND_IN_SET(sr.organ_id_,#{organIdList})
  178. </if>
  179. <if test="subjectId != null">
  180. AND sr.subject_id_ = #{subjectId}
  181. </if>
  182. <if test="type != null">
  183. AND sr.type_ = #{type}
  184. </if>
  185. <if test="repairStatus != null">
  186. AND sr.repair_status_ = #{repairStatus}
  187. </if>
  188. <if test="startTime != null">
  189. AND sr.create_time_ >= #{startTime}
  190. </if>
  191. <if test="endTime != null">
  192. AND sr.create_time_ &lt;= #{endTime}
  193. </if>
  194. </where>
  195. </sql>
  196. <select id="queryCount" resultType="int">
  197. SELECT COUNT(id_) FROM student_repair sr
  198. <include refid="queryPageSql"/>
  199. </select>
  200. <select id="getUserMusicGroup" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.MusicGroup">
  201. SELECT mg.id_,mg.name_,sr.user_id_ repair_user_id_ FROM music_group mg
  202. LEFT JOIN student_registration sr on sr.music_group_id_ = mg.id_
  203. WHERE sr.user_id_ IN
  204. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  205. #{userId}
  206. </foreach>
  207. AND mg.status_='PROGRESS'
  208. ORDER BY id_ DESC
  209. </select>
  210. <select id="getStudentInfo" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  211. SELECT su.username_,
  212. su.id_ user_id_,
  213. su.avatar_ head_url_,
  214. su.gender_,
  215. mg.id_ music_group_id_,
  216. mg.name_ music_group_name_,
  217. sr.subject_id_
  218. FROM sys_user su
  219. LEFT JOIN student_registration sr ON sr.user_id_ = su.id_
  220. LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
  221. WHERE su.id_ = #{studentId}
  222. ORDER BY mg.id_ DESC
  223. LIMIT 1
  224. </select>
  225. <select id="getRepairInfo" resultMap="StudentRepair">
  226. SELECT sr.*, su.phone_ employee_phone_, e.contact_address_ employee_address_
  227. FROM student_repair sr
  228. LEFT JOIN sys_user su ON su.id_ = sr.employee_id_
  229. LEFT JOIN employee e ON sr.employee_id_ = e.user_id_
  230. WHERE sr.id_ = #{id}
  231. </select>
  232. <select id="getStudentMusicGroupRepairer" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  233. SELECT su.real_name_ username_, su.id_ user_id_, su.avatar_ head_url_
  234. FROM music_group mg
  235. LEFT JOIN student_registration sr on sr.music_group_id_ = mg.id_
  236. LEFT JOIN sys_user su ON su.id_ = sr.id_
  237. WHERE sr.user_id_ = #{studentId}
  238. AND mg.status_ = 'PROGRESS'
  239. AND mg.repair_user_id_ IS NOT NULL
  240. ORDER BY id_ DESC
  241. LIMIT 1
  242. </select>
  243. <select id="getStudentOrganRepairer" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  244. SELECT su.real_name_ username_, su.id_ user_id_, su.avatar_ head_url_
  245. FROM employee e
  246. LEFT JOIN sys_user su ON su.id_ = e.user_id_
  247. LEFT JOIN sys_user_role sur ON sur.user_id_ = su.id_
  248. WHERE FIND_IN_SET(#{organId}, e.organ_id_list_)
  249. AND sur.role_id_ = 37
  250. ORDER BY RAND()
  251. LIMIT 1
  252. </select>
  253. </mapper>