StudentRepairMapper.xml 11 KB

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