StudentRepairMapper.xml 12 KB

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