XcglAssoXzbMapper.xml 7.91 KB
Newer Older
yuquan.zhu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
<?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.xcgl.XcglAssoXzbMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.xcgl.XcglAssoXzb" >
                <id column="id" property="id" />
                <result column="userid" property="userid" />
                <result column="xzyf" property="xzyf" />
                <result column="xzxid" property="xzxid" />
                <result column="xzxjg" property="xzxjg" />
                <result column="qyid" property="qyid" />
    </resultMap>
    
    <resultMap id="CalculationDtoMap" type="cn.timer.api.dto.xcgl.CalculationDto" >
            <result column="orgcode" property="orgcode" />
            <result column="empid" property="empid" />
            <result column="empnum" property="empnum" />
            <result column="empname" property="empname" />
            <result column="dept" property="dept" />
            <result column="post" property="post" />
            
            <collection property="calcu" ofType="cn.timer.api.dto.xcgl.CalculationValueDto">
		   		<result column="xzbid" property="xzbid"/>
		   		<result column="xzyf" property="xzyf"/>
		   		<result column="xzxid" property="xzxid"/>
		   		<result column="xzxjg" property="xzxjg"/>
		    </collection>
    </resultMap>
    
    <resultMap id="CalculationValueMap" type="cn.timer.api.dto.xcgl.CalculationValueDto" >
    			<result column="xzbid" property="xzbid"/>
                <result column="xzyf" property="xzyf"/>
		   		<result column="xzxid" property="xzxid"/>
		   		<result column="xzxjg" property="xzxjg"/>
    </resultMap>

    <sql id="Base_Column_List">
                id,
                userid,
                xzyf,
                xzxid,
                xzxjg,
                qyid
    </sql>
    
    <sql id="Base_Column_List_Alias">
                id XcglAssoXzb_id,
                userid XcglAssoXzb_userid,
                xzyf XcglAssoXzb_xzyf,
                xzxid XcglAssoXzb_xzxid,
                xzxjg XcglAssoXzb_xzxjg,
                qyid XcglAssoXzb_qyid
    </sql>

	<select id="CalculationResults" resultMap="CalculationDtoMap">
	select aa.orgcode,aa.empid,aa.empnum,aa.empname,aa.xzbid,aa.xzyf,
		aa.xzxid,aa.xzxjg,aa.dept,aa.post
	from (
		 		select emp.org_code as orgcode,
		 			emp.id as empid,
					emp.emp_num as empnum,
					emp.`name` as empname,
					xzbs.id as xzbid,
					xzbs.xzyf as xzyf,
					xzbs.xzxid as xzxid,
					xzbs.xzxjg as xzxjg,
					bmgw.dept,
		 			bmgw.post
			from yggl_main_emp emp
		LEFT JOIN  xcgl_asso_xzb as xzbs on xzbs.userid = emp.emp_num
		LEFT JOIN (select m.name as post,um.name as dept,m.id as mid
						 from zzgl_bmgw_m m 
						 left join zzgl_bmgw_m um on um.id = m.up_id  
					) as bmgw on bmgw.mid = emp.bmgw_id
		where emp.emp_num in (select xzury.userid from xcgl_asso_xzury xzury where xzury.xzzid = #{xzzid})
		and xzbs.xzyf = #{xzyf} or xzbs.xzyf = ''
		and emp.emp_num in (select xzury.userid from xcgl_asso_xzury xzury where xzury.xzzid = #{xzzid})
		) as aa
		where aa.orgcode = #{orgcode}
	</select>
	
	<select id="lateearlyDeduction" resultMap="CalculationValueMap">
			select xzbs.xzyf as xzyf,
					xzbs.xzxid as xzxid,
					xzbs.xzxjg as xzxjg
			from yggl_main_emp emp
		LEFT JOIN  xcgl_asso_xzb as xzbs on xzbs.userid = emp.emp_num
		where emp.emp_num = #{empnum}
		and xzbs.xzxid = (select jsgz.id from xcgl_asso_jsgzzx jsgz
					where jsgz.xzzid = #{xzzid}
					and jsgz.salaryitem = #{salaryitem})
	</select>
	
	<select id="SimultaneousAttendance" resultMap="CalculationDtoMap">
			select emp.id as empid,
					emp.emp_num as empnum,
					emp.`name` as empname,
					xzbs.id as xzbid,
					xzbs.xzyf as xzyf,
					xzbs.xzxid as xzxid,
					xzbs.xzxjg as xzxjg,
					bmgw.dept,
			 		bmgw.post
			from yggl_main_emp emp
		LEFT JOIN  xcgl_asso_xzb as xzbs on xzbs.userid = emp.emp_num
		LEFT JOIN (select m.name as post,um.name as dept,m.id as mid
						 from zzgl_bmgw_m m 
						 left join zzgl_bmgw_m um on um.id = m.up_id  
					) as bmgw on bmgw.mid = emp.bmgw_id
		where emp.emp_num in (select xzury.userid from xcgl_asso_xzury xzury
		where xzury.xzzid = #{xzzid})
		and xzbs.xzxid in (select jsgzzx.id from xcgl_asso_jsgzzx jsgzzx
			LEFT JOIN xcgl_asso_option as opt on opt.id = jsgzzx.optionid
			where opt.itemid = 2
			and jsgzzx.xzzid = #{xzzid})
	</select>
	

	<delete id="deleteByuserid" >
        <!-- DELETE FROM xcgl_asso_xzb
        WHERE userid = #{userid} -->
        
        DELETE FROM xcgl_asso_xzb
        WHERE userid = #{userid}
		and xzxid not in(select jsgzzx.id from xcgl_asso_jsgzzx jsgzzx
			LEFT JOIN xcgl_asso_option as opt on opt.id = jsgzzx.optionid
			where opt.itemid = 2
			and jsgzzx.xzzid = #{xzzid})
			and xzyf = #{xzyf}
    </delete>
    
    <delete id="deleteXcglAssoXzb">
    	DELETE FROM xcgl_asso_xzb
        WHERE userid = #{userid}
    </delete>
    
    <delete id="deleteByAttendance" >
    	DELETE from xcgl_asso_xzb
		where userid = #{userid}
		and xzxid in (select jsgzzx.id from xcgl_asso_jsgzzx jsgzzx
		LEFT JOIN xcgl_asso_option as opt on opt.id = jsgzzx.optionid
		where opt.itemid = 2
		and jsgzzx.xzzid = #{xzzid})
		and xzyf = #{xzyf}
    </delete>


    <insert id="xzbinsert" useGeneratedKeys="true" keyProperty="id" parameterType="cn.timer.api.bean.xcgl.XcglAssoXzb">
        INSERT INTO xcgl_asso_xzb
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != userid'>
                        userid,
                        </if>
                        <if test ='null != xzyf'>
                        xzyf,
                        </if>
                        <if test ='null != xzxid'>
                        xzxid,
                        </if>
                        <if test ='null != xzxjg'>
                        xzxjg,
                        </if>
                        <if test ='null != qyid'>
                        qyid
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != userid'>
                        #{userid},
                        </if>
                        <if test ='null != xzyf'>
                        #{xzyf},
                        </if>
                        <if test ='null != xzxid'>
                        #{xzxid},
                        </if>
                        <if test ='null != xzxjg'>
                        #{xzxjg},
                        </if>
                        <if test ='null != qyid'>
                        #{qyid}
                        </if>
        </trim>
    </insert>


	<update id="ModifyImportedSalary" parameterType="cn.timer.api.bean.xcgl.XcglAssoXzb">
		UPDATE xcgl_asso_xzb 
			set xzxjg = #{xzxjg}
		where userid = #{userid}
		and xzyf = #{xzyf}
		and xzxid = #{xzxid}
	</update>
195 196 197 198 199
	
    <!-- <delete id="delete" >
        DELETE FROM xcgl_asso_xzb
        WHERE id = #{id}
    </delete>
yuquan.zhu committed
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 225 226 227 228

    <update id="update" parameterType="cn.timer.api.bean.xcgl.XcglAssoXzb">
        UPDATE xcgl_asso_xzb
        <set>
                    <if test ='null != userid'>userid = #{userid},</if>
                    <if test ='null != xzyf'>xzyf = #{xzyf},</if>
                    <if test ='null != xzxid'>xzxid = #{xzxid},</if>
                    <if test ='null != xzxjg'>xzxjg = #{xzxjg},</if>
                    <if test ='null != qyid'>qyid = #{qyid}</if>
        </set>
        WHERE id = #{id}
    </update>


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

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

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM xcgl_asso_xzb
229
    </select> -->
yuquan.zhu committed
230 231 232


</mapper>