evo-Financial-pc/evo-admin/target/classes/mapper/system/SysStaffMapper.xml
2025-05-04 11:02:42 +08:00

255 lines
15 KiB
XML

<?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.evo.system.mapper.SysStaffMapper">
<resultMap type="SysStaff" id="SysStaffResult">
<result property="userId" column="user_id" />
<result property="companyName" column="company_name" />
<result property="deptId" column="dept_id" />
<result property="code" column="code" />
<result property="name" column="name" />
<result property="idCard" column="id_card" />
<result property="isLeader" column="is_leader" />
<result property="sex" column="sex" />
<result property="age" column="age" />
<result property="phone" column="phone" />
<result property="address" column="address" />
<result property="level" column="level" />
<result property="major" column="major" />
<result property="school" column="school" />
<result property="bankNumber" column="bank_number" />
<result property="bank" column="bank" />
<result property="employmentDate" column="employment_date" />
<result property="experience" column="experience" />
<result property="workerTerm" column="worker_term" />
<result property="regularDate" column="regular_date" />
<result property="quitDate" column="quit_date" />
<result property="contractStart" column="contract_start" />
<result property="contractEnd" column="contract_end" />
<result property="contractType" column="contract_type" />
<result property="socialType" column="social_type" />
<result property="seniority" column="seniority" />
<result property="isOvertimePay" column="is_overtime_pay" />
<result property="zsFlag" column="zs_flag" />
<result property="secrecy" column="secrecy" />
<result property="injury" column="injury" />
<result property="insurance" column="insurance" />
<result property="introducer" column="introducer" />
<result property="clockIn" column="clock_in" />
<result property="status" column="status" />
<result property="wagesRatioDate" column="wages_ratio_date" />
<result property="remarks" column="remarks" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="socialSubsidy" column="social_subsidy" />
</resultMap>
<sql id="selectSysStaffVo">
select user_id,company_name, dept_id, code, name, id_card,is_leader, sex, age, phone, address, level, major, school, bank_number,social_subsidy, bank, employment_date, experience, worker_term, regular_date, quit_date, contract_start, contract_end, contract_type, social_type, seniority, is_overtime_pay, zs_flag, secrecy, injury, insurance, introducer, clock_in, status, wages_ratio_date, remarks, del_flag, create_by, create_time, update_by, update_time from sys_staff
</sql>
<select id="selectSysStaffList" parameterType="SysStaff" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
<where>
del_flag = '0'
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="employmentDate != null"> and DATE_FORMAT(employment_date, '%Y%m') = DATE_FORMAT(#{employmentDate} , '%Y%m')</if>
<choose>
<when test="status != null and status != ''">
and status = #{status}
</when>
<otherwise>
and status != '-1'
</otherwise>
</choose>
<if test="experience != null and experience != ''"> and experience like concat('%', #{experience}, '%')</if>
<if test="isOvertimePay != null and isOvertimePay != ''"> and is_overtime_pay = #{isOvertimePay}</if>
<if test="zsFlag != null and zsFlag != ''"> and zs_flag = #{zsFlag}</if>
<if test="companyName != null and companyName != ''"> and company_name = #{companyName}</if>
</where>
</select>
<select id="selectSysStaffByUserId" parameterType="Long" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
where user_id = #{userId}
</select>
<insert id="insertSysStaff" parameterType="SysStaff" useGeneratedKeys="true" keyProperty="userId">
insert into sys_staff
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyName != null">company_name,</if>
<if test="deptId != null">dept_id,</if>
<if test="code != null and code != ''">code,</if>
<if test="name != null and name != ''">name,</if>
<if test="idCard != null and idCard != ''">id_card,</if>
<if test="isLeader != null and isLeader != ''">is_leader,</if>
<if test="sex != null">sex,</if>
<if test="age != null">age,</if>
<if test="phone != null">phone,</if>
<if test="address != null">address,</if>
<if test="level != null">level,</if>
<if test="major != null">major,</if>
<if test="school != null">school,</if>
<if test="bankNumber != null">bank_number,</if>
<if test="bank != null">bank,</if>
<if test="employmentDate != null">employment_date,</if>
<if test="experience != null">experience,</if>
<if test="workerTerm != null">worker_term,</if>
<if test="regularDate != null">regular_date,</if>
<if test="quitDate != null">quit_date,</if>
<if test="contractStart != null">contract_start,</if>
<if test="contractEnd != null">contract_end,</if>
<if test="contractType != null">contract_type,</if>
<if test="socialType != null">social_type,</if>
<if test="seniority != null">seniority,</if>
<if test="isOvertimePay != null and isOvertimePay != ''">is_overtime_pay,</if>
<if test="zsFlag != null">zs_flag,</if>
<if test="secrecy != null">secrecy,</if>
<if test="injury != null">injury,</if>
<if test="insurance != null">insurance,</if>
<if test="introducer != null">introducer,</if>
<if test="clockIn != null">clock_in,</if>
<if test="status != null and status != ''">status,</if>
<if test="wagesRatioDate != null">wages_ratio_date,</if>
<if test="remarks != null">remarks,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="socialSubsidy != null">social_subsidy,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyName != null">#{companyName},</if>
<if test="deptId != null">#{deptId},</if>
<if test="code != null and code != ''">#{code},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="idCard != null and idCard != ''">#{idCard},</if>
<if test="isLeader != null and isLeader != ''">#{isLeader},</if>
<if test="sex != null">#{sex},</if>
<if test="age != null">#{age},</if>
<if test="phone != null">#{phone},</if>
<if test="address != null">#{address},</if>
<if test="level != null">#{level},</if>
<if test="major != null">#{major},</if>
<if test="school != null">#{school},</if>
<if test="bankNumber != null">#{bankNumber},</if>
<if test="bank != null">#{bank},</if>
<if test="employmentDate != null">#{employmentDate},</if>
<if test="experience != null">#{experience},</if>
<if test="workerTerm != null">#{workerTerm},</if>
<if test="regularDate != null">#{regularDate},</if>
<if test="quitDate != null">#{quitDate},</if>
<if test="contractStart != null">#{contractStart},</if>
<if test="contractEnd != null">#{contractEnd},</if>
<if test="contractType != null">#{contractType},</if>
<if test="socialType != null">#{socialType},</if>
<if test="seniority != null">#{seniority},</if>
<if test="isOvertimePay != null and isOvertimePay != ''">#{isOvertimePay},</if>
<if test="zsFlag != null">#{zsFlag},</if>
<if test="secrecy != null">#{secrecy},</if>
<if test="injury != null">#{injury},</if>
<if test="insurance != null">#{insurance},</if>
<if test="introducer != null">#{introducer},</if>
<if test="clockIn != null">#{clockIn},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="wagesRatioDate != null">#{wagesRatioDate},</if>
<if test="remarks != null">#{remarks},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="socialSubsidy != null">#{socialSubsidy},</if>
</trim>
</insert>
<update id="updateSysStaff" parameterType="SysStaff">
update sys_staff
<trim prefix="SET" suffixOverrides=",">
<if test="companyName != null">company_name = #{companyName},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="code != null and code != ''">code = #{code},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
<if test="isLeader != null and isLeader != ''">is_leader = #{isLeader},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="age != null">age = #{age},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="address != null">address = #{address},</if>
<if test="level != null">level = #{level},</if>
<if test="major != null">major = #{major},</if>
<if test="school != null">school = #{school},</if>
<if test="bankNumber != null">bank_number = #{bankNumber},</if>
<if test="bank != null">bank = #{bank},</if>
<if test="employmentDate != null">employment_date = #{employmentDate},</if>
<if test="experience != null">experience = #{experience},</if>
<if test="workerTerm != null">worker_term = #{workerTerm},</if>
<if test="regularDate != null">regular_date = #{regularDate},</if>
<if test="quitDate != null">quit_date = #{quitDate},</if>
<if test="contractStart != null">contract_start = #{contractStart},</if>
<if test="contractEnd != null">contract_end = #{contractEnd},</if>
<if test="contractType != null">contract_type = #{contractType},</if>
<if test="socialType != null">social_type = #{socialType},</if>
<if test="seniority != null">seniority = #{seniority},</if>
<if test="isOvertimePay != null and isOvertimePay != ''">is_overtime_pay = #{isOvertimePay},</if>
<if test="zsFlag != null">zs_flag = #{zsFlag},</if>
<if test="secrecy != null">secrecy = #{secrecy},</if>
<if test="injury != null">injury = #{injury},</if>
<if test="insurance != null">insurance = #{insurance},</if>
<if test="introducer != null">introducer = #{introducer},</if>
<if test="clockIn != null">clock_in = #{clockIn},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="wagesRatioDate != null">wages_ratio_date = #{wagesRatioDate},</if>
<if test="remarks != null">remarks = #{remarks},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="socialSubsidy != null">social_subsidy = #{socialSubsidy},</if>
</trim>
where user_id = #{userId}
</update>
<!-- 查询所有的在职员工信息 -->
<select id="selectSysStaffListAll" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
where del_flag = '0' and status != '-1'
</select>
<!-- 根据身份证号查询员工 -->
<select id="queryysStaffByIdCard" parameterType="String" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
where id_card = #{idCard} and del_flag = '0'
</select>
<!-- 根据身份证号和部门ID查询员工 -->
<select id="queryysStaffByIdCardAndDeptId" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
where id_card = #{idCard} and dept_id = #{deptId} and del_flag = '1'
</select>
<!-- 根据公司名称查询公司最大编码 -->
<select id="querySysStaffOfMaxByCompany" parameterType="String" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
where company_name = #{compayName} order by code desc limit 1
</select>
<!-- 查询需要发放工资的员工信息 在职员工且入职时间在统计月或以前的或着在统计月离职的员工-->
<select id="querySysStaffListOfMonth" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
where del_flag = '0' and DATE_FORMAT(employment_date, '%Y%m%d') &lt; DATE_FORMAT(#{emplDate} , '%Y%m%d')
and (status != '-1' or DATE_FORMAT(quit_date, '%Y%m%d') &gt; DATE_FORMAT(#{quitDate} , '%Y%m%d'))
</select>
<!-- 根据部门查询在职且存在的员工 -->
<select id="queryysStaffByDeptId" parameterType="java.util.List" resultMap="SysStaffResult">
<include refid="selectSysStaffVo"/>
where del_flag = '0' and status != '-1' and dept_id in
<foreach collection="list" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</select>
</mapper>