KqglAssoMonthPunchSummaryMapper.xml 33.5 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
                <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" />
284718418@qq.com committed
141 142 143

				<result column="turnover_status" property="turnover_status" />
				<result column="custom_num" property="customNum" />
ilal committed
144
                
lal committed
145
                <collection property="balanceTo" ofType="cn.timer.api.dto.kqmk.BalanceSheetDataDto">
lal committed
146
                	<id column="yzid" property="yzid"/>
lal committed
147 148 149 150
			   		<result column="leaverulesid" property="leaverulesid"/>
			   		<result column="balancedays" property="balancedays"/>
			    </collection>
    </resultMap>
lal committed
151 152 153
    
    <resultMap id="DailyDetailsMap" type="cn.timer.api.dto.kqmk.DailyDetailsDto" >
                <result column="name" property="name" />
154 155
				<result column="num" property="num" />
				<result column="custom_num" property="customNum" />
lal committed
156 157
                <result column="dept" property="dept" />
                <result column="post" property="post" />
lal committed
158
                <result column="orgcode" property="orgcode" />
lal committed
159
                
lal committed
160 161 162 163 164 165 166
                <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
167 168 169 170 171 172 173
                 <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
174
                 <result column="isxbdk" property="isxbdk" />
lal committed
175
                 
ilal committed
176 177 178 179
                 <result column="dkst1" property="dkst1" />
                 <result column="dkst2" property="dkst2" />
                 <result column="dkst3" property="dkst3" />
                 
lal committed
180 181 182 183 184 185
                 <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
186
                
lal committed
187
                <result column="attname" property="attname" />
lal committed
188
                <result column="attpbfs" property="attpbfs" />
lal committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
                <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
204 205 206 207
                
                <result column="sbcdzs" property="sbcdzs" />
                <result column="xbztzs" property="xbztzs" />
                
lal committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
                <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
230
			    	<id column="yzid" property="yzid"/>
lal committed
231 232 233 234
			   		<result column="leaverulesid" property="leaverulesid"/>
			   		<result column="balancedays" property="balancedays"/>
			    </collection>
    </resultMap>
lal committed
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
    
    <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
252
	<select id="MonthlySummaryLeave" resultMap="BalanceSheetDataMap">
ilal committed
253
			<!-- select aa.leaverulesid,SUM(aa.balancedays) as balancedays from (
lal committed
254 255 256 257 258 259
				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
260 261 262 263 264 265 266 267 268 269 270 271 272
			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
273 274 275 276 277 278 279 280 281 282 283 284
	</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
285
    
lal committed
286
     <select id="AttendanceSummaryData" resultMap="SummarydataMap">
lal committed
287
			select sum.*,
284718418@qq.com committed
288 289 290
		   		(select kqz.name from kqgl_main_kqz kqz where kqz.id = sum.att_group) as attname,
	   			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,
		 		yme.custom_num AS custom_num
lal committed
291
			from kqgl_asso_month_punch_summary sum
284718418@qq.com committed
292
			LEFT JOIN yggl_main_emp yme ON yme.org_code = sum.org_code and yme.emp_num=sum.num
lal committed
293 294 295 296 297
			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 
284718418@qq.com committed
298 299 300
						sum.num like CONCAT('%',#{param.query},'%')
						or yme.custom_num like CONCAT('%',#{param.query},'%')
						)
lal committed
301 302 303 304
			</if>
			<if test="param.attid != null and param.attid != ''">
				and sum.att_group = #{param.attid}
			</if>
ilal committed
305 306 307
			<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
308
			
lal committed
309 310 311 312 313
			<!-- 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
314
     </select>
lal committed
315

lal committed
316
	<select id="Dailydetails" resultMap="DailyDetailsMap">
lal committed
317
				select sum.num,
318
					info.custom_num,
lal committed
319 320 321
					sum.`name`,
					sum.org_code as orgcode,
					sum.dept,sum.post,
lal committed
322 323 324 325
					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
326 327
					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
328 329 330 331 332
							 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
333
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
334 335 336 337
					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
338 339
					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
340 341 342 343 344
							 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
345
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
346 347 348 349
					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
350 351
					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
352 353 354 355 356
							 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
357
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
358 359
					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
360
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcsbdk1,	
lal committed
361
					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
362 363
					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
364 365 366 367 368
							 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
369
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
370 371
					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
372
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcxbdk1,	
lal committed
373
					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
374 375
					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
376 377 378 379 380
							 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
381
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
382 383 384 385
					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
386 387
					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
388 389 390 391 392
							 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
393
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
394 395
					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
396
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcxbdk2,		
lal committed
397
					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
398 399
					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
400 401 402 403 404
							 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
405
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
406 407
					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
408
							and pb.`data` = #{param.times} and pb.kqzid = sum.att_group) ELSE '' END))),'') as bcsbdk3,		
lal committed
409
					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
410 411
					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
412 413 414 415 416
							 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
417
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
418 419 420 421
					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
422 423
					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
424 425 426 427 428
							 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
429
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
430 431
					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
432 433
							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
434 435
					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
436 437 438 439 440
							 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
441
							 WHEN DAYNAME(#{param.times}) = 'Saturday' THEN '6' ELSE '7' END))))
lal committed
442 443 444
					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
445 446
					'' address,'' remarks,'' cardtype,'' macaddress,'' macname,
					IFNULL(rtj.attdate, '') attdate,IFNULL(rtj.userid,'') userid,
lal committed
447
					#{param.times} data,
lal committed
448 449 450 451 452 453
					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
454 455
					(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
456
					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
457
					IFNULL(rtj.dkst1,'') dkst1,IFNULL(rtj.dkst2,'') dkst2,IFNULL(rtj.dkst3,'') dkst3,
lal committed
458 459 460 461 462 463 464 465 466 467
					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
468 469 470 471 472 473 474 475 476 477 478 479 480 481
					(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
482 483 484 485 486 487 488
			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` ,
489
						dkmx.`yzcdcs` ,dkmx.`yzcdsc` ,dkmx.`kgcdfzs`,dkmx.dktj1,dkmx.dktj2,dkmx.dktj3,dkmx.dktj4,dkmx.dktj5,dkmx.dktj6,dkmx.dkst1,dkmx.dkst2,dkmx.dkst3,info.custom_num
lal committed
490 491 492 493
					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 
chenzg committed
494
						where dkmx.qyid = #{param.orgCode}
lal committed
495 496
					and dkmx.`data` = #{param.times}
			) as rtj on rtj.userid = sum.num
497
			LEFT JOIN yggl_main_emp as info on info.emp_num = sum.num and info.org_code = #{param.orgCode}
lal committed
498
			
lal committed
499 500 501 502 503
			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 
504 505
						sum.num like CONCAT('%',#{param.query},'%') or
				info.custom_num like CONCAT('%',#{param.query},'%'))
lal committed
506 507 508 509
			</if>
			<if test="param.attid != null and param.attid != ''">
				and sum.att_group = #{param.attid}
			</if>
ilal committed
510 511 512
			<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
513 514 515 516
			
			<!-- 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
517 518 519 520 521 522 523 524 525
					
					<!-- 
					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
526
	</select>
lal committed
527 528 529


</mapper>