123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <!--
- 这个文件是自动生成的。
- 不要修改此文件。所有改动将在下次重新自动生成时丢失。
- -->
- <mapper namespace="com.keao.edu.user.dao.ExamTeacherSalaryDao">
-
- <resultMap type="com.keao.edu.user.entity.ExamTeacherSalary" id="ExamTeacherSalary">
- <result column="id_" property="id" />
- <result column="examination_basic_id_" property="examinationBasicId" />
- <result column="exam_mode_" property="examMode" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
- <result column="teacher_id_" property="teacherId" />
- <result column="settlement_type_" property="settlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
- <result column="share_profit_amount_" property="shareProfitAmount" />
- <result column="total_invigilation_num_" property="totalInvigilationNum"/>
- <result column="total_invigilation_student_num_" property="totalInvigilationStudentNum"/>
- <result column="total_settlement_fee_" property="totalSettlementCost"/>
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="tenant_id_" property="tenantId" />
- <association property="teacher" columnPrefix="teacher_" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
- </resultMap>
- <resultMap id="ExamTeacherSalaryDto" type="com.keao.edu.user.dto.ExamTeacherSalaryDto" extends="ExamTeacherSalary">
- </resultMap>
-
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="ExamTeacherSalary" >
- SELECT * FROM exam_teacher_salary WHERE id_ = #{id}
- </select>
-
- <!-- 全查询 -->
- <select id="findAll" resultMap="ExamTeacherSalary">
- SELECT * FROM exam_teacher_salary ORDER BY id_
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.keao.edu.user.entity.ExamTeacherSalary" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO exam_teacher_salary (id_,examination_basic_id_,exam_mode_,teacher_id_,settlement_type_,share_profit_amount_,
- total_invigilation_num_,total_invigilation_student_num_,total_settlement_fee_,create_time_,update_time_,tenant_id_)
- VALUES(#{id},#{examinationBasicId},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{teacherId},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{shareProfitAmount},
- #{totalInvigilationNum},#{totalInvigilationStudentNum},#{totalSettlementCost},NOW(),NOW(),#{tenantId})
- </insert>
- <insert id="batchInsert" parameterType="com.keao.edu.user.entity.ExamTeacherSalary" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO exam_teacher_salary (examination_basic_id_,exam_mode_,teacher_id_,settlement_type_,share_profit_amount_,
- total_invigilation_num_,total_invigilation_student_num_,total_settlement_fee_,create_time_,update_time_,tenant_id_)
- VALUES
- <foreach collection="examTeacherSalaries" item="ets" separator=",">
- (#{ets.examinationBasicId},#{ets.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{ets.teacherId},
- #{ets.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{ets.shareProfitAmount},
- #{ets.totalInvigilationNum},#{ets.totalInvigilationStudentNum},#{ets.totalSettlementCost},NOW(),NOW(),#{ets.tenantId})
- </foreach>
- </insert>
-
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.keao.edu.user.entity.ExamTeacherSalary">
- UPDATE exam_teacher_salary
- <set>
- <if test="examinationBasicId != null">
- examination_basic_id_ = #{examinationBasicId},
- </if>
- <if test="teacherId != null">
- teacher_id_ = #{teacherId},
- </if>
- <if test="tenantId != null and tenantId != 0">
- tenant_id_ = #{tenantId},
- </if>
- <if test="examMode != null">
- exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="shareProfitAmount != null">
- share_profit_amount_ = #{shareProfitAmount},
- </if>
- <if test="settlementType != null">
- settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="totalInvigilationNum != null">
- total_invigilation_num_ = #{totalInvigilationNum},
- </if>
- <if test="totalInvigilationStudentNum != null">
- total_invigilation_student_num_ = #{totalInvigilationStudentNum},
- </if>
- <if test="totalSettlementCost != null">
- total_settlement_fee_ = #{totalSettlementCost},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{id}
- </update>
- <update id="batchUpdate" parameterType="com.keao.edu.user.entity.ExamTeacherSalary">
- <foreach collection="teacherSalaries" item="ts" separator=";">
- UPDATE exam_teacher_salary
- <set>
- <if test="ts.examinationBasicId != null">
- examination_basic_id_ = #{ts.examinationBasicId},
- </if>
- <if test="ts.teacherId != null">
- teacher_id_ = #{ts.teacherId},
- </if>
- <if test="ts.tenantId != null">
- tenant_id_ = #{ts.tenantId},
- </if>
- <if test="ts.examMode != null">
- exam_mode_ = #{ts.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="ts.shareProfitAmount != null">
- share_profit_amount_ = #{ts.shareProfitAmount},
- </if>
- <if test="ts.settlementType != null">
- settlement_type_ = #{ts.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="ts.totalInvigilationNum != null">
- total_invigilation_num_ = #{ts.totalInvigilationNum},
- </if>
- <if test="ts.totalInvigilationStudentNum != null">
- total_invigilation_student_num_ = #{ts.totalInvigilationStudentNum},
- </if>
- <if test="ts.totalSettlementCost != null">
- total_settlement_fee_ = #{ts.totalSettlementCost},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{ts.id}
- </foreach>
- </update>
-
- <!-- 根据主键删除一条记录 -->
- <delete id="delete" >
- DELETE FROM exam_teacher_salary WHERE id_ = #{id}
- </delete>
- <sql id="queryPageCondition">
- <where>
- examination_basic_id_ = #{examId}
- </where>
- </sql>
-
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="ExamTeacherSalary" parameterType="map">
- SELECT ets.*,su.real_name_ teacher_real_name_ FROM exam_teacher_salary ets
- LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
- <include refid="queryPageCondition"/>
- ORDER BY id_ <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM exam_teacher_salary ets
- <include refid="queryPageCondition"/>
- </select>
- <sql id="queryExamTeacherSalaryCondition">
- <where>
- <if test="examId!=null">
- AND ets.examination_basic_id_ = #{examId}
- </if>
- <if test="teacherId!=null">
- AND ets.teacher_id_=#{teacherId}
- </if>
- <if test="settlementType!=null">
- AND ets.settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="search!=null">
- AND (ets.teacher_id_=#{search} OR su.real_name_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- </where>
- </sql>
- <select id="queryExamTeacherSalary" resultMap="ExamTeacherSalaryDto" parameterType="map">
- SELECT ets.*,su.real_name_ teacher_real_name_,su.phone_ teacher_phone_
- FROM exam_teacher_salary ets
- LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
- <include refid="queryExamTeacherSalaryCondition"/>
- ORDER BY id_ <include refid="global.limit"/>
- </select>
- <select id="countExamTeacherSalary" resultType="int">
- SELECT COUNT(*) FROM exam_teacher_salary ets
- LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
- <include refid="queryExamTeacherSalaryCondition"/>
- </select>
- <select id="queryWithExam" resultMap="ExamTeacherSalary">
- SELECT * FROM exam_teacher_salary WHERE examination_basic_id_=#{examId}
- </select>
- <select id="getTeachersWithExam" resultMap="com.keao.edu.user.dao.SysUserDao.BaseUserInfoDto">
- SELECT <include refid="com.keao.edu.user.dao.SysUserDao.BaseUserColumns"/>
- FROM exam_teacher_salary ets
- LEFT JOIN sys_user sys_user ON ets.teacher_id_=sys_user.id_
- WHERE ets.examination_basic_id_=#{examId}
- </select>
- <select id="getWithExamAndTeacher" resultMap="ExamTeacherSalary">
- SELECT ets.*,su.real_name_ teacher_real_name_ FROM exam_teacher_salary ets
- LEFT JOIN sys_user su ON ets.teacher_id_=su.id_
- WHERE ets.examination_basic_id_=#{examId} AND ets.teacher_id_ IN
- <foreach collection="teacherIds" item="teacherId" separator="," open="(" close=")">
- #{teacherId}
- </foreach>
- </select>
- <sql id="queryUnRelatedWithExamTeachersCondition">
- <where>
- t.tenant_id_=#{tenantId}
- AND NOT EXISTS ( SELECT teacher_id_ FROM exam_teacher_salary WHERE teacher_id_ = t.user_id_ AND examination_basic_id_ = #{examId} )
- </where>
- </sql>
- <select id="queryUnRelatedWithExamTeachers" resultMap="com.keao.edu.user.dao.TeacherDao.TeacherDto">
- SELECT
- t.*,
- su.real_name_ sys_user_real_name_
- FROM
- teacher t
- LEFT JOIN sys_user su ON t.user_id_ = su.id_
- <include refid="queryUnRelatedWithExamTeachersCondition"/>
- ORDER BY t.user_id_
- <include refid="global.limit"/>
- </select>
- <select id="countUnRelatedWithExamTeachers" resultType="int">
- SELECT
- COUNT(t.user_id_)
- FROM
- teacher t
- LEFT JOIN sys_user su ON t.user_id_ = su.id_
- <include refid="queryUnRelatedWithExamTeachersCondition"/>
- </select>
- <select id="getExamTeacherSalaryStaticsInfo"
- resultType="com.keao.edu.user.dto.ExamTeacherSalaryStaticsInfo">
- SELECT
- COUNT(DISTINCT teacher_id_) teacherNum,
- SUM(total_settlement_fee_) expectExpenseAmount
- FROM
- exam_teacher_salary
- WHERE
- examination_basic_id_ =#{examId}
- </select>
- </mapper>
|