2023-06-30 16:44:56 +08:00
package com.engine.organization.service.impl ;
2023-07-05 17:54:58 +08:00
import com.engine.common.util.ServiceUtil ;
2023-06-30 16:44:56 +08:00
import com.engine.core.impl.Service ;
import com.engine.organization.entity.chart.ChartPO ;
2023-07-06 10:47:34 +08:00
import com.engine.organization.mapper.hrmresource.SystemDataMapper ;
2023-07-11 18:08:40 +08:00
import com.engine.organization.mapper.jclorgmap.JclOrgMapper ;
2023-06-30 16:44:56 +08:00
import com.engine.organization.service.ChartService ;
2023-07-11 18:08:40 +08:00
import com.engine.organization.service.OrgChartService ;
2023-06-30 16:44:56 +08:00
import com.engine.organization.util.HasRightUtil ;
2023-07-05 17:41:30 +08:00
import com.engine.organization.util.OrganizationAssert ;
2023-07-11 18:08:40 +08:00
import com.engine.organization.util.OrganizationDateUtil ;
2023-07-06 10:47:34 +08:00
import com.engine.organization.util.db.MapperProxyFactory ;
2023-07-05 17:41:30 +08:00
import org.apache.commons.collections.CollectionUtils ;
2023-06-30 16:44:56 +08:00
import org.apache.commons.lang3.StringUtils ;
import weaver.conn.RecordSet ;
2023-07-11 18:08:40 +08:00
import weaver.conn.RecordSetTrans ;
2023-06-30 16:44:56 +08:00
import weaver.general.Util ;
2023-07-11 18:08:40 +08:00
import weaver.hrm.User ;
2023-07-06 13:55:48 +08:00
import weaver.hrm.resource.ResourceComInfo ;
2023-06-30 16:44:56 +08:00
2023-07-11 18:08:40 +08:00
import java.time.LocalDate ;
2023-07-05 17:41:30 +08:00
import java.util.* ;
2023-06-30 16:44:56 +08:00
/ * *
* @author : dxfeng
* @createTime : 2023 / 06 / 29
* @version : 1 . 0
* /
public class ChartServiceImpl extends Service implements ChartService {
private static final String COMPANY_RIGHT = " OrgChart:All " ;
public String COMPANY_TABLE = " " ;
public String SUB_COMPANY_TABLE = " " ;
public String SUB_COMPANY_DEFINED_TABLE = " " ;
public String DEPARTMENT_TABLE = " " ;
public String DEPARTMENT_DEFINED_TABLE = " " ;
2023-07-12 11:15:11 +08:00
public String SUB_COMPANY_ID = " '' " ;
public String DEPARTMENT_ID = " '' " ;
2023-06-30 16:44:56 +08:00
/ * *
* 显示虚拟组织
* /
boolean showVirtual = false ;
/ * *
* 是否已创建虚拟组织字段
* /
boolean hasVirtualFields ;
2023-07-11 18:08:40 +08:00
private JclOrgMapper getJclOrgMapMapper ( ) {
return MapperProxyFactory . getProxy ( JclOrgMapper . class , true ) ;
}
private OrgChartService getOrgChartService ( User user ) {
return ServiceUtil . getService ( OrgChartServiceImpl . class , user ) ;
}
2023-07-12 10:17:06 +08:00
/ * *
* 是否实际组织维度
* /
boolean isRealDimension ;
/ * *
* 是否即时数据
* /
boolean isRealTime ;
2023-06-30 16:44:56 +08:00
@Override
public Map < String , Object > getCompanyData ( Map < String , Object > params ) {
Map < String , Object > result = new HashMap < > ( ) ;
boolean hasRight = HasRightUtil . hasRight ( user , COMPANY_RIGHT , true ) ;
result . put ( " hasRight " , hasRight ) ;
if ( ! hasRight ) {
return result ;
}
// 根结点
String root = Util . null2String ( params . get ( " root " ) ) ;
root = StringUtils . isBlank ( root ) ? " 0 " : root ;
// 维度
String dimension = Util . null2String ( params . get ( " fclass " ) ) ;
dimension = StringUtils . isBlank ( dimension ) ? " 0 " : dimension ;
// 是否展示虚拟组织
String isVirtual = Util . null2String ( params . get ( " fisvitual " ) ) ;
showVirtual = " 1 " . equals ( isVirtual ) ;
2023-07-07 14:54:21 +08:00
String depth = Util . null2String ( params . get ( " level " ) ) ;
2023-07-11 15:17:56 +08:00
//版本id
String id = Util . null2String ( params . get ( " id " ) ) ;
2023-06-30 16:44:56 +08:00
// 初始化表名
2023-07-12 10:17:06 +08:00
initTableNameByClass ( dimension , id ) ;
2023-06-30 16:44:56 +08:00
RecordSet rs = new RecordSet ( ) ;
List < ChartPO > dataList = new ArrayList < > ( ) ;
String sql = " " ;
ChartPO topChartPO = null ;
2023-07-11 15:17:56 +08:00
//查询当前实际数据
2023-07-12 10:17:06 +08:00
if ( isRealTime ) {
2023-07-11 15:17:56 +08:00
sql = getRealTimeTopSql ( root , dimension ) ;
2023-07-12 10:17:06 +08:00
} else {
sql = getLastTimeTopSql ( root , dimension , id ) ;
2023-07-11 15:17:56 +08:00
}
2023-06-30 16:44:56 +08:00
rs . executeQuery ( sql ) ;
// 封装顶部节点
if ( rs . next ( ) ) {
topChartPO = new ChartPO ( ) ;
topChartPO . setFtype ( rs . getString ( " type " ) ) ;
topChartPO . setFobjid ( rs . getString ( " id " ) ) ;
topChartPO . setFname ( rs . getString ( " name " ) ) ;
topChartPO . setParentId ( null ) ;
topChartPO . setExpand ( " 1 " ) ;
topChartPO . setFisvitual ( rs . getString ( " isvitual " ) ) ;
topChartPO . setHasChildren ( getHasChildren ( topChartPO . getFtype ( ) , topChartPO . getFobjid ( ) ) . toString ( ) ) ;
dataList . add ( topChartPO ) ;
}
// 向下查询数据
if ( null ! = topChartPO ) {
2023-07-12 10:17:06 +08:00
findChildData ( topChartPO , dataList , Integer . parseInt ( depth ) , id ) ;
2023-06-30 16:44:56 +08:00
}
result . put ( " api_status " , true ) ;
result . put ( " data " , dataList ) ;
return result ;
}
2023-07-11 15:17:56 +08:00
2023-07-03 10:49:48 +08:00
@Override
public Map < String , Object > asyncCompanyData ( Map < String , Object > params ) {
// 维度
String dimension = Util . null2String ( params . get ( " fclass " ) ) ;
dimension = StringUtils . isBlank ( dimension ) ? " 0 " : dimension ;
// 是否展示虚拟组织
String isVirtual = Util . null2String ( params . get ( " fisvitual " ) ) ;
showVirtual = " 1 " . equals ( isVirtual ) ;
2023-07-12 10:17:06 +08:00
//版本id
2023-07-12 17:00:01 +08:00
String versionId = Util . null2String ( params . get ( " id " ) ) ;
2023-07-03 10:49:48 +08:00
// 初始化表名
2023-07-12 17:00:01 +08:00
initTableNameByClass ( dimension , versionId ) ;
2023-07-03 10:49:48 +08:00
String ids = ( String ) params . get ( " ids " ) ;
List < ChartPO > dataList = new ArrayList < > ( ) ;
if ( StringUtils . isNotBlank ( ids ) ) {
RecordSet rs = new RecordSet ( ) ;
String [ ] split = ids . split ( " , " ) ;
for ( String s : split ) {
//TODO 查询当前实际数据
if ( s . contains ( " _ " ) ) {
String fObjId = s . split ( " _ " ) [ 1 ] ;
if ( s . startsWith ( " s " ) ) {
2023-07-12 17:00:01 +08:00
if ( isRealTime ) {
rs . executeQuery ( getRealTimeChildSql ( " " , " 1 " , fObjId ) ) ;
2023-07-03 10:49:48 +08:00
} else {
2023-07-12 17:00:01 +08:00
rs . executeQuery ( getLastTimeChildSql ( " " , " 1 " , fObjId , versionId ) ) ;
2023-07-03 10:49:48 +08:00
}
} else if ( s . startsWith ( " d " ) ) {
2023-07-12 17:00:01 +08:00
if ( isRealTime ) {
rs . executeQuery ( getRealTimeChildSql ( " " , " 2 " , fObjId ) ) ;
2023-07-03 10:49:48 +08:00
} else {
2023-07-12 17:00:01 +08:00
rs . executeQuery ( getLastTimeChildSql ( " " , " 2 " , fObjId , versionId ) ) ;
2023-07-03 10:49:48 +08:00
}
}
2023-07-12 10:17:06 +08:00
while ( rs . next ( ) ) {
2023-07-03 10:49:48 +08:00
ChartPO chartPO = new ChartPO ( ) ;
chartPO . setFtype ( rs . getString ( " type " ) ) ;
chartPO . setFobjid ( rs . getString ( " id " ) ) ;
chartPO . setFname ( rs . getString ( " name " ) ) ;
chartPO . setParentId ( s ) ;
chartPO . setExpand ( " 0 " ) ;
chartPO . setFisvitual ( rs . getString ( " isvitual " ) ) ;
chartPO . setHasChildren ( getHasChildren ( chartPO . getFtype ( ) , chartPO . getFobjid ( ) ) . toString ( ) ) ;
dataList . add ( chartPO ) ;
}
}
}
}
Map < String , Object > result = new HashMap < > ( ) ;
2023-07-05 17:41:30 +08:00
result . put ( " api_status " , true ) ;
result . put ( " data " , dataList ) ;
return result ;
}
@Override
public Map < String , Object > getDepartmentDetail ( Map < String , Object > params ) {
String rootId = Util . null2String ( params . get ( " rootId " ) ) ;
// 维度
String dimension = Util . null2String ( params . get ( " fclass " ) ) ;
dimension = StringUtils . isBlank ( dimension ) ? " 0 " : dimension ;
2023-07-07 10:19:59 +08:00
// 是否显示岗位
String showJobStr = Util . null2String ( params . get ( " showJob " ) ) ;
boolean showJob = " 1 " . equals ( showJobStr ) ;
2023-07-12 10:17:06 +08:00
//版本id
2023-07-12 11:15:11 +08:00
String versionId = Util . null2String ( params . get ( " id " ) ) ;
2023-07-05 17:41:30 +08:00
2023-07-12 16:09:04 +08:00
OrganizationAssert . isFalse ( StringUtils . isBlank ( rootId ) | | ! rootId . startsWith ( " d_ " ) , " 数据有误,未查询到对应数据 " ) ;
String departmentId = rootId . split ( " _ " ) [ 1 ] ;
String detauleType = Util . null2String ( params . get ( " detauleType " ) ) ;
if ( ! " chart " . equals ( detauleType ) ) {
// 展示列表模块
2023-07-12 17:00:01 +08:00
return ServiceUtil . getService ( HrmResourceServiceImpl . class , user ) . chartResourceList ( Integer . parseInt ( departmentId ) , versionId , dimension ) ;
2023-07-12 16:09:04 +08:00
}
2023-07-07 10:19:59 +08:00
2023-07-05 17:41:30 +08:00
// 初始化表名
2023-07-12 11:15:11 +08:00
initTableNameByClass ( dimension , versionId ) ;
2023-07-05 17:41:30 +08:00
List < ChartPO > dataList = new ArrayList < > ( ) ;
2023-07-07 10:19:59 +08:00
List < ChartPO > jobTitleList = new ArrayList < > ( ) ;
2023-07-06 10:06:38 +08:00
int departmentOnJob = 0 ;
2023-07-07 10:19:59 +08:00
int resourceNum ;
2023-07-05 17:41:30 +08:00
RecordSet rs = new RecordSet ( ) ;
// TODO 查询当前实际的数据
String sql ;
2023-07-12 11:15:11 +08:00
if ( isRealTime ) {
// 查询部门本身
if ( hasVirtualFields ) {
sql = " select a.id,a.departmentname as name,b.bmfzr,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = ' " + departmentId + " ' " ;
} else {
sql = " select a.id,a.departmentname as name,b.bmfzr from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = ' " + departmentId + " ' " ;
}
2023-07-12 10:17:06 +08:00
} else {
2023-07-12 11:15:11 +08:00
if ( hasVirtualFields ) {
2023-07-13 15:26:11 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name,fleader as bmfzr,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where a. " + DEPARTMENT_ID + " = ' " + departmentId + " ' and versionid = " + versionId ;
2023-07-12 11:15:11 +08:00
} else {
2023-07-13 15:26:11 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name from " + DEPARTMENT_TABLE + " a where a. " + DEPARTMENT_ID + " = ' " + departmentId + " ' and versionid = " + versionId ;
2023-07-12 11:15:11 +08:00
}
2023-07-05 17:41:30 +08:00
}
rs . executeQuery ( sql ) ;
2023-07-07 10:19:59 +08:00
ChartPO departmentChartPO = new ChartPO ( ) ;
2023-07-12 10:17:06 +08:00
if ( rs . next ( ) ) {
2023-07-07 10:19:59 +08:00
String fLeader = Util . null2String ( rs . getString ( " bmfzr " ) ) ;
departmentChartPO . setFtype ( " 2 " ) ;
departmentChartPO . setFobjid ( departmentId ) ;
departmentChartPO . setId ( rootId ) ;
departmentChartPO . setFname ( rs . getString ( " name " ) ) ;
2023-07-05 17:41:30 +08:00
// 岗位处理后的ID
2023-07-07 10:19:59 +08:00
departmentChartPO . setExpand ( " 1 " ) ;
departmentChartPO . setFisvitual ( rs . getString ( " isvitual " ) ) ;
2023-07-05 17:41:30 +08:00
2023-07-07 10:19:59 +08:00
// 部门负责人
departmentChartPO . setFleader ( getDepartmentLeader ( fLeader ) ) ;
dataList . add ( departmentChartPO ) ;
2023-07-05 17:41:30 +08:00
}
2023-07-07 10:19:59 +08:00
if ( showJob ) {
// 查询部门下的岗位
2023-07-12 11:15:11 +08:00
if ( isRealTime ) {
sql = " select a.id,a.jobtitlename as name from hrmjobtitles a inner join jcl_org_job b on a.id = b.ec_jobtitle where b.ec_department = ' " + departmentId + " ' " ;
2023-07-12 17:00:01 +08:00
} else {
2023-07-12 11:15:11 +08:00
sql = " select jobid as id ,jobname as name from jcl_chart_job where departmentid = ' " + departmentId + " ' and versionid = " + versionId ;
}
2023-07-05 17:41:30 +08:00
rs . executeQuery ( sql ) ;
2023-07-07 10:19:59 +08:00
while ( rs . next ( ) ) {
2023-07-05 17:41:30 +08:00
ChartPO chartPO = new ChartPO ( ) ;
chartPO . setFtype ( " 3 " ) ;
chartPO . setFobjid ( rs . getString ( " id " ) ) ;
chartPO . setId ( departmentId + " _ " + chartPO . getFobjid ( ) ) ;
chartPO . setFname ( rs . getString ( " name " ) ) ;
// 岗位处理后的ID
chartPO . setParentId ( rootId ) ;
chartPO . setExpand ( " 1 " ) ;
chartPO . setHasChildren ( " 1 " ) ;
2023-07-07 10:19:59 +08:00
jobTitleList . add ( chartPO ) ;
}
2023-07-05 17:41:30 +08:00
2023-07-12 11:15:11 +08:00
// 遍历岗位、查询对应岗位下的人员
if ( isRealTime ) {
if ( isRealDimension ) {
2023-07-12 16:13:08 +08:00
sql = " select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ? " ;
2023-07-12 11:15:11 +08:00
} else {
2023-07-12 16:13:08 +08:00
sql = " select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ? " ;
2023-07-12 11:15:11 +08:00
}
2023-07-07 10:19:59 +08:00
} else {
2023-07-12 16:13:08 +08:00
sql = " select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and a.jobtitleid = ? and versionid = " + versionId ;
2023-07-07 10:19:59 +08:00
}
for ( ChartPO jobTitlePO : jobTitleList ) {
resourceNum = 0 ;
rs . executeQuery ( sql , departmentId , jobTitlePO . getFobjid ( ) ) ;
2023-07-12 16:13:08 +08:00
String parentId = departmentId + " _ " + jobTitlePO . getFobjid ( ) ;
2023-07-07 10:19:59 +08:00
while ( rs . next ( ) ) {
2023-07-12 16:13:08 +08:00
ChartPO chartPO = getResourceChartPO ( rs . getString ( " id " ) , rs . getString ( " name " ) , parentId , rs . getString ( " belongto " ) , rs . getString ( " companyworkyear " ) ) ;
2023-07-07 10:19:59 +08:00
resourceNum + + ;
dataList . add ( chartPO ) ;
2023-07-05 17:41:30 +08:00
}
2023-07-07 10:19:59 +08:00
jobTitlePO . setFonjob ( resourceNum ) ;
departmentOnJob + = resourceNum ;
dataList . add ( jobTitlePO ) ;
2023-07-05 17:41:30 +08:00
}
2023-07-07 10:19:59 +08:00
departmentChartPO . setHasChildren ( CollectionUtils . isNotEmpty ( jobTitleList ) ? " 1 " : " 0 " ) ;
2023-07-12 10:17:06 +08:00
} else {
2023-07-07 10:19:59 +08:00
// 直接查询岗位下的人员
2023-07-12 16:13:08 +08:00
if ( isRealTime ) {
if ( isRealDimension ) {
sql = " select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? " ;
} else {
sql = " select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? " ;
}
} else {
sql = " select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and versionid = " + versionId ;
}
2023-07-07 10:19:59 +08:00
rs . executeQuery ( sql , departmentId ) ;
while ( rs . next ( ) ) {
2023-07-12 16:13:08 +08:00
ChartPO chartPO = getResourceChartPO ( rs . getString ( " id " ) , rs . getString ( " name " ) , rootId , rs . getString ( " belongto " ) , rs . getString ( " companyworkyear " ) ) ;
2023-07-07 10:19:59 +08:00
dataList . add ( chartPO ) ;
departmentOnJob + + ;
}
2023-07-05 17:41:30 +08:00
}
2023-07-07 10:19:59 +08:00
departmentChartPO . setFonjob ( departmentOnJob ) ;
2023-07-05 17:41:30 +08:00
Map < String , Object > result = new HashMap < > ( ) ;
2023-07-03 10:49:48 +08:00
result . put ( " api_status " , true ) ;
result . put ( " data " , dataList ) ;
return result ;
}
2023-07-11 15:17:56 +08:00
@Override
public String selectVersionDate ( String id ) {
RecordSet rs = new RecordSet ( ) ;
2023-07-12 10:17:06 +08:00
rs . executeQuery ( " select recorddate from jcl_org_chartversion where id = ? " , id ) ;
2023-07-11 15:17:56 +08:00
rs . next ( ) ;
return rs . getString ( " recorddate " ) ;
}
2023-07-12 16:13:08 +08:00
/ * *
* 构建人员图谱元素
*
* @param id 人员ID
* @param name 人员名称
* @param parentId 父级ID
* @param belongTo 是否次账号
* @param companyWorkYear 司龄
* @return
* /
private ChartPO getResourceChartPO ( String id , String name , String parentId , String belongTo , String companyWorkYear ) {
ChartPO chartPO = new ChartPO ( ) ;
chartPO . setFtype ( " 4 " ) ;
chartPO . setFobjid ( id ) ;
chartPO . setId ( chartPO . getFobjid ( ) ) ;
chartPO . setFname ( name ) ;
// 岗位处理后的ID
chartPO . setParentId ( parentId ) ;
chartPO . setExpand ( " 0 " ) ;
chartPO . setHasChildren ( " 0 " ) ;
chartPO . setBelongto ( Util . null2String ( belongTo ) ) ;
chartPO . setCompanyWorkYear ( companyWorkYear ) ;
try {
chartPO . setFleaderimg ( new ResourceComInfo ( ) . getMessagerUrls ( chartPO . getId ( ) ) ) ;
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
}
return chartPO ;
}
2023-07-11 15:17:56 +08:00
/ * *
* 获取历史顶部元素sql
2023-07-12 10:17:06 +08:00
*
2023-07-11 15:17:56 +08:00
* @param root
* @param dimension 维度ID
2023-07-12 10:17:06 +08:00
* @param versionId
2023-07-11 15:17:56 +08:00
* @return
* /
2023-07-12 10:17:06 +08:00
private String getLastTimeTopSql ( String root , String dimension , String versionId ) {
2023-07-11 15:17:56 +08:00
if ( " 0 " . equals ( root ) ) {
2023-07-11 16:06:23 +08:00
//查询集团维度历史版本
2023-07-12 10:17:06 +08:00
if ( isRealDimension ) {
2023-07-11 16:06:23 +08:00
//组织维度
2023-07-12 10:17:06 +08:00
return " select id,companyname as name,'0' as type from " + COMPANY_TABLE ;
2023-07-11 16:06:23 +08:00
} else {
//查询其他维度集团版本信息
2023-07-13 15:26:11 +08:00
return " select companyvirtualid as id,companyname as name,'0' as type from " + COMPANY_TABLE + " where " +
2023-07-12 10:17:06 +08:00
" versionid = " + versionId + " and companyvirtualid = " + dimension ;
}
} else {
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-12 11:15:11 +08:00
return " select " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root ;
2023-07-12 10:17:06 +08:00
} else {
2023-07-12 11:15:11 +08:00
return " select " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root + " and (isvirtual is null or isvirtual != '1') " ;
2023-07-12 10:17:06 +08:00
}
} else {
2023-07-12 11:15:11 +08:00
return " select " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root ;
2023-07-11 16:06:23 +08:00
}
2023-07-11 15:17:56 +08:00
}
}
2023-07-11 18:08:40 +08:00
@Override
public Map < String , Object > versionRecord ( Map < String , Object > params , User user ) {
RecordSetTrans recordSetTrans = new RecordSetTrans ( ) ;
recordSetTrans . setAutoCommit ( false ) ; //关闭自动提交
RecordSet rs = new RecordSet ( ) ;
// 维度
String dimension = Util . null2String ( params . get ( " fclass " ) ) ;
dimension = StringUtils . isBlank ( dimension ) ? " 0 " : dimension ;
//描述
String description = Util . null2String ( params . get ( " description " ) ) ;
//当前日期
String currentDate = OrganizationDateUtil . getFormatLocalDateTime ( new Date ( ) ) ;
//当前用户
String currentUser = String . valueOf ( user . getUID ( ) ) ;
//版本记录表数据存储
getOrgChartService ( user ) . insertChartVersion ( Integer . valueOf ( dimension ) , description ) ;
String versionId = " " ;
String createDate = OrganizationDateUtil . getFormatLocalDate ( LocalDate . now ( ) ) ;
2023-07-12 18:00:47 +08:00
rs . executeQuery ( " select id from JCL_ORG_CHARTVERSION where fclass = ? and createtime = ? " , dimension , createDate ) ;
2023-07-11 18:08:40 +08:00
if ( rs . next ( ) ) {
versionId = Util . null2String ( rs . getString ( " id " ) ) ;
}
2023-07-12 18:00:47 +08:00
if ( " 0 " . equals ( dimension ) ) {
//实体维度
trueDimension ( versionId , currentUser , currentDate ) ;
} else {
virtualDimension ( versionId , currentUser , currentDate , dimension ) ;
}
Map < String , Object > result = new HashMap < > ( ) ;
result . put ( " api_status " , true ) ;
return result ;
}
private void trueDimension ( String versionId , String currentUser , String currentDate ) {
RecordSet rs = new RecordSet ( ) ;
rs . execute ( " delete from jcl_chart_subcompany where versionid = " + versionId ) ;
rs . execute ( " delete from jcl_chart_department where versionid = " + versionId ) ;
rs . execute ( " delete from jcl_chart_job where versionid = " + versionId ) ;
rs . execute ( " delete from jcl_chart_resource where versionid = " + versionId ) ;
2023-07-11 18:08:40 +08:00
String subCompanyQuerySql ; //分部查询数据sql
String deptQuerySql ; //部门查询数据sql
//判断是否有虚拟组织字段
boolean virtualFlag = isHasVirtualFields ( ) ;
if ( virtualFlag ) {
subCompanyQuerySql = " select a.id as subcompanyid, \ n " +
" a.subcompanyname, \ n " +
" a.subcompanydesc, \ n " +
" a.companyid as company, \ n " +
" b.supsubcomid as supsubcompanyid, \ n " +
" b.subcompanyname as supsubcompany, \ n " +
" a.canceled, \ n " +
" a.subcompanycode, \ n " +
" a.limitusers, \ n " +
" a.tlevel, \ n " +
2023-07-12 18:00:47 +08:00
" c.fblx as isvirtual \ n " +
2023-07-11 18:08:40 +08:00
" from hrmsubcompany a \ n " +
" left join hrmsubcompany b on a.supsubcomid = b.id \ n " +
" left join hrmsubcompanydefined c on a.id = c.subcomid " ;
2023-07-12 18:00:47 +08:00
deptQuerySql = " select a.id as departmentid, a.departmentmark, a.departmentname, a.subcompanyid1 as subcompanyid, " +
" b.SUBCOMPANYNAME as subcompany,a.supdepid as supdepartmentid,c.departmentname as supdepartment, " +
" a.canceled,a.departmentcode,a.coadjutant,a.tlevel,d.bmlx as isvirtual,a.bmfzr as fleader " +
" from hrmdepartment a left join hrmsubcompany b on a.subcompanyid1 = b.id " +
" left join hrmdepartment c on a.supdepid = c.id " +
" left join hrmdepartmentdefined d on a.id=d.deptid " ;
2023-07-11 18:08:40 +08:00
} else {
subCompanyQuerySql = " select a.id as subcompanyid, \ n " +
" a.subcompanyname, \ n " +
" a.subcompanydesc, \ n " +
" a.companyid as company, \ n " +
" b.supsubcomid as supsubcompanyid, \ n " +
" b.subcompanyname as supsubcompany, \ n " +
" a.canceled, \ n " +
" a.subcompanycode, \ n " +
" a.limitusers, \ n " +
" a.tlevel, \ n " +
" from hrmsubcompany a \ n " +
" left join hrmsubcompany b on a.supsubcomid = b.id " ;
2023-07-12 18:00:47 +08:00
deptQuerySql = " select a.id as departmentid, \ n " +
2023-07-11 18:08:40 +08:00
" a.departmentmark, \ n " +
" a.departmentname, \ n " +
" a.subcompanyid1 as subcompanyid, \ n " +
" b.SUBCOMPANYNAME as subcompany, \ n " +
" a.supdepid as supdepartmentid, \ n " +
" c.departmentname as supdepartment, \ n " +
" a.canceled, \ n " +
" a.departmentcode, \ n " +
" a.coadjutant, \ n " +
" a.tlevel, \ n " +
" a.bmfzr as fleader \ n " +
" from hrmdepartment a \ n " +
" left join hrmsubcompany b on a.subcompanyid1 = b.id \ n " +
" left join hrmdepartment c on a.supdepid = c.id " ;
}
2023-07-12 18:00:47 +08:00
List < Object > insertList = new ArrayList < > ( ) ;
List < List < Object > > insertParamList = new ArrayList < > ( ) ;
2023-07-11 18:08:40 +08:00
//当前分部版本存储
rs . executeQuery ( subCompanyQuerySql ) ;
while ( rs . next ( ) ) {
2023-07-12 18:00:47 +08:00
insertList = new ArrayList < > ( ) ;
insertList . add ( currentUser ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " subcompanyid " ) ) ? null : rs . getInt ( " subcompanyid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " subcompanyname " ) ) ;
insertList . add ( rs . getString ( " subcompanydesc " ) ) ;
insertList . add ( rs . getString ( " company " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " supsubcompanyid " ) ) ? null : rs . getInt ( " supsubcompanyid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " supsubcompany " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " canceled " ) ) ? null : rs . getInt ( " canceled " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " subcompanycode " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " limitusers " ) ) ? null : rs . getInt ( " limitusers " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " tlevel " ) ) ? null : rs . getInt ( " tlevel " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentDate ) ;
insertList . add ( virtualFlag ? Util . getIntValue ( rs . getString ( " isvirtual " ) , 0 ) : 1 ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
2023-07-11 18:08:40 +08:00
}
2023-07-12 18:00:47 +08:00
String insertSubSql = " insert into jcl_chart_subcompany(creater, subcompanyid, subcompanyname, subcompanydesc, company, \ n " +
" supsubcompanyid, supsubcompany, canceled, subcompanycode, limitusers, \ n " +
" tlevel, versiondate, isvirtual,versionId) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
insertData ( insertSubSql , insertParamList ) ;
2023-07-11 18:08:40 +08:00
//当前部门版本存储
rs . executeQuery ( deptQuerySql ) ;
2023-07-12 18:00:47 +08:00
insertParamList = new ArrayList < > ( ) ;
2023-07-11 18:08:40 +08:00
while ( rs . next ( ) ) {
2023-07-12 18:00:47 +08:00
insertList = new ArrayList < > ( ) ;
insertList . add ( currentUser ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " departmentid " ) ) ? null : rs . getInt ( " departmentid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " departmentmark " ) ) ;
insertList . add ( rs . getString ( " departmentname " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " subcompanyid " ) ) ? null : rs . getInt ( " subcompanyid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " subcompany " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " supdepartmentid " ) ) ? null : rs . getInt ( " supdepartmentid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " supdepartment " ) ) ;
insertList . add ( rs . getInt ( " canceled " ) ) ;
insertList . add ( rs . getString ( " departmentcode " ) ) ;
insertList . add ( rs . getString ( " coadjutant " ) ) ;
// insertList.add(rs.getInt("tlevel"));
insertList . add ( rs . getString ( " fleader " ) ) ;
insertList . add ( currentDate ) ;
insertList . add ( virtualFlag ? Util . getIntValue ( rs . getString ( " isvirtual " ) , 0 ) : 1 ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
2023-07-11 18:08:40 +08:00
}
2023-07-12 18:00:47 +08:00
String insertDeptSql = " insert into jcl_chart_department(creater, departmentid, departmentmark, departmentname, subcompanyid, \ n " +
" subcompany, supdepartmentid, supdepartment, canceled, departmentcode, \ n " +
" coadjutant, fleader,versiondate, isvirtual,versionid) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
insertData ( insertDeptSql , insertParamList ) ;
//当前岗位版本存储
2023-07-13 15:26:11 +08:00
rs . executeQuery ( " select b.id as jobid,b.JOBTITLENAME as jobname,a.ec_department as departmentid, " +
2023-07-12 18:00:47 +08:00
" c.departmentname as department,a.ec_company as subcompanyid,d.subcompanyname as subcompany, " +
" b.jobresponsibility,a.forbidden_tag as canceled,a.job_no as jobcode,a.description " +
2023-07-13 15:26:11 +08:00
" from jcl_org_job a inner join hrmjobtitles b on a.ec_jobtitle = b.id " +
2023-07-12 18:00:47 +08:00
" left join hrmdepartment c on a.ec_department=c.id " +
" left join hrmsubcompany d on a.ec_company=d.id " ) ;
insertParamList = new ArrayList < > ( ) ;
2023-07-13 11:08:22 +08:00
while ( rs . next ( ) ) {
2023-07-12 18:00:47 +08:00
insertList = new ArrayList < > ( ) ;
2023-07-13 15:26:11 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " jobid " ) ) ? null : rs . getString ( " jobid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentUser ) ;
insertList . add ( rs . getString ( " jobname " ) ) ;
insertList . add ( rs . getString ( " departmentid " ) ) ;
insertList . add ( rs . getString ( " department " ) ) ;
insertList . add ( rs . getString ( " subcompanyid " ) ) ;
insertList . add ( rs . getString ( " subcompany " ) ) ;
insertList . add ( rs . getString ( " jobresponsibility " ) ) ;
insertList . add ( rs . getString ( " canceled " ) ) ;
insertList . add ( rs . getString ( " jobcode " ) ) ;
insertList . add ( rs . getString ( " description " ) ) ;
insertList . add ( currentDate ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
}
String insertJobSql = " insert into jcl_chart_job(jobid,creater,jobname,departmentid,department,subcompanyid, " +
" subcompany,jobresponsibility,canceled,jobcode,description,versiondate,versionid)values(?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
insertData ( insertJobSql , insertParamList ) ;
//当前人员版本存储
rs . executeQuery ( " select a.id as resourceid,workyear,usekind,managerstr,status,sex,accounttype,belongto, " +
" loginid,maritalstatus,a.telephone,mobile,mobilecall,email,b.locationname,resourcetype,startdate, " +
2023-07-13 15:26:11 +08:00
" enddate,d.id as jobtitleid,d.JOBTITLENAME as jobtitle,joblevel,seclevel,departmentid,e.departmentname as department, " +
2023-07-12 18:00:47 +08:00
" a.subcompanyid1 as subcompanyid,f.subcompanyname as subcompany,a.costcenterid as costcenter, " +
" a.managerid as manager,a.assistantid as assistant,workcode,classification,policy, " +
" degree,a.lastname,a.companyworkyear from hrmresource a " +
" left join hrmlocations b on a.locationid = b.id " +
2023-07-13 15:26:11 +08:00
" left join hrmjobtitles d on a.jobtitle = d.id " +
2023-07-12 18:00:47 +08:00
" left join hrmdepartment e on a.departmentid = e.id " +
" left join hrmsubcompany f on a.subcompanyid1=f.id " ) ;
insertParamList = new ArrayList < > ( ) ;
while ( rs . next ( ) ) {
insertList = new ArrayList < > ( ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " resourceid " ) ) ? null : rs . getInt ( " resourceid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentUser ) ;
2023-07-13 15:26:11 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " workyear " ) ) ? null : rs . getString ( " workyear " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " usekind " ) ) ;
insertList . add ( rs . getString ( " managerstr " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " status " ) ) ? null : rs . getInt ( " status " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " sex " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " accounttype " ) ) ? null : rs . getInt ( " accounttype " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " belongto " ) ) ? null : rs . getInt ( " belongto " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " loginid " ) ) ;
insertList . add ( rs . getString ( " maritalstatus " ) ) ;
insertList . add ( rs . getString ( " telephone " ) ) ;
insertList . add ( rs . getString ( " mobile " ) ) ;
insertList . add ( rs . getString ( " mobilecall " ) ) ;
insertList . add ( rs . getString ( " email " ) ) ;
insertList . add ( rs . getString ( " locationname " ) ) ;
insertList . add ( rs . getString ( " resourcetype " ) ) ;
insertList . add ( rs . getString ( " startdate " ) ) ;
insertList . add ( rs . getString ( " enddate " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " jobtitleid " ) ) ? null : rs . getInt ( " jobtitleid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " jobtitle " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " joblevel " ) ) ? null : rs . getInt ( " joblevel " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " seclevel " ) ) ? null : rs . getInt ( " seclevel " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " departmentid " ) ) ? null : rs . getInt ( " departmentid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " department " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " subcompanyid " ) ) ? null : rs . getInt ( " subcompanyid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " subcompany " ) ) ;
insertList . add ( rs . getString ( " costcenter " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " manager " ) ) ? null : rs . getInt ( " manager " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " assistant " ) ) ? null : rs . getInt ( " assistant " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " workcode " ) ) ;
insertList . add ( rs . getString ( " classification " ) ) ;
insertList . add ( currentDate ) ;
insertList . add ( rs . getString ( " policy " ) ) ;
insertList . add ( rs . getString ( " degree " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " lastname " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " companyworkyear " ) ) ? null : rs . getString ( " companyworkyear " ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
}
String insertResourceSql = " insert into jcl_chart_resource(resourceid, creater, workyear, usekind, managerstr, " +
" status, sex, accounttype,belongto, loginid, maritalstatus, telephone, mobile, mobilecall, email, " +
" locationname, resourcetype, startdate, enddate, jobtitleid, jobtitle, joblevel,seclevel, departmentid, " +
" department, subcompanyid, subcompany, costcenter,manager, assistant, workcode, classification, " +
" versiondate, policy, degree,versionid,lastname,companyworkyear) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
insertData ( insertResourceSql , insertParamList ) ;
}
private void virtualDimension ( String versionId , String currentUser , String currentDate , String fclass ) {
RecordSet rs = new RecordSet ( ) ;
List < Object > insertList ;
List < List < Object > > insertParamList = new ArrayList < > ( ) ;
rs . execute ( " delete from jcl_chart_companyvirtual where versionid = " + versionId ) ;
rs . execute ( " delete from jcl_chart_subcompanyvirtual where versionid = " + versionId ) ;
rs . execute ( " delete from jcl_chart_departmentvirtual where versionid = " + versionId ) ;
rs . execute ( " delete from jcl_chart_resource where versionid = " + versionId ) ;
2023-07-11 18:08:40 +08:00
//虚拟总部存储
rs . executeQuery ( " select id as companyvirtualid,companyname,companycode,companydesc,showorder,canceled, " +
2023-07-12 18:00:47 +08:00
" virtualtype,virtualtypedesc from hrmcompanyvirtual where id=? " , fclass ) ;
2023-07-11 18:08:40 +08:00
while ( rs . next ( ) ) {
2023-07-12 18:00:47 +08:00
insertList = new ArrayList < > ( ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " companyvirtualid " ) ) ? null : rs . getInt ( " companyvirtualid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentUser ) ;
insertList . add ( rs . getString ( " companyname " ) ) ;
insertList . add ( rs . getString ( " companycode " ) ) ;
insertList . add ( rs . getString ( " companydesc " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " showorder " ) ) ? null : rs . getInt ( " showorder " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " canceled " ) ) ? null : rs . getInt ( " canceled " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " virtualtype " ) ) ;
insertList . add ( rs . getString ( " virtualtypedesc " ) ) ;
insertList . add ( currentDate ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
2023-07-11 18:08:40 +08:00
}
2023-07-12 18:00:47 +08:00
String insertVirtualComSql = " insert into jcl_chart_companyvirtual(companyvirtualid,creater,companyname,companycode,companydesc,showorder, \ n " +
" canceled,virtualtype,virtualtypedesc,versiondate,versionid) values(?,?,?,?,?,?,?,?,?,?,?) " ;
insertData ( insertVirtualComSql , insertParamList ) ;
2023-07-11 18:08:40 +08:00
//虚拟分部版本存储
rs . executeQuery ( " select a.id as subcompanyvirtualid,a.subcompanyname,a.subcompanycode,a.subcompanydesc, " +
" b.subcompanyname as supsubcompany,a.supsubcomid,c.companyname as company,a.companyid,a.canceled, " +
" a.virtualtypeid as virtualtype,a.tlevel,a.showorder from hrmsubcompanyvirtual a " +
" left join hrmsubcompanyvirtual b on a.supsubcomid = b.id \ n " +
2023-07-12 18:00:47 +08:00
" left join hrmcompanyvirtual c on a.companyid = c.id where a.companyid=? " , fclass ) ;
insertParamList = new ArrayList < > ( ) ;
2023-07-11 18:08:40 +08:00
while ( rs . next ( ) ) {
2023-07-12 18:00:47 +08:00
insertList = new ArrayList < > ( ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " subcompanyvirtualid " ) ) ? null : rs . getInt ( " subcompanyvirtualid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentUser ) ;
insertList . add ( rs . getString ( " subcompanyname " ) ) ;
insertList . add ( rs . getString ( " subcompanycode " ) ) ;
insertList . add ( rs . getString ( " subcompanydesc " ) ) ;
insertList . add ( rs . getString ( " supsubcompany " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " supsubcomid " ) ) ? null : rs . getInt ( " supsubcomid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " company " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " companyid " ) ) ? null : rs . getInt ( " companyid " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " canceled " ) ) ? null : rs . getInt ( " canceled " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " virtualtype " ) ) ;
insertList . add ( rs . getString ( " tlevel " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " showorder " ) ) ? null : rs . getInt ( " showorder " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentDate ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
2023-07-11 18:08:40 +08:00
}
2023-07-12 18:00:47 +08:00
String insertVirtualSubComSql = " insert into jcl_chart_subcompanyvirtual(subcompanyvirtualid, creater, " +
2023-07-13 15:26:11 +08:00
" subcompanyname, subcompanycode,subcompanydesc, supsubcompany, supsubcompanyid, company, companyid, " +
2023-07-12 18:00:47 +08:00
" canceled, virtualtype, tlevel, showorder, versiondate,versionid) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
insertData ( insertVirtualSubComSql , insertParamList ) ;
2023-07-11 18:08:40 +08:00
2023-07-12 18:00:47 +08:00
//虚拟部门版本存储
rs . executeQuery ( " select a.id as departmentvirtualid,a.departmentname,a.departmentcode,a.departmentmark, " +
" b.DEPARTMENTNAME as supdeptment,b.SUPDEPID as supdepid,a.allsupdepid,c.SUBCOMPANYNAME as subcompany, " +
" a.SUBCOMPANYID1 as subcompanyid,a.canceled,a.virtualtype,a.tlevel,a.showorder from hrmdepartmentvirtual a " +
" left join hrmdepartmentvirtual b on a.SUPDEPID = b.id " +
2023-07-13 15:26:11 +08:00
" left join hrmsubcompanyvirtual c on a.SUBCOMPANYID1 = c.id where a.virtualtype = ? " , fclass ) ;
2023-07-12 18:00:47 +08:00
insertParamList = new ArrayList < > ( ) ;
while ( rs . next ( ) ) {
insertList = new ArrayList < > ( ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " departmentvirtualid " ) ) ? null : rs . getInt ( " departmentvirtualid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentUser ) ;
insertList . add ( rs . getString ( " departmentname " ) ) ;
insertList . add ( rs . getString ( " departmentcode " ) ) ;
insertList . add ( rs . getString ( " departmentmark " ) ) ;
insertList . add ( rs . getString ( " supdeptment " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " supdepid " ) ) ? null : rs . getInt ( " supdepid " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " allsupdepid " ) ) ? null : rs . getInt ( " allsupdepid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " subcompany " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " subcompanyid " ) ) ? null : rs . getInt ( " subcompanyid " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " canceled " ) ) ? null : rs . getInt ( " canceled " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " virtualtype " ) ) ;
insertList . add ( rs . getString ( " tlevel " ) ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " showorder " ) ) ? null : rs . getInt ( " showorder " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentDate ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
}
String insertVirtualDeptSql = " insert into jcl_chart_departmentvirtual(departmentvirtualid, creater, " +
" departmentname, departmentcode,departmentmark, supdeptment, supdepid, allsupdepid, subcompany, " +
" subcompanyid, canceled, virtualtype, tlevel, showorder, versiondate,versionid) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
insertData ( insertVirtualDeptSql , insertParamList ) ;
//虚拟人员版本存储
rs . executeQuery ( " select resourceid,a.managerid,b.SUBCOMPANYID1 as subcompanyid,b.departmentid,a.managerstr, " +
" virtualtype from hrmresourcevirtual a left join hrmresource b on a.RESOURCEID=b.ID where a.virtualtype=? " , fclass ) ;
insertParamList = new ArrayList < > ( ) ;
while ( rs . next ( ) ) {
insertList = new ArrayList < > ( ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " resourceid " ) ) ? null : rs . getInt ( " resourceid " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " managerid " ) ) ? null : rs . getInt ( " managerid " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " subcompanyid " ) ) ? null : rs . getInt ( " subcompanyid " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " departmentid " ) ) ? null : rs . getInt ( " departmentid " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " managerstr " ) ) ;
2023-07-13 15:26:11 +08:00
//insertList.add(rs.getString("virtualtype"));
2023-07-12 18:00:47 +08:00
insertList . add ( currentDate ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
}
String insertVirtualHrmSql = " insert into jcl_chart_resource(resourceid,MANAGER,subcompanyid, " +
2023-07-13 15:26:11 +08:00
" departmentid,managerstr, " +
//"virtualtype," +
" versiondate,versionid) values (?,?,?,?,?,?,?) " ;
2023-07-12 18:00:47 +08:00
insertData ( insertVirtualHrmSql , insertParamList ) ;
}
2023-07-11 18:08:40 +08:00
2023-07-12 18:00:47 +08:00
private void insertData ( String insertSql , List < List < Object > > insertParamList ) {
RecordSetTrans recordSetTrans = new RecordSetTrans ( ) ;
recordSetTrans . setAutoCommit ( false ) ; //关闭自动提交
try {
recordSetTrans . executeBatchSql ( insertSql , insertParamList ) ;
recordSetTrans . commit ( ) ;
} catch ( Exception e ) {
recordSetTrans . rollback ( ) ;
e . printStackTrace ( ) ;
}
2023-07-11 18:08:40 +08:00
}
private boolean isHasVirtualFields ( ) {
RecordSet rs = new RecordSet ( ) ;
boolean flag = false ;
rs . executeQuery ( " select count(1) as num from hrm_formfield where (GROUPID =6 and FIELDNAME = 'fblx') or (GROUPID =7 and FIELDNAME = 'bmlx') " ) ;
if ( rs . next ( ) ) {
String num = rs . getString ( " num " ) ;
flag = " 2 " . equals ( num ) ;
}
return flag ;
}
2023-06-30 16:44:56 +08:00
/ * *
* 查询实时数据 , 顶级元素SQL
*
* @param root 顶级元素ID
* @param dimension 维度ID
* @return 查询SQL
* /
private String getRealTimeTopSql ( String root , String dimension ) {
if ( " 0 " . equals ( root ) ) {
// 查询集团数据
2023-07-12 10:17:06 +08:00
if ( isRealDimension ) {
2023-06-30 16:44:56 +08:00
// 查询实际集团表
2023-07-11 11:19:19 +08:00
return " select id,companyname as name,'0' as type from " + COMPANY_TABLE ;
2023-06-30 16:44:56 +08:00
} else {
// 查询其他维度集团信息
2023-07-11 11:19:19 +08:00
return " select id,companyname as name,'0' as type from " + COMPANY_TABLE + " where id = ' " + dimension + " ' " ;
2023-06-30 16:44:56 +08:00
}
} else {
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-11 11:19:19 +08:00
return " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where a.id = ' " + root + " ' " ;
2023-06-30 16:44:56 +08:00
} else {
2023-07-11 11:19:19 +08:00
return " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where a.id = ' " + root + " ' and (b.fblx is null or b.fblx!='1') " ;
2023-06-30 16:44:56 +08:00
}
} else {
2023-07-11 11:19:19 +08:00
return " select id,subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " where id = ' " + root + " ' " ;
2023-06-30 16:44:56 +08:00
}
}
}
/ * *
2023-07-12 10:17:06 +08:00
* 查询实时数据 , 子元素SQL
2023-06-30 16:44:56 +08:00
*
2023-07-12 10:17:06 +08:00
* @param sql 查询SQL
* @param fType 上级元素类型
* @param fObjId 上级元素ID
* @return 查询SQL
2023-06-30 16:44:56 +08:00
* /
2023-07-12 10:17:06 +08:00
private String getRealTimeChildSql ( String sql , String fType , String fObjId ) {
2023-06-30 16:44:56 +08:00
if ( StringUtils . isNotBlank ( fType ) ) {
switch ( fType ) {
case " 0 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and (a.supsubcomid is null or a.supsubcomid = '0') and a.companyid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
} else {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and (a.supsubcomid is null or a.supsubcomid = '0') and (b.fblx is null or b.fblx != '1') and a.companyid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
}
} else {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcomid is null or a.supsubcomid = '0') and a.companyid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
}
break ;
case " 1 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and a.supsubcomid = ' " + fObjId + " ' " +
" union select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and subcompanyid1 = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
} else {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and (b.fblx is null or b.fblx != '1') and a.supsubcomid = ' " + fObjId + " ' " +
" union select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and (b.bmlx is null or b.bmlx != '1') and subcompanyid1 = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
}
} else {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (canceled is null or canceled != '1') and supsubcomid = ' " + fObjId + " ' " +
" union select a.id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
}
break ;
case " 2 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and supdepid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
} else {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where (canceled is null or canceled != '1') and (b.bmlx is null or b.bmlx != '1') and a.supdepid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
}
} else {
2023-07-11 11:19:19 +08:00
sql = " select a.id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and supdepid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
}
break ;
default :
break ;
}
}
2023-07-12 10:17:06 +08:00
return sql ;
}
/ * *
* 查询历史数据 , 子元素SQL
*
* @param sql 查询SQL
* @param fType 上级元素类型
* @param fObjId 上级元素ID
* @return 查询SQL
* /
private String getLastTimeChildSql ( String sql , String fType , String fObjId , String versionId ) {
if ( StringUtils . isNotBlank ( fType ) ) {
switch ( fType ) {
case " 0 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-12 11:15:11 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcompanyid is null or a.supsubcompanyid = '0') and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
} else {
2023-07-12 11:15:11 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcompanyid is null or a.supsubcompanyid = '0') and (isvirtual is null or isvirtual != '1') and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
}
} else {
2023-07-12 11:15:11 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcompanyid is null or a.supsubcompanyid = '0') and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
}
2023-07-12 17:00:01 +08:00
if ( ! isRealDimension ) {
2023-07-12 10:17:06 +08:00
sql + = " and companyid = " + fObjId ;
}
break ;
case " 1 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-12 11:15:11 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and a.supsubcompanyid = ' " + fObjId + " ' and versionid = " + versionId +
" union select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supdepartmentid is null or a.supdepartmentid = '0') and subcompanyid = ' " + fObjId + " ' and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
} else {
2023-07-12 11:15:11 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (isvirtual is null or isvirtual != '1') and a.supsubcompanyid = ' " + fObjId + " ' and versionid = " + versionId +
" union select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supdepartmentid is null or a.supdepartmentid = '0') and (isvirtual is null or isvirtual != '1') and subcompanyid = ' " + fObjId + " ' and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
}
} else {
2023-07-12 11:15:11 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (canceled is null or canceled != '1') and supsubcompanyid = ' " + fObjId + " ' and versionid = " + versionId +
2023-07-13 15:26:11 +08:00
" union select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid = ' " + fObjId + " ' and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
}
break ;
case " 2 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-07-12 11:15:11 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (a.canceled is null or a.canceled != '1') and supdepartmentid = ' " + fObjId + " ' and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
} else {
2023-07-12 17:00:01 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (isvirtual is null or isvirtual != '1') and a.supdepartmentid = ' " + fObjId + " ' and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
}
} else {
2023-07-13 15:26:11 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and supdepid = ' " + fObjId + " ' and versionid = " + versionId ;
2023-07-12 10:17:06 +08:00
}
break ;
default :
break ;
}
}
return sql ;
}
/ * *
* 查询实时数据 , 子节点元素
*
* @param topChartPO 父级元素
* @param dataList 所有元素集合
* @param selectDepth 所选部门层级
* /
2023-07-12 17:00:01 +08:00
private void findChildData ( ChartPO topChartPO , List < ChartPO > dataList , Integer selectDepth , String versionId ) {
2023-07-12 10:17:06 +08:00
String fType = topChartPO . getFtype ( ) ;
String fObjId = topChartPO . getFobjid ( ) ;
String sql = " " ;
if ( isRealTime ) {
sql = getRealTimeChildSql ( sql , fType , fObjId ) ;
} else {
2023-07-12 17:00:01 +08:00
sql = getLastTimeChildSql ( sql , fType , fObjId , versionId ) ;
2023-07-12 10:17:06 +08:00
}
2023-06-30 16:44:56 +08:00
if ( StringUtils . isNotBlank ( sql ) ) {
List < ChartPO > currentList = new ArrayList < > ( ) ;
RecordSet recordSet = new RecordSet ( ) ;
recordSet . executeQuery ( sql ) ;
while ( recordSet . next ( ) ) {
ChartPO chartPO = new ChartPO ( ) ;
chartPO . setFtype ( recordSet . getString ( " type " ) ) ;
chartPO . setFobjid ( recordSet . getString ( " id " ) ) ;
chartPO . setFname ( recordSet . getString ( " name " ) ) ;
chartPO . setParentId ( topChartPO . getId ( ) ) ;
chartPO . setFisvitual ( recordSet . getString ( " isvitual " ) ) ;
chartPO . setHasChildren ( getHasChildren ( chartPO . getFtype ( ) , chartPO . getFobjid ( ) ) . toString ( ) ) ;
2023-07-07 14:54:21 +08:00
chartPO . setDepartmentDepth ( getDepartmentDepth ( chartPO , topChartPO ) ) ;
// 小于、等于所选层级元素展开
2023-07-12 10:17:06 +08:00
chartPO . setExpand ( inDepth ( selectDepth , chartPO . getDepartmentDepth ( ) ) ? " 1 " : " 0 " ) ;
2023-06-30 16:44:56 +08:00
currentList . add ( chartPO ) ;
}
for ( ChartPO chartPO : currentList ) {
2023-07-07 14:54:21 +08:00
if ( inDepth ( selectDepth , chartPO . getDepartmentDepth ( ) ) ) {
2023-07-12 17:00:01 +08:00
findChildData ( chartPO , dataList , selectDepth , versionId ) ;
2023-06-30 16:44:56 +08:00
}
}
dataList . addAll ( currentList ) ;
}
}
/ * *
* 根据维度初始化表名
*
2023-07-12 10:17:06 +08:00
* @param dimension 所选维度
2023-06-30 16:44:56 +08:00
* /
2023-07-12 10:17:06 +08:00
public void initTableNameByClass ( String dimension , String id ) {
isRealDimension = StringUtils . isBlank ( dimension ) | | " 0 " . equals ( dimension ) ;
isRealTime = StringUtils . isBlank ( id ) | | " 0 " . equals ( id ) ;
if ( isRealTime ) {
if ( isRealDimension ) {
COMPANY_TABLE = " hrmcompany " ;
SUB_COMPANY_TABLE = " hrmsubcompany " ;
SUB_COMPANY_DEFINED_TABLE = " hrmsubcompanydefined " ;
DEPARTMENT_TABLE = " hrmdepartment " ;
DEPARTMENT_DEFINED_TABLE = " hrmdepartmentdefined " ;
RecordSet rs = new RecordSet ( ) ;
rs . executeQuery ( " select count(1) as num from hrm_formfield where (GROUPID =6 and FIELDNAME = 'fblx') or (GROUPID =7 and FIELDNAME = 'bmlx') " ) ;
if ( rs . next ( ) ) {
String num = rs . getString ( " num " ) ;
hasVirtualFields = " 2 " . equals ( num ) ;
2023-07-03 10:49:48 +08:00
2023-07-12 10:17:06 +08:00
} else {
hasVirtualFields = false ;
}
2023-07-03 10:49:48 +08:00
} else {
2023-07-12 10:17:06 +08:00
COMPANY_TABLE = " hrmcompanyvirtual " ;
SUB_COMPANY_TABLE = " hrmsubcompanyvirtual " ;
DEPARTMENT_TABLE = " hrmdepartmentvirtual " ;
// 其他维度,无虚拟组织
2023-07-03 10:49:48 +08:00
hasVirtualFields = false ;
}
2023-06-30 16:44:56 +08:00
} else {
2023-07-12 10:17:06 +08:00
if ( isRealDimension ) {
COMPANY_TABLE = " hrmcompany " ;
SUB_COMPANY_TABLE = " jcl_chart_subcompany " ;
DEPARTMENT_TABLE = " jcl_chart_department " ;
2023-07-12 11:15:11 +08:00
SUB_COMPANY_ID = " subcompanyid " ;
DEPARTMENT_ID = " departmentid " ;
2023-07-12 10:17:06 +08:00
hasVirtualFields = true ;
} else {
COMPANY_TABLE = " jcl_chart_companyvirtual " ;
SUB_COMPANY_TABLE = " jcl_chart_subcompanyvirtual " ;
DEPARTMENT_TABLE = " jcl_chart_departmentvirtual " ;
2023-07-12 11:15:11 +08:00
SUB_COMPANY_ID = " subcompanyvirtualid " ;
DEPARTMENT_ID = " departmentvirtualid " ;
2023-07-12 10:17:06 +08:00
// 其他维度,无虚拟组织
hasVirtualFields = false ;
}
2023-06-30 16:44:56 +08:00
}
}
/ * *
* 判断是否有子元素
*
* @param fType 元素类型
* @param fObjId 元素ID
* @return boolean 包含子元素 : true , 不包含子元素 : false
* /
private Boolean getHasChildren ( String fType , String fObjId ) {
2023-07-12 10:17:06 +08:00
//String sql = "";
//if (StringUtils.isNotBlank(fType)) {
// switch (fType) {
// case "0":
// sql = "select id from " + SUB_COMPANY_TABLE + " where (supsubcomid is null or supsubcomid = '0') and companyid = '" + fObjId + "'";
// break;
// case "1":
// if (hasVirtualFields && !showVirtual) {
// sql = "select a.id from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and (b.fblx is null or b.fblx != '1') and a.supsubcomid = '" + fObjId + "' union select a.id from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and (b.bmlx is null or b.bmlx != '1') and subcompanyid1 = '" + fObjId + "'";
// } else {
// sql = "select id from " + SUB_COMPANY_TABLE + " where (canceled is null or canceled != '1') and supsubcomid = '" + fObjId + "' union select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'";
// }
// break;
// case "2":
// if (hasVirtualFields && !showVirtual) {
// sql = "select a.id from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where (canceled is null or canceled != '1') and (b.bmlx is null or b.bmlx != '1') and a.supdepid = '" + fObjId + "'";
// } else {
// sql = "select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'";
// }
// break;
// default:
// break;
// }
//}
//if (StringUtils.isNotBlank(sql)) {
// RecordSet rs = new RecordSet();
// rs.executeQuery(sql);
// return rs.next();
//}
2023-06-30 16:44:56 +08:00
return false ;
}
2023-07-06 10:47:34 +08:00
2023-07-07 14:54:21 +08:00
/ * *
* 获取部门负责人
*
* @param ids 部门负责人ID
* @return 人员名称
* /
2023-07-06 10:47:34 +08:00
private String getDepartmentLeader ( String ids ) {
2023-07-12 17:00:01 +08:00
if ( ! isRealTime ) {
return ids ;
}
2023-07-06 10:47:34 +08:00
if ( StringUtils . isBlank ( ids ) ) {
return " " ;
}
List < String > leaderList = new ArrayList < > ( ) ;
String [ ] split = ids . split ( " , " ) ;
for ( String s : split ) {
String lastName = MapperProxyFactory . getProxy ( SystemDataMapper . class ) . getScHrmResourceNameById ( s ) ;
if ( StringUtils . isNotBlank ( lastName ) ) {
leaderList . add ( lastName ) ;
}
}
return StringUtils . join ( leaderList , " , " ) ;
}
2023-07-07 14:54:21 +08:00
/ * *
* 当前元素是否在展开层级内
*
* @param selectDepth 所选部门层级
* @param currentDepth 当前部门层级
* /
private boolean inDepth ( Integer selectDepth , Integer currentDepth ) {
if ( selectDepth = = 1 ) {
return true ;
}
return currentDepth < selectDepth + 1 ;
}
/ * *
* 获取当前部门层级
*
* @param chartPO 当前元素
* @param parentChart 上级元素
* /
private Integer getDepartmentDepth ( ChartPO chartPO , ChartPO parentChart ) {
if ( " 2 " . equals ( chartPO . getFtype ( ) ) ) {
if ( " 1 " . equals ( parentChart . getFtype ( ) ) ) {
return 2 ;
}
return parentChart . getDepartmentDepth ( ) + 1 ;
}
return 0 ;
}
2023-06-30 16:44:56 +08:00
}