@ -58,54 +58,29 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
item . put ( "companyname" , rs . getString ( "companyname" ) ) ;
item . put ( "companyname" , rs . getString ( "companyname" ) ) ;
fclasslist . add ( item ) ;
fclasslist . add ( item ) ;
}
}
List < CompanyTreePO > companyTree = new ArrayList < > ( ) ;
String sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType . get ( new RecordSet ( ) . getDBType ( ) ) . ifNull ( "supsubcomid" , "0" ) + " = '0'" ;
// 一级分部数据分权处理
String dimension = Util . null2String ( request2Map . get ( "fclass" ) ) ;
//版本id
String id = Util . null2String ( request2Map . get ( "id" ) ) ;
boolean isRealDimension = StringUtils . isBlank ( dimension ) | | "0" . equals ( dimension ) ;
boolean isRealTime = StringUtils . isBlank ( id ) | | "0" . equals ( id ) ;
if ( isRealTime & & user . getUID ( ) ! = 1 & & isRealDimension ) {
DetachUtil detachUtil = new DetachUtil ( user ) ;
if ( detachUtil . isDETACH ( ) ) {
String ids = detachUtil . getJclRoleLevels ( ) ;
sql = sql + " and id in (" + ids + ")" ;
}
}
rs . executeQuery ( sql ) ;
while ( rs . next ( ) ) {
companyTree . add ( CompanyTreePO . builder ( ) . id ( rs . getString ( "id" ) ) . pId ( rs . getString ( "pId" ) ) . value ( rs . getString ( "value" ) ) . title ( rs . getString ( "title" ) ) . isLeaf ( judgeTreeLeaf ( "select id from hrmsubcompany where (canceled is null or canceled != '1') and supsubcomid = ?" , rs . getString ( "id" ) ) ) . build ( ) ) ;
}
result . put ( "api_status" , true ) ;
result . put ( "api_status" , true ) ;
result . put ( "fclasslist" , fclasslist ) ;
result . put ( "fclasslist" , fclasslist ) ;
result . put ( "companyTree" , companyTree ) ;
Map < String , Object > subCompanyTree = getSubCompanyTree ( request2Map ) ;
result . putAll ( subCompanyTree ) ;
return result ;
return result ;
}
}
@Override
@Override
public Map < String , Object > getSubCompanyTree ( Map < String , Object > params ) {
public Map < String , Object > getSubCompanyTree ( Map < String , Object > params ) {
Map < String , Object > result = new HashMap < > ( 2 ) ;
Map < String , Object > result = new HashMap < > ( 2 ) ;
List < CompanyTreePO > departmentTree = ChartServiceImpl . getDepartmentTreeList ( params ) ;
result . put ( "companyTree" , departmentTree ) ;
return result ;
}
RecordSet rs = new RecordSet ( ) ;
private String getSubCompanyTreeSql ( String id , String fclass , String subcompany ) {
List < CompanyTreePO > companyTree = new ArrayList < > ( ) ;
String subcompany = Util . null2String ( params . get ( "subcompany" ) ) ;
if ( StringUtils . isBlank ( subcompany ) ) {
subcompany = "0" ;
}
String fclass = Util . null2String ( params . get ( "fclass" ) ) ;
String id = Util . null2String ( params . get ( "id" ) ) ;
// 是否展示当前数据
// 是否展示当前数据
boolean isSearchCurrent = StringUtils . isBlank ( id ) | | "0" . equals ( id ) ;
boolean isSearchCurrent = StringUtils . isBlank ( id ) | | "0" . equals ( id ) ;
String sql ;
String sql ;
String judgeTreeLeafSql ;
if ( isSearchCurrent ) {
if ( isSearchCurrent ) {
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType . get ( new RecordSet ( ) . getDBType ( ) ) . ifNull ( "supsubcomid" , "0" ) + " = ? " ;
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType . get ( new RecordSet ( ) . getDBType ( ) ) . ifNull ( "supsubcomid" , "0" ) + " = ? " ;
boolean isRealDimension = StringUtils . isBlank ( fclass ) | | "0" . equals ( fclass ) ;
boolean isRealDimension = StringUtils . isBlank ( fclass ) | | "0" . equals ( fclass ) ;
boolean isRealTime = StringUtils . isBlank ( id ) | | "0" . equals ( id ) ;
boolean isRealTime = StringUtils . isBlank ( id ) | | "0" . equals ( id ) ;
judgeTreeLeafSql = sql ;
if ( isRealTime & & user . getUID ( ) ! = 1 & & isRealDimension ) {
if ( isRealTime & & user . getUID ( ) ! = 1 & & isRealDimension ) {
DetachUtil detachUtil = new DetachUtil ( user ) ;
DetachUtil detachUtil = new DetachUtil ( user ) ;
if ( detachUtil . isDETACH ( ) ) {
if ( detachUtil . isDETACH ( ) ) {
@ -125,14 +100,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
}
// 添加时间轴条件
// 添加时间轴条件
sql + = " and versionid = " + id ;
sql + = " and versionid = " + id ;
judgeTreeLeafSql = sql ;
}
}
rs . executeQuery ( sql , subcompany ) ;
return sql ;
while ( rs . next ( ) ) {
companyTree . add ( CompanyTreePO . builder ( ) . id ( rs . getString ( "id" ) ) . pId ( rs . getString ( "pId" ) ) . value ( rs . getString ( "value" ) ) . title ( rs . getString ( "title" ) ) . isLeaf ( judgeTreeLeaf ( judgeTreeLeafSql , rs . getString ( "id" ) ) ) . build ( ) ) ;
}
result . put ( "companyTree" , companyTree ) ;
return result ;
}
}
private String companyDateWhereSql ( Map < String , Object > request2Map ) {
private String companyDateWhereSql ( Map < String , Object > request2Map ) {
@ -705,16 +674,19 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
return fieldname ;
return fieldname ;
}
}
/ * *
/ * *
* 判 断 树 是 否 为 叶 子 节 点
* 判 断 树 是 否 为 叶 子 节 点
*
*
* @param sql 查 询 下 级 元 素 SQL
* @param versionId
* @param treeId 当 前 元 素 ID
* @param dimension
* @param subCompany
* @return
* @return
* /
* /
private boolean judgeTreeLeaf ( String sql, String treeId ) {
private boolean judgeTreeLeaf ( String versionId, String dimension , String subCompany ) {
RecordSet recordSet = new RecordSet ( ) ;
RecordSet recordSet = new RecordSet ( ) ;
recordSet . executeQuery ( sql , treeId ) ;
String sql = getSubCompanyTreeSql ( versionId , dimension , subCompany ) ;
recordSet . executeQuery ( sql , subCompany ) ;
return ! recordSet . next ( ) ;
return ! recordSet . next ( ) ;
}
}