2023-06-30 16:44:56 +08:00
package com.engine.organization.service.impl ;
2023-09-13 18:04:09 +08:00
import cn.hutool.core.thread.ThreadUtil ;
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 ;
2023-09-13 18:04:09 +08:00
import com.engine.organization.entity.chart.* ;
2024-04-24 16:46:47 +08:00
import com.engine.organization.entity.chart.params.ModeHrmResourceParam ;
2023-09-13 18:04:09 +08:00
import com.engine.organization.entity.chart.params.StatisticsParam ;
2023-09-12 11:20:20 +08:00
import com.engine.organization.enums.ModuleTypeEnum ;
2023-07-06 10:47:34 +08:00
import com.engine.organization.mapper.hrmresource.SystemDataMapper ;
2023-06-30 16:44:56 +08:00
import com.engine.organization.service.ChartService ;
2024-04-24 16:46:47 +08:00
import com.engine.organization.service.ModeHrmResourceService ;
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-09-13 18:04:09 +08:00
import com.engine.organization.util.OrganizationCommonUtil ;
2023-07-11 18:08:40 +08:00
import com.engine.organization.util.OrganizationDateUtil ;
2023-07-24 16:38:17 +08:00
import com.engine.organization.util.db.DBType ;
2023-07-06 10:47:34 +08:00
import com.engine.organization.util.db.MapperProxyFactory ;
2023-11-15 17:06:07 +08:00
import com.engine.organization.util.detach.DetachUtil ;
2023-09-12 11:20:20 +08:00
import lombok.SneakyThrows ;
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-11-27 17:51:07 +08:00
import weaver.general.BaseBean ;
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-08-01 14:05:17 +08:00
import weaver.hrm.company.DepartmentComInfo ;
import weaver.hrm.company.SubCompanyComInfo ;
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-09-13 18:04:09 +08:00
import java.time.LocalDateTime ;
2024-04-26 16:45:47 +08:00
import java.time.format.DateTimeFormatter ;
2023-07-05 17:41:30 +08:00
import java.util.* ;
2023-09-13 18:04:09 +08:00
import java.util.concurrent.ExecutorService ;
2023-09-15 10:28:37 +08:00
2023-07-26 11:23:15 +08:00
import java.util.stream.Collectors ;
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 OrgChartService getOrgChartService ( User user ) {
return ServiceUtil . getService ( OrgChartServiceImpl . class , user ) ;
}
2024-04-26 16:45:47 +08:00
private ModeHrmResourceService getModeHrmResourceService ( User user ) {
return ServiceUtil . getService ( ModeHrmResourceServiceImpl . 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 ;
}
// 根结点
2024-04-24 16:46:47 +08:00
String root = new BaseBean ( ) . getPropValue ( " hrmOrganization " , " subCompanyId " ) ;
2023-06-30 16:44:56 +08:00
// 维度
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-08-17 14:21:43 +08:00
boolean hideDepartment = " 1 " . equals ( Util . null2String ( params . get ( " hidedept " ) ) ) ;
2024-04-24 16:46:47 +08:00
//一级部门节点
String department = Util . null2String ( params . get ( " department " ) ) ;
//隐藏班组
boolean showClass = " 1 " . equals ( Util . null2String ( params . get ( " showClass " ) ) ) ;
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 " ) ) ;
2023-11-24 10:01:58 +08:00
topChartPO . setOnJobNum ( isRealTime ? Util . getIntValue ( rs . getString ( " on_job_num " ) , 0 ) : Util . getIntValue ( rs . getString ( " job_num " ) , 0 ) ) ;
2023-09-14 16:20:08 +08:00
topChartPO . setStaffNum ( Util . getIntValue ( rs . getString ( " staff_num " ) , 0 ) ) ;
2023-06-30 16:44:56 +08:00
topChartPO . setParentId ( null ) ;
topChartPO . setExpand ( " 1 " ) ;
topChartPO . setFisvitual ( rs . getString ( " isvitual " ) ) ;
topChartPO . setHasChildren ( getHasChildren ( topChartPO . getFtype ( ) , topChartPO . getFobjid ( ) ) . toString ( ) ) ;
2023-08-17 14:21:43 +08:00
filterAndAddData ( dataList , topChartPO , hideDepartment ) ;
//dataList.add(topChartPO);
2023-06-30 16:44:56 +08:00
}
// 向下查询数据
if ( null ! = topChartPO ) {
2024-04-24 16:46:47 +08:00
findChildData ( topChartPO , dataList , Integer . parseInt ( depth ) , id , hideDepartment , department , showClass ) ;
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-08-17 14:21:43 +08:00
boolean hideDepartment = " 1 " . equals ( Util . null2String ( params . get ( " hidedept " ) ) ) ;
2023-07-03 10:49:48 +08:00
2024-04-24 16:46:47 +08:00
//一级部门节点
String department = Util . null2String ( params . get ( " department " ) ) ;
//显示班组
boolean showClass = " 1 " . equals ( Util . null2String ( params . get ( " showClass " ) ) ) ;
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 ) {
2024-04-24 16:46:47 +08:00
rs . executeQuery ( getRealTimeChildSql ( " " , " 1 " , fObjId , department , showClass ) ) ;
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 ) {
2024-04-24 16:46:47 +08:00
rs . executeQuery ( getRealTimeChildSql ( " " , " 2 " , fObjId , department , showClass ) ) ;
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 ( ) ) {
2024-04-29 17:18:23 +08:00
String type = rs . getString ( " type " ) ;
2023-07-03 10:49:48 +08:00
ChartPO chartPO = new ChartPO ( ) ;
2024-04-29 17:18:23 +08:00
chartPO . setFtype ( type ) ;
2023-07-03 10:49:48 +08:00
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 ( ) ) ;
2024-01-09 09:07:52 +08:00
chartPO . setOnJobNum ( isRealTime ? Util . getIntValue ( rs . getString ( " on_job_num " ) , 0 ) : Util . getIntValue ( rs . getString ( " job_num " ) , 0 ) ) ;
chartPO . setStaffNum ( Util . getIntValue ( rs . getString ( " staff_num " ) , 0 ) ) ;
2024-04-29 17:18:23 +08:00
if ( " 2 " . equals ( type ) ) {
chartPO . setDeptLevel ( Util . getIntValue ( rs . getString ( " bmcj " ) , 0 ) ) ;
}
2023-08-17 14:21:43 +08:00
filterAndAddData ( dataList , chartPO , hideDepartment ) ;
2023-11-24 10:01:58 +08:00
2024-04-29 17:18:23 +08:00
2023-08-17 14:21:43 +08:00
//dataList.add(chartPO);
2023-07-03 10:49:48 +08:00
}
}
}
}
2024-04-29 17:18:23 +08:00
Map < String , Object > result = new HashMap < > ( 4 ) ;
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 ) {
2023-09-21 18:16:23 +08:00
sql = " select a.id,a.jobtitlename as name from hrmjobtitles a inner join jcl_org_job b on a.id = b.ec_jobtitle and (b.delete_type is null or b.delete_type = 0) 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 ;
}
2024-04-24 16:46:47 +08:00
@Override
public Map < String , Object > getDepartmentNewDetail ( Map < String , Object > params ) {
String rootId = Util . null2String ( params . get ( " rootId " ) ) ;
2024-04-29 17:18:23 +08:00
String nbValue = Util . null2String ( params . get ( " nbValue " ) ) ;
String wbValue = Util . null2String ( params . get ( " wbValue " ) ) ;
2024-04-24 16:46:47 +08:00
String departmentId = rootId . split ( " _ " ) [ 1 ] ;
2024-04-29 17:18:23 +08:00
ModeHrmResourceParam build = ModeHrmResourceParam . builder ( )
. nbValue ( nbValue )
. wbValue ( wbValue )
. departmentId ( departmentId )
. build ( ) ;
2024-04-24 16:46:47 +08:00
2024-04-29 17:18:23 +08:00
String detauleType = Util . null2String ( params . get ( " detailType " ) ) ;
2024-04-24 16:46:47 +08:00
if ( ! " chart " . equals ( detauleType ) ) {
// 展示列表模块
return ServiceUtil . getService ( ModeHrmResourceServiceImpl . class , user ) . chartResourceList ( build ) ;
} else {
return ServiceUtil . getService ( ModeHrmResourceServiceImpl . class , user ) . chartResourceChart ( build
) ;
}
}
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-11-24 10:01:58 +08:00
return " select " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type,isvirtual as isvitual,a.job_num,a.staff_num from " + SUB_COMPANY_TABLE + " a where versionid = " + versionId + " and subcompanyid = " + root ;
2023-07-12 10:17:06 +08:00
} else {
2023-11-24 10:01:58 +08:00
return " select " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type,isvirtual as isvitual,a.job_num,a.staff_num from " + SUB_COMPANY_TABLE + " a where versionid = " + versionId + " and subcompanyid = " + root + " and (isvirtual is null or isvirtual != '1') " ;
2023-07-12 10:17:06 +08:00
}
} else {
2023-11-24 10:01:58 +08:00
return " select " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type,a.job_num,a.staff_num from " + SUB_COMPANY_TABLE + " a 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 ) {
2023-07-14 15:00:49 +08:00
2023-07-11 18:08:40 +08:00
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 ( ) ) ;
//版本记录表数据存储
2023-07-17 14:30:44 +08:00
synchronized ( this ) {
getOrgChartService ( user ) . insertChartVersion ( Integer . valueOf ( dimension ) , description ) ;
String versionId = " " ;
String createDate = OrganizationDateUtil . getFormatLocalDate ( LocalDate . now ( ) ) ;
rs . executeQuery ( " select id from JCL_ORG_CHARTVERSION where fclass = ? and createtime = ? " , dimension , createDate ) ;
if ( rs . next ( ) ) {
versionId = Util . null2String ( rs . getString ( " id " ) ) ;
}
2023-07-14 15:00:49 +08:00
2023-07-17 14:30:44 +08:00
RecordSetTrans recordSetTrans = new RecordSetTrans ( ) ;
try {
recordSetTrans . setAutoCommit ( false ) ;
if ( " 0 " . equals ( dimension ) ) {
//实体维度
trueDimension ( recordSetTrans , versionId , currentUser , currentDate ) ;
} else {
virtualDimension ( recordSetTrans , versionId , currentUser , currentDate , dimension ) ;
}
recordSetTrans . commit ( ) ;
} catch ( Exception e ) {
recordSetTrans . rollback ( ) ;
e . printStackTrace ( ) ;
2023-07-14 15:00:49 +08:00
}
2023-07-12 18:00:47 +08:00
}
Map < String , Object > result = new HashMap < > ( ) ;
result . put ( " api_status " , true ) ;
return result ;
}
2023-07-24 16:38:17 +08:00
@Override
public Map < String , Object > getDepartmentTree ( Map < String , Object > params ) {
Map < String , Object > result = new HashMap < > ( 2 ) ;
RecordSet rs = new RecordSet ( ) ;
List < CompanyTreePO > departmentTree = new ArrayList < > ( ) ;
2024-04-24 16:46:47 +08:00
List < CompanyTreePO > topDepartmentTree = new ArrayList < > ( ) ;
2023-07-24 16:38:17 +08:00
String subCompany = Util . null2String ( params . get ( " subcompany " ) ) ;
if ( StringUtils . isBlank ( subCompany ) ) {
subCompany = " 0 " ;
}
2024-04-24 16:46:47 +08:00
DBType dbType = DBType . get ( new RecordSet ( ) . getDBType ( ) ) ;
// 根据分部查询顶级部门
String sql = " select id as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartment where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and " + dbType . ifNull ( " subcompanyid1 " , " 0 " ) + " = " + subCompany ;
2023-07-24 16:38:17 +08:00
rs . executeQuery ( sql ) ;
while ( rs . next ( ) ) {
2024-04-24 16:46:47 +08:00
topDepartmentTree . add (
CompanyTreePO . builder ( )
. id ( rs . getString ( " id " ) )
. pId ( rs . getString ( " pId " ) )
. disabled ( false )
. value ( rs . getString ( " value " ) )
. title ( rs . getString ( " title " ) )
. isLeaf ( true )
. build ( )
) ;
2023-07-24 16:38:17 +08:00
}
2024-04-24 16:46:47 +08:00
//只查询一级部门
// if (CollectionUtils.isNotEmpty(topDepartmentTree)) {
// sql = "select id as id, id as value, departmentname as title, supdepid as pId from hrmdepartment where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepid", "0") + " = ?";
// for (CompanyTreePO department : topDepartmentTree) {
// getChildDepartment(department, sql, departmentTree);
// }
// }
result . put ( " departmentTree " , topDepartmentTree ) ;
2023-07-24 16:38:17 +08:00
result . put ( " api_status " , true ) ;
return result ;
}
2024-04-24 16:46:47 +08:00
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 " ) )
. isLeaf ( true )
. build ( ) ;
getChildDepartment ( build , sql , departmentTree ) ;
parentDepartment . setLeaf ( false ) ;
}
departmentTree . add ( parentDepartment ) ;
}
2023-07-26 10:52:10 +08:00
@Override
public Map < String , Object > getMovingTree ( Map < String , Object > params ) {
RecordSet rs = new RecordSet ( ) ;
2023-07-31 17:45:42 +08:00
rs . executeQuery ( " select id,companyname from hrmcompany " ) ;
TreeSelect companyTree = null ;
List < String > expandedKeys = new ArrayList < > ( ) ;
2023-08-01 14:05:17 +08:00
String showCanceled = Util . null2String ( params . get ( " showCanceled " ) ) ;
String expandedKeyStr = Util . null2String ( params . get ( " expandedKeys " ) ) ;
2023-08-17 14:21:43 +08:00
if ( rs . next ( ) ) {
2023-08-01 14:05:17 +08:00
companyTree = TreeSelect . builder ( ) . key ( rs . getString ( " id " ) ) . title ( rs . getString ( " companyname " ) ) . type ( TreeSelect . COMPANY ) . showCanceled ( showCanceled ) . build ( ) ;
2023-07-31 17:45:42 +08:00
expandedKeys . add ( companyTree . getKey ( ) ) ;
2023-07-26 10:52:10 +08:00
}
2023-08-01 14:05:17 +08:00
// 所有需展开节点, 同时需查询父级部门、分部ID
addParentTreeId ( expandedKeys , expandedKeyStr ) ;
2023-07-27 17:45:02 +08:00
Map < String , Object > result = new HashMap < > ( 3 ) ;
2023-07-31 17:45:42 +08:00
result . put ( " movingTree " , Collections . singletonList ( companyTree ) ) ;
result . put ( " expandedKeys " , expandedKeys ) ;
2023-07-27 14:32:07 +08:00
result . put ( " api_status " , true ) ;
return result ;
}
@Override
public Map < String , Object > getFullSelectTree ( Map < String , Object > params ) {
RecordSet rs = new RecordSet ( ) ;
rs . executeQuery ( " select id,companyname from hrmcompany " ) ;
TreeSelect companyTree = null ;
List < String > expandedKeys = new ArrayList < > ( ) ;
2023-08-01 14:05:17 +08:00
String showCanceled = Util . null2String ( params . get ( " showCanceled " ) ) ;
2023-08-17 14:21:43 +08:00
if ( rs . next ( ) ) {
2023-08-01 14:05:17 +08:00
companyTree = TreeSelect . builder ( ) . key ( rs . getString ( " id " ) ) . title ( rs . getString ( " companyname " ) ) . type ( TreeSelect . COMPANY ) . showCanceled ( showCanceled ) . build ( ) ;
2023-07-31 09:29:10 +08:00
expandedKeys = companyTree . getChildren ( ) . stream ( ) . filter ( item - > CollectionUtils . isNotEmpty ( item . getChildren ( ) ) ) . map ( TreeSelect : : getKey ) . collect ( Collectors . toList ( ) ) ;
2023-07-27 14:32:07 +08:00
expandedKeys . add ( companyTree . getKey ( ) ) ;
}
2023-08-17 14:21:43 +08:00
disableTreeItem ( Collections . singletonList ( companyTree ) , TreeSelect . DEPARTMENT ) ;
2023-07-27 17:45:02 +08:00
Map < String , Object > result = new HashMap < > ( 3 ) ;
2023-07-27 14:32:07 +08:00
result . put ( " selectTree " , companyTree ) ;
result . put ( " expandedKeys " , expandedKeys ) ;
2023-07-26 10:52:10 +08:00
result . put ( " api_status " , true ) ;
return result ;
}
2023-09-12 11:20:20 +08:00
@SneakyThrows
@Override
public Map < String , Object > selectStatistics ( Map < String , Object > params ) {
RecordSet rs = new RecordSet ( ) ;
Map < String , Object > result = new HashMap < > ( 4 ) ;
DepartmentComInfo departmentComInfo = new DepartmentComInfo ( ) ;
ResourceComInfo resourceComInfo = new ResourceComInfo ( ) ;
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo ( ) ;
List < StatisticsVO > statisticsVOS = new ArrayList < > ( ) ;
rs . executeQuery ( " select id,data_id,super_id,type,on_job_num,staff_num,creator,create_time,update_time from jcl_org_onjob " ) ;
while ( rs . next ( ) ) {
Integer type = Util . getIntValue ( rs . getString ( " type " ) ) ;
2023-09-14 11:05:39 +08:00
String dataIdName ;
String superIdName ;
2023-09-12 11:20:20 +08:00
if ( ModuleTypeEnum . subcompanyfielddefined . getValue ( ) . equals ( type ) ) {
dataIdName = subCompanyComInfo . getSubCompanyname ( Util . null2String ( ( rs . getString ( " data_id " ) ) ) ) ;
superIdName = subCompanyComInfo . getSubCompanyname ( Util . null2String ( ( rs . getString ( " super_id " ) ) ) ) ;
} else {
dataIdName = departmentComInfo . getDepartmentname ( Util . null2String ( ( rs . getString ( " data_id " ) ) ) ) ;
superIdName = departmentComInfo . getDepartmentname ( Util . null2String ( ( rs . getString ( " super_id " ) ) ) ) ;
}
StatisticsVO statisticsVO = StatisticsVO . builder ( )
. key ( Util . getIntValue ( rs . getString ( " id " ) ) )
. dataIdName ( dataIdName )
. superIdName ( superIdName )
. type ( type )
. onJobNum ( Util . getIntValue ( rs . getString ( " on_job_num " ) ) )
. staffNum ( Util . getIntValue ( rs . getString ( " staff_num " ) ) )
. creator ( resourceComInfo . getLastname ( Util . null2String ( rs . getString ( " creator " ) ) ) )
. createTime ( Util . null2String ( rs . getString ( " create_time " ) ) )
. updateTime ( Util . null2String ( rs . getString ( " update_time " ) ) )
. build ( ) ;
statisticsVOS . add ( statisticsVO ) ;
}
result . put ( " result " , statisticsVOS ) ;
return result ;
}
2023-09-13 18:04:09 +08:00
@Override
public Map < String , Object > recordStatistics ( StatisticsParam statisticsParam ) {
Map < String , Object > result = new HashMap < > ( 2 ) ;
long startTime = System . currentTimeMillis ( ) ;
2024-04-26 16:45:47 +08:00
//需要新增的数据List
2023-09-13 18:04:09 +08:00
List < StatisticsPO > list = filterIds ( statisticsParam . getCompanyId ( ) ) ;
RecordSetTrans rst = new RecordSetTrans ( ) ;
// 核心线程数
int corePoolSize = 5 ;
// 最大线程数
int maxPoolSize = 10 ;
// 设置每个子列表的大小
int batchSize = 100 ;
List < List < StatisticsPO > > splittedLists = OrganizationCommonUtil . splitList ( list , batchSize ) ;
// 创建线程池
ExecutorService executorService = ThreadUtil . newExecutor ( corePoolSize , maxPoolSize ) ;
// 遍历每个子列表,并提交给线程池执行
for ( List < StatisticsPO > subList : splittedLists ) {
executorService . submit ( ( ) - > {
// 在此处编写处理子列表的逻辑
for ( StatisticsPO statisticsPO : subList ) {
// 处理逻辑
StatisticsPO po = buildCount ( statisticsPO ) ;
statisticsPO . setOnJobNum ( po . getOnJobNum ( ) ) ;
statisticsPO . setStaffNum ( po . getStaffNum ( ) ) ;
statisticsPO . setUpdateTime ( OrganizationDateUtil . getFormatLocalDateTime ( LocalDateTime . now ( ) ) ) ;
}
} ) ;
}
// 关闭线程池
executorService . shutdown ( ) ;
// 等待线程池关闭
while ( ! executorService . isTerminated ( ) ) {
// 空循环等待线程池终止
}
try {
rst . setAutoCommit ( false ) ;
for ( StatisticsPO item : list ) {
rst . executeUpdate ( " update jcl_org_onjob set on_job_num = ?,staff_num = ? where data_id = ? and type = ? " , item . getOnJobNum ( ) ,
item . getStaffNum ( ) , item . getDataId ( ) , item . getType ( ) ) ;
}
rst . commit ( ) ;
} catch ( Exception e ) {
2023-09-14 11:05:39 +08:00
result . put ( " errorMsg " , e . getMessage ( ) ) ;
2023-09-13 18:04:09 +08:00
rst . rollback ( ) ;
}
2024-04-26 16:45:47 +08:00
//上海中远重工唯一分部在编数和编制更新
List < Integer > jobList = new ArrayList < > ( ) ;
List < Integer > staffList = new ArrayList < > ( ) ;
RecordSet rs = new RecordSet ( ) ;
rs . executeQuery ( " select on_job_num,staff_num from jcl_org_onjob where type = 2 and super_id = 0 " ) ;
while ( rs . next ( ) ) {
jobList . add ( Util . getIntValue ( rs . getString ( " on_job_num " ) , 0 ) ) ;
staffList . add ( Util . getIntValue ( rs . getString ( " staff_num " ) , 0 ) ) ;
}
int jobSum = jobList . stream ( ) . mapToInt ( Integer : : intValue ) . sum ( ) ;
int staffSum = staffList . stream ( ) . mapToInt ( Integer : : intValue ) . sum ( ) ;
rs . executeUpdate ( " update jcl_org_onjob set on_job_num = ?,staff_num = ? where type = 1 " , jobSum , staffSum ) ;
2023-09-13 18:04:09 +08:00
long endTime = System . currentTimeMillis ( ) ;
long executionTime = endTime - startTime ;
result . put ( " time " , executionTime ) ;
return result ;
}
2024-04-24 16:46:47 +08:00
2023-09-13 18:04:09 +08:00
/ * *
* 生成人数
* @param stp
* @return
* /
private StatisticsPO buildCount ( StatisticsPO stp ) {
RecordSet rs = new RecordSet ( ) ;
DepartmentComInfo dept = new DepartmentComInfo ( ) ;
ArrayList < Integer > list = new ArrayList < > ( ) ;
list . add ( stp . getDataId ( ) ) ;
2024-04-26 16:45:47 +08:00
if ( ModuleTypeEnum . departmentfielddefined . getValue ( ) . equals ( stp . getType ( ) ) ) {
2023-09-13 18:04:09 +08:00
dept . getAllChildDeptByDepId ( list , String . valueOf ( stp . getDataId ( ) ) ) ;
String value = StringUtils . join ( list , " , " ) ;
2024-04-26 16:45:47 +08:00
int jobNum = getModeHrmResourceService ( user ) . selcetPersonCount ( value ) ;
stp . setOnJobNum ( jobNum ) ;
2023-09-13 18:04:09 +08:00
2024-04-26 16:45:47 +08:00
LocalDateTime currentDateTime = LocalDateTime . now ( ) ;
DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( " yyyy-MM " ) ;
String currentYearMonth = currentDateTime . format ( formatter ) ;
2023-09-13 18:04:09 +08:00
2024-04-26 16:45:47 +08:00
rs . executeQuery ( " select bzrs from uf_bzgljmb where bm = ? and ny = ? " , stp . getDataId ( ) , currentYearMonth ) ;
if ( rs . next ( ) ) {
stp . setStaffNum ( Util . getIntValue ( rs . getString ( " bzrs " ) , 0 ) ) ;
}
2023-09-13 18:04:09 +08:00
}
return stp ;
}
/ * *
* 基础数据过滤
* @param companyId
* @return
* /
private List < StatisticsPO > filterIds ( Integer companyId ) {
RecordSet rs = new RecordSet ( ) ;
RecordSet iRs = new RecordSet ( ) ;
List < Integer > hisCompanyList = new ArrayList < > ( ) ;
List < Integer > hisDepartmentList = new ArrayList < > ( ) ;
2024-04-26 16:45:47 +08:00
String propValue = new BaseBean ( ) . getPropValue ( " hrmOrganization " , " subCompanyId " ) ;
rs . executeQuery ( " select data_id from jcl_org_onjob where type = 1 " ) ;
2023-09-13 18:04:09 +08:00
while ( rs . next ( ) ) {
hisCompanyList . add ( Util . getIntValue ( rs . getString ( " data_id " ) ) ) ;
}
rs . executeQuery ( " select data_id from jcl_org_onjob where type = 2 " ) ;
while ( rs . next ( ) ) {
hisDepartmentList . add ( Util . getIntValue ( rs . getString ( " data_id " ) ) ) ;
}
List < StatisticsPO > companyList = new ArrayList < > ( ) ;
List < StatisticsPO > departmentList = new ArrayList < > ( ) ;
StringBuilder sql = new StringBuilder ( ) ;
StringBuilder sql1 = new StringBuilder ( ) ;
sql . append ( " select id,supsubcomid from hrmsubcompany where 1=1 " ) ;
sql1 . append ( " select id,supdepid from hrmdepartment where 1=1 " ) ;
2024-04-26 16:45:47 +08:00
//中远重工指定分部数据记录
companyId = Integer . parseInt ( propValue ) ;
sql . append ( " and id = " ) . append ( companyId ) ;
sql1 . append ( " and subcompanyid1 = " ) . append ( companyId ) ;
2023-09-13 18:04:09 +08:00
rs . executeQuery ( sql . toString ( ) ) ;
2023-11-24 10:01:58 +08:00
while ( rs . next ( ) ) {
2023-09-13 18:04:09 +08:00
2023-11-24 10:01:58 +08:00
StatisticsPO statisticsPO = StatisticsPO . builder ( )
. dataId ( Util . getIntValue ( rs . getString ( " id " ) ) )
. superId ( Util . getIntValue ( rs . getString ( " supsubcomid " ) ) )
. type ( 1 )
. onJobNum ( 0 )
. staffNum ( 0 )
. creator ( user . getUID ( ) )
. createTime ( OrganizationDateUtil . getFormatLocalDateTime ( LocalDateTime . now ( ) ) )
. updateTime ( OrganizationDateUtil . getFormatLocalDateTime ( LocalDateTime . now ( ) ) )
. build ( ) ;
companyList . add ( statisticsPO ) ;
}
2023-09-13 18:04:09 +08:00
2023-11-24 10:01:58 +08:00
rs . executeQuery ( sql1 . toString ( ) ) ;
while ( rs . next ( ) ) {
StatisticsPO statisticsPO = StatisticsPO . builder ( )
. dataId ( Util . getIntValue ( rs . getString ( " id " ) ) )
. superId ( Util . getIntValue ( rs . getString ( " supdepid " ) ) )
. type ( 2 )
. onJobNum ( 0 )
. staffNum ( 0 )
. creator ( user . getUID ( ) )
. createTime ( OrganizationDateUtil . getFormatLocalDateTime ( LocalDateTime . now ( ) ) )
. updateTime ( OrganizationDateUtil . getFormatLocalDateTime ( LocalDateTime . now ( ) ) )
. build ( ) ;
departmentList . add ( statisticsPO ) ;
2023-09-13 18:04:09 +08:00
}
List < StatisticsPO > addCompanyList = companyList . stream ( )
. filter ( entity - > ! hisCompanyList . contains ( entity . getDataId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
List < StatisticsPO > addDeptList = departmentList . stream ( )
. filter ( entity - > ! hisDepartmentList . contains ( entity . getDataId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
addCompanyList . addAll ( addDeptList ) ;
if ( CollectionUtils . isNotEmpty ( addCompanyList ) ) {
addCompanyList . forEach ( item - > iRs . executeUpdate ( " insert into jcl_org_onjob(data_id,super_id,type,on_job_num,staff_num,creator,create_time,update_time) " +
2023-11-24 10:01:58 +08:00
" values(?,?,?,?,?,?,?,?) " , item . getDataId ( ) , item . getSuperId ( ) , item . getType ( ) ,
2023-09-13 18:04:09 +08:00
item . getOnJobNum ( ) , item . getStaffNum ( ) , item . getCreator ( ) , item . getCreateTime ( ) , item . getUpdateTime ( ) ) ) ;
}
companyList . addAll ( departmentList ) ;
return companyList ;
}
2023-08-01 14:05:17 +08:00
/ * *
* 添加树结构所有上级节点
*
* @param expandedKeys 完整的上级ID集合
* @param expandedKeyStr 需要展开的树ID
* /
2023-08-17 14:21:43 +08:00
private void addParentTreeId ( List < String > expandedKeys , String expandedKeyStr ) {
2023-08-02 11:29:19 +08:00
if ( StringUtils . isNotBlank ( expandedKeyStr ) ) {
try {
2023-08-02 14:53:53 +08:00
if ( expandedKeyStr . startsWith ( " d " ) ) {
expandedKeyStr = expandedKeyStr . replace ( " d " , " " ) ;
String [ ] array ;
// 上级分部ID
String subcompanyid1 = new DepartmentComInfo ( ) . getSubcompanyid1 ( expandedKeyStr ) ;
if ( StringUtils . isNotBlank ( subcompanyid1 ) ) {
String allSupCompany = new SubCompanyComInfo ( ) . getAllSupCompany ( subcompanyid1 ) ;
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 ( expandedKeyStr ) ;
array = allSupDepartment . split ( " , " ) ;
for ( String supDepartment : array ) {
if ( StringUtils . isBlank ( supDepartment ) ) {
continue ;
}
expandedKeys . add ( " d " + supDepartment ) ;
}
expandedKeys . add ( " d " + expandedKeyStr ) ;
} else {
// 上级分部ID
String allSupCompany = new SubCompanyComInfo ( ) . getAllSupCompany ( expandedKeyStr ) ;
String [ ] array = allSupCompany . split ( " , " ) ;
2023-08-01 14:05:17 +08:00
for ( String supCompany : array ) {
if ( StringUtils . isBlank ( supCompany ) ) {
continue ;
}
expandedKeys . add ( " s " + supCompany ) ;
}
2023-08-02 14:53:53 +08:00
expandedKeys . add ( " s " + expandedKeyStr ) ;
2023-08-01 14:05:17 +08:00
}
2023-08-02 11:29:19 +08:00
} catch ( Exception e ) {
throw new RuntimeException ( e ) ;
2023-08-01 14:05:17 +08:00
}
2023-08-02 11:29:19 +08:00
2023-08-01 14:05:17 +08:00
}
}
2023-07-31 10:02:38 +08:00
/ * *
* 树节点是否禁用
*
* @param companyTreeList TreeSelect组件数据集合
* /
private void disableTreeItem ( List < TreeSelect > companyTreeList , String enableTreeType ) {
if ( CollectionUtils . isNotEmpty ( companyTreeList ) ) {
for ( TreeSelect treeSelect : companyTreeList ) {
treeSelect . setDisabled ( ! enableTreeType . equals ( treeSelect . getType ( ) ) ) ;
List < TreeSelect > children = treeSelect . getChildren ( ) ;
if ( CollectionUtils . isNotEmpty ( children ) ) {
disableTreeItem ( children , enableTreeType ) ;
}
}
}
}
2023-08-17 14:21:43 +08:00
private void trueDimension ( RecordSetTrans recordSetTrans , String versionId , String currentUser , String currentDate ) {
2023-07-12 18:00:47 +08:00
RecordSet rs = new RecordSet ( ) ;
2023-08-17 14:21:43 +08:00
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-12 18:00:47 +08:00
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 " +
2023-07-13 17:16:22 +08:00
" a.SUPSUBCOMID as supsubcompanyid, \ n " +
2023-07-11 18:08:40 +08:00
" b.subcompanyname as supsubcompany, \ n " +
" a.canceled, \ n " +
" a.subcompanycode, \ n " +
" a.limitusers, \ n " +
" a.tlevel, \ n " +
2023-09-12 10:24:44 +08:00
" c.fblx as isvirtual,d.on_job_num,d.staff_num \ n " +
2023-07-11 18:08:40 +08:00
" from hrmsubcompany a \ n " +
" left join hrmsubcompany b on a.supsubcomid = b.id \ n " +
2023-09-12 10:24:44 +08:00
" left join hrmsubcompanydefined c on a.id = c.subcomid " +
" left join JCL_ORG_ONJOB d on a.id=d.data_id and d.type=1 " ;
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, " +
2023-09-12 10:24:44 +08:00
" a.canceled,a.departmentcode,a.coadjutant,a.tlevel,d.bmlx as isvirtual,a.bmfzr as fleader,e.on_job_num,e.staff_num " +
2023-07-12 18:00:47 +08:00
" from hrmdepartment a left join hrmsubcompany b on a.subcompanyid1 = b.id " +
" left join hrmdepartment c on a.supdepid = c.id " +
2023-09-12 10:24:44 +08:00
" left join hrmdepartmentdefined d on a.id=d.deptid " +
" left join JCL_ORG_ONJOB e on a.id=e.data_id and e.type=2 " ;
2023-07-11 18:08:40 +08:00
2023-08-17 14:21:43 +08:00
} else {
2023-07-11 18:08:40 +08:00
subCompanyQuerySql = " select a.id as subcompanyid, \ n " +
" a.subcompanyname, \ n " +
" a.subcompanydesc, \ n " +
" a.companyid as company, \ n " +
2023-07-14 14:46:05 +08:00
" a.supsubcomid as supsubcompanyid, \ n " +
2023-07-11 18:08:40 +08:00
" b.subcompanyname as supsubcompany, \ n " +
" a.canceled, \ n " +
" a.subcompanycode, \ n " +
" a.limitusers, \ n " +
2023-09-12 10:24:44 +08:00
" a.tlevel, \ n " +
" c.on_job_num, \ n " +
" c.staff_num \ n " +
2023-07-11 18:08:40 +08:00
" from hrmsubcompany a \ n " +
2023-09-12 10:24:44 +08:00
" left join hrmsubcompany b on a.supsubcomid = b.id \ n " +
" left join JCL_ORG_ONJOB c on a.id=c.data_id and c.type=1 " ;
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 " +
2023-09-12 10:24:44 +08:00
" a.bmfzr as fleader, \ n " +
" d.on_job_num, \ n " +
" d.staff_num " +
2023-07-11 18:08:40 +08:00
" from hrmdepartment a \ n " +
" left join hrmsubcompany b on a.subcompanyid1 = b.id \ n " +
2023-09-12 10:24:44 +08:00
" left join hrmdepartment c on a.supdepid = c.id \ n " +
" left join JCL_ORG_ONJOB d on a.id=d.data_id and d.type=2 " ;
2023-07-11 18:08:40 +08:00
}
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 ) ;
2023-08-17 14:21:43 +08:00
insertList . add ( virtualFlag ? Util . getIntValue ( rs . getString ( " isvirtual " ) , 0 ) : 0 ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-09-12 10:24:44 +08:00
insertList . add ( Util . getIntValue ( rs . getString ( " on_job_num " ) , 0 ) ) ;
insertList . add ( Util . getIntValue ( rs . getString ( " staff_num " ) , 0 ) ) ;
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 " +
2023-09-12 10:24:44 +08:00
" tlevel, versiondate, isvirtual,versionId,job_num,staff_num) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , 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-08-17 14:21:43 +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 ) ;
2023-08-17 14:21:43 +08:00
insertList . add ( virtualFlag ? Util . getIntValue ( rs . getString ( " isvirtual " ) , 0 ) : 0 ) ;
2023-07-13 11:08:22 +08:00
insertList . add ( StringUtils . isBlank ( versionId ) ? null : Util . getIntValue ( versionId ) ) ;
2023-09-12 10:24:44 +08:00
insertList . add ( Util . getIntValue ( rs . getString ( " on_job_num " ) , 0 ) ) ;
insertList . add ( Util . getIntValue ( rs . getString ( " staff_num " ) , 0 ) ) ;
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 " +
2023-09-12 10:24:44 +08:00
" coadjutant, fleader,versiondate, isvirtual,versionid,job_num,staff_num) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , insertDeptSql , insertParamList ) ;
2023-07-12 18:00:47 +08:00
//当前岗位版本存储
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-08-17 14:21:43 +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 " ) ) ;
2023-07-14 14:46:05 +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 ( " 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(?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , insertJobSql , insertParamList ) ;
2023-07-12 18:00:47 +08:00
//当前人员版本存储
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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , insertResourceSql , insertParamList ) ;
2023-07-12 18:00:47 +08:00
}
2023-08-17 14:21:43 +08:00
private void virtualDimension ( RecordSetTrans recordSetTrans , String versionId , String currentUser , String currentDate , String fclass ) {
2023-07-12 18:00:47 +08:00
RecordSet rs = new RecordSet ( ) ;
List < Object > insertList ;
List < List < Object > > insertParamList = new ArrayList < > ( ) ;
2023-08-17 14:21:43 +08:00
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-08-17 14:21:43 +08:00
" virtualtype,virtualtypedesc from hrmcompanyvirtual where id=? " , fclass ) ;
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(?,?,?,?,?,?,?,?,?,?,?) " ;
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , 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-08-17 14:21:43 +08:00
" left join hrmcompanyvirtual c on a.companyid = c.id where a.companyid=? " , fclass ) ;
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 < > ( ) ;
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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , 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-08-17 14:21:43 +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 < > ( ) ;
2023-08-17 14:21:43 +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 ( " 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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , insertVirtualDeptSql , insertParamList ) ;
2023-07-12 18:00:47 +08:00
//虚拟人员版本存储
2023-07-13 16:58:22 +08:00
rs . executeQuery ( " select resourceid,workyear,usekind,a.managerstr,status,sex,accounttype,belongto,loginid, " +
" maritalstatus,b.telephone,mobile,mobilecall,email,c.locationname,resourcetype,startdate,enddate, " +
2023-07-13 17:51:16 +08:00
" d.id as jobtitleid,d.JOBTITLENAME as jobtitle,joblevel,seclevel,e.id as departmentid,e.departmentname as department, " +
" f.id as subcompanyid,f.subcompanyname as subcompany,b.costcenterid as costcenter, " +
2023-07-13 18:05:17 +08:00
" b.managerid as manager,b.assistantid as assistant,workcode,classification,policy,degree,b.lastname,b.companyworkyear, " +
2023-07-13 16:58:22 +08:00
" a.virtualtype from hrmresourcevirtual a \ n " +
" left join hrmresource b on a.RESOURCEID=b.ID \ n " +
" left join hrmlocations c on b.locationid=c.id \ n " +
" left join hrmjobtitles d on b.jobtitle=d.id \ n " +
2023-07-13 17:51:16 +08:00
" left join hrmdepartmentvirtual e on a.DEPARTMENTID=e.id \ n " +
2023-08-17 14:21:43 +08:00
" left join hrmsubcompanyvirtual f on a.SUBCOMPANYID=f.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 ( " resourceid " ) ) ? null : rs . getInt ( " resourceid " ) ) ;
2023-07-13 16:58:22 +08:00
insertList . add ( currentUser ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " workyear " ) ) ? null : rs . getString ( " workyear " ) ) ;
insertList . add ( rs . getString ( " usekind " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( rs . getString ( " managerstr " ) ) ;
2023-07-13 16:58:22 +08:00
insertList . add ( StringUtils . isBlank ( rs . getString ( " status " ) ) ? null : rs . getInt ( " status " ) ) ;
insertList . add ( rs . getString ( " sex " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " accounttype " ) ) ? null : rs . getInt ( " accounttype " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " belongto " ) ) ? null : rs . getInt ( " belongto " ) ) ;
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 " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " jobtitleid " ) ) ? null : rs . getInt ( " jobtitleid " ) ) ;
insertList . add ( rs . getString ( " jobtitle " ) ) ;
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 " ) ) ;
insertList . add ( rs . getString ( " department " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " subcompanyid " ) ) ? null : rs . getInt ( " subcompanyid " ) ) ;
insertList . add ( rs . getString ( " subcompany " ) ) ;
insertList . add ( rs . getString ( " costcenter " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " manager " ) ) ? null : rs . getInt ( " manager " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " assistant " ) ) ? null : rs . getInt ( " assistant " ) ) ;
insertList . add ( rs . getString ( " workcode " ) ) ;
insertList . add ( rs . getString ( " classification " ) ) ;
2023-07-12 18:00:47 +08:00
insertList . add ( currentDate ) ;
2023-07-13 16:58:22 +08:00
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-13 16:58:22 +08:00
insertList . add ( rs . getString ( " lastname " ) ) ;
insertList . add ( StringUtils . isBlank ( rs . getString ( " companyworkyear " ) ) ? null : rs . getString ( " companyworkyear " ) ) ;
2023-07-12 18:00:47 +08:00
insertParamList . add ( insertList ) ;
}
2023-07-13 16:58:22 +08:00
String insertVirtualHrmSql = " 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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, " +
" ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " ;
2024-09-09 15:50:19 +08:00
2023-08-17 14:21:43 +08:00
insertData ( recordSetTrans , insertVirtualHrmSql , insertParamList ) ;
2023-07-12 18:00:47 +08:00
}
2023-07-11 18:08:40 +08:00
2023-08-17 14:21:43 +08:00
private void insertData ( RecordSetTrans recordSetTrans , String insertSql , List < List < Object > > insertParamList ) {
2023-07-12 18:00:47 +08:00
try {
2023-08-17 14:21:43 +08:00
recordSetTrans . executeBatchSql ( insertSql , insertParamList ) ;
2023-07-12 18:00:47 +08:00
} 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 ) {
2024-04-24 16:46:47 +08:00
// 查询集团数据
if ( isRealDimension ) {
// 查询实际集团表
return " select id,companyname as name,'0' as type from " + COMPANY_TABLE ;
2023-06-30 16:44:56 +08:00
} else {
2024-04-24 16:46:47 +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
}
}
/ * *
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
* /
2024-04-24 16:46:47 +08:00
private String getRealTimeChildSql ( String sql , String fType , String fObjId , String department , boolean showClass ) {
2023-06-30 16:44:56 +08:00
if ( StringUtils . isNotBlank ( fType ) ) {
switch ( fType ) {
case " 0 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-09-15 09:45:31 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 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-09-15 09:45:31 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 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-09-15 09:45:31 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type,b.on_job_num,b.staff_num from " + SUB_COMPANY_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=1 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
}
2023-11-15 17:06:07 +08:00
2024-04-24 16:46:47 +08:00
//中远重工二开 只能查看某一分部(非标分权无效)
String subCompanyId = new BaseBean ( ) . getPropValue ( " hrmOrganization " , " subCompanyId " ) ;
sql = sql + " and a.id = " + subCompanyId ;
2023-11-15 17:06:07 +08:00
// 一级分部数据分权处理
if ( isRealTime & & user . getUID ( ) ! = 1 & & isRealDimension ) {
DetachUtil detachUtil = new DetachUtil ( user ) ;
2024-02-20 14:13:40 +08:00
if ( detachUtil . isDETACH ( ) ) {
String ids = detachUtil . getJclRoleLevels ( ) ;
sql = sql + " and a.id in ( " + ids + " ) " ;
}
2023-11-15 17:06:07 +08:00
}
2024-04-24 16:46:47 +08:00
2023-06-30 16:44:56 +08:00
break ;
case " 1 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-09-15 09:45:31 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,showorder,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 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,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 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 {
2024-04-29 17:18:23 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,0,showorder,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 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,b.bmcj,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 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-09-15 09:45:31 +08:00
sql = " select a.id,a.subcompanyname as name,'1' as type,showorder,b.on_job_num,b.staff_num from " + SUB_COMPANY_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=1 where (canceled is null or canceled != '1') and supsubcomid = ' " + fObjId + " ' " +
" union select a.id,a.departmentname as name,'2' as type,showorder,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 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
}
2024-04-24 16:46:47 +08:00
//指定筛选一级部门节点数据
if ( StringUtils . isNotEmpty ( department ) ) {
sql + = " and a.id = " + department ;
}
break ;
2023-06-30 16:44:56 +08:00
case " 2 " :
if ( hasVirtualFields ) {
if ( showVirtual ) {
2023-09-15 09:45:31 +08:00
sql = " select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (a.canceled is null or a.canceled != '1') and supdepid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
} else {
2024-04-29 17:18:23 +08:00
sql = " select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,b.bmcj,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 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-09-15 09:45:31 +08:00
sql = " select a.id,a.departmentname as name,'2' as type,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where (canceled is null or canceled != '1') and supdepid = ' " + fObjId + " ' " ;
2023-06-30 16:44:56 +08:00
}
2024-04-24 16:46:47 +08:00
//隐藏班组数据
if ( ! showClass ) {
sql + = " and (b.sfbz is null or b.sfbz != '1') " ;
}
2023-06-30 16:44:56 +08:00
break ;
default :
break ;
}
2023-08-14 15:22:21 +08:00
sql + = " order by showorder,id " ;
2023-06-30 16:44:56 +08:00
}
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-11-24 10:01:58 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual,a.job_num,a.staff_num 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,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual,a.job_num,a.staff_num 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,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type,a.job_num,a.staff_num from " + SUB_COMPANY_TABLE + " a where (canceled is null or canceled != '1') and supsubcompanyid = ' " + fObjId + " ' and versionid = " + versionId +
" union select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual,a.job_num,a.staff_num 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-11-24 10:01:58 +08:00
sql = " select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type,a.job_num,a.staff_num 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 ;
}
/ * *
* 查询实时数据 , 子节点元素
*
2023-08-17 14:21:43 +08:00
* @param topChartPO 父级元素
* @param dataList 所有元素集合
* @param selectDepth 所选部门层级
* @param hideDepartment
2023-07-12 10:17:06 +08:00
* /
2024-04-24 16:46:47 +08:00
private void findChildData ( ChartPO topChartPO , List < ChartPO > dataList , Integer selectDepth , String versionId , boolean hideDepartment , String department , boolean showClass ) {
2023-07-12 10:17:06 +08:00
String fType = topChartPO . getFtype ( ) ;
String fObjId = topChartPO . getFobjid ( ) ;
String sql = " " ;
if ( isRealTime ) {
2024-04-24 16:46:47 +08:00
sql = getRealTimeChildSql ( sql , fType , fObjId , department , showClass ) ;
2023-07-12 10:17:06 +08:00
} 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 ( ) ) {
2024-04-29 17:18:23 +08:00
String type = recordSet . getString ( " type " ) ;
2023-06-30 16:44:56 +08:00
ChartPO chartPO = new ChartPO ( ) ;
2024-04-29 17:18:23 +08:00
chartPO . setFtype ( type ) ;
2023-06-30 16:44:56 +08:00
chartPO . setFobjid ( recordSet . getString ( " id " ) ) ;
chartPO . setFname ( recordSet . getString ( " name " ) ) ;
2023-11-24 10:01:58 +08:00
chartPO . setOnJobNum ( isRealTime ? Util . getIntValue ( recordSet . getString ( " on_job_num " ) , 0 ) : Util . getIntValue ( recordSet . getString ( " job_num " ) , 0 ) ) ;
2023-09-13 13:31:44 +08:00
chartPO . setStaffNum ( Util . getIntValue ( recordSet . getString ( " staff_num " ) , 0 ) ) ;
2023-06-30 16:44:56 +08:00
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 " ) ;
2024-04-29 17:18:23 +08:00
if ( " 2 " . equals ( type ) ) {
chartPO . setDeptLevel ( Util . getIntValue ( recordSet . getString ( " bmcj " ) , 0 ) ) ;
}
2023-08-17 14:21:43 +08:00
filterAndAddData ( currentList , chartPO , hideDepartment ) ;
//currentList.add(chartPO);
2023-06-30 16:44:56 +08:00
}
2023-11-15 17:06:07 +08:00
2023-06-30 16:44:56 +08:00
for ( ChartPO chartPO : currentList ) {
2023-07-07 14:54:21 +08:00
if ( inDepth ( selectDepth , chartPO . getDepartmentDepth ( ) ) ) {
2024-04-24 16:46:47 +08:00
findChildData ( chartPO , dataList , selectDepth , versionId , hideDepartment , department , showClass ) ;
2023-06-30 16:44:56 +08:00
}
}
2023-11-15 17:06:07 +08:00
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-07-24 16:38:17 +08:00
/ * *
* 获取部门树下拉框SQL
*
* @param versionId 版本ID
* @param dimension 维度
* @param subCompany 上级Id
* @return SQL
* /
private String getDepartmentTreeSql ( String versionId , String dimension , String subCompany ) {
// 是否展示当前数据
boolean isSearchCurrent = StringUtils . isBlank ( versionId ) | | " 0 " . equals ( versionId ) ;
boolean isCurrentDimension = StringUtils . isNotBlank ( dimension ) & & ! " 0 " . equals ( dimension ) ;
boolean isDepartment = subCompany . startsWith ( " d " ) ;
String sql ;
DBType dbType = DBType . get ( new RecordSet ( ) . getDBType ( ) ) ;
if ( isDepartment ) {
subCompany = subCompany . replace ( " d " , " " ) ;
if ( isSearchCurrent ) {
sql = " select " + dbType . concat ( " d " , " id " ) + " as id, id as value, departmentname as title, " + dbType . concat ( " d " , " supdepid " ) + " as pId from hrmdepartment where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supdepid " , " 0 " ) + " = " + subCompany ;
if ( isCurrentDimension ) {
sql = " select " + dbType . concat ( " d " , " id " ) + " as id, id as value, departmentname as title, " + dbType . concat ( " d " , " supdepid " ) + " as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supdepid " , " 0 " ) + " = " + subCompany ;
}
2023-07-31 17:45:42 +08:00
sql + = " order by showorder,id " ;
2023-07-24 16:38:17 +08:00
} else {
sql = " select " + dbType . concat ( " d " , " departmentid " ) + " as id, departmentid as value, departmentname as title, " + dbType . concat ( " d " , " supdepartmentid " ) + " as pId from jcl_chart_department where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supdepartmentid " , " 0 " ) + " = " + subCompany ;
if ( isCurrentDimension ) {
sql = " select " + dbType . concat ( " d " , " departmentvirtualid " ) + " as id, departmentvirtualid as value, departmentname as title, " + dbType . concat ( " d " , " supdepid " ) + " as pId from jcl_chart_departmentvirtual where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supdepid " , " 0 " ) + " = " + subCompany ;
}
// 添加时间轴条件
sql + = " and versionid = " + versionId ;
}
} else {
if ( isSearchCurrent ) {
2023-08-02 14:53:53 +08:00
sql = " select " + dbType . concat ( " " , " id " ) + " as id, id as value, subcompanyname as title, supsubcomid as pId, showorder from hrmsubcompany where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supsubcomid " , " 0 " ) + " = " + subCompany +
2023-07-31 17:45:42 +08:00
" union select " + dbType . concat ( " d " , " id " ) + " as id, id as value, departmentname as title, subcompanyid1 as pId, showorder from hrmdepartment where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and " + dbType . ifNull ( " subcompanyid1 " , " 0 " ) + " = " + subCompany ;
2023-07-24 16:38:17 +08:00
if ( isCurrentDimension ) {
sql = " select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supsubcomid " , " 0 " ) + " = " + subCompany + " and companyid = ' " + dimension + " ' " +
2023-07-31 17:45:42 +08:00
" union select " + dbType . concat ( " d " , " 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 ;
2023-07-24 16:38:17 +08:00
}
2023-07-31 17:45:42 +08:00
sql + = " order by showorder,id " ;
2023-07-24 16:38:17 +08:00
} else {
2023-08-02 14:53:53 +08:00
sql = " select " + dbType . concat ( " " , " subcompanyid " ) + " as id, subcompanyid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompany where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supsubcompanyid " , " 0 " ) + " = " + subCompany +
2023-07-31 17:45:42 +08:00
" union select " + dbType . concat ( " d " , " subcompanyid " ) + " as id, subcompanyid as value, departmentname as title, subcompanyid as pId from jcl_chart_department where (canceled is null or canceled != '1') and (supdepartmentid is null or supdepartmentid =0) and " + dbType . ifNull ( " subcompanyid " , " 0 " ) + " = " + subCompany ;
2023-07-24 16:38:17 +08:00
if ( isCurrentDimension ) {
2023-08-02 14:53:53 +08:00
sql = " select " + dbType . concat ( " " , " subcompanyvirtualid " ) + " as id, subcompanyvirtualid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompanyvirtual where (canceled is null or canceled != '1') and " + dbType . ifNull ( " supsubcompanyid " , " 0 " ) + " = " + subCompany + " and companyid = ' " + dimension + " ' " +
2023-07-31 17:45:42 +08:00
" union select " + dbType . concat ( " d " , " departmentvirtualid " ) + " as id, departmentvirtualid as value, departmentname as title, subcompanyid as pId from jcl_chart_departmentvirtual where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and " + dbType . ifNull ( " subcompanyid " , " 0 " ) + " = " + subCompany ;
2023-07-24 16:38:17 +08:00
}
// 添加时间轴条件
sql + = " and versionid = " + versionId ;
}
}
return sql ;
}
/ * *
* 判断树是否为叶子节点
*
* @param sql 查询下级元素SQL
* @param treeId 当前元素ID
* @return
* /
/ * *
* 判断树是否为叶子节点
2023-08-17 14:21:43 +08:00
*
* @param versionId 版本ID
* @param dimension 维度
2023-07-24 16:38:17 +08:00
* @param subCompany 上级元素ID
* @return
* /
private boolean judgeTreeLeaf ( String versionId , String dimension , String subCompany ) {
RecordSet recordSet = new RecordSet ( ) ;
String sql = getDepartmentTreeSql ( versionId , dimension , subCompany ) ;
recordSet . executeQuery ( sql ) ;
return ! recordSet . next ( ) ;
}
2023-08-17 14:21:43 +08:00
/ * *
* 过滤部门元素
*
* @param currentList
* @param chartPO
* @param hideDepartment
* /
private void filterAndAddData ( List < ChartPO > currentList , ChartPO chartPO , boolean hideDepartment ) {
2023-11-15 17:06:07 +08:00
2023-08-17 14:21:43 +08:00
if ( hideDepartment ) {
if ( " 2 " . equals ( chartPO . getFtype ( ) ) ) {
return ;
}
}
2023-11-15 17:06:07 +08:00
2023-08-17 14:21:43 +08:00
currentList . add ( chartPO ) ;
}
2024-09-09 15:50:19 +08:00
@Override
public Map < String , Object > versionDelete ( Integer versionId ) {
Map < String , Object > data = new HashMap < > ( ) ;
RecordSet rs = new RecordSet ( ) ;
//1.删除版本表
rs . executeUpdate ( " delete from jcl_org_chartversion where id = ? " , versionId ) ;
//2.删除历史分部表
rs . executeUpdate ( " delete from jcl_chart_subcompany where versionid = ? " , versionId ) ;
//3.删除历史部门表
rs . executeUpdate ( " delete from jcl_chart_department where versionid = ? " , versionId ) ;
//4.删除历史聚才林岗位表
rs . executeUpdate ( " delete from jcl_chart_job where versionid = ? " , versionId ) ;
//5.删除历史人员表
rs . executeUpdate ( " delete from jcl_chart_resource where versionid = ? " , versionId ) ;
data . put ( " versionId " , versionId ) ;
return data ;
}
2023-06-30 16:44:56 +08:00
}