KqglAssoLeaveBalanceMapper.xml 12.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
            <result column="turnover_status" property="turnover_status" />
ilal committed
27 28 29 30
            <collection property="balanceTo" ofType="cn.timer.api.dto.kqmk.BalanceSheetDataDto">
		   		<result column="leaverulesid" property="leaverulesid"/>
		   		<result column="balancedays" property="balancedays"/>
		    </collection>
ilal committed
31
    </resultMap>
lal committed
32
    
lal committed
33 34 35 36 37
    <resultMap id="JiaqibalanceMap" type="cn.timer.api.dto.kqmk.JiaqibalanceDto" >
   			<result column="userid" property="userid" />
            <result column="balancedays" property="balancedays" />
    </resultMap>
    
lal committed
38 39 40
    <resultMap id="AdditionalMap" type="cn.timer.api.dto.kqmk.AdditionalDto" >
            <result column="empnum" property="empnum" />
            <result column="empname" property="empname" />
lal committed
41
            <result column="phone" property="phone" />
lal committed
42 43 44
            <result column="department" property="department" />
            <result column="position" property="position" />
    </resultMap>
ilal committed
45 46 47 48 49 50 51 52 53 54 55

    <sql id="Base_Column_List">
                id,
                leave_rules_id,
                userid,
                modify_action,
                balance_days,
                reason,
                modify_userid,
                modify_timer,
                modify_number,
ilal committed
56 57
                org_code,
                is_automatic
ilal committed
58 59 60 61 62 63 64 65 66 67 68 69
    </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
70 71
                org_code KqglAssoLeaveBalance_org_code,
                is_automatic KqglAssoLeaveBalance_is_automatic
ilal committed
72
    </sql>
ilal committed
73 74
    
    <select id="selectPageByQueryLeaveBalance" resultMap="LeaveBalanceMap">
lal committed
75 76
			SELECT emp.emp_num as empnum,
				   emp.`name` as empname,
lal committed
77
				   emp.org_code as orgcode,
lal committed
78
				   IFNULL(c.name,'') as department,
ilal committed
79 80
			       IFNULL(emp.rz_time,'') as rztime,
			       IFNULL((select em.job_status from yggl_main_lzb em where em.emp_num = emp.emp_num and em.org_code = emp.org_code),0) as turnover_status
lal committed
81 82 83
			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
84 85 86 87 88 89
			where emp.org_code = #{param.orgCode}
			<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
90
			<if test="param.deptid != null and param.deptid != ''">
ilal committed
91
				and c.id in (select m.id from zzgl_bmgw_m m where m.up_id = #{param.deptid}) or (c.id =#{param.deptid})
lal committed
92
			</if>
ilal committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
			<if test="param.turnover_status == 0">
				and emp.emp_num not in (select em.emp_num from yggl_main_lzb em where em.org_code = #{param.orgCode} and em.job_status = 3)			
			</if>
			<if test="param.turnover_status == 1">
			UNION
				SELECT emp.emp_num AS empnum,
					emp.`name` AS empname,
					emp.org_code AS orgcode,
					IFNULL(c. NAME, '') AS department,
					IFNULL(emp.rz_time, '') AS rztime,
					IFNULL((select em.job_status from yggl_main_lzb em where em.emp_num = emp.emp_num and em.org_code = emp.org_code),0) as turnover_status
				FROM yggl_main_lzb 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 1=1
				<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>
				<if test="param.deptid != null and param.deptid != ''">
					and c.id in (select m.id from zzgl_bmgw_m m where m.up_id = #{param.deptid}) or (c.id =#{param.deptid})
				</if>
				and emp.org_code = #{param.orgCode}
ilal committed
117
				AND emp.job_status = 3
ilal committed
118
			</if>
ilal committed
119 120 121
			<!--and c.id = #{param.deptid} 
				
			ORDER BY emp.emp_num DESC
lal committed
122 123 124
			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
125
    </select>
lal committed
126 127 128 129 130 131 132 133 134 135 136 137 138
    
    
    <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
139 140 141 142
    
    <select id="selectAdditionalList" resultMap="AdditionalMap">
    	SELECT emp.emp_num as empnum,
				   emp.`name` as empname,
lal committed
143
				   emp.phone,
lal committed
144 145
				   IFNULL(c.name,null) as department,
			       IFNULL(gw.`name`,null) as position
lal committed
146 147 148 149
			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} 
ilal committed
150
			<!-- and emp.emp_num = 100083 -->
ilal committed
151
			<!-- and emp.job_status != 3 -->
lal committed
152
    </select>
lal committed
153
    
lal committed
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 179 180 181 182
    <select id="RealTimeUpdate" resultMap="AdditionalMap">
    		SELECT emp.emp_num as empnum,
				   emp.`name` as empname,
				   emp.phone,
				   IFNULL(c.name,null) as department,
			       IFNULL(gw.`name`,null) as position
			from yggl_main_emp emp
			LEFT JOIN kqgl_asso_yhkqz as yhkqz on yhkqz.userid = emp.emp_num
			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 yhkqz.kqzid = #{kqzid} 
			and emp.job_status != 3;
    </select>
    
    <select id="selectAdditionalByempnum" resultMap="AdditionalMap">
    	SELECT emp.emp_num as empnum,
				   emp.`name` as empname,
				   emp.phone,
				   IFNULL(c.name,null) as department,
			       IFNULL(gw.`name`,null) 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.job_status != 3
			and emp.emp_num = #{empnum}
    </select>
    
lal committed
183
    
lal committed
184
    <!-- <select id="selectleavebalanceList" resultMap="JiaqibalanceMap">
lal committed
185 186 187 188
    	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
189 190 191 192
    </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
193
    </select>
ilal committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224

	<!-- 

    <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
225 226 227 228
                        org_code,
                        </if>
                        <if test ='null != isAutomatic'>
                        is_automatic
ilal committed
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
                        </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
257 258 259 260
                        #{orgCode},
                        </if>
                        <if test ='null != isAutomatic'>
                        #{isAutomatic}
ilal committed
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
                        </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
281 282
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != isAutomatic'>is_automatic = #{isAutomatic}</if>
ilal committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
        </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>