ExamTeacherSalaryMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.keao.edu.user.dao.ExamTeacherSalaryDao">
  8. <resultMap type="com.keao.edu.user.entity.ExamTeacherSalary" id="ExamTeacherSalary">
  9. <result column="id_" property="id" />
  10. <result column="examination_basic_id_" property="examinationBasicId" />
  11. <result column="exam_mode_" property="examMode" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
  12. <result column="teacher_id_" property="teacherId" />
  13. <result column="settlement_type_" property="settlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
  14. <result column="share_profit_amount_" property="shareProfitAmount" />
  15. <result column="total_invigilation_num_" property="totalInvigilationNum"/>
  16. <result column="total_invigilation_student_num_" property="totalInvigilationStudentNum"/>
  17. <result column="total_settlement_fee_" property="totalSettlementCost"/>
  18. <result column="create_time_" property="createTime" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="tenant_id_" property="tenantId" />
  21. <association property="teacher" columnPrefix="teacher_" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
  22. </resultMap>
  23. <resultMap id="ExamTeacherSalaryDto" type="com.keao.edu.user.dto.ExamTeacherSalaryDto" extends="ExamTeacherSalary">
  24. </resultMap>
  25. <!-- 根据主键查询一条记录 -->
  26. <select id="get" resultMap="ExamTeacherSalary" >
  27. SELECT * FROM exam_teacher_salary WHERE id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="ExamTeacherSalary">
  31. SELECT * FROM exam_teacher_salary ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.keao.edu.user.entity.ExamTeacherSalary" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  35. INSERT INTO exam_teacher_salary (id_,examination_basic_id_,exam_mode_,teacher_id_,settlement_type_,share_profit_amount_,
  36. total_invigilation_num_,total_invigilation_student_num_,total_settlement_fee_,create_time_,update_time_,tenant_id_)
  37. VALUES(#{id},#{examinationBasicId},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{teacherId},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{shareProfitAmount},
  38. #{totalInvigilationNum},#{totalInvigilationStudentNum},#{totalSettlementCost},NOW(),NOW(),#{tenantId})
  39. </insert>
  40. <insert id="batchInsert" parameterType="com.keao.edu.user.entity.ExamTeacherSalary" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  41. INSERT INTO exam_teacher_salary (examination_basic_id_,exam_mode_,teacher_id_,settlement_type_,share_profit_amount_,
  42. total_invigilation_num_,total_invigilation_student_num_,total_settlement_fee_,create_time_,update_time_,tenant_id_)
  43. VALUES
  44. <foreach collection="examTeacherSalaries" item="ets" separator=",">
  45. (#{ets.examinationBasicId},#{ets.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{ets.teacherId},
  46. #{ets.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{ets.shareProfitAmount},
  47. #{ets.totalInvigilationNum},#{ets.totalInvigilationStudentNum},#{ets.totalSettlementCost},NOW(),NOW(),#{ets.tenantId})
  48. </foreach>
  49. </insert>
  50. <!-- 根据主键查询一条记录 -->
  51. <update id="update" parameterType="com.keao.edu.user.entity.ExamTeacherSalary">
  52. UPDATE exam_teacher_salary
  53. <set>
  54. <if test="examinationBasicId != null">
  55. examination_basic_id_ = #{examinationBasicId},
  56. </if>
  57. <if test="teacherId != null">
  58. teacher_id_ = #{teacherId},
  59. </if>
  60. <if test="tenantId != null and tenantId != 0">
  61. tenant_id_ = #{tenantId},
  62. </if>
  63. <if test="examMode != null">
  64. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  65. </if>
  66. <if test="shareProfitAmount != null">
  67. share_profit_amount_ = #{shareProfitAmount},
  68. </if>
  69. <if test="settlementType != null">
  70. settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  71. </if>
  72. <if test="totalInvigilationNum != null">
  73. total_invigilation_num_ = #{totalInvigilationNum},
  74. </if>
  75. <if test="totalInvigilationStudentNum != null">
  76. total_invigilation_student_num_ = #{totalInvigilationStudentNum},
  77. </if>
  78. <if test="totalSettlementCost != null">
  79. total_settlement_fee_ = #{totalSettlementCost},
  80. </if>
  81. update_time_ = NOW()
  82. </set> WHERE id_ = #{id}
  83. </update>
  84. <update id="batchUpdate" parameterType="com.keao.edu.user.entity.ExamTeacherSalary">
  85. <foreach collection="teacherSalaries" item="ts" separator=";">
  86. UPDATE exam_teacher_salary
  87. <set>
  88. <if test="ts.examinationBasicId != null">
  89. examination_basic_id_ = #{ts.examinationBasicId},
  90. </if>
  91. <if test="ts.teacherId != null">
  92. teacher_id_ = #{ts.teacherId},
  93. </if>
  94. <if test="ts.tenantId != null">
  95. tenant_id_ = #{ts.tenantId},
  96. </if>
  97. <if test="ts.examMode != null">
  98. exam_mode_ = #{ts.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  99. </if>
  100. <if test="ts.shareProfitAmount != null">
  101. share_profit_amount_ = #{ts.shareProfitAmount},
  102. </if>
  103. <if test="ts.settlementType != null">
  104. settlement_type_ = #{ts.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  105. </if>
  106. <if test="ts.totalInvigilationNum != null">
  107. total_invigilation_num_ = #{ts.totalInvigilationNum},
  108. </if>
  109. <if test="ts.totalInvigilationStudentNum != null">
  110. total_invigilation_student_num_ = #{ts.totalInvigilationStudentNum},
  111. </if>
  112. <if test="ts.totalSettlementCost != null">
  113. total_settlement_fee_ = #{ts.totalSettlementCost},
  114. </if>
  115. update_time_ = NOW()
  116. </set> WHERE id_ = #{ts.id}
  117. </foreach>
  118. </update>
  119. <!-- 根据主键删除一条记录 -->
  120. <delete id="delete" >
  121. DELETE FROM exam_teacher_salary WHERE id_ = #{id}
  122. </delete>
  123. <sql id="queryPageCondition">
  124. <where>
  125. examination_basic_id_ = #{examId}
  126. </where>
  127. </sql>
  128. <!-- 分页查询 -->
  129. <select id="queryPage" resultMap="ExamTeacherSalary" parameterType="map">
  130. SELECT ets.*,su.real_name_ teacher_real_name_ FROM exam_teacher_salary ets
  131. LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
  132. <include refid="queryPageCondition"/>
  133. ORDER BY id_ <include refid="global.limit"/>
  134. </select>
  135. <!-- 查询当前表的总记录数 -->
  136. <select id="queryCount" resultType="int">
  137. SELECT COUNT(*) FROM exam_teacher_salary ets
  138. <include refid="queryPageCondition"/>
  139. </select>
  140. <sql id="queryExamTeacherSalaryCondition">
  141. <where>
  142. <if test="examId!=null">
  143. AND ets.examination_basic_id_ = #{examId}
  144. </if>
  145. <if test="teacherId!=null">
  146. AND ets.teacher_id_=#{teacherId}
  147. </if>
  148. <if test="settlementType!=null">
  149. AND ets.settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
  150. </if>
  151. <if test="search!=null">
  152. AND (ets.teacher_id_=#{search} OR su.real_name_ LIKE CONCAT('%', #{search}, '%'))
  153. </if>
  154. </where>
  155. </sql>
  156. <select id="queryExamTeacherSalary" resultMap="ExamTeacherSalaryDto" parameterType="map">
  157. SELECT ets.*,su.real_name_ teacher_real_name_,su.phone_ teacher_phone_
  158. FROM exam_teacher_salary ets
  159. LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
  160. <include refid="queryExamTeacherSalaryCondition"/>
  161. ORDER BY id_ <include refid="global.limit"/>
  162. </select>
  163. <select id="countExamTeacherSalary" resultType="int">
  164. SELECT COUNT(*) FROM exam_teacher_salary ets
  165. LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
  166. <include refid="queryExamTeacherSalaryCondition"/>
  167. </select>
  168. <select id="queryWithExam" resultMap="ExamTeacherSalary">
  169. SELECT * FROM exam_teacher_salary WHERE examination_basic_id_=#{examId}
  170. </select>
  171. <select id="getTeachersWithExam" resultMap="com.keao.edu.user.dao.SysUserDao.BaseUserInfoDto">
  172. SELECT <include refid="com.keao.edu.user.dao.SysUserDao.BaseUserColumns"/>
  173. FROM exam_teacher_salary ets
  174. LEFT JOIN sys_user sys_user ON ets.teacher_id_=sys_user.id_
  175. WHERE ets.examination_basic_id_=#{examId}
  176. </select>
  177. <select id="getWithExamAndTeacher" resultMap="ExamTeacherSalary">
  178. SELECT ets.*,su.real_name_ teacher_real_name_ FROM exam_teacher_salary ets
  179. LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
  180. WHERE ets.examination_basic_id_=#{examId} AND ets.teacher_id_ IN
  181. <foreach collection="teacherIds" item="teacherId" separator="," open="(" close=")">
  182. #{teacherId}
  183. </foreach>
  184. </select>
  185. <sql id="queryUnRelatedWithExamTeachersCondition">
  186. <where>
  187. t.tenant_id_=#{tenantId}
  188. AND NOT EXISTS ( SELECT teacher_id_ FROM exam_teacher_salary WHERE teacher_id_ = t.user_id_ AND examination_basic_id_ = #{examId} )
  189. </where>
  190. </sql>
  191. <select id="queryUnRelatedWithExamTeachers" resultMap="com.keao.edu.user.dao.TeacherDao.TeacherDto">
  192. SELECT
  193. t.*,
  194. su.real_name_ sys_user_real_name_
  195. FROM
  196. teacher t
  197. LEFT JOIN sys_user su ON t.user_id_ = su.id_
  198. <include refid="queryUnRelatedWithExamTeachersCondition"/>
  199. ORDER BY t.user_id_
  200. <include refid="global.limit"/>
  201. </select>
  202. <select id="countUnRelatedWithExamTeachers" resultType="int">
  203. SELECT
  204. COUNT(t.user_id_)
  205. FROM
  206. teacher t
  207. LEFT JOIN sys_user su ON t.user_id_ = su.id_
  208. <include refid="queryUnRelatedWithExamTeachersCondition"/>
  209. </select>
  210. <select id="getExamTeacherSalaryStaticsInfo"
  211. resultType="com.keao.edu.user.dto.ExamTeacherSalaryStaticsInfo">
  212. SELECT
  213. COUNT(DISTINCT teacher_id_) teacherNum,
  214. SUM(total_settlement_fee_) expectExpenseAmount
  215. FROM
  216. exam_teacher_salary
  217. WHERE
  218. examination_basic_id_ =#{examId}
  219. </select>
  220. </mapper>