KqglAssoMonthPunchSummaryMapper.xml 33.1 KB
Newer Older
lal 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
<?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.KqglAssoMonthPunchSummaryMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.kqmk.KqglAssoMonthPunchSummary" >
                <id column="id" property="id" />
                <result column="name" property="name" />
                <result column="num" property="num" />
                <result column="dept" property="dept" />
                <result column="post" property="post" />
                <result column="att_group" property="attGroup" />
                <result column="shift" property="shift" />
                <result column="days_on_duty" property="daysOnDuty" />
                <result column="actual_att_days" property="actualAttDays" />
                <result column="days_off" property="daysOff" />
                <result column="working_hours" property="workingHours" />
                <result column="late_times" property="lateTimes" />
                <result column="late_hours" property="lateHours" />
                <result column="serious_late_times" property="seriousLateTimes" />
                <result column="serious_late_hours" property="seriousLateHours" />
                <result column="absen_late_times" property="absenLateTimes" />
                <result column="early_leave_times" property="earlyLeaveTimes" />
                <result column="length_early_leave" property="lengthEarlyLeave" />
                <result column="number_work_card_shortage" property="numberWorkCardShortage" />
                <result column="number_duty_card_shortage" property="numberDutyCardShortage" />
                <result column="absenteeism_days" property="absenteeismDays" />
                <result column="length_business_trip" property="lengthBusinessTrip" />
                <result column="time_out" property="timeOut" />
                <result column="total_overtime_hours" property="totalOvertimeHours" />
                <result column="working_turn_compen_leave" property="workingTurnCompenLeave" />
                <result column="rest_turn_compen_leave" property="restTurnCompenLeave" />
                <result column="holiday_turn_compen_leave" property="holidayTurnCompenLeave" />
                <result column="working_transfer_overtime" property="workingTransferOvertime" />
                <result column="rest_transfer_overtime" property="restTransferOvertime" />
                <result column="holiday_transfer_overtime" property="holidayTransferOvertime" />
                <result column="day1" property="day1" />
                <result column="day2" property="day2" />
                <result column="day3" property="day3" />
                <result column="day4" property="day4" />
                <result column="day5" property="day5" />
                <result column="day6" property="day6" />
                <result column="day7" property="day7" />
                <result column="day8" property="day8" />
                <result column="day9" property="day9" />
                <result column="day10" property="day10" />
                <result column="day11" property="day11" />
                <result column="day12" property="day12" />
                <result column="day13" property="day13" />
                <result column="day14" property="day14" />
                <result column="day15" property="day15" />
                <result column="day16" property="day16" />
                <result column="day17" property="day17" />
                <result column="day18" property="day18" />
                <result column="day19" property="day19" />
                <result column="day20" property="day20" />
                <result column="day21" property="day21" />
                <result column="day22" property="day22" />
                <result column="day23" property="day23" />
                <result column="day24" property="day24" />
                <result column="day25" property="day25" />
                <result column="day26" property="day26" />
                <result column="day27" property="day27" />
                <result column="day28" property="day28" />
                <result column="day29" property="day29" />
                <result column="day30" property="day30" />
                <result column="day31" property="day31" />
                <result column="belong_year" property="belongYear" />
                <result column="belong_month" property="belongMonth" />
                <result column="org_code" property="orgCode" />
                <result column="last_modified" property="lastModified" />
    </resultMap>
lal committed
73 74 75 76 77 78 79 80
    
    <resultMap id="SummarydataMap" type="cn.timer.api.dto.kqmk.KqglAssoMonthPunchSummaryDto" >
                <id column="id" property="id" />
                <result column="name" property="name" />
                <result column="num" property="num" />
                <result column="dept" property="dept" />
                <result column="post" property="post" />
                <result column="att_group" property="attGroup" />
lal committed
81
                <result column="attname" property="attname" />
lal committed
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
                <result column="shift" property="shift" />
                <result column="days_on_duty" property="daysOnDuty" />
                <result column="actual_att_days" property="actualAttDays" />
                <result column="days_off" property="daysOff" />
                <result column="working_hours" property="workingHours" />
                <result column="late_times" property="lateTimes" />
                <result column="late_hours" property="lateHours" />
                <result column="serious_late_times" property="seriousLateTimes" />
                <result column="serious_late_hours" property="seriousLateHours" />
                <result column="absen_late_times" property="absenLateTimes" />
                <result column="early_leave_times" property="earlyLeaveTimes" />
                <result column="length_early_leave" property="lengthEarlyLeave" />
                <result column="number_work_card_shortage" property="numberWorkCardShortage" />
                <result column="number_duty_card_shortage" property="numberDutyCardShortage" />
                <result column="absenteeism_days" property="absenteeismDays" />
                <result column="length_business_trip" property="lengthBusinessTrip" />
                <result column="time_out" property="timeOut" />
                <result column="total_overtime_hours" property="totalOvertimeHours" />
                <result column="working_turn_compen_leave" property="workingTurnCompenLeave" />
                <result column="rest_turn_compen_leave" property="restTurnCompenLeave" />
                <result column="holiday_turn_compen_leave" property="holidayTurnCompenLeave" />
                <result column="working_transfer_overtime" property="workingTransferOvertime" />
                <result column="rest_transfer_overtime" property="restTransferOvertime" />
                <result column="holiday_transfer_overtime" property="holidayTransferOvertime" />
                <result column="day1" property="day1" />
                <result column="day2" property="day2" />
                <result column="day3" property="day3" />
                <result column="day4" property="day4" />
                <result column="day5" property="day5" />
                <result column="day6" property="day6" />
                <result column="day7" property="day7" />
                <result column="day8" property="day8" />
                <result column="day9" property="day9" />
                <result column="day10" property="day10" />
                <result column="day11" property="day11" />
                <result column="day12" property="day12" />
                <result column="day13" property="day13" />
                <result column="day14" property="day14" />
                <result column="day15" property="day15" />
                <result column="day16" property="day16" />
                <result column="day17" property="day17" />
                <result column="day18" property="day18" />
                <result column="day19" property="day19" />
                <result column="day20" property="day20" />
                <result column="day21" property="day21" />
                <result column="day22" property="day22" />
                <result column="day23" property="day23" />
                <result column="day24" property="day24" />
                <result column="day25" property="day25" />
                <result column="day26" property="day26" />
                <result column="day27" property="day27" />
                <result column="day28" property="day28" />
                <result column="day29" property="day29" />
                <result column="day30" property="day30" />
                <result column="day31" property="day31" />
                <result column="belong_year" property="belongYear" />
                <result column="belong_month" property="belongMonth" />
                <result column="org_code" property="orgCode" />
                <result column="last_modified" property="lastModified" />
                
ilal committed
142 143
                <result column="turnover_status" property="turnover_status" />
                
lal committed
144
                <collection property="balanceTo" ofType="cn.timer.api.dto.kqmk.BalanceSheetDataDto">
lal committed
145
                	<id column="yzid" property="yzid"/>
lal committed
146 147 148 149
			   		<result column="leaverulesid" property="leaverulesid"/>
			   		<result column="balancedays" property="balancedays"/>
			    </collection>
    </resultMap>
lal committed
150 151 152 153 154 155
    
    <resultMap id="DailyDetailsMap" type="cn.timer.api.dto.kqmk.DailyDetailsDto" >
                <result column="name" property="name" />
                <result column="num" property="num" />
                <result column="dept" property="dept" />
                <result column="post" property="post" />
lal committed
156
                <result column="orgcode" property="orgcode" />
lal committed
157
                
lal committed
158 159 160 161 162 163 164
                <result column="address" property="address" />
                <result column="remarks" property="remarks" />
                <result column="cardtype" property="cardtype" />
                <result column="macaddress" property="macaddress" />
                <result column="macname" property="macname" />
                
                 <result column="bcszid" property="bcszid" />
lal committed
165 166 167 168 169 170 171
                 <result column="bcname" property="bcname" />
                 <result column="bcsbdk1" property="bcsbdk1" />
                 <result column="bcxbdk1" property="bcxbdk1" />
                 <result column="bcsbdk2" property="bcsbdk2" />
                 <result column="bcxbdk2" property="bcxbdk2" />
                 <result column="bcsbdk3" property="bcsbdk3" />
                 <result column="bcxbdk3" property="bcxbdk3" />
lal committed
172
                 <result column="isxbdk" property="isxbdk" />
lal committed
173
                 
ilal committed
174 175 176 177
                 <result column="dkst1" property="dkst1" />
                 <result column="dkst2" property="dkst2" />
                 <result column="dkst3" property="dkst3" />
                 
lal committed
178 179 180 181 182 183
                 <result column="dktj1" property="dktj1" />
                 <result column="dktj2" property="dktj2" />
                 <result column="dktj3" property="dktj3" />
                 <result column="dktj4" property="dktj4" />
                 <result column="dktj5" property="dktj5" />
                 <result column="dktj6" property="dktj6" />
lal committed
184
                
lal committed
185
                <result column="attname" property="attname" />
lal committed
186
                <result column="attpbfs" property="attpbfs" />
lal committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
                <result column="attdate" property="attdate" />
                <result column="userid" property="userid" />
                <result column="data" property="data" />
                <result column="sbdk1" property="sbdk1" />
                <result column="sbdk1jg" property="sbdk1jg" />
                <result column="xbdk1" property="xbdk1" />
                <result column="xbdk1jg" property="xbdk1jg" />
                <result column="sbdk2" property="sbdk2" />
                <result column="sbdk2jg" property="sbdk2jg" />
                <result column="xbdk2" property="xbdk2" />
                <result column="xbdk2jg" property="xbdk2jg" />
                <result column="sbdk3" property="sbdk3" />
                <result column="sbdk3jg" property="sbdk3jg" />
                <result column="xbdk3" property="xbdk3" />
                <result column="xbdk3jg" property="xbdk3jg" />
lal committed
202 203 204 205
                
                <result column="sbcdzs" property="sbcdzs" />
                <result column="xbztzs" property="xbztzs" />
                
lal committed
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
                <result column="ydkcs" property="ydkcs" />
                <result column="gzsc" property="gzsc" />
                <result column="qyid" property="qyid" />
                <result column="dksj" property="dksj" />
                <result column="yzcdcs" property="yzcdcs" />
                <result column="yzcdsc" property="yzcdsc" />
                <result column="kgcdfzs" property="kgcdfzs" />
                <result column="daysonduty" property="daysonduty" />
                <result column="daysoff" property="daysoff" />
				<result column="lengthbusinesstrip" property="lengthbusinesstrip" />
				<result column="timeout" property="timeout" />
				<result column="totalovertimehours" property="totalovertimehours" />
			    <result column="workingturncompenleave" property="workingturncompenleave" />
				<result column="restturncompenleave" property="restturncompenleave" />
				<result column="holidayturncompenleave" property="holidayturncompenleave" />
				<result column="workingtransferovertime" property="workingtransferovertime" />
				<result column="resttransferovertime" property="resttransferovertime" />
				<result column="holidaytransferovertime" property="holidaytransferovertime" />
			    <result column="leaverulesid" property="leaverulesid" />
			    <result column="duration" property="duration" />
			    
			    <collection property="balanceTo" ofType="cn.timer.api.dto.kqmk.BalanceSheetDataDto">
lal committed
228
			    	<id column="yzid" property="yzid"/>
lal committed
229 230 231 232
			   		<result column="leaverulesid" property="leaverulesid"/>
			   		<result column="balancedays" property="balancedays"/>
			    </collection>
    </resultMap>
lal committed
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
    
    <resultMap id="BalanceSheetDataMap" type="cn.timer.api.dto.kqmk.BalanceSheetDataDto" >
    			<id column="yzid" property="yzid"/>
		   		<result column="leaverulesid" property="leaverulesid"/>
		   		<result column="balancedays" property="balancedays"/>
    </resultMap>
	
	
	 <select id="AttenSumDailyDetails" resultMap="BalanceSheetDataMap">
	 	select SUM(su.duration) as balancedays,su.leave_type_id as leaverulesid from kqgl_asso_relation_summary su 
			where su.org_code = #{orgcode}
			and su.approval_type = 2 
			and su.user_id = #{userid}
			and su.app_time = #{apptime}
			GROUP BY su.leave_type_id
	 </select>
	
lal committed
250
	<select id="MonthlySummaryLeave" resultMap="BalanceSheetDataMap">
ilal committed
251
			<!-- select aa.leaverulesid,SUM(aa.balancedays) as balancedays from (
lal committed
252 253 254 255 256 257
				select res.leave_type_id as leaverulesid,res.duration as balancedays from kqgl_asso_relation_summary res 
				where res.user_id = #{userid}
				and res.approval_type = 2
				and res.org_code = #{orgcode}
				and SUBSTR(res.app_time,1,7) = #{apptime}
				GROUP BY res.leave_type_id,res.duration) as aa
ilal committed
258 259 260 261 262 263 264 265 266 267 268 269 270
			GROUP BY aa.leaverulesid -->
			
			select aa.leaverulesid,SUM(aa.balancedays) as balancedays from (
				select res.leave_type_id as leaverulesid,
								res.duration as balancedays 
				 from kqgl_asso_relation_summary res
				where res.user_id = #{userid}
					and res.approval_type = 2
					and res.org_code = #{orgcode}
					and SUBSTR(res.app_time,1,7) = #{apptime}
					and res.ordernum = 1
				) as aa
				GROUP BY aa.leaverulesid
lal committed
271 272 273 274 275 276 277 278 279 280 281 282
	</select>
	
	<select id="FormMonthlySummaryLeave" resultMap="BalanceSheetDataMap">
		select IFNULL(SUM(aa.balancedays),0) as balancedays  from (
				select res.leave_type_id as leaverulesid,res.duration as balancedays from kqgl_asso_relation_summary res 
				where res.user_id = #{userid}
				and res.approval_type = 2
				and res.org_code = #{orgcode}
				and SUBSTR(res.app_time,1,7) = #{apptime}
				GROUP BY res.leave_type_id,res.duration
			) as aa
	</select>
lal committed
283
    
lal committed
284
     <select id="AttendanceSummaryData" resultMap="SummarydataMap">
lal committed
285
			select sum.*,
ilal committed
286
     	       (select kqz.name from kqgl_main_kqz kqz where kqz.id = sum.att_group) as attname,
ilal committed
287
     	       IFNULL((select em.job_status from yggl_main_lzb em where em.emp_num = sum.num and em.org_code = sum.org_code LIMIT 1),0) as turnover_status
lal committed
288 289 290 291 292 293 294 295 296 297 298
			from kqgl_asso_month_punch_summary sum
			where sum.org_code = #{param.orgCode}
			and sum.belong_year = #{param.year}
			and sum.belong_month = #{param.month}
			<if test="param.query != null and param.query != ''">
				and (	sum.`name` like CONCAT('%',#{param.query},'%') or 
						sum.num like CONCAT('%',#{param.query},'%'))
			</if>
			<if test="param.attid != null and param.attid != ''">
				and sum.att_group = #{param.attid}
			</if>
ilal committed
299 300 301
			<if test="param.turnover_status == 1">
				and sum.num not in (select em.emp_num from yggl_main_lzb em where em.org_code = #{param.orgCode} and em.job_status = 3)
			</if>
lal committed
302
			
lal committed
303 304 305 306 307
			<!-- yz.id as yzid,
				yz.leave_rules_id as leaverulesid,
				yz.balance_days as balancedays
			LEFT JOIN kqgl_asso_leave_employee_balance as yz on yz.userid = sum.num
			ORDER BY sum.num DESC -->
lal committed
308
     </select>
lal committed
309

lal committed
310
	<select id="Dailydetails" resultMap="DailyDetailsMap">
lal committed
311 312 313 314
				select sum.num,
					sum.`name`,
					sum.org_code as orgcode,
					sum.dept,sum.post,
lal committed
315 316 317 318
					IFNULL((select kqz.name from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') as attname,
					IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') as attpbfs,
					IFNULL((select kqz.id from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') as attid,
					(CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
319 320
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
321 322 323 324 325
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
326
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
327 328 329 330
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END) as bcszid,
					IFNULL((select bc.name from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
331 332
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
333 334 335 336 337
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
338
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
339 340 341 342
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcname,		
					IFNULL((select bc.sbdk1 from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
343 344
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
345 346 347 348 349
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
350
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
351 352
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
ilal committed
353
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcsbdk1,	
lal committed
354
					IFNULL((select bc.xbdk1 from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
355 356
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
357 358 359 360 361
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
362
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
363 364
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
ilal committed
365
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcxbdk1,	
lal committed
366
					IFNULL((select bc.sbdk2 from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
367 368
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
369 370 371 372 373
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
374
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
375 376 377 378
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcsbdk2,	
					IFNULL((select bc.xbdk2 from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
379 380
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
381 382 383 384 385
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
386
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
387 388
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
ilal committed
389
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcxbdk2,		
lal committed
390
					IFNULL((select bc.sbdk3 from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
391 392
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
393 394 395 396 397
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
398
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
399 400
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
ilal committed
401
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcsbdk3,		
lal committed
402
					IFNULL((select bc.xbdk3 from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
403 404
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
405 406 407 408 409
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
410
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
411 412 413 414
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcxbdk3,	
					IFNULL((select (bc.sxbcs * 2) from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
415 416
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					),(select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
417 418 419 420 421
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
422
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
423 424
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
lal committed
425 426
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as ydkcs,
					IFNULL((select bc.is_xbdk from kqgl_asso_bcsz bc where bc.id = ((CASE WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 1 
ilal committed
427 428
					THEN (IFNULL((select te.bcid from kqgl_asso_teshu te where te.kqzid = sum.att_group and te.tsrq = #{param.times}
					), (select zh.bcid from kqgl_asso_zhoupaiban zh where zh.kqzid = sum.att_group
lal committed
429 430 431 432 433
							 and zh.type = (select CASE WHEN DAYNAME(#{param.times}) = 'Monday' THEN '1' 
							 WHEN DAYNAME(#{param.times}) = 'Tuesday' THEN '2' 
							 WHEN DAYNAME(#{param.times}) = 'Wednesday' THEN '3' 
							 WHEN DAYNAME(#{param.times}) = 'Thursday' THEN '4' 
							 WHEN DAYNAME(#{param.times}) = 'Friday' THEN '5' 
ilal committed
434
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
435 436 437
					WHEN IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') = 2 
					THEN (select pb.bcid from kqgl_asso_pbmx pb where pb.userid = sum.num
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as isxbdk,
lal committed
438 439
					'' address,'' remarks,'' cardtype,'' macaddress,'' macname,
					IFNULL(rtj.attdate, '') attdate,IFNULL(rtj.userid,'') userid,
lal committed
440
					#{param.times} data,
lal committed
441 442 443 444 445 446
					IFNULL(rtj.sbdk1,'') sbdk1,IFNULL(rtj.sbdk1jg,'') sbdk1jg,
					IFNULL(rtj.xbdk1 ,'') xbdk1,IFNULL(rtj.xbdk1jg,'') xbdk1jg,
					IFNULL(rtj.sbdk2 ,'') sbdk2,IFNULL(rtj.sbdk2jg ,'') sbdk2jg,
					IFNULL(rtj.xbdk2 ,'') xbdk2,IFNULL(rtj.xbdk2jg,'') xbdk2jg,
					IFNULL(rtj.sbdk3 ,'') sbdk3,IFNULL(rtj.sbdk3jg ,'') sbdk3jg,
					IFNULL(rtj.xbdk3,'') xbdk3,IFNULL(rtj.xbdk3jg ,'') xbdk3jg,
lal committed
447 448
					(IFNULL(rtj.sbdk1jg,0) + IFNULL(rtj.sbdk2jg ,0) + IFNULL(rtj.sbdk3jg ,0)) as sbcdzs,
					(IFNULL(rtj.xbdk1jg,0) + IFNULL(rtj.xbdk2jg ,0) + IFNULL(rtj.xbdk3jg ,0)) as xbztzs,
lal committed
449
					IFNULL(rtj.dktj1,'') dktj1,IFNULL(rtj.dktj2,'') dktj2,IFNULL(rtj.dktj3,'') dktj3,IFNULL(rtj.dktj4,'') dktj4,IFNULL(rtj.dktj5,'') dktj5,IFNULL(rtj.dktj6,'') dktj6,
ilal committed
450
					IFNULL(rtj.dkst1,'') dkst1,IFNULL(rtj.dkst2,'') dkst2,IFNULL(rtj.dkst3,'') dkst3,
lal committed
451 452 453 454 455 456 457 458 459 460
					IFNULL(rtj.gzsc ,'') gzsc,
					IFNULL(rtj.qyid,'') qyid,
					IFNULL(rtj.dksj ,'') dksj,
					IFNULL(rtj.yzcdcs ,'') yzcdcs,
					IFNULL(rtj.yzcdsc ,'') yzcdsc,
					IFNULL(rtj.kgcdfzs,'') kgcdfzs,
					sum.days_on_duty as daysonduty,
					sum.days_off as daysoff,
					sum.length_business_trip as lengthbusinesstrip,
					sum.time_out as timeout,
lal committed
461 462 463 464 465 466 467 468 469 470 471 472 473 474
					(select SUM(su.duration) as duration from kqgl_asso_relation_summary su where su.user_id = sum.num and su.approval_type = 1 and su.overtime_type_id = 1 
						and su.app_time = #{param.times}) as totalovertimehours,
					(select SUM(su.duration) as duration from kqgl_asso_relation_summary su where su.user_id = sum.num and su.approval_type = 1 
					and (su.compensate_id = 1 or su.compensate_id = 3) and su.overtime_type_id = 1 and su.app_time = #{param.times}) as workingturncompenleave,
					(select SUM(su.duration) as duration from kqgl_asso_relation_summary su where su.user_id = sum.num and su.approval_type = 1 
					and (su.compensate_id = 1 or su.compensate_id = 3) and su.overtime_type_id = 2 and su.app_time = #{param.times}) as restturncompenleave,
					(select SUM(su.duration) as duration from kqgl_asso_relation_summary su where su.user_id = sum.num and su.approval_type = 1 
					and (su.compensate_id = 1 or su.compensate_id = 3) and su.overtime_type_id = 3 and su.app_time = #{param.times}) as holidayturncompenleave,
					(select SUM(su.duration) as duration from kqgl_asso_relation_summary su where su.user_id = sum.num and su.approval_type = 1 
					and (su.compensate_id = 2 or su.compensate_id = 4) and su.overtime_type_id = 1 and su.app_time = #{param.times}) as workingtransferovertime,
					(select SUM(su.duration) as duration from kqgl_asso_relation_summary su where su.user_id = sum.num and su.approval_type = 1 
					and (su.compensate_id = 2 or su.compensate_id = 4) and su.overtime_type_id = 2 and su.app_time = #{param.times}) as resttransferovertime,
					(select SUM(su.duration) as duration from kqgl_asso_relation_summary su where su.user_id = sum.num and su.approval_type = 1 
					and (su.compensate_id = 2 or su.compensate_id = 4) and su.overtime_type_id = 3 and su.app_time = #{param.times}) as holidaytransferovertime
lal committed
475 476 477 478 479 480 481
			from kqgl_asso_month_punch_summary sum
			LEFT JOIN (
				select DISTINCT info.`name` as username ,
						dkjl.attdate,bcsz.id as bcszid,
						bcsz.`name` as bcname,bcsz.sbdk1 as bcsbdk1,bcsz.xbdk1 as bcxbdk1,bcsz.sbdk2 as bcsbdk2,bcsz.xbdk2 as bcxbdk2,bcsz.sbdk3 as bcsbdk3,bcsz.xbdk3 as bcxbdk3,
						dkmx.`userid`,dkmx.`data` ,dkmx.`sbdk1`,dkmx.`sbdk1jg`,dkmx.`xbdk1` ,dkmx.`xbdk1jg`,dkmx.`sbdk2` ,dkmx.`sbdk2jg` ,dkmx.`xbdk2` ,
						dkmx.`xbdk2jg`,dkmx.`sbdk3` ,dkmx.`sbdk3jg` ,dkmx.`xbdk3`,dkmx.`xbdk3jg` ,dkmx.`ydkcs` ,dkmx.`gzsc` ,dkmx.`qyid`,dkmx.`dksj` ,
ilal committed
482
						dkmx.`yzcdcs` ,dkmx.`yzcdsc` ,dkmx.`kgcdfzs`,dkmx.dktj1,dkmx.dktj2,dkmx.dktj3,dkmx.dktj4,dkmx.dktj5,dkmx.dktj6,dkmx.dkst1,dkmx.dkst2,dkmx.dkst3
lal committed
483 484 485 486 487 488 489
					from kqgl_asso_dkmx dkmx 
					LEFT JOIN yggl_main_emp as info on info.emp_num = dkmx.userid and info.org_code = #{param.orgCode}
					LEFT JOIN kqgl_asso_dkjl as dkjl on dkjl.dkmxid = dkmx.id
					LEFT JOIN kqgl_asso_bcsz as bcsz on bcsz.id = dkjl.bcid 
					where dkmx.qyid = #{param.orgCode}
					and dkmx.`data` = #{param.times}
			) as rtj on rtj.userid = sum.num
lal committed
490
			
lal committed
491 492 493 494 495 496 497 498 499 500
			where sum.org_code = #{param.orgCode}
			and sum.belong_year = #{param.year}
			and sum.belong_month = #{param.month}
			<if test="param.query != null and param.query != ''">
				and (	sum.`name` like CONCAT('%',#{param.query},'%') or 
						sum.num like CONCAT('%',#{param.query},'%'))
			</if>
			<if test="param.attid != null and param.attid != ''">
				and sum.att_group = #{param.attid}
			</if>
ilal committed
501 502 503
			<if test="param.turnover_status == 1">
				and sum.num not in (select em.emp_num from yggl_main_lzb em where em.org_code = #{param.orgCode} and em.job_status = 3)
			</if>
lal committed
504 505 506 507
			
			<!-- LEFT JOIN kqgl_asso_leave_employee_balance as mrtj on mrtj.userid = sum.num 
			IFNULL(mrtj.leave_rules_id,'') as leaverulesid,
					IFNULL(mrtj.balance_days,'') as balancedays-->
lal committed
508 509 510 511 512 513 514 515 516
					
					<!-- 
					sum.total_overtime_hours as totalovertimehours,
					sum.working_turn_compen_leave as workingturncompenleave,
					sum.rest_turn_compen_leave as restturncompenleave,
					sum.holiday_turn_compen_leave as holidayturncompenleave,
					sum.working_transfer_overtime as workingtransferovertime,
					sum.rest_transfer_overtime as resttransferovertime,
					sum.holiday_transfer_overtime as holidaytransferovertime -->
lal committed
517
	</select>
lal committed
518 519 520


</mapper>