<?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.willalp.stat.mapper.HsStatClockingInMapper">

    <resultMap type="com.willalp.stat.domain.HsStatClockingIn" id="HsStatClockingInResult">
        <result property="id" column="id"/>
        <result property="userCode" column="user_code"/>
        <result property="clockingInMonth" column="clocking_in_month"/>
        <result property="jobNo" column="job_no"/>
        <result property="userName" column="user_name"/>
        <result property="department" column="department"/>
        <result property="upLjjx" column="up_ljjx"/>
        <result property="upWorkLeave" column="up_work_leave"/>
        <result property="upYqAddLeave" column="up_yq_add_leave"/>
        <result property="upParentalLeave" column="up_parental_leave"/>
        <result property="upParentalLeaveEndTime" column="up_parental_leave_end_time"/>
        <result property="thisShouldJob" column="this_should_job"/>
        <result property="thisAlreadyJob" column="this_already_job"/>
        <result property="thisPersonalLeave" column="this_personal_leave"/>
        <result property="thisSickLeave" column="this_sick_leave"/>
        <result property="thisProductLeave" column="this_product_leave"/>
        <result property="thisWorkLeave" column="this_work_leave"/>
        <result property="thisAddLeave" column="this_add_leave"/>
        <result property="thisSumParentalLeave" column="this_sum_parental_leave"/>
        <result property="thisSumLjjx" column="this_sum_ljjx"/>
        <result property="thisSumWorkLeave" column="this_sum_work_leave"/>
        <result property="thisSumYqAddLeave" column="this_sum_yq_add_leave"/>
        <result property="orgCode" column="org_code"/>
        <result property="isDelete" column="is_delete"/>
        <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="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsStatClockingInVo">
        select id,
               user_code,
               clocking_in_month,
               job_no,
               user_name,
               department,
               up_ljjx,
               up_work_leave,
               up_yq_add_leave,
               up_parental_leave,
               up_parental_leave_end_time,
               this_should_job,
               this_already_job,
               this_personal_leave,
               this_sick_leave,
               this_product_leave,
               this_work_leave,
               this_add_leave,
               this_sum_parental_leave,
               this_sum_ljjx,
               this_sum_work_leave,
               this_sum_yq_add_leave,
               org_code,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_stat_clocking_in
    </sql>

    <select id="selectHsStatClockingInList" parameterType="HsStatClockingIn" resultMap="HsStatClockingInResult">
        <include refid="selectHsStatClockingInVo"/>
        <where>
            is_delete = 0
            and department = (
            select dept_name from sys_dept where dept_id = (
            select department from hs_org_personnel_files
            where is_delete = 0 and user_code = #{userCode}))
            <if test="clockingInMonth != null  and clockingInMonth != ''">
                and clocking_in_month = #{clockingInMonth}
            </if>
            <if test="jobNo != null  and jobNo != ''">
                and job_no like concat('%', #{jobNo}, '%')
            </if>
            <if test="userName != null  and userName != ''">
                and user_name like concat('%', #{userName}, '%')
            </if>
            <if test="upLjjx != null  and upLjjx != ''">
                and up_ljjx = #{upLjjx}
            </if>
            <if test="upWorkLeave != null  and upWorkLeave != ''">
                and up_work_leave = #{upWorkLeave}
            </if>
            <if test="upYqAddLeave != null  and upYqAddLeave != ''">
                and up_yq_add_leave = #{upYqAddLeave}
            </if>
            <if test="upParentalLeave != null  and upParentalLeave != ''">
                and up_parental_leave = #{upParentalLeave}
            </if>
            <if test="upParentalLeaveEndTime != null ">
                and up_parental_leave_end_time = #{upParentalLeaveEndTime}
            </if>
            <if test="thisShouldJob != null  and thisShouldJob != ''">
                and this_should_job = #{thisShouldJob}
            </if>
            <if test="thisAlreadyJob != null  and thisAlreadyJob != ''">
                and this_already_job = #{thisAlreadyJob}
            </if>
            <if test="thisPersonalLeave != null  and thisPersonalLeave != ''">
                and this_personal_leave = #{thisPersonalLeave}
            </if>
            <if test="thisSickLeave != null  and thisSickLeave != ''">
                and this_sick_leave = #{thisSickLeave}
            </if>
            <if test="thisProductLeave != null  and thisProductLeave != ''">
                and this_product_leave = #{thisProductLeave}
            </if>
            <if test="thisWorkLeave != null  and thisWorkLeave != ''">
                and this_work_leave = #{thisWorkLeave}
            </if>
            <if test="thisAddLeave != null  and thisAddLeave != ''">
                and this_add_leave = #{thisAddLeave}
            </if>
            <if test="thisSumParentalLeave != null  and thisSumParentalLeave != ''">
                and this_sum_parental_leave = #{thisSumParentalLeave}
            </if>
            <if test="thisSumLjjx != null  and thisSumLjjx != ''">
                and this_sum_ljjx = #{thisSumLjjx}
            </if>
            <if test="thisSumWorkLeave != null  and thisSumWorkLeave != ''">
                and this_sum_work_leave = #{thisSumWorkLeave}
            </if>
            <if test="thisSumYqAddLeave != null  and thisSumYqAddLeave != ''">
                and this_sum_yq_add_leave = #{thisSumYqAddLeave}
            </if>
            <if test="zend != null  and zend != ''">
                and zend = #{zend}
            </if>
            <if test="orgCode != null  and orgCode != ''">
                and org_code = #{orgCode}
            </if>
        </where>
    </select>
</mapper>
