@ -20,6 +20,8 @@ import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans ;
import weaver.general.Util ;
import weaver.hrm.User ;
import weaver.hrm.company.DepartmentComInfo ;
import weaver.hrm.company.SubCompanyComInfo ;
import weaver.hrm.resource.ResourceComInfo ;
import java.time.LocalDate ;
@ -479,11 +481,14 @@ public class ChartServiceImpl extends Service implements ChartService {
rs . executeQuery ( "select id,companyname from hrmcompany" ) ;
TreeSelect companyTree = null ;
List < String > expandedKeys = new ArrayList < > ( ) ;
String canceled = Util . null2String ( params . get ( "canceled" ) ) ;
String showCanceled = Util . null2String ( params . get ( "showCanceled" ) ) ;
String expandedKeyStr = Util . null2String ( params . get ( "expandedKeys" ) ) ;
if ( rs . next ( ) ) {
companyTree = TreeSelect . builder ( ) . key ( rs . getString ( "id" ) ) . title ( rs . getString ( "companyname" ) ) . type ( TreeSelect . COMPANY ) . cancelSql( c anceled) . build ( ) ;
companyTree = TreeSelect . builder ( ) . key ( rs . getString ( "id" ) ) . title ( rs . getString ( "companyname" ) ) . type ( TreeSelect . COMPANY ) . showCanceled( showC anceled) . build ( ) ;
expandedKeys . add ( companyTree . getKey ( ) ) ;
}
// 所有需展开节点, 同时需查询父级部门、分部ID
addParentTreeId ( expandedKeys , expandedKeyStr ) ;
Map < String , Object > result = new HashMap < > ( 3 ) ;
result . put ( "movingTree" , Collections . singletonList ( companyTree ) ) ;
result . put ( "expandedKeys" , expandedKeys ) ;
@ -497,9 +502,9 @@ public class ChartServiceImpl extends Service implements ChartService {
rs . executeQuery ( "select id,companyname from hrmcompany" ) ;
TreeSelect companyTree = null ;
List < String > expandedKeys = new ArrayList < > ( ) ;
String c anceled = Util . null2String ( params . get ( " c anceled") ) ;
String showC anceled = Util . null2String ( params . get ( " showC anceled") ) ;
if ( rs . next ( ) ) {
companyTree = TreeSelect . builder ( ) . key ( rs . getString ( "id" ) ) . title ( rs . getString ( "companyname" ) ) . type ( TreeSelect . COMPANY ) . cancelSql( c anceled) . build ( ) ;
companyTree = TreeSelect . builder ( ) . key ( rs . getString ( "id" ) ) . title ( rs . getString ( "companyname" ) ) . type ( TreeSelect . COMPANY ) . showCanceled( showC anceled) . build ( ) ;
expandedKeys = companyTree . getChildren ( ) . stream ( ) . filter ( item - > CollectionUtils . isNotEmpty ( item . getChildren ( ) ) ) . map ( TreeSelect : : getKey ) . collect ( Collectors . toList ( ) ) ;
expandedKeys . add ( companyTree . getKey ( ) ) ;
}
@ -511,6 +516,47 @@ public class ChartServiceImpl extends Service implements ChartService {
return result ;
}
/ * *
* 添 加 树 结 构 所 有 上 级 节 点
*
* @param expandedKeys 完 整 的 上 级 ID 集 合
* @param expandedKeyStr 需 要 展 开 的 树 ID
* /
private void addParentTreeId ( List < String > expandedKeys , String expandedKeyStr ) {
if ( StringUtils . isNotBlank ( expandedKeyStr ) ) {
String [ ] split = expandedKeyStr . split ( "," ) ;
for ( String s : split ) {
try {
// 上级分部ID
String subcompanyid1 = new DepartmentComInfo ( ) . getSubcompanyid1 ( s ) ;
String allSupCompany = new SubCompanyComInfo ( ) . getAllSupCompany ( subcompanyid1 ) ;
String [ ] array = allSupCompany . split ( "," ) ;
for ( String supCompany : array ) {
if ( StringUtils . isBlank ( supCompany ) ) {
continue ;
}
expandedKeys . add ( "s" + supCompany ) ;
}
expandedKeys . add ( "s" + subcompanyid1 ) ;
// 上级部门ID
String allSupDepartment = new DepartmentComInfo ( ) . getAllSupDepartment ( s ) ;
array = allSupDepartment . split ( "," ) ;
for ( String supDepartment : array ) {
if ( StringUtils . isBlank ( supDepartment ) ) {
continue ;
}
expandedKeys . add ( "d" + supDepartment ) ;
}
expandedKeys . add ( "d" + s ) ;
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
}
}
}
}
/ * *
* 树 节 点 是 否 禁 用
*