@ -15,37 +15,43 @@ import java.util.*;
* @version : 1.0
* /
public class DetachUtil {
private boolean DETACH = true ;
private boolean detach = true ;
private final Set < String > companyIds = new HashSet < > ( ) ;
private final Set < String > departmentIds = new HashSet < > ( ) ;
public DetachUtil ( User user ) {
if ( 1 = = user . getUID ( ) | | user . isAdmin ( ) ) {
DETACH = false ;
detach = false ;
}
if ( DETACH ) {
if ( detach ) {
try {
RecordSet rs = new RecordSet ( ) ;
// 查询建模表、添加相应的权限
rs . executeQuery ( "select fbqx from uf_zzjgtqx where yh = ? " , user . getUID ( ) ) ;
if ( rs . next ( ) ) {
String fbqx = rs . getString ( "fbqx" ) ;
if ( StringUtils . isNotBlank ( fbqx ) ) {
String [ ] manageCompanyIds = fbqx . split ( "," ) ;
for ( String companyId : manageCompanyIds ) {
rs . executeQuery ( "select id from hrmdepartment where subcompanyid1 = ? " , companyId ) ;
while ( rs . next ( ) ) {
getDetachDepartment ( rs . getString ( "id" ) ) ;
}
getDetachCompany ( companyId ) ;
}
}
}
// 拥有所辖部门及所在部门的权限
rs . executeQuery ( "select a.id, a.subcompanyid1 from hrmdepartment a inner join hrmdepartmentdefined b on a.id = b.deptid where a.id = ? or b.bmfzr = ? " , String . valueOf ( user . getUserDepartment ( ) ) , String . valueOf ( user . getUID ( ) ) ) ;
while ( rs . next ( ) ) {
String departmentId = rs . getString ( "id" ) ;
String allSupDepartment = new DepartmentComInfo ( ) . getAllSupDepartment ( departmentId ) ;
if ( StringUtils . isNotBlank ( allSupDepartment ) ) {
List < String > ids = Arrays . asList ( allSupDepartment . split ( "," ) ) ;
departmentIds . addAll ( ids ) ;
}
ArrayList < String > childDeptIds = new ArrayList < > ( ) ;
new DepartmentComInfo ( ) . getAllChildDeptByDepId ( childDeptIds , departmentId ) ;
departmentIds . addAll ( childDeptIds ) ;
departmentIds . add ( departmentId ) ;
getDetachDepartment ( departmentId ) ;
String subCompanyId = rs . getString ( "subcompanyid1" ) ;
String allSupCompany = new SubCompanyComInfo ( ) . getAllSupCompany ( subCompanyId ) ;
if ( StringUtils . isNotBlank ( allSupCompany ) ) {
List < String > ids = Arrays . asList ( allSupCompany . split ( "," ) ) ;
companyIds . addAll ( ids ) ;
}
companyIds . add ( subCompanyId ) ;
getDetachCompany ( subCompanyId ) ;
}
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
@ -53,8 +59,8 @@ public class DetachUtil {
}
}
public boolean isD ETACH ( ) {
return DETACH ;
public boolean isD etach ( ) {
return detach ;
}
public String getCompanyIds ( ) {
@ -70,4 +76,31 @@ public class DetachUtil {
}
return "" ;
}
private void getDetachDepartment ( String departmentId ) throws Exception {
if ( StringUtils . isBlank ( departmentId ) ) {
return ;
}
String allSupDepartment = new DepartmentComInfo ( ) . getAllSupDepartment ( departmentId ) ;
if ( StringUtils . isNotBlank ( allSupDepartment ) ) {
List < String > ids = Arrays . asList ( allSupDepartment . split ( "," ) ) ;
departmentIds . addAll ( ids ) ;
}
ArrayList < String > childDeptIds = new ArrayList < > ( ) ;
new DepartmentComInfo ( ) . getAllChildDeptByDepId ( childDeptIds , departmentId ) ;
departmentIds . addAll ( childDeptIds ) ;
departmentIds . add ( departmentId ) ;
}
private void getDetachCompany ( String companyId ) throws Exception {
if ( StringUtils . isBlank ( companyId ) ) {
return ;
}
String allSupCompany = new SubCompanyComInfo ( ) . getAllSupCompany ( companyId ) ;
if ( StringUtils . isNotBlank ( allSupCompany ) ) {
List < String > ids = Arrays . asList ( allSupCompany . split ( "," ) ) ;
companyIds . addAll ( ids ) ;
}
companyIds . add ( companyId ) ;
}
}