@ -1,9 +1,8 @@
package com.engine.junchuang.service .impl ;
package com.engine.junchuang.service ;
import cn.hutool.core.date.DateField ;
import cn.hutool.core.date.DateField ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.date.DateUtil ;
import com.engine.core.impl.Service ;
import com.engine.core.impl.Service ;
import com.engine.junchuang.service.OrgChartService ;
import com.engine.junchuang.util.OrganizationDateUtil ;
import com.engine.junchuang.util.OrganizationDateUtil ;
import com.engine.junchuang.util.db.DBType ;
import com.engine.junchuang.util.db.DBType ;
import com.engine.junchuang.util.detach.DetachUtil ;
import com.engine.junchuang.util.detach.DetachUtil ;
@ -37,11 +36,22 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
String sql = "select id, fnumber, fname, ftype from junc_org_map where ftype in (0, 1) " ;
String sql = "select id, fnumber, fname, ftype from junc_org_map where ftype in (0, 1) " ;
// 分部分权过滤
// 分部分权过滤
DetachUtil detachUtil = new DetachUtil ( user . getUID ( ) ) ;
//DetachUtil detachUtil = new DetachUtil(user.getUID());
//if (detachUtil.isDETACH()) {
// String jclRoleLevels = detachUtil.getJclRoleLevels();
// if (StringUtils.isNotBlank(jclRoleLevels)) {
// sql = "select id, fnumber, fname, ftype from junc_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) ";
// } else {
// sql = "select id, fnumber, fname, ftype from junc_org_map where ftype = 0 ";
// }
//}
DetachUtil detachUtil = new DetachUtil ( user ) ;
if ( detachUtil . isDETACH ( ) ) {
if ( detachUtil . isDETACH ( ) ) {
String jclRoleLevels = detachUtil . getJclRoleLevels ( ) ;
String companyIds = detachUtil . getCompanyIds ( ) ;
if ( StringUtils . isNotBlank ( jclRoleLevels ) ) {
String departmentIds = detachUtil . getDepartmentIds ( ) ;
sql = "select id, fnumber, fname, ftype from junc_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) " ;
if ( StringUtils . isNotBlank ( departmentIds ) ) {
sql = "select id, fnumber, fname, ftype from junc_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + companyIds + ")) or (ftype = 2 and fobjid in(" + departmentIds + "))) " ;
} else {
} else {
sql = "select id, fnumber, fname, ftype from junc_org_map where ftype = 0 " ;
sql = "select id, fnumber, fname, ftype from junc_org_map where ftype = 0 " ;
}
}
@ -83,9 +93,11 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
rs . executeQuery ( "select t.id, t.fname, t.ftype, t.fparentid, t.fleadername,t.fobjid,t.fecid, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader, t.fleaderlv, t.fleaderst, t.fecid, t.fisvitual from junc_org_map t " + whereSql + whereItemSql ) ;
rs . executeQuery ( "select t.id, t.fname, t.ftype, t.fparentid, t.fleadername,t.fobjid,t.fecid, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader, t.fleaderlv, t.fleaderst, t.fecid, t.fisvitual from junc_org_map t " + whereSql + whereItemSql ) ;
List < Map < String , Object > > list = new ArrayList < > ( ) ;
List < Map < String , Object > > list = new ArrayList < > ( ) ;
String id = null ;
String id = null ;
String type = "0" ;
if ( rs . next ( ) ) {
if ( rs . next ( ) ) {
Map < String , Object > item = new HashMap < > ( ) ;
Map < String , Object > item = new HashMap < > ( ) ;
id = rs . getString ( "id" ) ;
id = rs . getString ( "id" ) ;
type = rs . getString ( "ftype" ) ;
item . put ( "id" , rs . getString ( "id" ) ) ;
item . put ( "id" , rs . getString ( "id" ) ) ;
item . put ( "fname" , rs . getString ( "fname" ) ) ;
item . put ( "fname" , rs . getString ( "fname" ) ) ;
item . put ( "ftype" , rs . getString ( "ftype" ) ) ;
item . put ( "ftype" , rs . getString ( "ftype" ) ) ;
@ -114,7 +126,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
}
int currentLevel = 1 ;
int currentLevel = 1 ;
findUserItemByParantId ( id , currentLevel + 1 , level , rs , list , whereSql , currentLevel + 1 < = Integer . parseInt ( level ) );
findUserItemByParantId ( id , currentLevel + 1 , level , rs , list , whereSql , currentLevel + 1 < = Integer . parseInt ( level ) , type , null );
// 分部数据,构建层级关系
// 分部数据,构建层级关系
reBuildTreeList ( list , root ) ;
reBuildTreeList ( list , root ) ;
@ -128,28 +140,67 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
public Map < String , Object > asyncUserData ( Map < String , Object > request2Map , User user ) {
public Map < String , Object > asyncUserData ( Map < String , Object > request2Map , User user ) {
String ids = ( String ) request2Map . get ( "ids" ) ;
String ids = ( String ) request2Map . get ( "ids" ) ;
String whereSql = userWhereSql ( request2Map ) ;
String whereSql = userWhereSql ( request2Map ) ;
String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader,t.fleaderlv, t.fleaderst,t.fobjid,t.fisvitual from junc_org_map t " ;
String bmfzr = "" ;
RecordSet rs = new RecordSet ( ) ;
whereSql + = " and fparentid in (" + ids + ") " ;
if ( ids . contains ( "_" ) ) {
whereSql + = " and ftype = 3 " ;
} else if ( Integer . parseInt ( ids ) > 100000000 & & Integer . parseInt ( ids ) < 200000000 ) {
rs . executeQuery ( "select bmfzr from hrmdepartmentdefined where deptid =? " , Integer . parseInt ( ids ) - 100000000 ) ;
if ( rs . next ( ) ) {
bmfzr = rs . getString ( "bmfzr" ) ;
}
}
RecordSet rs = new RecordSet ( ) ;
DetachUtil detachUtil = new DetachUtil ( user ) ;
rs . executeQuery ( "select t.id, t.fname, t.ftype, t.fparentid, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader,t.fleaderlv, t.fleaderst,t.fobjid,t.fisvitual from junc_org_map t " + whereSql ) ;
if ( detachUtil . isDETACH ( ) ) {
if ( "0" . equals ( ids ) ) {
whereSql + = " and t.ftype = 1 and t.fobjid in(" + detachUtil . getCompanyIds ( ) + ")" ;
} else {
if ( StringUtils . isNotBlank ( bmfzr ) ) {
bmfzr = bmfzr . split ( "," ) [ 0 ] ;
whereSql + = " and ((t.fparentid = " + ids . split ( "_" ) [ 0 ] + " and t.ftype =2 and t.fobjid in(" + detachUtil . getDepartmentIds ( ) + ")) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))" ;
bmfzr = String . valueOf ( 200000000 + Integer . parseInt ( bmfzr ) ) ;
} else {
whereSql + = " and t.fparentid = " + ids . split ( "_" ) [ 0 ] + " and ((t.ftype =2 and t.fobjid in(" + detachUtil . getDepartmentIds ( ) + ")) or (t.ftype = 3 ))" ;
}
}
} else {
if ( StringUtils . isNotBlank ( bmfzr ) ) {
bmfzr = bmfzr . split ( "," ) [ 0 ] ;
whereSql + = " and ((t.fparentid = " + ids . split ( "_" ) [ 0 ] + " and t.ftype =2 ) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))" ;
bmfzr = String . valueOf ( 200000000 + Integer . parseInt ( bmfzr ) ) ;
} else {
whereSql + = " and t.fparentid = " + ids . split ( "_" ) [ 0 ] ;
}
}
rs . executeQuery ( sql + whereSql ) ;
List < Map < String , Object > > currentList = new ArrayList < > ( ) ;
List < Map < String , Object > > currentList = new ArrayList < > ( ) ;
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
Map < String , Object > item = new HashMap < > ( ) ;
Map < String , Object > item = new HashMap < > ( ) ;
item . put ( "id" , rs . getString ( "id" ) ) ;
item . put ( "id" , rs . getString ( "id" ) ) ;
item . put ( "fname" , rs . getString ( "fname" ) ) ;
item . put ( "fname" , rs . getString ( "fname" ) ) ;
item . put ( "ftype" , rs . getString ( "ftype" ) ) ;
item . put ( "ftype" , rs . getString ( "ftype" ) ) ;
item . put ( "parentId" , rs . getString ( "fparentid" ) ) ;
item . put ( "parentId" , ids. contains ( "_" ) ? ids : rs. getString ( "fparentid" ) ) ;
item . put ( "fplan" , rs . getString ( "fplan" ) ) ;
item . put ( "fplan" , rs . getString ( "fplan" ) ) ;
item . put ( "fonjob" , rs . getString ( "fonjob" ) ) ;
item . put ( "fonjob" , rs . getString ( "fonjob" ) ) ;
item . put ( "fnumber" , rs . getString ( "fnumber" ) ) ;
item . put ( "fnumber" , rs . getString ( "fnumber" ) ) ;
item . put ( "hasChildren" , hasChildren ( rs . getString ( "id" ) , false ) ) ;
item . put ( "fleader" , rs . getString ( "fleader" ) ) ;
item . put ( "fleader" , rs . getString ( "fleader" ) ) ;
item . put ( "fleaderimg" , rs . getString ( "fleaderimg" ) ) ;
item . put ( "fleaderimg" , rs . getString ( "fleaderimg" ) ) ;
item . put ( "fleadername" , rs . getString ( "fleadername" ) ) ;
item . put ( "fleadername" , rs . getString ( "fleadername" ) ) ;
item . put ( "fleaderjob" , rs . getString ( "fleaderjob" ) ) ;
item . put ( "fleaderjob" , rs . getString ( "fleaderjob" ) ) ;
item . put ( "fobjid" , rs . getString ( "fobjid" ) ) ;
item . put ( "fobjid" , rs . getString ( "fobjid" ) ) ;
item . put ( "fisvitual" , rs . getString ( "fisvitual" ) ) ;
item . put ( "fisvitual" , rs . getString ( "fisvitual" ) ) ;
if ( bmfzr . equals ( item . get ( "id" ) ) ) {
item . put ( "id" , ids + "_" + bmfzr ) ;
item . put ( "parentId" , ids ) ;
item . put ( "hasChildren" , hasChildren ( ids , false ) ) ;
} else {
item . put ( "hasChildren" , hasChildren ( rs . getString ( "id" ) , false ) ) ;
}
currentList . add ( item ) ;
currentList . add ( item ) ;
}
}
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
@ -169,9 +220,9 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
RecordSet rs = new RecordSet ( ) ;
RecordSet rs = new RecordSet ( ) ;
// 1、清空当天所有数据
// 1、清空当天所有数据
rs . execute ( "delete from junc_org_map where fdatebegin = TO_DATE('" + date + "','yyyy-MM-dd')" ) ;
rs . execute ( "delete from junc_org_map where fdatebegin = TO_DATE('" + date + "','yyyy-MM-dd')" ) ;
// 2、修改所有失效数据
// 2、修改所有失效数据
rs . execute ( "update junc_org_map set fdateend=TO_DATE('" + yesterday + "','yyyy-MM-dd') where fdateend > TO_DATE('" + date + "','yyyy-MM-dd')" ) ;
rs . execute ( "update junc_org_map set fdateend=TO_DATE('" + yesterday + "','yyyy-MM-dd') where fdateend > TO_DATE('" + date + "','yyyy-MM-dd')" ) ;
// 3、同步集团数据
// 3、同步集团数据
String jtSql = "INSERT INTO junc_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,\n" +
String jtSql = "INSERT INTO junc_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,\n" +
" fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid,\n" +
" fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid,\n" +
@ -210,37 +261,37 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
String queryDept = "select id from hrmdepartment a where nvl(a.canceled,0)='0' " ;
String queryDept = "select id from hrmdepartment a where nvl(a.canceled,0)='0' " ;
RecordSet recordSet = new RecordSet ( ) ;
RecordSet recordSet = new RecordSet ( ) ;
recordSet . execute ( queryDept ) ;
recordSet . execute ( queryDept ) ;
while ( recordSet . next ( ) ) {
while ( recordSet . next ( ) ) {
String deptId = Util . null2String ( recordSet . getString ( "id" ) ) ;
String deptId = Util . null2String ( recordSet . getString ( "id" ) ) ;
// 处理部门(含子部门人数)
// 处理部门(含子部门人数)
String getSupDeptSql = "select wm_concat(id) as allSupDept from hrmdepartment a start with a.id=" + deptId + " connect by a.supdepid=prior a.id" ;
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 ) ;
rs . execute ( getSupDeptSql ) ;
String allSupDeptIds = null ;
String allSupDeptIds = null ;
if ( rs . next ( ) ) {
if ( rs . next ( ) ) {
allSupDeptIds = Util . null2String ( rs . getString ( "allSupDept" ) ) ;
allSupDeptIds = Util . null2String ( rs . getString ( "allSupDept" ) ) ;
}
}
String getZrs = "select nvl(sum(zrs),0) zrs from (\n" +
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" +
"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 + ")" ;
") b where b.departmentid in (" + allSupDeptIds + ")" ;
rs . execute ( getZrs ) ;
rs . execute ( getZrs ) ;
String zrs = "0" ;
String zrs = "0" ;
if ( rs . next ( ) ) {
if ( rs . next ( ) ) {
zrs = Util . null2String ( rs . getString ( "zrs" ) ) ;
zrs = Util . null2String ( rs . getString ( "zrs" ) ) ;
}
}
rs . execute ( "update junc_org_map set fonjob = '" + zrs + "' where ftype=2 and fdateend>sysdate and fobjid=" + deptId ) ;
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" +
String noHaveChildSql = "select a.id,a.managerid from hrmresource a \n" +
"inner join (select id from hrmresource where departmentid='" + deptId + "'\n" +
"inner join (select id from hrmresource where departmentid='" + deptId + "'\n" +
"MINUS\n" +
"MINUS\n" +
"select managerid from hrmresource a \n" +
"select managerid from hrmresource a \n" +
"where a.managerid in (select id from hrmresource where departmentid='" + deptId + "')\n" +
"where a.managerid in (select id from hrmresource where departmentid='" + deptId + "')\n" +
"and a.departmentid='" + deptId + "') b on a.id=b.id" ;
"and a.departmentid='" + deptId + "') b on a.id=b.id" ;
rs . execute ( noHaveChildSql ) ;
rs . execute ( noHaveChildSql ) ;
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
String id = Util . null2String ( rs . getString ( "id" ) ) ;
String id = Util . null2String ( rs . getString ( "id" ) ) ;
String managerid = Util . null2String ( rs . getString ( "managerid" ) ) ;
String managerid = Util . null2String ( rs . getString ( "managerid" ) ) ;
handleSuperior ( id , managerid , deptId ) ;
handleSuperior ( id , managerid , deptId ) ;
}
}
}
}
// 7、删除重复人员上级
// 7、删除重复人员上级
@ -268,8 +319,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
recordSet . execute ( "update junc_org_map set fonjob = (\n" +
recordSet . execute ( "update junc_org_map set fonjob = (\n" +
"select nvl(sum(fbrs),0) fbrs from (\n" +
"select nvl(sum(fbrs),0) fbrs from (\n" +
"select subcompanyid1,count(id) fbrs from hrmresource where status<4 group by subcompanyid1) \n" +
"select subcompanyid1,count(id) fbrs from hrmresource where status<4 group by subcompanyid1) \n" +
"where subcompanyid1 in (select id from hrmsubcompany a start with a.id=" + rs . getString ( "id" ) + " connect by a.supsubcomid=prior a.id)) \n" +
"where subcompanyid1 in (select id from hrmsubcompany a start with a.id=" + rs . getString ( "id" ) + " connect by a.supsubcomid=prior a.id)) \n" +
"where ftype=1 and fdateend>sysdate and fobjid=" + rs . getString ( "id" ) ) ;
"where ftype=1 and fdateend>sysdate and fobjid=" + rs . getString ( "id" ) ) ;
}
}
return "同步成功" ;
return "同步成功" ;
}
}
@ -279,10 +330,10 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
* @Date 2023 / 3 / 7 15 : 47
* @Date 2023 / 3 / 7 15 : 47
* @Description 处 理 上 级
* @Description 处 理 上 级
* /
* /
private void handleSuperior ( String id , String managerid , String deptId ) {
private void handleSuperior ( String id , String managerid , String deptId ) {
// 校验当前人员的直接上级是否在同一部门, 如不在当前部门, map表中的上级应为部门id+
// 校验当前人员的直接上级是否在同一部门, 如不在当前部门, map表中的上级应为部门id+
RecordSet rs = new RecordSet ( ) ;
RecordSet rs = new RecordSet ( ) ;
Boolean flag = checkManager ( rs , managerid , deptId ) ;
Boolean flag = checkManager ( rs , managerid , deptId ) ;
if ( flag ) {
if ( flag ) {
rs . execute ( "insert into junc_org_map\n" +
rs . execute ( "insert into junc_org_map\n" +
@ -294,14 +345,14 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
"from hrmresource a\n" +
"from hrmresource a\n" +
"left join hrmjobtitles b on a.jobtitle=b.id\n" +
"left join hrmjobtitles b on a.jobtitle=b.id\n" +
"where a.status < 4 and a.id='" + id + "'" ) ;
"where a.status < 4 and a.id='" + id + "'" ) ;
// 找上级的上级
// 找上级的上级
rs . execute ( "select id,managerid,departmentid from hrmresource where id='" + managerid + "'" ) ;
rs . execute ( "select id,managerid,departmentid from hrmresource where id='" + managerid + "'" ) ;
if ( rs . next ( ) ) {
if ( rs . next ( ) ) {
String supId = Util . null2String ( rs . getString ( "id" ) ) ;
String supId = Util . null2String ( rs . getString ( "id" ) ) ;
String supManagerId = Util . null2String ( rs . getString ( "managerid" ) ) ;
String supManagerId = Util . null2String ( rs . getString ( "managerid" ) ) ;
String departmentid = Util . null2String ( rs . getString ( "departmentid" ) ) ;
String departmentid = Util . null2String ( rs . getString ( "departmentid" ) ) ;
handleSuperior ( supId , supManagerId , departmentid ) ;
handleSuperior ( supId , supManagerId , departmentid ) ;
}
}
} else {
} else {
rs . execute ( "insert into junc_org_map\n" +
rs . execute ( "insert into junc_org_map\n" +
@ -313,7 +364,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
"from hrmresource a\n" +
"from hrmresource a\n" +
"left join hrmjobtitles b on a.jobtitle=b.id\n" +
"left join hrmjobtitles b on a.jobtitle=b.id\n" +
"where a.status < 4 and a.id='" + id + "'" ) ;
"where a.status < 4 and a.id='" + id + "'" ) ;
}
}
}
}
@ -322,10 +373,10 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
* @Date 2023 / 3 / 7 17 : 14
* @Date 2023 / 3 / 7 17 : 14
* @Description 校 验 上 级 是 否 在 当 前 部 门
* @Description 校 验 上 级 是 否 在 当 前 部 门
* /
* /
private Boolean checkManager ( RecordSet recordSet , String managerid , String deptId ) {
private Boolean checkManager ( RecordSet recordSet , String managerid , String deptId ) {
Boolean flag = false ;
Boolean flag = false ;
recordSet . execute ( "select departmentid from hrmresource where id='" + managerid + "'" ) ;
recordSet . execute ( "select departmentid from hrmresource where id='" + managerid + "'" ) ;
if ( recordSet . next ( ) ) {
if ( recordSet . next ( ) ) {
if ( deptId . equals ( Util . null2String ( recordSet . getString ( "departmentid" ) ) ) ) {
if ( deptId . equals ( Util . null2String ( recordSet . getString ( "departmentid" ) ) ) ) {
flag = true ;
flag = true ;
}
}
@ -376,28 +427,49 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
return ! "0" . equals ( count ) ;
return ! "0" . equals ( count ) ;
}
}
private String getFieldName ( String fieldabel ) {
RecordSet recordSet = new RecordSet ( ) ;
String fieldname = null ;
recordSet . executeQuery ( "select fieldname from jcl_org_field where fieldlabel='" + fieldabel + "'" ) ;
if ( recordSet . next ( ) ) {
fieldname = recordSet . getString ( "fieldname" ) ;
}
return fieldname ;
}
private void findUserItemByParantId ( String id , int currentLevel , String level , RecordSet rs , List < Map < String , Object > > list , String whereSql , boolean expand ) {
private void findUserItemByParantId ( String id , int currentLevel , String level , RecordSet rs , List < Map < String , Object > > list , String whereSql , boolean expand , String type , String parentDeptId ) {
String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fobjparentid, t.fleader, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fobjid, t.fecid, t.fleaderlv, t.fleaderst, t.fisvitual from junc_org_map t " + whereSql ;
String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fobjparentid, t.fleader, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fobjid, t.fecid, t.fleaderlv, t.fleaderst, t.fisvitual from junc_org_map t " + whereSql ;
DetachUtil detachUtil = new DetachUtil ( user . getUID ( ) ) ;
String bmfzr = "" ;
String manageDeptId = "" ;
if ( "2" . equals ( type ) ) {
rs . executeQuery ( "select bmfzr from hrmdepartmentdefined where deptid =? " , parentDeptId ) ;
if ( rs . next ( ) ) {
bmfzr = rs . getString ( "bmfzr" ) ;
}
}
if ( "3" . equals ( type ) ) {
manageDeptId = id ;
id = id . split ( "_" ) [ 0 ] ;
sql + = " and ftype = 3 " ;
}
DetachUtil detachUtil = new DetachUtil ( user ) ;
if ( detachUtil . isDETACH ( ) ) {
if ( detachUtil . isDETACH ( ) ) {
if ( "0" . equals ( id ) ) {
if ( "0" . equals ( id ) ) {
sql + = " and t.ftype = 1 and t.fobjid in(" + detachUtil . getJclRoleLevels ( ) + ")" ;
sql + = " and t.ftype = 1 and t.fobjid in(" + detachUtil . get CompanyId s( ) + ")" ;
} else {
} else {
sql + = " and t.fparentid = " + id + " and t.ftype !=1" ;
if ( StringUtils . isNotBlank ( bmfzr ) ) {
bmfzr = bmfzr . split ( "," ) [ 0 ] ;
sql + = " and ((t.fparentid = " + id + " and t.ftype =2 and t.fobjid in(" + detachUtil . getDepartmentIds ( ) + ")) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))" ;
bmfzr = String . valueOf ( 200000000 + Integer . parseInt ( bmfzr ) ) ;
} else {
sql + = " and t.fparentid = " + id + " and ((t.ftype =2 and t.fobjid in(" + detachUtil . getDepartmentIds ( ) + ")) or (t.ftype = 3 ))" ;
}
}
}
} else {
} else {
sql + = " and t.fparentid = " + id ;
if ( StringUtils . isNotBlank ( bmfzr ) ) {
bmfzr = bmfzr . split ( "," ) [ 0 ] ;
sql + = " and ((t.fparentid = " + id + " and t.ftype =2 ) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))" ;
bmfzr = String . valueOf ( 200000000 + Integer . parseInt ( bmfzr ) ) ;
} else {
sql + = " and t.fparentid = " + id ;
}
}
}
rs . executeQuery ( sql ) ;
rs . executeQuery ( sql ) ;
List < Map < String , Object > > currentList = new ArrayList < > ( ) ;
List < Map < String , Object > > currentList = new ArrayList < > ( ) ;
while ( rs . next ( ) ) {
while ( rs . next ( ) ) {
@ -405,7 +477,12 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
item . put ( "id" , rs . getString ( "id" ) ) ;
item . put ( "id" , rs . getString ( "id" ) ) ;
item . put ( "fname" , rs . getString ( "fname" ) ) ;
item . put ( "fname" , rs . getString ( "fname" ) ) ;
item . put ( "ftype" , rs . getString ( "ftype" ) ) ;
item . put ( "ftype" , rs . getString ( "ftype" ) ) ;
item . put ( "parentId" , rs . getString ( "fparentid" ) ) ;
if ( "3" . equals ( type ) ) {
item . put ( "parentId" , manageDeptId ) ;
} else {
item . put ( "parentId" , rs . getString ( "fparentid" ) ) ;
}
item . put ( "fobjparentId" , rs . getString ( "fobjparentid" ) ) ;
item . put ( "fobjparentId" , rs . getString ( "fobjparentid" ) ) ;
item . put ( "fplan" , rs . getString ( "fplan" ) ) ;
item . put ( "fplan" , rs . getString ( "fplan" ) ) ;
item . put ( "fonjob" , rs . getString ( "fonjob" ) ) ;
item . put ( "fonjob" , rs . getString ( "fonjob" ) ) ;
@ -419,30 +496,25 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
item . put ( "fleaderjob" , rs . getString ( "fleaderjob" ) ) ;
item . put ( "fleaderjob" , rs . getString ( "fleaderjob" ) ) ;
item . put ( "fisvitual" , rs . getString ( "fisvitual" ) ) ;
item . put ( "fisvitual" , rs . getString ( "fisvitual" ) ) ;
item . put ( "hasChildren" , hasChildren ( rs . getString ( "id" ) , false ) ) ;
if ( bmfzr . equals ( item . get ( "id" ) ) ) {
// TODO
item . put ( "id" , id + "_" + bmfzr ) ;
item . put ( "parentId" , id ) ;
item . put ( "hasChildren" , hasChildren ( id , false ) ) ;
} else {
item . put ( "hasChildren" , hasChildren ( rs . getString ( "id" ) , false ) ) ;
}
currentList . add ( item ) ;
currentList . add ( item ) ;
}
}
for ( Map < String , Object > stringObjectMap : currentList ) {
for ( Map < String , Object > stringObjectMap : currentList ) {
if ( "4" . equals ( stringObjectMap . get ( "ftype" ) ) ) { // 员工信息
String fType = Util . null2String ( stringObjectMap . get ( "ftype" ) ) ;
rs . executeQuery ( "select id, mobile, homeaddress from hrmresource where id = ? " , stringObjectMap . get ( "fnumber" ) ) ;
if ( rs . next ( ) ) {
stringObjectMap . put ( "mobile" , rs . getString ( "mobile" ) ) ;
stringObjectMap . put ( "address" , rs . getString ( "homeaddress" ) ) ;
}
rs . executeQuery ( "select departmentname from hrmresource hrm \n" +
"left join hrmdepartment d\n" +
"on hrm.departmentid = d.id\n" +
"where hrm.id = ? " , stringObjectMap . get ( "fnumber" ) ) ;
if ( rs . next ( ) ) {
stringObjectMap . put ( "department" , rs . getString ( "departmentname" ) ) ;
}
}
if ( currentLevel + 1 < = Integer . parseInt ( level ) ) {
if ( currentLevel + 1 < = Integer . parseInt ( level ) ) {
findUserItemByParantId ( ( String ) stringObjectMap . get ( "id" ) , currentLevel + 1 , level , rs , list , whereSql , true ) ;
findUserItemByParantId ( ( String ) stringObjectMap . get ( "id" ) , currentLevel + 1 , level , rs , list , whereSql , true , fType , Util . null2String ( stringObjectMap . get ( "fobjid" ) ) ) ;
} else if ( currentLevel = = Integer . parseInt ( level ) ) { // 多查一层
} else if ( currentLevel = = Integer . parseInt ( level ) ) {
findUserItemByParantId ( ( String ) stringObjectMap . get ( "id" ) , currentLevel + 1 , level , rs , list , whereSql , false ) ;
// 多查一层
findUserItemByParantId ( ( String ) stringObjectMap . get ( "id" ) , currentLevel + 1 , level , rs , list , whereSql , false , fType , Util . null2String ( stringObjectMap . get ( "fobjid" ) ) ) ;
}
}
}
}
list . addAll ( currentList ) ;
list . addAll ( currentList ) ;
@ -458,25 +530,32 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
}
} ) ;
} ) ;
}
}
static class OrgSelectItem {
static class OrgSelectItem {
private String id ;
private String id ;
private String fnumber ;
private String fnumber ;
private String fname ;
private String fname ;
public String getId ( ) {
public String getId ( ) {
return id ;
return id ;
}
}
public void setId ( String id ) {
public void setId ( String id ) {
this . id = id ;
this . id = id ;
}
}
public String getFnumber ( ) {
public String getFnumber ( ) {
return fnumber ;
return fnumber ;
}
}
public void setFnumber ( String fnumber ) {
public void setFnumber ( String fnumber ) {
this . fnumber = fnumber ;
this . fnumber = fnumber ;
}
}
public String getFname ( ) {
public String getFname ( ) {
return fname ;
return fname ;
}
}
public void setFname ( String fname ) {
public void setFname ( String fname ) {
this . fname = fname ;
this . fname = fname ;
}
}