KqglAssoLeaveBalanceMapper.xml 10.6 KB
Newer Older
ilal committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?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="cn.timer.api.dao.kqmk.KqglAssoLeaveBalanceMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.kqmk.KqglAssoLeaveBalance" >
                <id column="id" property="id" />
                <result column="leave_rules_id" property="leaveRulesId" />
                <result column="userid" property="userid" />
                <result column="modify_action" property="modifyAction" />
                <result column="balance_days" property="balanceDays" />
                <result column="reason" property="reason" />
                <result column="modify_userid" property="modifyUserid" />
                <result column="modify_timer" property="modifyTimer" />
                <result column="modify_number" property="modifyNumber" />
                <result column="org_code" property="orgCode" />
ilal committed
17 18 19 20 21 22 23 24
                <result column="is_automatic" property="isAutomatic" />
    </resultMap>
    
    <resultMap id="LeaveBalanceMap" type="cn.timer.api.dto.kqmk.EmployeeLeaveBalanceDto" >
            <result column="empnum" property="empnum" />
            <result column="empname" property="empname" />
            <result column="department" property="department" />
            <result column="rztime" property="rztime" />
lal committed
25
            <result column="orgcode" property="orgcode" />
ilal committed
26 27 28 29
            <collection property="balanceTo" ofType="cn.timer.api.dto.kqmk.BalanceSheetDataDto">
		   		<result column="leaverulesid" property="leaverulesid"/>
		   		<result column="balancedays" property="balancedays"/>
		    </collection>
ilal committed
30
    </resultMap>
lal committed
31
    
lal committed
32 33 34 35 36
    <resultMap id="JiaqibalanceMap" type="cn.timer.api.dto.kqmk.JiaqibalanceDto" >
   			<result column="userid" property="userid" />
            <result column="balancedays" property="balancedays" />
    </resultMap>
    
lal committed
37 38 39 40 41 42
    <resultMap id="AdditionalMap" type="cn.timer.api.dto.kqmk.AdditionalDto" >
            <result column="empnum" property="empnum" />
            <result column="empname" property="empname" />
            <result column="department" property="department" />
            <result column="position" property="position" />
    </resultMap>
ilal committed
43 44 45 46 47 48 49 50 51 52 53

    <sql id="Base_Column_List">
                id,
                leave_rules_id,
                userid,
                modify_action,
                balance_days,
                reason,
                modify_userid,
                modify_timer,
                modify_number,
ilal committed
54 55
                org_code,
                is_automatic
ilal committed
56 57 58 59 60 61 62 63 64 65 66 67
    </sql>
    
    <sql id="Base_Column_List_Alias">
                id KqglAssoLeaveBalance_id,
                leave_rules_id KqglAssoLeaveBalance_leave_rules_id,
                userid KqglAssoLeaveBalance_userid,
                modify_action KqglAssoLeaveBalance_modify_action,
                balance_days KqglAssoLeaveBalance_balance_days,
                reason KqglAssoLeaveBalance_reason,
                modify_userid KqglAssoLeaveBalance_modify_userid,
                modify_timer KqglAssoLeaveBalance_modify_timer,
                modify_number KqglAssoLeaveBalance_modify_number,
ilal committed
68 69
                org_code KqglAssoLeaveBalance_org_code,
                is_automatic KqglAssoLeaveBalance_is_automatic
ilal committed
70
    </sql>
ilal committed
71 72
    
    <select id="selectPageByQueryLeaveBalance" resultMap="LeaveBalanceMap">
lal committed
73
	    	<!-- SELECT emp.emp_num as empnum,
ilal committed
74 75 76 77 78 79 80 81 82 83 84 85
				   emp.`name` as empname,
				   IFNULL(c.name,'') as department,
			       IFNULL(emp.rz_time,'') as rztime,
				   yz.leave_rules_id as leaverulesid,
				   yz.balancedays
			from yggl_main_emp emp
			LEFT JOIN zzgl_bmgw_m as gw on gw.id = emp.bmgw_id
			LEFT JOIN zzgl_bmgw_m as c ON c.id = gw.up_id
			LEFT JOIN (select bal.leave_rules_id,bal.userid,SUM(bal.balance_days) as balancedays 
						from kqgl_asso_leave_balance bal 
						where bal.org_code = #{param.orgCode} 
						GROUP BY bal.userid,bal.leave_rules_id) as yz on yz.userid = emp.emp_num
lal committed
86 87 88 89
			where emp.org_code = #{param.orgCode} -->
			
			SELECT emp.emp_num as empnum,
				   emp.`name` as empname,
lal committed
90
				   emp.org_code as orgcode,
lal committed
91
				   IFNULL(c.name,'') as department,
lal committed
92
			       IFNULL(emp.rz_time,'') as rztime
lal committed
93 94 95
			from yggl_main_emp emp
			LEFT JOIN zzgl_bmgw_m as gw on gw.id = emp.bmgw_id
			LEFT JOIN zzgl_bmgw_m as c ON c.id = gw.up_id
ilal committed
96
			where emp.org_code = #{param.orgCode}
lal committed
97
			and emp.job_status != 3
ilal committed
98 99 100 101 102
			<if test="param.query != null and param.query != ''">
				and (	emp.`name` like CONCAT('%',#{param.query},'%') or 
						emp.emp_num like CONCAT('%',#{param.query},'%') or
						c.name like CONCAT('%',#{param.query},'%'))
			</if>
lal committed
103 104 105
			<if test="param.deptid != null and param.deptid != ''">
				and c.id = #{param.deptid}
			</if>
lal committed
106 107 108 109
			<!-- ORDER BY emp.emp_num DESC
			LEFT JOIN kqgl_asso_leave_employee_balance as yz on yz.userid = emp.emp_num 
			yz.leave_rules_id as leaverulesid,
				   yz.balance_days as balancedays-->
ilal committed
110
    </select>
lal committed
111 112 113 114 115 116 117 118 119 120 121 122 123
    
    
    <select id="selectAdditional" resultMap="AdditionalMap">
    	SELECT emp.emp_num as empnum,
				   emp.`name` as empname,
				   IFNULL(c.name,'') as department,
			     gw.`name` as position
			from yggl_main_emp emp
			LEFT JOIN zzgl_bmgw_m as gw on gw.id = emp.bmgw_id
			LEFT JOIN zzgl_bmgw_m as c ON c.id = gw.up_id
			where emp.org_code = #{orgcode} 
			and emp.emp_num = #{empnum}
    </select>
lal committed
124 125 126 127
    
    <select id="selectAdditionalList" resultMap="AdditionalMap">
    	SELECT emp.emp_num as empnum,
				   emp.`name` as empname,
lal committed
128 129
				   IFNULL(c.name,null) as department,
			       IFNULL(gw.`name`,null) as position
lal committed
130 131 132 133
			from yggl_main_emp emp
			LEFT JOIN zzgl_bmgw_m as gw on gw.id = emp.bmgw_id
			LEFT JOIN zzgl_bmgw_m as c ON c.id = gw.up_id
			where emp.org_code = #{orgcode} 
lal committed
134
			and emp.job_status != 3
lal committed
135
    </select>
lal committed
136 137
    
    
lal committed
138
    <!-- <select id="selectleavebalanceList" resultMap="JiaqibalanceMap">
lal committed
139 140 141 142
    	select bal.userid,SUM(bal.balance_days) as balancedays 
			from kqgl_asso_leave_balance bal 
			where bal.leave_rules_id = #{leaverulesid} and bal.userid = #{userid}
			GROUP BY bal.userid
lal committed
143 144 145 146
    </select> -->

	<select id="Sumbalancedays" resultType="java.lang.Double">
        select SUM(ba.balance_days) from kqgl_asso_leave_balance ba where ba.userid = #{userid} and ba.org_code = #{orgcode} and ba.leave_rules_id = #{leaverulesid}
lal committed
147
    </select>
ilal committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.kqmk.KqglAssoLeaveBalance">
        INSERT INTO kqgl_asso_leave_balance
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != leaveRulesId'>
                        leave_rules_id,
                        </if>
                        <if test ='null != userid'>
                        userid,
                        </if>
                        <if test ='null != modifyAction'>
                        modify_action,
                        </if>
                        <if test ='null != balanceDays'>
                        balance_days,
                        </if>
                        <if test ='null != reason'>
                        reason,
                        </if>
                        <if test ='null != modifyUserid'>
                        modify_userid,
                        </if>
                        <if test ='null != modifyTimer'>
                        modify_timer,
                        </if>
                        <if test ='null != modifyNumber'>
                        modify_number,
                        </if>
                        <if test ='null != orgCode'>
ilal committed
179 180 181 182
                        org_code,
                        </if>
                        <if test ='null != isAutomatic'>
                        is_automatic
ilal committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != leaveRulesId'>
                        #{leaveRulesId},
                        </if>
                        <if test ='null != userid'>
                        #{userid},
                        </if>
                        <if test ='null != modifyAction'>
                        #{modifyAction},
                        </if>
                        <if test ='null != balanceDays'>
                        #{balanceDays},
                        </if>
                        <if test ='null != reason'>
                        #{reason},
                        </if>
                        <if test ='null != modifyUserid'>
                        #{modifyUserid},
                        </if>
                        <if test ='null != modifyTimer'>
                        #{modifyTimer},
                        </if>
                        <if test ='null != modifyNumber'>
                        #{modifyNumber},
                        </if>
                        <if test ='null != orgCode'>
ilal committed
211 212 213 214
                        #{orgCode},
                        </if>
                        <if test ='null != isAutomatic'>
                        #{isAutomatic}
ilal committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM kqgl_asso_leave_balance
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.kqmk.KqglAssoLeaveBalance">
        UPDATE kqgl_asso_leave_balance
        <set>
                    <if test ='null != leaveRulesId'>leave_rules_id = #{leaveRulesId},</if>
                    <if test ='null != userid'>userid = #{userid},</if>
                    <if test ='null != modifyAction'>modify_action = #{modifyAction},</if>
                    <if test ='null != balanceDays'>balance_days = #{balanceDays},</if>
                    <if test ='null != reason'>reason = #{reason},</if>
                    <if test ='null != modifyUserid'>modify_userid = #{modifyUserid},</if>
                    <if test ='null != modifyTimer'>modify_timer = #{modifyTimer},</if>
                    <if test ='null != modifyNumber'>modify_number = #{modifyNumber},</if>
ilal committed
235 236
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != isAutomatic'>is_automatic = #{isAutomatic}</if>
ilal committed
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM kqgl_asso_leave_balance
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM kqgl_asso_leave_balance
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM kqgl_asso_leave_balance
    </select>

	 -->

</mapper>