@ -19,7 +19,6 @@ import com.engine.organization.util.detach.DetachUtil;
import lombok.SneakyThrows ;
import org.apache.commons.collections.CollectionUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.docx4j.wml.U ;
import weaver.conn.RecordSet ;
import weaver.conn.RecordSetTrans ;
import weaver.general.BaseBean ;
@ -34,7 +33,6 @@ import java.time.LocalDate;
import java.time.LocalDateTime ;
import java.util.* ;
import java.util.concurrent.ExecutorService ;
import java.util.stream.Collectors ;
/ * *
@ -516,22 +514,63 @@ public class ChartServiceImpl extends Service implements ChartService {
RecordSet rs = new RecordSet ( ) ;
List < CompanyTreePO > departmentTree = new ArrayList < > ( ) ;
List < CompanyTreePO > topDepartmentTree = new ArrayList < > ( ) ;
String subCompany = Util . null2String ( params . get ( "subcompany" ) ) ;
String dimension = Util . null2String ( params . get ( "fclass" ) ) ;
String versionId = Util . null2String ( params . get ( "id" ) ) ;
if ( StringUtils . isBlank ( subCompany ) ) {
subCompany = "0" ;
}
String sql = getDepartmentTreeSql ( versionId , dimension , subCompany ) ;
DBType dbType = DBType . get ( new RecordSet ( ) . getDBType ( ) ) ;
// 根据分部查询顶级部门
String sql = "select id as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and" + dbType . ifNull ( "subcompanyid1" , "0" ) + " = " + subCompany ;
rs . executeQuery ( sql ) ;
while ( rs . next ( ) ) {
departmentTree . add ( CompanyTreePO . builder ( ) . id ( rs . getString ( "id" ) ) . pId ( rs . getString ( "pId" ) ) . disabled ( ! rs . getString ( "id" ) . startsWith ( "d" ) ) . value ( rs . getString ( "value" ) ) . title ( rs . getString ( "title" ) ) . isLeaf ( judgeTreeLeaf ( versionId , dimension , rs . getString ( "id" ) ) ) . build ( ) ) ;
topDepartmentTree . add (
CompanyTreePO . builder ( )
. id ( rs . getString ( "id" ) )
. pId ( rs . getString ( "pId" ) )
. disabled ( false )
. value ( rs . getString ( "value" ) )
. title ( rs . getString ( "title" ) )
. isLeaf ( true )
//.isLeaf(judgeTreeLeaf(versionId, dimension, rs.getString("id")))
. level ( 1 )
. build ( )
) ;
}
if ( CollectionUtils . isNotEmpty ( topDepartmentTree ) ) {
sql = "select id as id, id as value, departmentname as title, supdepid as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and " + dbType . ifNull ( "supdepid" , "0" ) + " = ?" ;
for ( CompanyTreePO department : topDepartmentTree ) {
getChildDepartment ( department , sql , departmentTree ) ;
}
}
result . put ( "departmentTree" , departmentTree ) ;
result . put ( "api_status" , true ) ;
return result ;
}
private void getChildDepartment ( CompanyTreePO parentDepartment , String sql , List < CompanyTreePO > departmentTree ) {
RecordSet rs = new RecordSet ( ) ;
rs . executeQuery ( sql , parentDepartment . getId ( ) ) ;
while ( rs . next ( ) ) {
CompanyTreePO build = CompanyTreePO . builder ( )
. id ( rs . getString ( "id" ) )
. pId ( rs . getString ( "pId" ) )
. disabled ( false )
. value ( rs . getString ( "value" ) )
. title ( rs . getString ( "title" ) )
. level ( parentDepartment . getLevel ( ) + 1 )
. isLeaf ( true )
. build ( ) ;
getChildDepartment ( build , sql , departmentTree ) ;
parentDepartment . setLeaf ( false ) ;
}
departmentTree . add ( parentDepartment ) ;
}
@Override
public Map < String , Object > getMovingTree ( Map < String , Object > params ) {
RecordSet rs = new RecordSet ( ) ;