(select kqz.name from kqgl_main_kqz kqz where kqz.id = sum.att_group) as attname,
INSERT INTO kqgl_asso_month_punch_summary
IFNULL(rtj.attdate, '') attdate,
<trim prefix="(" suffix=")" suffixOverrides=",">
IFNULL(rtj.userid,'') userid,
<if test ='null != name'>
IFNULL(rtj.data,'') data,
name,
IFNULL(rtj.sbdk1,'') sbdk1,
</if>
IFNULL(rtj.sbdk1jg,'') sbdk1jg,
<if test ='null != num'>
IFNULL(rtj.xbdk1 ,'') xbdk1,
num,
IFNULL(rtj.xbdk1jg,'') xbdk1jg,
</if>
IFNULL(rtj.sbdk2 ,'') sbdk2,
<if test ='null != dept'>
IFNULL(rtj.sbdk2jg ,'') sbdk2jg,
dept,
IFNULL(rtj.xbdk2 ,'') xbdk2,
</if>
IFNULL(rtj.xbdk2jg,'') xbdk2jg,
<if test ='null != post'>
IFNULL(rtj.sbdk3 ,'') sbdk3,
post,
IFNULL(rtj.sbdk3jg ,'') sbdk3jg,
</if>
IFNULL(rtj.xbdk3,'') xbdk3,
<if test ='null != attGroup'>
IFNULL(rtj.xbdk3jg ,'') xbdk3jg,
att_group,
IFNULL(rtj.ydkcs ,'') ydkcs,
</if>
IFNULL(rtj.gzsc ,'') gzsc,
<if test ='null != shift'>
IFNULL(rtj.qyid,'') qyid,
shift,
IFNULL(rtj.dksj ,'') dksj,
</if>
IFNULL(rtj.yzcdcs ,'') yzcdcs,
<if test ='null != daysOnDuty'>
IFNULL(rtj.yzcdsc ,'') yzcdsc,
days_on_duty,
IFNULL(rtj.kgcdfzs,'') kgcdfzs,
</if>
sum.days_on_duty as daysonduty,
<if test ='null != actualAttDays'>
sum.days_off as daysoff,
actual_att_days,
sum.length_business_trip as lengthbusinesstrip,
</if>
sum.time_out as timeout,
<if test ='null != daysOff'>
sum.total_overtime_hours as totalovertimehours,
days_off,
sum.working_turn_compen_leave as workingturncompenleave,
</if>
sum.rest_turn_compen_leave as restturncompenleave,
<if test ='null != workingHours'>
sum.holiday_turn_compen_leave as holidayturncompenleave,
working_hours,
sum.working_transfer_overtime as workingtransferovertime,
</if>
sum.rest_transfer_overtime as resttransferovertime,
<if test ='null != lateTimes'>
sum.holiday_transfer_overtime as holidaytransferovertime,
late_times,
mrtj.leaverulesid,
</if>
mrtj.duration as balancedays
<if test ='null != lateHours'>
from kqgl_asso_month_punch_summary sum
late_hours,
LEFT JOIN (
</if>
select DISTINCT info.`name` as username ,
<if test ='null != seriousLateTimes'>
dkjl.attdate,
serious_late_times,
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,