" case when sum(workmins)>0 then 1 end as workdays, sum(workmins) as workmins,"+
" case when sum(workmins)>0 then 1 end as workdays, sum(workmins) as workmins,"+
" cast(sum(attendanceMins)AS decimal(10, 2))/sum(workmins) as attendancedays, sum(attendanceMins) as attendanceMins,"+
" case when sum(workmins)>0 then cast(sum(attendanceMins)AS decimal(10, 2))/sum(workmins) else 0 end as attendancedays, sum(attendanceMins) as attendanceMins,"+
" cast(sum(signmins)AS decimal(10, 2))/sum(workmins) as signdays, sum(signmins) as signmins,"+
// " cast(sum(attendanceMins)AS decimal(10, 2))/sum(workmins) as attendancedays, sum(attendanceMins) as attendanceMins," +
" case when sum(workmins)>0 then cast(sum(signmins)AS decimal(10, 2))/sum(workmins) else 0 end as signdays, sum(signmins) as signmins,"+
// " cast(sum(signmins)AS decimal(10, 2))/sum(workmins) as signdays, sum(signmins) as signmins," +
" sum(case when belatemins> 0 then 1 else 0 end) as belate,sum(belatemins) as belatemins,"+
" sum(case when belatemins> 0 then 1 else 0 end) as belate,sum(belatemins) as belatemins,"+
" sum(case when graveBeLateMins> 0 then 1 else 0 end) as graveBeLate,sum(graveBeLateMins) as graveBeLateMins,"+
" sum(case when graveBeLateMins> 0 then 1 else 0 end) as graveBeLate,sum(graveBeLateMins) as graveBeLateMins,"+
" sum(case when leaveearlymins> 0 then 1 else 0 end) as leaveearly,sum(leaveearlymins) as leaveearlymins,"+
" sum(case when leaveearlymins> 0 then 1 else 0 end) as leaveearly,sum(leaveearlymins) as leaveearlymins,"+
@ -193,11 +197,13 @@ public class KQFormatData extends BaseBean {
List<TimeScopeEntity>lsRestTime=newArrayList<>();
List<TimeScopeEntity>lsRestTime=newArrayList<>();
List<Object>workFlow=null;
List<Object>workFlow=null;
intworkminsNew=0;
if(workTime!=null){
if(workTime!=null){
lsSignTime=workTime.getSignTime();//允许打卡时间
lsSignTime=workTime.getSignTime();//允许打卡时间
lsWorkTime=workTime.getWorkTime();//工作时间
lsWorkTime=workTime.getWorkTime();//工作时间
lsRestTime=workTime.getRestTime();//休息时段时间
lsRestTime=workTime.getRestTime();//休息时段时间
oneSign=lsWorkTime!=null&&lsWorkTime.size()==1;
oneSign=lsWorkTime!=null&&lsWorkTime.size()==1;
workminsNew=workTime.getWorkMins();
}
}
int[]dayMins=newint[2880];//一天所有分钟数
int[]dayMins=newint[2880];//一天所有分钟数
@ -279,6 +285,8 @@ public class KQFormatData extends BaseBean {
sqlWhere+=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere+=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere+=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if(!"1".equals(isNoAccount)){
sqlWhere+=" and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql=" select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) "+sqlWhere+
" group by resourceid, newleavetype, durationrule ";
@ -379,7 +473,7 @@ public class KQReportBiz extends BaseBean {
}
}
sql=" select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+
sql=" select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) " +sqlWhere+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) " +sqlWhere+
" group by resourceid, newleavetype, durationrule ";
" group by resourceid, newleavetype, durationrule ";
rs.execute(sql);
rs.execute(sql);
while(rs.next()){
while(rs.next()){
@ -416,6 +510,98 @@ public class KQReportBiz extends BaseBean {
sqlWhere+=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere+=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere+=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if(!"1".equals(isNoAccount)){
sqlWhere+=" and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql=" select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) "+sqlWhere+
" group by resourceid, newleavetype, durationrule,belongdate ";
@ -473,7 +659,7 @@ public class KQReportBiz extends BaseBean {
}
}
sql=" select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+
sql=" select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) " +sqlWhere+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) " +sqlWhere+
" group by resourceid, newleavetype, durationrule,belongdate ";
" group by resourceid, newleavetype, durationrule,belongdate ";
rs.execute(sql);
rs.execute(sql);
while(rs.next()){
while(rs.next()){
@ -1832,6 +2018,17 @@ public class KQReportBiz extends BaseBean {
StringbackFields=" (select workdays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayworkdays," +
StringbackFields=" (select zma.workdays from kq_format_total zma where zma.resourceid = a.id and zma.kqdate = b.kqdate and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayworkdays," +
" (select attendancedays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayattendancedays," +
" (select zma.attendancedays from kq_format_total zma where zma.resourceid = a.id and zma.kqdate = b.kqdate and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayattendancedays," +
" (select workdays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayworkdays," +
" (select zma.workdays from kq_format_total zma where zma.resourceid = a.id and zma.kqdate = b.kqdate and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayworkdays," +
" (select attendancedays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayattendancedays," +
" (select zma.attendancedays from kq_format_total zma where zma.resourceid = a.id and zma.kqdate = b.kqdate and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayattendancedays," +
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder,"+
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder,"+
StringbackFields=" (select sum(workdays) from kq_format_total where resourceid = a.id and kqdate >='" +fromDate+"' and kqdate <='" +toDate+"' and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayworkdays," +
StringbackFields=" (select sum(zma.workdays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" +fromDate+"' and zma.kqdate <='" +toDate+"' and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) AND zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayworkdays," +
" (select count(0) from kq_shiftschedule where resourceid = a.id and kqdate >='"+fromDate+"' and kqdate <='"+toDate+"' and serialid="+supportSerId+" )as supportTotal,"+
" (select count(0) from kq_shiftschedule where resourceid = a.id and kqdate >='"+fromDate+"' and kqdate <='"+toDate+"' and serialid="+supportSerId+" )as supportTotal,"+
" (select sum(attendancedays) from kq_format_total where resourceid = a.id and kqdate >='" +fromDate+"' and kqdate <='" +toDate+"' and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayattendancedays," +
" (select sum(zma.attendancedays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" +fromDate+"' and zma.kqdate <='" +toDate+"' and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) AND zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayattendancedays," +
" (select sum(workdays) from kq_format_total where resourceid = a.id and kqdate >='" +fromDate+"' and kqdate <='" +toDate+"' and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayworkdays," +
" (select sum(zma.workdays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" +fromDate+"' and zma.kqdate <='" +toDate+"' and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayworkdays," +
" (select sum(attendancedays) from kq_format_total where resourceid = a.id and kqdate >='" +fromDate+"' and kqdate <='" +toDate+"' and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayattendancedays," +
" (select sum(zma.attendancedays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" +fromDate+"' and zma.kqdate <='" +toDate+"' and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayattendancedays," +
"a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle,"+
"a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle,"+
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays,"+
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays,"+
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, "+
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, "+
@ -333,6 +341,10 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {