XcglAssoXzbMapper.xml 11.3 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
<?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>
ilal committed
37 38 39 40 41 42 43 44
    
    <resultMap id="UserPersonnelDtoMap" type="cn.timer.api.dto.xcgl.UserPersonnelDto" >
            <result column="orgcode" property="orgcode" />
            <result column="empnum" property="empnum" />
            <result column="empname" property="empname" />
            <result column="dept" property="dept" />
            <result column="post" property="post" />
    </resultMap>
ilal committed
45 46 47 48 49
    
    <resultMap id="HolidayInquiryDtoMap" type="cn.timer.api.dto.xcgl.HolidayInquiryDto" >
            <result column="num" property="num" />
            <result column="balance" property="balance" />
    </resultMap>
yuquan.zhu committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

    <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>
ilal committed
68
    
ilal committed
69 70 71 72 73 74 75 76 77 78 79
    <select id="PayInColumn" resultMap="BaseResultMap">
    	select * from xcgl_asso_xzb zx
		where zx.xzxid = (select gg.id from xcgl_asso_jsgzzx gg
		where gg.optionid = 70
		and gg.xzzid = (select jsg.xzzid from xcgl_asso_jsgzzx jsg
		where jsg.id = #{xzxid})
		)
		and zx.userid = #{userid}
		and zx.xzyf = #{xzyf}
    </select>
    
ilal committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
    <select id="UserPersonnel" resultMap="UserPersonnelDtoMap">
    	select aa.orgcode,aa.empnum,aa.empname,aa.dept,aa.post
		from (select emp.org_code as orgcode,
						emp.emp_num as empnum,
						emp.`name` as empname,
						bmgw.dept,
			 			bmgw.post
				from yggl_main_emp emp
			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})
			) as aa
			where aa.orgcode = #{orgcode}
    </select>
    
ilal committed
97 98 99 100 101 102 103 104 105 106 107
    <select id="HolidayamountNum" resultMap="HolidayInquiryDtoMap">
    	select COUNT(*) as num
	    	from kqgl_asso_relation_summary su 
			where su.approval_type = 2
			and su.org_code = #{orgcode}
			and su.ordernum = 1
			and SUBSTR(su.app_time,1,7) = #{apptime}
			and su.leave_type_id = (select ru.id from kqgl_asso_leave_rules ru where ru.org_code = #{orgcode} and ru.rules_type = #{rules_type})
			and su.user_id = #{userid}
    </select>
    
ilal committed
108 109
    <select id="Holidayamount" resultMap="HolidayInquiryDtoMap">
	    select IFNULL(SUM(su.duration),0) as balance
ilal committed
110 111 112 113 114 115 116 117 118
	    	from kqgl_asso_relation_summary su 
			where su.approval_type = 2
			and su.org_code = #{orgcode}
			and su.ordernum = 1
			and SUBSTR(su.app_time,1,7) = #{apptime}
			and su.leave_type_id = (select ru.id from kqgl_asso_leave_rules ru where ru.org_code = #{orgcode} and ru.rules_type = #{rules_type})
			and su.user_id = #{userid}
	</select>
	
ilal committed
119 120
	<select id="NumberOvertime" resultMap="HolidayInquiryDtoMap">
	    select COUNT(*) as num
ilal committed
121 122 123 124 125 126 127
	    	from kqgl_asso_relation_summary su 
			where su.approval_type = 5
			and su.org_code = #{orgcode}
			and SUBSTR(su.app_time,1,7) = #{apptime}
			and su.user_id = #{userid}
	</select>
	
ilal committed
128 129
	<select id="PeriodsOvertime" resultMap="HolidayInquiryDtoMap">
		select IFNULL(SUM(su.duration),0) as balance
ilal committed
130 131 132 133 134 135 136
			from kqgl_asso_relation_summary su 
			where su.approval_type = 1
			and su.org_code = #{orgcode}
			and SUBSTR(su.app_time,1,7) = #{apptime}
			and su.overtime_type_id = #{overtimetypeid}
			and su.user_id = #{userid}
	</select>
yuquan.zhu committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

	<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
158
		where emp.emp_num in (select xzury.userid from xcgl_asso_xzury xzury where xzury.xzzid = #{paygroupid})
ilal committed
159
		<if test="text != null and text != ''" >
160 161
			and (emp.`name` like CONCAT('%',#{text},'%') or emp.emp_num = #{text})
		</if>
yuquan.zhu committed
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
		) 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}
		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})
ilal committed
210 211 212 213
			and xzyf = #{xzyf} -->
			
			DELETE FROM xcgl_asso_xzb
        WHERE userid = #{userid}
yuquan.zhu committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
			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>
279 280 281 282 283 284 285 286 287 288 289

	<!-- 批量更新薪资结果 -->
	<update id="updateBatchXzxjg" parameterType="java.util.List">
		<foreach collection="list" item="item" index="index" open="" close="" separator=";">
			UPDATE xcgl_asso_xzb
			<set>
				xzxjg=${item.xzxjg}
			</set>
			where id = ${item.id}
		</foreach>
	</update>
290 291 292 293 294
	
    <!-- <delete id="delete" >
        DELETE FROM xcgl_asso_xzb
        WHERE id = #{id}
    </delete>
yuquan.zhu committed
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323

    <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
324
    </select> -->
yuquan.zhu committed
325 326 327


</mapper>