"case when b.belatemins > 0 and b.belatemins <= 10 and b.leaveearlymins > 0 and b.leaveearlymins <= 10 then 2 when b.belatemins > 0 and b.belatemins <= 10 and (b.leaveearlymins <= 0 or b.leaveearlymins > 10) then 1 when b.leaveearlymins > 0 and b.leaveearlymins <= 10 and (b.belatemins <= 0 or b.belatemins > 10) then 1 else 0 end as cdztten,\n"+
"case when b.belatemins > 10 and b.belatemins <= 30 and b.leaveearlymins > 10 and b.leaveearlymins <= 30 then 2 when b.belatemins > 10 and b.belatemins <= 30 and (b.leaveearlymins <= 10 or b.leaveearlymins > 30) then 1 when b.leaveearlymins > 10 and b.leaveearlymins <= 30 and (b.belatemins <= 10 or b.belatemins > 30) then 1 else 0 end as cdzttentothirty,\n"+
"case when b.belatemins > 30 and b.belatemins <= 60 and b.leaveearlymins > 30 and b.leaveearlymins <= 60 then 2 when b.belatemins > 30 and b.belatemins <= 60 and (b.leaveearlymins <= 30 or b.leaveearlymins > 60) then 1 when b.leaveearlymins > 30 and b.leaveearlymins <= 60 and (b.belatemins <= 30 or b.belatemins > 60) then 1 else 0 end as cdztthirtytosixty,\n"+
"case when b.belatemins > 60 and b.leaveearlymins > 60 then 2 when b.belatemins > 60 and b.leaveearlymins <= 60 then 1 when b.leaveearlymins > 60 and b.belatemins <= 60 then 1 else 0 end as cdztsixty,"+
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder,"+
StringsqlFrom=" from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
StringsqlFrom=" from hrmresource a join kq_format_total b on a.id = b.resourceid "+
"left join (select a1.id,h1.departmentmark as zwyjbm\n"+
",h2.departmentmark as zwejbm\n"+
",h3.departmentmark as zwsjbm\n"+
",h4.departmentmark as zwsijbm\n"+
" from cus_fielddata a1 \n"+
"left join hrmdepartment h1 on a1.field40 = h1.id\n"+
"left join hrmdepartment h2 on a1.field41 = h2.id\n"+
"left join hrmdepartment h3 on a1.field42 = h3.id\n"+
"left join hrmdepartment h4 on a1.field43 = h4.id\n"+
"where a1.scope = 'HrmCustomFieldByInfoType'\n"+
" and a1.scopeid = -1) a2 on a2.id = a.id "+
" left join kq_format_total k1 on a.id = k1.resourceid and k1.kqdate = b.kqdate and ((k1.belatemins is not null and k1.belatemins > 0 and k1.belatemins <= 10) or (k1.leaveearlymins is not null and k1.leaveearlymins > 0 and k1.leaveearlymins <= 10))"+
" left join kq_format_total k2 on a.id = k2.resourceid and k2.kqdate = b.kqdate and ((k2.belatemins is not null and k2.belatemins > 10 and k2.belatemins <= 30) or (k2.leaveearlymins is not null and k2.leaveearlymins > 10 and k2.leaveearlymins <= 30))"+
" left join kq_format_total k3 on a.id = k3.resourceid and k3.kqdate = b.kqdate and ((k3.belatemins is not null and k3.belatemins > 30 and k3.belatemins <= 60) or (k3.leaveearlymins is not null and k3.leaveearlymins > 30 and k3.leaveearlymins <= 60))"+
" left join kq_format_total k4 on a.id = k4.resourceid and k4.kqdate = b.kqdate and ((k4.belatemins is not null and k4.belatemins > 60) or (k4.leaveearlymins is not null and k4.leaveearlymins > 60))"+
"where b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
StringsqlWhere=rightSql;
StringgroupBy=" group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle ";
StringgroupBy=" group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle,a2.zwyjbm, a2.zwejbm, a2.zwsjbm, a2.zwsijbm ";
if(subCompanyId.length()>0){
sqlWhere+=" and a.subcompanyid1 in("+subCompanyId+") ";
}
@ -282,7 +301,7 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
"case when b.belatemins > 0 and b.belatemins <= 10 and b.leaveearlymins > 0 and b.leaveearlymins <= 10 then 2 when b.belatemins > 0 and b.belatemins <= 10 and (b.leaveearlymins <= 0 or b.leaveearlymins > 10) then 1 when b.leaveearlymins > 0 and b.leaveearlymins <= 10 and (b.belatemins <= 0 or b.belatemins > 10) then 1 else 0 end as cdztten,\n"+
"case when b.belatemins > 10 and b.belatemins <= 30 and b.leaveearlymins > 10 and b.leaveearlymins <= 30 then 2 when b.belatemins > 10 and b.belatemins <= 30 and (b.leaveearlymins <= 10 or b.leaveearlymins > 30) then 1 when b.leaveearlymins > 10 and b.leaveearlymins <= 30 and (b.belatemins <= 10 or b.belatemins > 30) then 1 else 0 end as cdzttentothirty,\n"+
"case when b.belatemins > 30 and b.belatemins <= 60 and b.leaveearlymins > 30 and b.leaveearlymins <= 60 then 2 when b.belatemins > 30 and b.belatemins <= 60 and (b.leaveearlymins <= 30 or b.leaveearlymins > 60) then 1 when b.leaveearlymins > 30 and b.leaveearlymins <= 60 and (b.belatemins <= 30 or b.belatemins > 60) then 1 else 0 end as cdztthirtytosixty,\n"+
"case when b.belatemins > 60 and b.leaveearlymins > 60 then 2 when b.belatemins > 60 and b.leaveearlymins <= 60 then 1 when b.leaveearlymins > 60 and b.belatemins <= 60 then 1 else 0 end as cdztsixty,"+
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder,"+
StringsqlFrom=" from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
StringsqlFrom=" from hrmresource a join kq_format_total b on a.id = b.resourceid "+
"left join (select a1.id,h1.departmentmark as zwyjbm\n"+
",h2.departmentmark as zwejbm\n"+
",h3.departmentmark as zwsjbm\n"+
",h4.departmentmark as zwsijbm\n"+
" from cus_fielddata a1 \n"+
"left join hrmdepartment h1 on a1.field40 = h1.id\n"+
"left join hrmdepartment h2 on a1.field41 = h2.id\n"+
"left join hrmdepartment h3 on a1.field42 = h3.id\n"+
"left join hrmdepartment h4 on a1.field43 = h4.id\n"+
"where a1.scope = 'HrmCustomFieldByInfoType'\n"+
" and a1.scopeid = -1) a2 on a2.id = a.id "+
" left join kq_format_total k1 on a.id = k1.resourceid and k1.kqdate = b.kqdate and ((k1.belatemins is not null and k1.belatemins > 0 and k1.belatemins <= 10) or (k1.leaveearlymins is not null and k1.leaveearlymins > 0 and k1.leaveearlymins <= 10))"+
" left join kq_format_total k2 on a.id = k2.resourceid and k2.kqdate = b.kqdate and ((k2.belatemins is not null and k2.belatemins > 10 and k2.belatemins <= 30) or (k2.leaveearlymins is not null and k2.leaveearlymins > 10 and k2.leaveearlymins <= 30))"+
" left join kq_format_total k3 on a.id = k3.resourceid and k3.kqdate = b.kqdate and ((k3.belatemins is not null and k3.belatemins > 30 and k3.belatemins <= 60) or (k3.leaveearlymins is not null and k3.leaveearlymins > 30 and k3.leaveearlymins <= 60))"+
" left join kq_format_total k4 on a.id = k4.resourceid and k4.kqdate = b.kqdate and ((k4.belatemins is not null and k4.belatemins > 60) or (k4.leaveearlymins is not null and k4.leaveearlymins > 60))"+
"where b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
StringsqlWhere=rightSql;
StringgroupBy=" group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle ";
StringgroupBy=" group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle,a2.zwyjbm, a2.zwejbm, a2.zwsjbm, a2.zwsijbm ";
if(subCompanyId.length()>0){
sqlWhere+=" and a.subcompanyid1 in("+subCompanyId+") ";
}
@ -329,7 +348,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {