@ -565,7 +565,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
// 同步部门负责人
getJclOrgMapMapper ( ) . insertBmfzrToMapJZ ( level , grade ) ;
RecordSet rs = new RecordSet ( ) ;
rs . execute ( "select c.id as id,c.department id as departmentid from hrmdepartment a \n" +
rs . execute ( "select c.id ,a. id as departmentid from hrmdepartment a \n" +
"inner join hrmdepartmentdefined b on a.id=b.DEPTID\n" +
"inner join hrmresource c on cast(b.BMFZR as varchar(10))=cast(c.ID as varchar(10)) " ) ; //sqlserver版
while ( rs . next ( ) ) {
@ -576,10 +576,56 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
//清除部门合并、转移造成的脏数据
getJclOrgMapMapper ( ) . deleteJobNull ( date ) ;
//刷新在岗数、编制数(从岗位向上刷,岗位不需处理)
List < JclOrgMap > jclOrgMaps = getJclOrgMapMapper ( ) . getJclOrgMapByType ( "3" , date ) ;
for ( JclOrgMap jclOrgMap : jclOrgMaps ) {
int id = jclOrgMap . getId ( ) ;
countJobAndPlans ( "3" , id , currentDate ) ;
// List<JclOrgMap> jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType("3",date);
// for (JclOrgMap jclOrgMap : jclOrgMaps){
// int id = jclOrgMap.getId();
// countJobAndPlans("3",id,currentDate);
// }
// 同步人员数据
String queryDept = "select id from hrmdepartment a where nvl(a.canceled,0)='0' " ;
RecordSet recordSet = new RecordSet ( ) ;
recordSet . execute ( queryDept ) ;
while ( recordSet . next ( ) ) {
String deptId = Util . null2String ( recordSet . getString ( "id" ) ) ;
// 处理部门(含子部门人数)
String recSql = "with children as\n" +
"(select id,supdepid from HrmDepartment where id = '6'\n" +
"union all \n" +
"select b.id,b.supdepid from children a inner join HrmDepartment b on a.id=b.supdepid\n" +
")select * from children" ;
rs . execute ( recSql ) ;
while ( rs . next ( ) ) {
}
String getSupDeptSql = "select wm_concat(id) as allSupDept from hrmdepartment a start with a.id=" + deptId + " connect by a.supdepid=prior a.id" ;
rs . execute ( getSupDeptSql ) ;
String allSupDeptIds = null ;
if ( rs . next ( ) ) {
allSupDeptIds = Util . null2String ( rs . getString ( "allSupDept" ) ) ;
}
String getZrs = "select nvl(sum(zrs),0) zrs from (\n" +
"select a.departmentid,count(id) as zrs from hrmresource a where a.status<4 group by a.departmentid\n" +
") b where b.departmentid in (" + allSupDeptIds + ")" ;
rs . execute ( getZrs ) ;
String zrs = "0" ;
if ( rs . next ( ) ) {
zrs = Util . null2String ( rs . getString ( "zrs" ) ) ;
}
rs . execute ( "update junc_org_map set fonjob = '" + zrs + "' where ftype=2 and fdateend>sysdate and fobjid=" + deptId ) ;
// 找出没有下级的人员
String noHaveChildSql = "select a.id,a.managerid from hrmresource a \n" +
"inner join (select id from hrmresource where departmentid='" + deptId + "'\n" +
"MINUS\n" +
"select managerid from hrmresource a \n" +
"where a.managerid in (select id from hrmresource where departmentid='" + deptId + "')\n" +
"and a.departmentid='" + deptId + "') b on a.id=b.id" ;
rs . execute ( noHaveChildSql ) ;
while ( rs . next ( ) ) {
String id = Util . null2String ( rs . getString ( "id" ) ) ;
String managerid = Util . null2String ( rs . getString ( "managerid" ) ) ;
// handleSuperior(id, managerid, deptId);
}
}
return "同步成功" ;
}