subCompanySql="select t.id, t.subcompanyname, t.supsubcomid, ( select distinct 1 as hasnext from hrmsubcompany_back s where (s.supsubcomid = t.id and (s.CANCELED IS NULL OR s.CANCELED != '1') and s.sync_date = '"+syncDate+"') ) as hassubnext, ( select distinct 1 as hasnext from HrmDepartment_back d where (d.subcompanyid1 = t.id and (d.CANCELED IS NULL OR d.CANCELED != '1') and d.sync_date = '"+syncDate+"')) as hasdeptnext, t.tlevel from hrmsubcompany_back t where (t.canceled IS NULL OR t.canceled != '1') and t.id != t.supsubcomid and tlevel <= 10000 and sync_date = '"+syncDate+"' order by t.supsubcomid, t.showorder, t.subcompanyname";
departmentSql="select t.id, t.departmentname, t.subcompanyid1, isnull(t.supdepid,0) as supdepid, (case when t.supdepid != 0 and ( select COUNT(id) from hrmdepartment_back where id = t.supdepid and sync_date = '"+syncDate+"')= 0 then 0 else 1 end) as isExist, ( select distinct 1 as hasnext from hrmdepartment_back d where d.supdepid = t.id and (CANCELED IS NULL OR CANCELED != '1') and sync_date = '"+syncDate+"') as hasnext, t.tlevel from hrmdepartment_back t where t.id != ISNULL(t.supdepid, 0) and tlevel <= 10000 and (t.canceled IS NULL OR t.canceled != '1') and (t.canceled IS NULL OR t.canceled != '1') and sync_date = '" +syncDate+"' order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
departmentSql="select t.id, t.departmentname, t.subcompanyid1, isnull(t.supdepid,0) as supdepid, (case when t.supdepid != 0 and ( select COUNT(id) from hrmdepartment_back where id = t.supdepid and sync_date = '"+syncDate+"')= 0 then 0 else 1 end) as isExist, ( select distinct 1 as hasnext from hrmdepartment_back d where d.supdepid = t.id and (CANCELED IS NULL OR CANCELED != '1') and sync_date = '"+syncDate+"') as hasnext, t.tlevel from hrmdepartment_back t where t.id != ISNULL(t.supdepid, 0) and SNULL(t.tlevel,0) <= 10000 and (t.canceled IS NULL OR t.canceled != '1') and (t.canceled IS NULL OR t.canceled != '1') and sync_date = '" +syncDate+"' order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
}else{
subCompanySql="select t.id,t.subcompanyname,t.supsubcomid,(select distinct 1 as hasnext from hrmsubcompany s where (s.supsubcomid=t.id and (s.CANCELED IS NULL OR s.CANCELED !='1')) ) as hassubnext,(select distinct 1 as hasnext from HrmDepartment d where (d.subcompanyid1=t.id and (d.CANCELED IS NULL OR d.CANCELED !='1')) ) as hasdeptnext,t.tlevel from hrmsubcompany t where (t.canceled IS NULL OR t.canceled !='1') and t.id != t.supsubcomid and tlevel <= 10000 order by t.supsubcomid,t.showorder,t.subcompanyname";
departmentSql="select t.id,t.departmentname,t.subcompanyid1,isnull(t.supdepid,0) as supdepid,(case when t.supdepid != 0 and (select COUNT(id) from hrmdepartment where id = t.supdepid)=0 then 0 else 1 end) as isExist,(select distinct 1 as hasnext from hrmdepartment d where d.supdepid=t.id and (CANCELED IS NULL OR CANCELED !='1')) as hasnext,t.tlevel from hrmdepartment t where t.id != ISNULL(t.supdepid,0) and tlevel <= 10000 and (t.canceled IS NULL OR t.canceled !='1') order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
departmentSql="select t.id,t.departmentname,t.subcompanyid1,isnull(t.supdepid,0) as supdepid,(case when t.supdepid != 0 and (select COUNT(id) from hrmdepartment where id = t.supdepid)=0 then 0 else 1 end) as isExist,(select distinct 1 as hasnext from hrmdepartment d where d.supdepid=t.id and (CANCELED IS NULL OR CANCELED !='1')) as hasnext,t.tlevel from hrmdepartment t where t.id != ISNULL(t.supdepid,0) and ISNULL(t.tlevel,0) <= 10000 and (t.canceled IS NULL OR t.canceled !='1') order by t.subcompanyid1 asc , t.supdepid asc , t.showorder asc, t.departmentname asc";
}
RecordSetrs=newRecordSet();
@ -318,13 +318,17 @@ public class DanikorResourceBackServiceImpl extends Service implements DanikorRe
sql="select a.id, a.managerid , a.lastname , b.jobtitlename, ( select count(1) from HrmResource_back where managerid = a.id and sync_date = '" +syncDate+"') subordinate from HrmResource_back a left join HrmJobTitles b on a.jobtitle = b.id where seclevel >= 40 and sync_date = '" +syncDate+"'";
sql="select a.id, a.managerid , a.lastname , b.jobtitlename, ( select count(1) from HrmResource_back where managerid = a.id and and seclevel >= " +secLevel+" and sync_date = '" +syncDate+"') subordinate from HrmResource_back a left join HrmJobTitles b on a.jobtitle = b.id where seclevel >= " +secLevel+" and sync_date = '" +syncDate+"'";
}else{
sql="select a.id, a.managerid , a.lastname , b.jobtitlename, ( select count(1) from HrmResource where managerid = a.id) subordinate from HrmResource a left join HrmJobTitles b on a.jobtitle = b.id where seclevel >= 40";
sql="select a.id, a.managerid , a.lastname , b.jobtitlename, ( select count(1) from HrmResource where managerid = a.id and seclevel >= " +secLevel+") subordinate from HrmResource a left join HrmJobTitles b on a.jobtitle = b.id where seclevel >= "+secLevel;
}
RecordSetrs=newRecordSet();
@ -337,9 +341,9 @@ public class DanikorResourceBackServiceImpl extends Service implements DanikorRe