2022-05-20 15:00:03 +08:00
package com.engine.organization.service.impl ;
2022-05-27 18:05:15 +08:00
import com.alibaba.fastjson.JSONObject ;
2022-05-23 19:16:31 +08:00
import com.api.browser.bean.SearchConditionGroup ;
import com.api.browser.bean.SearchConditionItem ;
2022-05-27 18:05:15 +08:00
import com.api.browser.bean.SearchConditionOption ;
2022-05-23 17:46:37 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn ;
import com.cloudstore.eccom.result.WeaResultMsg ;
2022-05-27 18:05:15 +08:00
import com.engine.common.util.ServiceUtil ;
2022-05-20 15:00:03 +08:00
import com.engine.core.impl.Service ;
2022-06-06 13:17:35 +08:00
import com.engine.hrm.entity.RuleCodeType ;
2022-05-23 17:46:37 +08:00
import com.engine.organization.component.OrganizationWeaTable ;
2022-09-08 15:36:47 +08:00
import com.engine.organization.entity.DeleteParam ;
2022-06-23 09:14:19 +08:00
import com.engine.organization.entity.codesetting.po.CodeRulePO ;
2022-08-26 15:36:06 +08:00
import com.engine.organization.entity.commom.RecordInfo ;
2022-06-02 09:58:16 +08:00
import com.engine.organization.entity.company.bo.CompBO ;
import com.engine.organization.entity.company.po.CompPO ;
2022-05-20 15:00:03 +08:00
import com.engine.organization.entity.department.bo.DepartmentBO ;
2022-05-23 17:46:37 +08:00
import com.engine.organization.entity.department.dto.DepartmentListDTO ;
2022-06-02 15:43:19 +08:00
import com.engine.organization.entity.department.param.* ;
2022-05-20 15:00:03 +08:00
import com.engine.organization.entity.department.po.DepartmentPO ;
import com.engine.organization.entity.department.vo.SingleDeptTreeVO ;
2022-06-14 14:31:52 +08:00
import com.engine.organization.entity.extend.po.ExtendTitlePO ;
2022-06-02 16:49:25 +08:00
import com.engine.organization.entity.job.bo.JobBO ;
2022-06-02 11:40:24 +08:00
import com.engine.organization.entity.job.po.JobPO ;
2022-06-02 16:49:25 +08:00
import com.engine.organization.entity.job.vo.SingleJobTreeVO ;
2022-10-19 15:38:47 +08:00
import com.engine.organization.entity.map.JclOrgMap ;
2022-06-02 09:58:16 +08:00
import com.engine.organization.entity.searchtree.SearchTree ;
import com.engine.organization.entity.searchtree.SearchTreeParams ;
2022-07-13 10:55:44 +08:00
import com.engine.organization.enums.LogModuleNameEnum ;
2022-10-19 15:38:47 +08:00
import com.engine.organization.enums.ModuleTypeEnum ;
2022-07-13 10:55:44 +08:00
import com.engine.organization.enums.OperateTypeEnum ;
2022-06-23 09:14:19 +08:00
import com.engine.organization.mapper.codesetting.CodeRuleMapper ;
2022-05-27 18:05:15 +08:00
import com.engine.organization.mapper.comp.CompMapper ;
2022-05-20 15:00:03 +08:00
import com.engine.organization.mapper.department.DepartmentMapper ;
2022-08-22 09:10:00 +08:00
import com.engine.organization.mapper.extend.ExtDTMapper ;
import com.engine.organization.mapper.extend.ExtMapper ;
2022-06-14 14:31:52 +08:00
import com.engine.organization.mapper.extend.ExtendTitleMapper ;
2022-08-26 15:36:06 +08:00
import com.engine.organization.mapper.hrmresource.SystemDataMapper ;
2022-10-19 15:38:47 +08:00
import com.engine.organization.mapper.jclorgmap.JclOrgMapper ;
2022-06-02 11:40:24 +08:00
import com.engine.organization.mapper.job.JobMapper ;
2022-05-20 15:00:03 +08:00
import com.engine.organization.service.DepartmentService ;
2022-05-27 18:05:15 +08:00
import com.engine.organization.service.ExtService ;
2022-08-31 14:24:00 +08:00
import com.engine.organization.thread.DepartmentTriggerRunnable ;
2022-09-08 15:36:47 +08:00
import com.engine.organization.thread.HrmResourceTriggerRunnable ;
2022-08-31 14:24:00 +08:00
import com.engine.organization.thread.JobTriggerRunnable ;
2022-08-26 15:36:06 +08:00
import com.engine.organization.thread.OrganizationSyncEc ;
2022-06-23 18:49:47 +08:00
import com.engine.organization.util.* ;
2022-06-06 17:48:11 +08:00
import com.engine.organization.util.coderule.CodeRuleUtil ;
2022-05-20 15:00:03 +08:00
import com.engine.organization.util.db.MapperProxyFactory ;
2022-10-28 17:43:46 +08:00
import com.engine.organization.util.detach.DetachUtil ;
2022-05-23 17:46:37 +08:00
import com.engine.organization.util.page.Column ;
2022-05-20 15:00:03 +08:00
import com.engine.organization.util.page.PageInfo ;
import com.engine.organization.util.page.PageUtil ;
2022-08-30 10:46:42 +08:00
import com.engine.organization.util.relation.EcHrmRelationUtil ;
2022-06-06 14:41:46 +08:00
import com.engine.organization.util.tree.SearchTreeUtil ;
2022-09-09 14:41:04 +08:00
import com.google.common.collect.Lists ;
2022-06-02 09:58:16 +08:00
import org.apache.commons.collections4.CollectionUtils ;
2022-06-23 09:14:19 +08:00
import org.apache.commons.lang.StringUtils ;
2022-09-08 15:36:47 +08:00
import weaver.conn.RecordSet ;
2022-05-23 17:46:37 +08:00
import weaver.general.StringUtil ;
2022-05-27 18:05:15 +08:00
import weaver.general.Util ;
import weaver.hrm.User ;
2022-05-20 15:00:03 +08:00
2022-05-23 19:16:31 +08:00
import java.util.* ;
import java.util.stream.Collectors ;
2022-05-20 15:00:03 +08:00
/ * *
* @Author weaver_cl
2022-06-14 11:07:48 +08:00
* @description :
2022-05-20 15:00:03 +08:00
* @Date 2022 / 5 / 20
* @Version V1 . 0
* * /
public class DepartmentServiceImpl extends Service implements DepartmentService {
2022-05-27 18:05:15 +08:00
/ * *
* 分组类型
* 1 : 分部
* 2 : 部门
* 3 : 岗位
* /
2022-05-30 18:39:03 +08:00
private static final String EXTEND_TYPE = " 2 " ;
2022-06-13 17:22:34 +08:00
/ * *
* 主表
* /
private static final String JCL_ORG_DEPT = " JCL_ORG_DEPT " ;
2022-05-27 18:05:15 +08:00
/ * *
* 主表拓展表
* /
private static final String JCL_ORG_DEPTEXT = " JCL_ORG_DEPTEXT " ;
/ * *
* 明细表拓展表
* /
private static final String JCL_ORG_DEPTEXT_DT1 = " JCL_ORG_DEPTEXT_DT1 " ;
2022-06-07 12:02:36 +08:00
private static final String RIGHT_NAME = " Department:All " ;
2022-06-13 17:22:34 +08:00
/ * *
* 部门主表title指定ID
* /
2022-06-17 16:00:05 +08:00
private static final Long GROUP_ID = 2L ;
2022-06-13 17:22:34 +08:00
2022-08-26 15:36:06 +08:00
private static final String HRM_DEPARTMENT = " hrmdepartment " ;
2022-06-02 09:58:16 +08:00
2022-07-27 10:48:43 +08:00
private static DepartmentMapper getDepartmentMapper ( ) {
2022-05-23 19:16:31 +08:00
return MapperProxyFactory . getProxy ( DepartmentMapper . class ) ;
}
2022-05-20 15:00:03 +08:00
2022-08-30 10:46:42 +08:00
private static JobMapper getJobMapper ( ) {
return MapperProxyFactory . getProxy ( JobMapper . class ) ;
}
2022-05-27 18:05:15 +08:00
private CompMapper getCompMapper ( ) {
return MapperProxyFactory . getProxy ( CompMapper . class ) ;
}
2022-06-14 14:31:52 +08:00
private ExtendTitleMapper getExtendTitleMapper ( ) {
return MapperProxyFactory . getProxy ( ExtendTitleMapper . class ) ;
2022-05-27 18:05:15 +08:00
}
2022-08-26 15:36:06 +08:00
private SystemDataMapper getSystemDataMapper ( ) {
return MapperProxyFactory . getProxy ( SystemDataMapper . class ) ;
}
2022-05-27 18:05:15 +08:00
private ExtService getExtService ( User user ) {
return ServiceUtil . getService ( ExtServiceImpl . class , user ) ;
}
2022-05-20 15:00:03 +08:00
@Override
public PageInfo < SingleDeptTreeVO > getDeptListByPid ( QuerySingleDeptListParam param ) {
//1.查询分部下所有部门
2022-05-26 10:04:04 +08:00
//PageUtil.start(param.getCurrent(), param.getPageSize());
2022-06-23 18:49:47 +08:00
List < DepartmentPO > departmentPOS = MapperProxyFactory . getProxy ( DepartmentMapper . class ) . list ( " show_order " ) ;
2022-05-23 17:33:10 +08:00
PageInfo < DepartmentPO > pageInfo = new PageInfo < > ( departmentPOS ) ;
2022-06-02 09:58:16 +08:00
List < SingleDeptTreeVO > singleDeptTreeVOS = DepartmentBO . buildSingleDeptTreeVOS ( departmentPOS , param . getParentComp ( ) ) ;
2022-05-23 19:16:31 +08:00
PageInfo < SingleDeptTreeVO > pageInfos = new PageInfo < > ( singleDeptTreeVOS , SingleDeptTreeVO . class ) ;
2022-05-23 17:33:10 +08:00
pageInfos . setTotal ( pageInfo . getTotal ( ) ) ;
2022-05-20 15:00:03 +08:00
pageInfos . setPageNum ( param . getCurrent ( ) ) ;
pageInfos . setPageSize ( param . getPageSize ( ) ) ;
return pageInfos ;
}
2022-05-23 17:46:37 +08:00
2022-06-02 16:49:25 +08:00
@Override
public PageInfo < SingleJobTreeVO > getJobListByPid ( QuerySingleDeptListParam param ) {
List < JobPO > jobPOS = MapperProxyFactory . getProxy ( JobMapper . class ) . listAll ( ) ;
PageInfo < JobPO > pageInfo = new PageInfo < > ( jobPOS ) ;
List < SingleJobTreeVO > singleDeptTreeVOS = JobBO . buildSingleJobTreeVOS ( jobPOS , param . getParentDept ( ) ) ;
PageInfo < SingleJobTreeVO > pageInfos = new PageInfo < > ( singleDeptTreeVOS , SingleJobTreeVO . class ) ;
pageInfos . setTotal ( pageInfo . getTotal ( ) ) ;
pageInfos . setPageNum ( param . getCurrent ( ) ) ;
pageInfos . setPageSize ( param . getPageSize ( ) ) ;
return pageInfos ;
}
2022-06-02 09:58:16 +08:00
@Override
public Map < String , Object > getSearchTree ( SearchTreeParams params ) {
String keyword = params . getKeyword ( ) ;
String id = params . getId ( ) ;
2022-06-06 14:41:46 +08:00
String type = Util . null2String ( params . getType ( ) ) ;
List < SearchTree > treeList = getFilterCompany ( id , keyword ) ;
return SearchTreeUtil . getSearchTree ( type , treeList ) ;
2022-06-02 09:58:16 +08:00
}
2022-05-23 17:46:37 +08:00
@Override
public Map < String , Object > listPage ( DeptSearchParam param ) {
Map < String , Object > datas = new HashMap < > ( ) ;
2022-06-07 12:02:36 +08:00
boolean hasRight = HasRightUtil . hasRight ( user , RIGHT_NAME , true ) ;
datas . put ( " hasRight " , hasRight ) ;
if ( ! hasRight ) {
2022-06-06 19:19:28 +08:00
return datas ;
}
2022-06-02 09:58:16 +08:00
DepartmentPO departmentPO = DepartmentBO . convertParamsToPO ( param , user . getUID ( ) ) ;
2022-05-27 18:05:15 +08:00
boolean filter = isFilter ( departmentPO ) ;
PageInfo < DepartmentListDTO > pageInfos ;
2022-06-23 18:49:47 +08:00
String orderSql = PageInfoSortUtil . getSortSql ( param . getSortParams ( ) ) ;
List < DepartmentPO > allList = getDepartmentMapper ( ) . list ( orderSql ) ;
2022-10-28 17:43:46 +08:00
new DetachUtil ( user . getUID ( ) ) . filterDepartmentList ( allList ) ;
2022-05-27 18:05:15 +08:00
// 通过子级遍历父级元素
if ( filter ) {
// 根据条件获取元素
2022-06-23 18:49:47 +08:00
List < DepartmentPO > filterDeptPOs = getDepartmentMapper ( ) . listByFilter ( departmentPO , orderSql ) ;
2022-10-28 17:43:46 +08:00
new DetachUtil ( user . getUID ( ) ) . filterDepartmentList ( filterDeptPOs ) ;
2022-05-27 18:05:15 +08:00
// 添加父级元素
2022-06-02 09:58:16 +08:00
List < DepartmentListDTO > compListDTOS = DepartmentBO . buildDeptDTOList ( allList , filterDeptPOs ) ;
2022-05-27 18:05:15 +08:00
List < DepartmentListDTO > subList = PageUtil . subList ( param . getCurrent ( ) , param . getPageSize ( ) , compListDTOS ) ;
pageInfos = new PageInfo < > ( subList , DepartmentListDTO . class ) ;
pageInfos . setTotal ( compListDTOS . size ( ) ) ;
} else {
// 组合list
2022-06-02 09:58:16 +08:00
List < DepartmentListDTO > compListDTOS = DepartmentBO . buildDeptDTOList ( allList ) ;
2022-05-27 18:05:15 +08:00
List < DepartmentListDTO > subList = PageUtil . subList ( param . getCurrent ( ) , param . getPageSize ( ) , compListDTOS ) ;
pageInfos = new PageInfo < > ( subList , DepartmentListDTO . class ) ;
pageInfos . setTotal ( compListDTOS . size ( ) ) ;
}
2022-05-24 15:15:49 +08:00
2022-05-23 17:46:37 +08:00
pageInfos . setPageNum ( param . getCurrent ( ) ) ;
pageInfos . setPageSize ( param . getPageSize ( ) ) ;
OrganizationWeaTable < DepartmentListDTO > table = new OrganizationWeaTable < > ( user , DepartmentListDTO . class ) ;
List < Column > columns = pageInfos . getColumns ( ) ;
List < WeaTableColumn > weaTableColumn = columns . stream ( ) . map ( v - > new WeaTableColumn ( " 100 " , v . getTitle ( ) , v . getKey ( ) ) ) . collect ( Collectors . toList ( ) ) ;
table . setColumns ( weaTableColumn ) ;
WeaResultMsg result = new WeaResultMsg ( false ) ;
result . putAll ( table . makeDataResult ( ) ) ;
result . success ( ) ;
datas . put ( " pageInfo " , pageInfos ) ;
datas . put ( " dataKey " , result . getResultMap ( ) ) ;
return datas ;
}
2022-05-23 19:16:31 +08:00
@Override
2022-06-23 16:55:26 +08:00
public Long saveBaseForm ( Map < String , Object > params ) {
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-06-13 17:22:34 +08:00
String deptNo = ( String ) params . get ( " dept_no " ) ;
2022-06-23 09:14:19 +08:00
// 判断是否开启自动编号
deptNo = repeatDetermine ( deptNo ) ;
2022-06-13 17:22:34 +08:00
params . put ( " dept_no " , deptNo ) ;
2022-07-13 10:55:44 +08:00
if ( StringUtils . isBlank ( Util . null2String ( params . get ( " show_order " ) ) ) ) {
2022-07-22 16:02:32 +08:00
Integer maxShowOrder = getDepartmentMapper ( ) . getMaxShowOrder ( ) ;
if ( null = = maxShowOrder ) {
maxShowOrder = 0 ;
}
2022-06-23 09:14:19 +08:00
params . put ( " show_order " , maxShowOrder + 1 ) ;
}
2022-09-05 17:25:11 +08:00
// 上级分部
String ecCompany = Util . null2String ( params . get ( " ec_company " ) ) ;
if ( StringUtils . isNotBlank ( ecCompany ) ) {
CompPO jclCompanyId = EcHrmRelationUtil . getJclCompanyId ( ecCompany ) ;
if ( null ! = jclCompanyId ) {
params . put ( " parent_comp " , jclCompanyId . getId ( ) ) ;
}
}
// 上级部门
String ecDepartment = Util . null2String ( params . get ( " ec_department " ) ) ;
if ( StringUtils . isNotBlank ( ecDepartment ) ) {
DepartmentPO jclDepartmentId = EcHrmRelationUtil . getJclDepartmentId ( ecDepartment ) ;
if ( null ! = jclDepartmentId ) {
params . put ( " parent_dept " , jclDepartmentId . getId ( ) ) ;
// 部门不为空,自动指定所属分部
params . put ( " parent_comp " , jclDepartmentId . getParentComp ( ) ) ;
2022-09-09 10:25:57 +08:00
params . put ( " ec_company " , EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( jclDepartmentId . getParentComp ( ) ) ) ) ;
2022-09-05 17:25:11 +08:00
}
}
2022-08-26 15:36:06 +08:00
Map < String , Object > syncMap = new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . ADD , params ) . sync ( ) ;
String ecCompanyID = Util . null2String ( syncMap . get ( " id " ) ) ;
OrganizationAssert . isTrue ( StringUtils . isNotBlank ( ecCompanyID ) , syncMap . get ( " message " ) . toString ( ) ) ;
// 查询UUID
RecordInfo recordInfo = getSystemDataMapper ( ) . getHrmObjectByID ( HRM_DEPARTMENT , ecCompanyID ) ;
params . put ( " uuid " , recordInfo . getUuid ( ) ) ;
return getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_DEPT , params , " " , null ) ;
2022-05-27 18:05:15 +08:00
}
@Override
public int updateForbiddenTagById ( DeptSearchParam params ) {
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-05-27 18:05:15 +08:00
DepartmentPO departmentPO = DepartmentPO . builder ( ) . id ( params . getId ( ) ) . forbiddenTag ( params . getForbiddenTag ( ) ? 0 : 1 ) . build ( ) ;
2022-10-14 14:56:35 +08:00
if ( ! params . getForbiddenTag ( ) ) {
// 判断当前岗位下是否有启用岗位,如有启用岗位,部门无法禁用
int countUsedInJob = getDepartmentMapper ( ) . countUsedInJob ( params . getId ( ) ) ;
OrganizationAssert . isTrue ( countUsedInJob = = 0 , " 部门存在下级岗位,不能封存 " ) ;
}
2022-07-13 10:55:44 +08:00
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " id " , departmentPO . getId ( ) ) ;
map . put ( " forbiddenTag " , departmentPO . getForbiddenTag ( ) ) ;
2022-08-26 15:36:06 +08:00
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
2022-05-27 18:05:15 +08:00
return getDepartmentMapper ( ) . updateForbiddenTagById ( departmentPO ) ;
}
@Override
2022-06-23 16:55:26 +08:00
public Long updateForm ( Map < String , Object > params ) {
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-05-27 18:05:15 +08:00
DeptSearchParam searchParam = JSONObject . parseObject ( JSONObject . toJSONString ( params ) , DeptSearchParam . class ) ;
String groupId = ( String ) params . get ( " viewCondition " ) ;
2022-06-13 17:22:34 +08:00
if ( " 0 " . equals ( groupId ) ) {
groupId = GROUP_ID . toString ( ) ;
}
2022-06-23 09:14:19 +08:00
2022-10-26 20:12:14 +08:00
DepartmentPO oldDept = getDepartmentMapper ( ) . getDeptById ( searchParam . getId ( ) ) ;
2022-06-23 09:14:19 +08:00
String deptNo = searchParam . getDeptNo ( ) ;
2022-10-26 20:12:14 +08:00
if ( ! deptNo . equals ( oldDept . getDeptNo ( ) ) ) {
2022-06-23 09:14:19 +08:00
deptNo = repeatDetermine ( deptNo ) ;
params . put ( " dept_no " , deptNo ) ;
}
2022-09-05 17:25:11 +08:00
// 上级分部
String ecCompany = Util . null2String ( params . get ( " ec_company " ) ) ;
if ( StringUtils . isNotBlank ( ecCompany ) ) {
CompPO jclCompanyId = EcHrmRelationUtil . getJclCompanyId ( ecCompany ) ;
if ( null ! = jclCompanyId ) {
params . put ( " parent_comp " , jclCompanyId . getId ( ) ) ;
}
}
// 上级部门
String ecDepartment = Util . null2String ( params . get ( " ec_department " ) ) ;
if ( StringUtils . isNotBlank ( ecDepartment ) ) {
DepartmentPO jclDepartmentId = EcHrmRelationUtil . getJclDepartmentId ( ecDepartment ) ;
if ( null ! = jclDepartmentId ) {
2022-09-23 15:53:37 +08:00
// 上级部门不能选择本身
OrganizationAssert . isFalse ( jclDepartmentId . getId ( ) . equals ( searchParam . getId ( ) ) , " 上级部门不能选择本身 " ) ;
2022-09-05 17:25:11 +08:00
params . put ( " parent_dept " , jclDepartmentId . getId ( ) ) ;
// 部门不为空,自动指定所属分部
params . put ( " parent_comp " , jclDepartmentId . getParentComp ( ) ) ;
2022-09-09 10:25:57 +08:00
params . put ( " ec_company " , EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( jclDepartmentId . getParentComp ( ) ) ) ) ;
2022-09-05 17:25:11 +08:00
}
2022-09-08 15:36:47 +08:00
} else {
params . put ( " parent_dept " , " " ) ;
2022-08-31 14:24:00 +08:00
}
2022-08-26 15:36:06 +08:00
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . UPDATE , params ) . sync ( ) ;
2022-05-27 18:05:15 +08:00
// 更新主表数据
2022-06-23 16:55:26 +08:00
getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_DEPT , params , " " , searchParam . getId ( ) ) ;
2022-05-27 18:05:15 +08:00
// 更新主表拓展表
2022-06-23 16:55:26 +08:00
getExtService ( user ) . updateExtForm ( user , EXTEND_TYPE , JCL_ORG_DEPTEXT , params , groupId , searchParam . getId ( ) ) ;
2022-05-27 18:05:15 +08:00
//更新明细表
2022-06-13 17:22:34 +08:00
getExtService ( user ) . updateExtDT ( user , EXTEND_TYPE , JCL_ORG_DEPTEXT_DT1 , params , searchParam . getId ( ) ) ;
2022-05-27 18:05:15 +08:00
2022-10-26 20:12:14 +08:00
DepartmentPO newDeptById = getDepartmentMapper ( ) . getDeptById ( searchParam . getId ( ) ) ;
new DepartmentTriggerRunnable ( oldDept , newDeptById ) . run ( ) ;
2022-09-05 17:25:11 +08:00
Long parentComp = StringUtils . isNotEmpty ( Util . null2String ( params . get ( " parent_comp " ) ) ) ? Long . parseLong ( Util . null2String ( params . get ( " parent_comp " ) ) ) : null ;
// 刷新岗位所属分部
refreshJobComp ( searchParam . getId ( ) , parentComp ) ;
List < DepartmentPO > childList = getDepartmentMapper ( ) . getDeptListByPId ( searchParam . getId ( ) ) ;
2022-09-08 15:36:47 +08:00
String ecCompanyId = EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( parentComp ) ) ;
forbiddenChildTag ( parentComp , ecCompanyId , childList ) ;
2022-09-05 17:25:11 +08:00
2022-06-23 16:55:26 +08:00
return searchParam . getId ( ) ;
2022-05-27 18:05:15 +08:00
}
@Override
public int deleteByIds ( Collection < Long > ids ) {
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-05-27 18:05:15 +08:00
OrganizationAssert . notEmpty ( ids , " 请选择要删除的数据 " ) ;
2022-07-13 10:55:44 +08:00
Map < String , Object > map = new HashMap < > ( ) ;
2022-08-26 15:36:06 +08:00
2022-08-22 09:10:00 +08:00
for ( Long id : ids ) {
2022-08-26 15:36:06 +08:00
map . put ( " id " , id ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
2022-08-22 09:10:00 +08:00
// 删除拓展表、明细表
MapperProxyFactory . getProxy ( ExtMapper . class ) . deleteByID ( " jcl_org_deptext " , id ) ;
2022-11-14 19:13:35 +08:00
MapperProxyFactory . getProxy ( ExtDTMapper . class ) . deleteByMainID ( " jcl_org_deptext_dt1 " , id , null ) ;
2022-08-22 09:10:00 +08:00
}
2022-08-26 15:36:06 +08:00
2022-05-27 18:05:15 +08:00
return getDepartmentMapper ( ) . deleteByIds ( ids ) ;
}
@Override
public Map < String , Object > getSearchCondition ( Map < String , Object > params ) {
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > conditionItems = new ArrayList < > ( ) ;
// 编号
SearchConditionItem deptNoItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , " 编号 " , " deptNo " ) ;
// 名称
2022-06-02 09:58:16 +08:00
SearchConditionItem deptNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , " 名称 " , " departmentName " ) ;
2022-05-27 18:05:15 +08:00
// 简称
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , " 简称 " , " deptNameShort " ) ;
// 所属分部
2022-09-05 17:25:11 +08:00
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , " 所属分部 " , " 164 " , " ecCompany " , " " ) ;
2022-05-27 18:05:15 +08:00
// 上级部门
2022-09-05 17:25:11 +08:00
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , " 上级部门 " , " 4 " , " ecDepartment " , " " ) ;
2022-05-27 18:05:15 +08:00
// 部门负责人
SearchConditionItem deptPrincipalBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , " 部门负责人 " , " 1 " , " deptPrincipal " , " " ) ;
// 显示顺序
SearchConditionItem showOrderItem = OrganizationFormItemUtil . inputNumberItem ( user , 2 , 16 , 2 , " 显示顺序 " , " showOrder " ) ;
// 禁用标记
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
SearchConditionOption enableOption = new SearchConditionOption ( " true " , " 启用 " ) ;
SearchConditionOption disableOption = new SearchConditionOption ( " false " , " 禁用 " ) ;
selectOptions . add ( enableOption ) ;
selectOptions . add ( disableOption ) ;
SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil . selectItem ( user , selectOptions , 2 , 16 , 6 , false , " 禁用标记 " , " forbiddenTag " ) ;
conditionItems . add ( deptNoItem ) ;
conditionItems . add ( deptNameItem ) ;
conditionItems . add ( deptNameShortItem ) ;
conditionItems . add ( parentCompBrowserItem ) ;
conditionItems . add ( parentDeptBrowserItem ) ;
conditionItems . add ( deptPrincipalBrowserItem ) ;
conditionItems . add ( showOrderItem ) ;
conditionItems . add ( forbiddenTagItem ) ;
addGroups . add ( new SearchConditionGroup ( " 高级搜索条件 " , true , conditionItems ) ) ;
apiDatas . put ( " conditions " , addGroups ) ;
return apiDatas ;
}
@Override
2022-09-14 17:14:12 +08:00
public Map < String , List < MenuBtn > > getHasRight ( ) {
2022-06-06 19:19:28 +08:00
return MenuBtn . getDatasHasCopy ( ) ;
2022-05-27 18:05:15 +08:00
}
@Override
public Map < String , Object > getDeptBaseForm ( Map < String , Object > params ) {
OrganizationAssert . notNull ( params . get ( " viewAttr " ) , " 请标识操作类型 " ) ;
// 2编辑 1查看
int viewAttr = Integer . parseInt ( ( String ) params . get ( " viewAttr " ) ) ;
long id = Long . parseLong ( ( String ) params . get ( " id " ) ) ;
String groupId = ( String ) params . get ( " viewCondition " ) ;
HashMap < String , Object > buttonsMap = new HashMap < > ( ) ;
buttonsMap . put ( " hasEdit " , true ) ;
buttonsMap . put ( " hasSave " , true ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
2022-06-13 17:22:34 +08:00
if ( " 0 " . equals ( groupId ) ) {
groupId = GROUP_ID . toString ( ) ;
}
2022-08-26 15:36:06 +08:00
List < ExtendTitlePO > extendTitles = getExtendTitleMapper ( ) . getTitlesByGroupID ( Long . parseLong ( groupId ) , " 1 " ) ;
2022-06-14 14:31:52 +08:00
if ( CollectionUtils . isNotEmpty ( extendTitles ) ) {
for ( ExtendTitlePO extendTitle : extendTitles ) {
2022-06-23 13:43:52 +08:00
List < SearchConditionItem > items = getExtService ( user ) . getExtForm ( user , EXTEND_TYPE + " " , GROUP_ID . equals ( Long . parseLong ( groupId ) ) ? JCL_ORG_DEPT : JCL_ORG_DEPTEXT , viewAttr , id , extendTitle . getId ( ) . toString ( ) , " " ) ;
2022-06-23 09:14:19 +08:00
if ( CollectionUtils . isNotEmpty ( items ) ) {
addGroups . add ( new SearchConditionGroup ( extendTitle . getTitle ( ) , true , items ) ) ;
}
2022-06-13 17:22:34 +08:00
}
2022-05-27 18:05:15 +08:00
}
HashMap < String , Object > resultMap = new HashMap < > ( ) ;
resultMap . put ( " buttons " , buttonsMap ) ;
resultMap . put ( " conditions " , addGroups ) ;
resultMap . put ( " id " , id ) ;
// 拓展页面分组
resultMap . put ( " tabInfo " , getExtService ( user ) . getTabInfo ( EXTEND_TYPE , JCL_ORG_DEPTEXT ) ) ;
// 处理明细表
2022-06-14 17:53:49 +08:00
resultMap . put ( " tables " , getExtService ( user ) . getExtendTables ( user , EXTEND_TYPE , Long . parseLong ( groupId ) , JCL_ORG_DEPTEXT_DT1 , id , viewAttr , false ) ) ;
2022-05-27 18:05:15 +08:00
Map < String , Object > apiDatas = new HashMap < > ( ) ;
apiDatas . put ( " result " , resultMap ) ;
return apiDatas ;
2022-05-23 19:16:31 +08:00
}
@Override
2022-09-07 15:40:19 +08:00
public Map < String , Object > getSaveForm ( DeptSearchParam param ) {
2022-06-13 17:22:34 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-05-23 19:16:31 +08:00
Map < String , Object > apiDatas = new HashMap < > ( ) ;
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
2022-08-26 15:36:06 +08:00
List < ExtendTitlePO > extendTitles = getExtendTitleMapper ( ) . getTitlesByGroupID ( GROUP_ID , " 1 " ) ;
2022-06-14 14:31:52 +08:00
if ( CollectionUtils . isNotEmpty ( extendTitles ) ) {
2022-09-07 15:40:19 +08:00
Map < String , Object > params = new HashMap < > ( ) ;
// 分部
if ( StringUtils . isNotBlank ( Util . null2String ( param . getSubcompanyid1 ( ) ) ) ) {
CompPO compPO = getCompMapper ( ) . listById ( param . getSubcompanyid1 ( ) ) ;
if ( null ! = compPO ) {
params . put ( " parent_comp " , compPO . getId ( ) ) ;
params . put ( " ec_company " , EcHrmRelationUtil . getEcCompanyId ( compPO . getId ( ) . toString ( ) ) ) ;
}
}
// 部门
if ( StringUtils . isNotBlank ( Util . null2String ( param . getDepartmentid ( ) ) ) ) {
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( param . getDepartmentid ( ) ) ;
if ( null ! = deptById ) {
params . put ( " parent_dept " , deptById . getId ( ) ) ;
params . put ( " ec_department " , EcHrmRelationUtil . getEcDepartmentId ( deptById . getId ( ) . toString ( ) ) ) ;
params . put ( " parent_comp " , deptById . getParentComp ( ) ) ;
params . put ( " ec_company " , EcHrmRelationUtil . getEcCompanyId ( deptById . getParentComp ( ) . toString ( ) ) ) ;
}
}
2022-06-14 14:31:52 +08:00
for ( ExtendTitlePO extendTitle : extendTitles ) {
2022-09-07 15:40:19 +08:00
List < SearchConditionItem > items = getExtService ( user ) . getExtSaveForm ( user , EXTEND_TYPE + " " , JCL_ORG_DEPT , 2 , extendTitle . getId ( ) . toString ( ) , " dept_no " , RuleCodeType . DEPARTMENT . getValue ( ) , params ) ;
2022-06-23 09:14:19 +08:00
if ( CollectionUtils . isNotEmpty ( items ) ) {
addGroups . add ( new SearchConditionGroup ( extendTitle . getTitle ( ) , true , items ) ) ;
}
2022-06-13 17:22:34 +08:00
}
2022-06-06 13:17:35 +08:00
}
2022-05-23 19:16:31 +08:00
apiDatas . put ( " condition " , addGroups ) ;
return apiDatas ;
}
2022-06-02 10:53:43 +08:00
/ * *
* 复制表单
*
* @return
* /
@Override
public List < SearchConditionGroup > getCopyForm ( ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
2022-09-05 17:25:11 +08:00
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , " 复制到 " , " 164 " , " company " , " " ) ;
2022-06-02 11:40:24 +08:00
compBrowserItem . setRules ( " required|string " ) ;
2022-09-15 10:41:04 +08:00
SearchConditionItem isCheckItem = OrganizationFormItemUtil . selectItem ( user , Lists . newArrayList ( new SearchConditionOption ( " 1 " , " " ) ) , 2 , 5 , 10 , false , " 复制岗位信息 " , " copyJob " ) ;
2022-06-02 10:53:43 +08:00
isCheckItem . setDetailtype ( 2 ) ;
2022-09-15 10:41:04 +08:00
SearchConditionItem copySubDeptItem = OrganizationFormItemUtil . selectItem ( user , Lists . newArrayList ( new SearchConditionOption ( " 1 " , " " ) ) , 2 , 5 , 10 , false , " 复制子部门信息 " , " copySubDept " ) ;
2022-09-09 14:41:04 +08:00
copySubDeptItem . setDetailtype ( 2 ) ;
2022-09-15 10:41:04 +08:00
SearchConditionItem copySubJob = OrganizationFormItemUtil . selectItem ( user , Lists . newArrayList ( new SearchConditionOption ( " 1 " , " " ) ) , 2 , 5 , 10 , false , " 复制子部门岗位信息 " , " copySubJob " ) ;
2022-09-09 14:41:04 +08:00
copySubJob . setDetailtype ( 2 ) ;
2022-06-02 11:40:24 +08:00
condition . add ( compBrowserItem ) ;
2022-06-02 10:53:43 +08:00
condition . add ( isCheckItem ) ;
2022-09-09 14:41:04 +08:00
condition . add ( copySubDeptItem ) ;
condition . add ( copySubJob ) ;
2022-06-02 10:53:43 +08:00
addGroups . add ( new SearchConditionGroup ( " " , true , condition ) ) ;
return addGroups ;
}
2022-06-02 11:40:24 +08:00
/ * *
* 复制岗位到指定部门
*
* @param copyParam
* @return
* /
@Override
public int copyDepartment ( DeptCopyParam copyParam ) {
2022-09-09 14:41:04 +08:00
// 批量复制,后续优化
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-06-02 11:40:24 +08:00
OrganizationAssert . notBlank ( copyParam . getCompany ( ) , " 请指定需要复制的公司/分部 " ) ;
int insertCount = 0 ;
2022-09-09 14:41:04 +08:00
// 需复制的部门
2022-06-02 11:40:24 +08:00
List < Long > idList = Arrays . stream ( copyParam . getIds ( ) . split ( " , " ) ) . map ( Long : : parseLong ) . collect ( Collectors . toList ( ) ) ;
2022-08-29 15:39:35 +08:00
Integer maxShowOrder = getDepartmentMapper ( ) . getMaxShowOrder ( ) ;
maxShowOrder = null = = maxShowOrder ? 0 : maxShowOrder ;
2022-09-09 14:41:04 +08:00
for ( Long departmentId : idList ) {
// 复制当前部门
recursionCopyDept ( departmentId , null , Long . parseLong ( copyParam . getCompany ( ) ) , maxShowOrder , copyParam . getCopyJob ( ) , copyParam . getCopySubDept ( ) , copyParam . getCopySubJob ( ) ) ;
2022-06-02 11:40:24 +08:00
}
return insertCount ;
}
2022-09-09 14:41:04 +08:00
private void recursionCopyDept ( Long originalDeptId , Long parentDepartmentId , Long companyId , Integer maxShowOrder , String copyJob , String copySubDept , String copySubJob ) {
// 源部门
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( originalDeptId ) ;
long timeMillis = System . currentTimeMillis ( ) ;
deptById . setDeptName ( deptById . getDeptName ( ) + " _ " + timeMillis ) ;
deptById . setDeptNameShort ( deptById . getDeptNameShort ( ) + " _ " + timeMillis ) ;
// 处理自动编号
deptById . setDeptNo ( CodeRuleUtil . generateCode ( RuleCodeType . DEPARTMENT , deptById . getDeptNo ( ) , timeMillis ) ) ;
// 设置上级分部
deptById . setParentComp ( EcHrmRelationUtil . getJclCompanyId ( Util . null2String ( companyId ) ) . getId ( ) ) ;
deptById . setEcCompany ( companyId ) ;
deptById . setParentDept ( parentDepartmentId ) ;
if ( null ! = parentDepartmentId ) {
deptById . setEcDepartment ( Long . parseLong ( EcHrmRelationUtil . getEcDepartmentId ( Util . null2String ( parentDepartmentId ) ) ) ) ;
}
// 显示顺序字段
deptById . setShowOrder ( + + maxShowOrder ) ;
deptById . setCreator ( ( long ) user . getUID ( ) ) ;
deptById . setCreateTime ( new Date ( ) ) ;
2022-09-29 15:57:00 +08:00
deptById . setDeptPrincipal ( null ) ;
2022-09-09 14:41:04 +08:00
// 新增EC表部门
Map < String , Object > syncMap = addEcDepartment ( deptById ) ;
String ecDepartmentID = Util . null2String ( syncMap . get ( " id " ) ) ;
OrganizationAssert . isTrue ( StringUtils . isNotBlank ( ecDepartmentID ) , syncMap . get ( " message " ) . toString ( ) ) ;
// 查询UUID
RecordInfo recordInfo = getSystemDataMapper ( ) . getHrmObjectByID ( HRM_DEPARTMENT , ecDepartmentID ) ;
deptById . setUuid ( recordInfo . getUuid ( ) ) ;
getDepartmentMapper ( ) . insertIgnoreNull ( deptById ) ;
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new DepartmentTriggerRunnable ( deptById . getId ( ) ) . run ( ) ;
2022-09-09 14:41:04 +08:00
// 复制当前部门岗位信息
if ( " 1 " . equals ( copyJob ) ) {
List < JobPO > jobPOS = MapperProxyFactory . getProxy ( JobMapper . class ) . listJobsByDepartmentId ( originalDeptId ) ;
jobPOS = jobPOS . stream ( ) . filter ( item - > null = = item . getParentJob ( ) | | 0 = = item . getParentJob ( ) ) . collect ( Collectors . toList ( ) ) ;
Integer maxJobOrder = MapperProxyFactory . getProxy ( JobMapper . class ) . getMaxShowOrder ( ) ;
if ( maxJobOrder = = null ) {
maxJobOrder = 0 ;
}
recursionCopyJob ( jobPOS , companyId , deptById . getId ( ) , null , maxJobOrder , timeMillis ) ;
}
// 是否复制子部门信息
if ( " 1 " . equals ( copySubDept ) ) {
// 查询当前部门的子部门
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( originalDeptId ) ;
for ( DepartmentPO departmentPO : deptListByPId ) {
// 复制子部门信息、子部门岗位信息
recursionCopyDept ( departmentPO . getId ( ) , deptById . getId ( ) , companyId , maxShowOrder , copySubJob , copySubDept , copySubJob ) ;
}
}
}
2022-06-02 15:43:19 +08:00
@Override
public List < SearchConditionGroup > getMergeForm ( Long id ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
2022-09-05 17:25:11 +08:00
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , " 合并到部门 " , " 4 " , " department " , " " ) ;
2022-06-02 15:43:19 +08:00
deptBrowserItem . setRules ( " required|string " ) ;
SearchConditionItem mergeNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , " 合并后名称 " , " mergeName " ) ;
mergeNameItem . setRules ( " required|string " ) ;
condition . add ( deptBrowserItem ) ;
condition . add ( mergeNameItem ) ;
addGroups . add ( new SearchConditionGroup ( " " , true , condition ) ) ;
return addGroups ;
}
@Override
public int mergeDepartment ( DepartmentMergeParam mergeParam ) {
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-09-08 15:36:47 +08:00
// 被合并部门
2022-09-05 17:25:11 +08:00
Long ecParamDepartment = mergeParam . getDepartment ( ) ;
2022-09-09 14:41:04 +08:00
DepartmentPO targetDepartment = EcHrmRelationUtil . getJclDepartmentId ( Util . null2String ( ecParamDepartment ) ) ;
2022-10-19 15:38:47 +08:00
// map表中合并部门parentID
Long oldParamDepartment = mergeParam . getId ( ) ;
DepartmentPO oldDepartment = EcHrmRelationUtil . getJclDepartmentId ( Util . null2String ( oldParamDepartment ) ) ;
2022-10-20 17:30:34 +08:00
Integer oldFParentId = null ;
2022-10-24 15:57:08 +08:00
if ( null ! = oldDepartment ) {
java . sql . Date currentDate = new java . sql . Date ( OrganizationDateUtil . stringToDate ( OrganizationDateUtil . getFormatLocalDate ( new Date ( ) ) ) . getTime ( ) ) ;
2022-10-19 15:38:47 +08:00
JclOrgMap jclOrgMap = MapperProxyFactory . getProxy ( JclOrgMapper . class ) . getJclOrgMapByObjID ( currentDate , ModuleTypeEnum . departmentfielddefined . getValue ( ) . toString ( ) , oldDepartment . getId ( ) . toString ( ) ) ;
2022-10-24 15:57:08 +08:00
if ( null ! = jclOrgMap ) {
2022-10-20 17:30:34 +08:00
oldFParentId = jclOrgMap . getFParentId ( ) ;
2022-10-19 15:38:47 +08:00
}
}
2022-09-08 15:36:47 +08:00
// 断言判断
OrganizationAssert . isFalse ( null = = targetDepartment , " 被合并部门数据有误,暂时无法合并 " ) ;
OrganizationAssert . isFalse ( mergeParam . getId ( ) . equals ( targetDepartment . getId ( ) ) , " 所选部门与待合并部门一致,无需操作 " ) ;
2022-06-06 16:19:35 +08:00
OrganizationAssert . notNull ( mergeParam . getDepartment ( ) , " 请选择需要合并的部门 " ) ;
OrganizationAssert . notBlank ( mergeParam . getMergeName ( ) , " 请输入合并后的名称 " ) ;
2022-06-24 18:26:15 +08:00
2022-09-08 15:36:47 +08:00
// 不可选择合并的数据,本身及子部门
2022-08-22 15:04:38 +08:00
Set < Long > disableIds = new HashSet < > ( ) ;
2022-09-08 15:36:47 +08:00
// 添加选择部门本身
2022-08-22 15:04:38 +08:00
disableIds . add ( mergeParam . getId ( ) ) ;
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( mergeParam . getId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
OrganizationAssert . isFalse ( disableIds . contains ( targetDepartment . getId ( ) ) , " 请勿选择当前部门本身及其子部门 " ) ;
2022-09-08 15:36:47 +08:00
// 查询该部门下一级部门
List < DepartmentPO > firstChildDeptList = getDepartmentMapper ( ) . getDeptListByPId ( mergeParam . getId ( ) ) ;
// 更新所属部门、所属分部
for ( DepartmentPO departmentPO : firstChildDeptList ) {
departmentPO . setParentDept ( targetDepartment . getId ( ) ) ;
departmentPO . setEcDepartment ( ecParamDepartment ) ;
departmentPO . setParentComp ( targetDepartment . getParentComp ( ) ) ;
departmentPO . setEcCompany ( targetDepartment . getEcCompany ( ) ) ;
updateEcDepartment ( departmentPO ) ;
getDepartmentMapper ( ) . updateBaseDept ( departmentPO ) ;
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new DepartmentTriggerRunnable ( departmentPO . getId ( ) ) . run ( ) ;
2022-09-08 15:36:47 +08:00
}
// 查询该部门一级岗位、更新岗位所属分部、所属部门
2022-09-08 17:54:46 +08:00
List < JobPO > firstChildJobList = getJobMapper ( ) . listJobsByDepartmentId ( mergeParam . getId ( ) ) ;
2022-09-09 14:41:04 +08:00
firstChildJobList = firstChildJobList . stream ( ) . filter ( item - > null = = item . getParentJob ( ) | | 0 = = item . getParentJob ( ) ) . collect ( Collectors . toList ( ) ) ;
2022-09-08 15:36:47 +08:00
// 批量更新部门、所属分部
RecordSet rs = new RecordSet ( ) ;
String targetEcDeptId = EcHrmRelationUtil . getEcDepartmentId ( targetDepartment . getId ( ) . toString ( ) ) ;
String mergeEcDeptId = EcHrmRelationUtil . getEcDepartmentId ( mergeParam . getId ( ) . toString ( ) ) ;
rs . executeUpdate ( " update jcl_org_job set parent_comp =?,ec_company =?,parent_dept =?,ec_department =? where parent_dept =? " , targetDepartment . getParentComp ( ) , targetDepartment . getEcCompany ( ) , targetDepartment . getId ( ) , targetEcDeptId , mergeParam . getId ( ) ) ;
2022-09-08 17:54:46 +08:00
// 更新岗位组织架构图
for ( JobPO jobPO : firstChildJobList ) {
// 刷新组织架构图
2022-10-26 20:12:14 +08:00
new JobTriggerRunnable ( jobPO . getId ( ) ) . run ( ) ;
2022-09-08 17:54:46 +08:00
}
2022-09-08 15:36:47 +08:00
// 更新当前部门下的人员
2022-10-21 15:57:55 +08:00
List < Long > hrmResourceIds = getSystemDataMapper ( ) . getHrmResourceIdsByDept ( mergeParam . getId ( ) . toString ( ) ) ;
2022-09-08 15:36:47 +08:00
rs . executeUpdate ( " update hrmresource set SUBCOMPANYID1 =?,DEPARTMENTID =? where DEPARTMENTID =? " , targetDepartment . getEcCompany ( ) , targetEcDeptId , mergeEcDeptId ) ;
2022-10-21 17:44:53 +08:00
new RecordSet ( ) . executeUpdate ( " update jcl_org_hrmresource set company_id =? ,ec_company = ? ,department_id = ?, ec_department = ?where department_id =? " , targetDepartment . getParentComp ( ) , targetDepartment . getEcCompany ( ) , targetDepartment . getId ( ) , targetEcDeptId , mergeParam . getId ( ) ) ;
2022-09-08 15:36:47 +08:00
// 更新人员组织架构图
for ( Long hrmResourceId : hrmResourceIds ) {
2022-10-26 20:12:14 +08:00
new HrmResourceTriggerRunnable ( hrmResourceId ) . run ( ) ;
2022-09-08 15:36:47 +08:00
}
// 更新子部门下岗位的所属分部
for ( DepartmentPO departmentPO : firstChildDeptList ) {
List < DepartmentPO > deptList = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
forbiddenChildTag ( targetDepartment . getParentComp ( ) , Util . null2String ( targetDepartment . getEcCompany ( ) ) , deptList ) ;
}
// 原部门删除
2022-09-08 17:54:46 +08:00
DepartmentPO mergeDepartment = getDepartmentMapper ( ) . getDeptById ( mergeParam . getId ( ) ) ;
2022-09-08 15:36:47 +08:00
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " id " , mergeParam . getId ( ) ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
// 删除拓展表、明细表
MapperProxyFactory . getProxy ( ExtMapper . class ) . deleteByID ( " jcl_org_deptext " , mergeParam . getId ( ) ) ;
2022-11-14 19:13:35 +08:00
MapperProxyFactory . getProxy ( ExtDTMapper . class ) . deleteByMainID ( " jcl_org_deptext_dt1 " , mergeParam . getId ( ) , null ) ;
2022-09-08 15:36:47 +08:00
getDepartmentMapper ( ) . deleteByIds ( DeleteParam . builder ( ) . ids ( mergeParam . getId ( ) . toString ( ) ) . build ( ) . getIds ( ) ) ;
2022-08-31 14:24:00 +08:00
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new DepartmentTriggerRunnable ( mergeDepartment ) . run ( ) ;
2022-09-08 15:36:47 +08:00
// 更新部门合并后名称
targetDepartment . setDeptName ( mergeParam . getMergeName ( ) ) ;
targetDepartment . setDeptNameShort ( mergeParam . getMergeName ( ) ) ;
updateEcDepartment ( targetDepartment ) ;
getDepartmentMapper ( ) . updateBaseDept ( targetDepartment ) ;
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new DepartmentTriggerRunnable ( oldFParentId , targetDepartment . getId ( ) ) . run ( ) ;
2022-09-08 15:36:47 +08:00
return 0 ;
2022-06-02 15:43:19 +08:00
}
@Override
public List < SearchConditionGroup > getMoveForm ( ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
2022-09-05 17:25:11 +08:00
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , " 选择分部 " , " 164 " , " company " , " " ) ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , " 选择部门 " , " 4 " , " department " , " " ) ;
2022-06-02 15:43:19 +08:00
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
2022-06-23 09:14:19 +08:00
SearchConditionOption compOption = new SearchConditionOption ( " 0 " , " 分部 " ) ;
2022-06-02 15:43:19 +08:00
SearchConditionOption deptOption = new SearchConditionOption ( " 1 " , " 部门 " ) ;
selectOptions . add ( compOption ) ;
selectOptions . add ( deptOption ) ;
SearchConditionItem moveTypeItem = OrganizationFormItemUtil . selectItem ( user , selectOptions , 2 , 16 , 6 , false , " 转移到 " , " moveType " ) ;
moveTypeItem . setDetailtype ( 3 ) ;
2022-06-06 19:19:28 +08:00
moveTypeItem . setValue ( " 0 " ) ;
2022-06-02 15:43:19 +08:00
condition . add ( moveTypeItem ) ;
condition . add ( compBrowserItem ) ;
condition . add ( deptBrowserItem ) ;
addGroups . add ( new SearchConditionGroup ( " " , true , condition ) ) ;
return addGroups ;
}
@Override
public int moveDepartment ( DepartmentMoveParam moveParam ) {
2022-06-07 12:02:36 +08:00
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
2022-06-02 15:43:19 +08:00
OrganizationAssert . notBlank ( moveParam . getMoveType ( ) , " 请选择转移类型 " ) ;
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( moveParam . getId ( ) ) ;
// 0: 公司/分部 1: 部门
if ( " 0 " . equals ( moveParam . getMoveType ( ) ) ) {
Long company = moveParam . getCompany ( ) ;
2022-06-23 09:14:19 +08:00
OrganizationAssert . notNull ( company , " 请选择要转移到的分部 " ) ;
2022-09-05 17:25:11 +08:00
deptById . setEcCompany ( company ) ;
2022-09-09 14:41:04 +08:00
deptById . setParentComp ( Objects . requireNonNull ( EcHrmRelationUtil . getJclCompanyId ( Util . null2String ( company ) ) ) . getId ( ) ) ;
2022-06-02 15:43:19 +08:00
deptById . setParentDept ( null ) ;
2022-09-20 10:25:13 +08:00
deptById . setEcDepartment ( null ) ;
2022-10-20 17:30:34 +08:00
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new DepartmentTriggerRunnable ( company . toString ( ) , deptById ) . run ( ) ;
2022-06-02 15:43:19 +08:00
} else if ( " 1 " . equals ( moveParam . getMoveType ( ) ) ) {
Long department = moveParam . getDepartment ( ) ;
2022-09-09 14:41:04 +08:00
Long departmentId = Objects . requireNonNull ( EcHrmRelationUtil . getJclDepartmentId ( Util . null2String ( department ) ) ) . getId ( ) ;
2022-09-05 17:25:11 +08:00
OrganizationAssert . notNull ( departmentId , " 请选择要转移到的部门 " ) ;
2022-08-17 09:28:04 +08:00
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( moveParam . getId ( ) ) ;
Set < Long > disableIds = new HashSet < > ( ) ;
disableIds . add ( moveParam . getId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
2022-09-05 17:25:11 +08:00
OrganizationAssert . isFalse ( disableIds . contains ( departmentId ) , " 请勿选择当前部门本身及其子部门 " ) ;
deptById . setParentDept ( departmentId ) ;
deptById . setEcDepartment ( department ) ;
DepartmentPO parentDepartment = getDepartmentMapper ( ) . getDeptById ( departmentId ) ;
2022-07-13 10:55:44 +08:00
deptById . setParentComp ( parentDepartment . getParentComp ( ) ) ;
2022-10-14 11:33:24 +08:00
deptById . setEcCompany ( parentDepartment . getEcCompany ( ) ) ;
2022-10-20 17:30:34 +08:00
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new DepartmentTriggerRunnable ( Integer . toString ( 100000000 + department . intValue ( ) ) , deptById ) . run ( ) ;
2022-06-02 15:43:19 +08:00
}
2022-07-13 10:55:44 +08:00
// 更新EC部门
updateEcDepartment ( deptById ) ;
2022-08-30 10:46:42 +08:00
int updateBaseDept = getDepartmentMapper ( ) . updateBaseDept ( deptById ) ;
2022-10-20 17:30:34 +08:00
2022-08-30 10:46:42 +08:00
// 刷新岗位分部
refreshJobComp ( deptById . getId ( ) , deptById . getParentComp ( ) ) ;
List < DepartmentPO > deptList = getDepartmentMapper ( ) . getDeptListByPId ( deptById . getId ( ) ) ;
2022-09-08 15:36:47 +08:00
String ecCompanyId = EcHrmRelationUtil . getEcCompanyId ( Util . null2String ( deptById . getParentComp ( ) ) ) ;
2022-09-09 15:29:21 +08:00
// 更新当前部门下的人员
List < Long > hrmResourceIds = getSystemDataMapper ( ) . getHrmResourceIdsByDept ( deptById . getId ( ) . toString ( ) ) ;
String ecDepartmentId = EcHrmRelationUtil . getEcDepartmentId ( deptById . getId ( ) . toString ( ) ) ;
2022-10-21 15:57:55 +08:00
new RecordSet ( ) . executeUpdate ( " update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ? " , ecCompanyId , ecDepartmentId ) ;
new RecordSet ( ) . executeUpdate ( " update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =? " , deptById . getParentComp ( ) , ecCompanyId , deptById . getId ( ) ) ;
2022-09-09 15:29:21 +08:00
// 更新人员组织架构图
for ( Long hrmResourceId : hrmResourceIds ) {
2022-10-26 20:12:14 +08:00
new HrmResourceTriggerRunnable ( hrmResourceId ) . run ( ) ;
2022-09-09 15:29:21 +08:00
}
2022-09-08 15:36:47 +08:00
forbiddenChildTag ( deptById . getParentComp ( ) , ecCompanyId , deptList ) ;
2022-08-30 10:46:42 +08:00
// 递归更新下级部门、岗位
return updateBaseDept ;
2022-06-02 15:43:19 +08:00
}
/ * *
* 获取所有子部门id
*
2022-06-24 18:26:15 +08:00
* @param parentComp
2022-06-02 15:43:19 +08:00
* @param deptList
* /
2022-09-08 15:36:47 +08:00
void forbiddenChildTag ( Long parentComp , String ecCompanyId , List < DepartmentPO > deptList ) {
2022-06-02 15:43:19 +08:00
if ( CollectionUtils . isNotEmpty ( deptList ) ) {
for ( DepartmentPO departmentPO : deptList ) {
2022-06-24 18:26:15 +08:00
departmentPO . setParentComp ( parentComp ) ;
2022-09-08 15:36:47 +08:00
departmentPO . setEcCompany ( Long . parseLong ( ecCompanyId ) ) ;
2022-07-13 10:55:44 +08:00
// 更新EC表部门
updateEcDepartment ( departmentPO ) ;
2022-08-26 15:36:06 +08:00
getDepartmentMapper ( ) . updateBaseDept ( departmentPO ) ;
2022-08-31 14:24:00 +08:00
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new DepartmentTriggerRunnable ( departmentPO . getId ( ) ) . run ( ) ;
2022-08-30 10:46:42 +08:00
// 刷新岗位所属分部
refreshJobComp ( departmentPO . getId ( ) , parentComp ) ;
2022-09-08 15:36:47 +08:00
// 更新当前部门下的人员
List < Long > hrmResourceIds = getSystemDataMapper ( ) . getHrmResourceIdsByDept ( departmentPO . getId ( ) . toString ( ) ) ;
String ecDepartmentId = EcHrmRelationUtil . getEcDepartmentId ( departmentPO . getId ( ) . toString ( ) ) ;
2022-10-21 15:57:55 +08:00
new RecordSet ( ) . executeUpdate ( " update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ? " , ecCompanyId , ecDepartmentId ) ;
new RecordSet ( ) . executeUpdate ( " update jcl_org_hrmresource set company_id =? ,ec_company = ? where department_id =? " , parentComp , ecCompanyId , departmentPO . getId ( ) ) ;
2022-09-08 15:36:47 +08:00
// 更新人员组织架构图
for ( Long hrmResourceId : hrmResourceIds ) {
2022-10-26 20:12:14 +08:00
new HrmResourceTriggerRunnable ( hrmResourceId ) . run ( ) ;
2022-09-08 15:36:47 +08:00
}
2022-06-02 15:43:19 +08:00
List < DepartmentPO > childList = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
2022-09-08 15:36:47 +08:00
forbiddenChildTag ( parentComp , ecCompanyId , childList ) ;
2022-06-02 15:43:19 +08:00
}
}
}
2022-05-23 17:46:37 +08:00
/ * *
2022-05-27 18:05:15 +08:00
* 是否为搜索查询
2022-05-23 17:46:37 +08:00
*
* @param departmentPO
* @return
* /
2022-05-27 18:05:15 +08:00
private boolean isFilter ( DepartmentPO departmentPO ) {
2022-09-05 17:25:11 +08:00
return ! ( StringUtil . isEmpty ( departmentPO . getDeptNo ( ) )
& & StringUtil . isEmpty ( departmentPO . getDeptName ( ) )
& & StringUtil . isEmpty ( departmentPO . getDeptNameShort ( ) )
& & null = = departmentPO . getEcCompany ( )
& & null = = departmentPO . getEcDepartment ( )
2022-09-06 10:33:46 +08:00
& & null = = departmentPO . getParentComp ( )
& & null = = departmentPO . getParentDept ( )
2022-09-05 17:25:11 +08:00
& & null = = departmentPO . getDeptPrincipal ( )
& & null = = departmentPO . getShowOrder ( )
& & null = = departmentPO . getForbiddenTag ( ) ) ;
2022-05-27 18:05:15 +08:00
}
2022-05-23 17:46:37 +08:00
2022-06-02 09:58:16 +08:00
/ * *
* 根据keyword查询数据
*
* @param id
* @param keyword
* @return
* /
2022-06-06 14:41:46 +08:00
private List < SearchTree > getFilterCompany ( String id , String keyword ) {
2022-06-02 09:58:16 +08:00
// 查询部门信息
Long parentCompId = StringUtil . isEmpty ( id ) ? null : Long . parseLong ( id ) ;
2022-09-06 15:19:16 +08:00
CompPO compBuild = CompPO . builder ( ) . compName ( keyword ) . parentCompany ( parentCompId ) . forbiddenTag ( 0 ) . build ( ) ;
2022-10-28 17:43:46 +08:00
List < CompPO > allCompanys = getCompMapper ( ) . list ( " show_order " ) ;
new DetachUtil ( user . getUID ( ) ) . filterCompanyList ( allCompanys ) ;
2022-06-23 18:49:47 +08:00
List < CompPO > filterComps = getCompMapper ( ) . listByFilter ( compBuild , " show_order " ) ;
2022-10-28 17:43:46 +08:00
new DetachUtil ( user . getUID ( ) ) . filterCompanyList ( filterComps ) ;
Map < Long , CompPO > allMaps = allCompanys . stream ( ) . collect ( Collectors . toMap ( CompPO : : getId , item - > item , ( k1 , k2 ) - > k1 ) ) ;
2022-06-02 09:58:16 +08:00
Set < CompPO > builderComps = new HashSet < > ( ) ;
for ( CompPO compPO : filterComps ) {
2022-10-28 17:43:46 +08:00
buildParentComps ( compPO , builderComps , allMaps ) ;
2022-06-02 09:58:16 +08:00
}
2022-06-06 14:41:46 +08:00
return SearchTreeUtil . builderTreeMode ( CompBO . buildSetToSearchTree ( builderComps ) ) ;
2022-06-02 09:58:16 +08:00
}
/ * *
* 添加查询元素的父级元素
*
* @param compPO
* @param builderComps
* /
2022-10-28 17:43:46 +08:00
private void buildParentComps ( CompPO compPO , Set < CompPO > builderComps , Map < Long , CompPO > allMaps ) {
2022-06-02 09:58:16 +08:00
builderComps . add ( compPO ) ;
2022-10-28 17:43:46 +08:00
CompPO parentComp = allMaps . get ( compPO . getParentCompany ( ) ) ;
2022-09-06 15:19:16 +08:00
if ( null ! = parentComp & & 0 = = parentComp . getForbiddenTag ( ) ) {
2022-10-28 17:43:46 +08:00
buildParentComps ( parentComp , builderComps , allMaps ) ;
2022-06-02 09:58:16 +08:00
}
}
2022-06-23 09:14:19 +08:00
/ * *
* 判断编号是否重复
*
* @return
* /
2022-07-27 10:48:43 +08:00
public static String repeatDetermine ( String deptNo ) {
2022-06-23 13:43:52 +08:00
CodeRulePO codeRuleByType = MapperProxyFactory . getProxy ( CodeRuleMapper . class ) . getCodeRuleByType ( RuleCodeType . DEPARTMENT . getValue ( ) ) ;
2022-06-23 09:14:19 +08:00
if ( StringUtils . isNotBlank ( deptNo ) ) {
deptNo = CodeRuleUtil . generateCode ( RuleCodeType . DEPARTMENT , deptNo ) ;
List < DepartmentPO > list = getDepartmentMapper ( ) . listByNo ( Util . null2String ( deptNo ) ) ;
OrganizationAssert . isEmpty ( list , " 编号不允许重复 " ) ;
} else {
if ( null ! = codeRuleByType & & " 1 " . equals ( codeRuleByType . getSerialEnable ( ) ) ) {
deptNo = autoCreateCompanyNo ( ) ;
}
}
return deptNo ;
}
/ * *
* 自动编号处理
*
* @return
* /
2022-07-27 10:48:43 +08:00
private static String autoCreateCompanyNo ( ) {
2022-06-23 09:14:19 +08:00
String generateCode = CodeRuleUtil . generateCode ( RuleCodeType . DEPARTMENT , " " ) ;
List < DepartmentPO > list = getDepartmentMapper ( ) . listByNo ( Util . null2String ( generateCode ) ) ;
if ( CollectionUtils . isNotEmpty ( list ) ) {
generateCode = autoCreateCompanyNo ( ) ;
}
return generateCode ;
}
2022-06-24 14:40:49 +08:00
/ * *
* 递归复制岗位信息
*
* @param jobPOS
* @param parentCompId
* @param parentDeptId
* @param orderNum
* /
2022-09-09 14:41:04 +08:00
private void recursionCopyJob ( List < JobPO > jobPOS , Long parentCompId , Long parentDeptId , Long currentParentJobId , int orderNum , long timeMillis ) {
2022-06-24 14:40:49 +08:00
for ( JobPO jobPO : jobPOS ) {
orderNum + + ;
2022-09-09 14:41:04 +08:00
// 查询源岗位的下级岗位
List < JobPO > jobsByPid = MapperProxyFactory . getProxy ( JobMapper . class ) . getJobsByPid ( jobPO . getId ( ) ) ;
2022-06-24 14:40:49 +08:00
// 处理自动编号
2022-09-05 18:33:20 +08:00
jobPO . setJobNo ( CodeRuleUtil . generateCode ( RuleCodeType . JOBTITLES , jobPO . getJobNo ( ) , timeMillis ) ) ;
2022-09-15 10:41:04 +08:00
// 所属部门赋值
jobPO . setParentDept ( parentDeptId ) ;
String ecDepartmentId = EcHrmRelationUtil . getEcDepartmentId ( parentDeptId . toString ( ) ) ;
if ( StringUtils . isNotBlank ( ecDepartmentId ) ) {
jobPO . setEcDepartment ( Long . parseLong ( ecDepartmentId ) ) ;
2022-09-09 14:41:04 +08:00
}
2022-09-15 10:41:04 +08:00
// 所属分部赋值
2022-09-09 14:41:04 +08:00
jobPO . setEcCompany ( parentCompId ) ;
CompPO jclCompanyId = EcHrmRelationUtil . getJclCompanyId ( Util . null2String ( parentCompId ) ) ;
if ( null ! = jclCompanyId ) {
2022-09-09 15:29:21 +08:00
jobPO . setParentComp ( jclCompanyId . getId ( ) ) ;
2022-09-09 14:41:04 +08:00
}
// 指定上级岗位
jobPO . setParentJob ( currentParentJobId ) ;
jobPO . setCreator ( ( long ) user . getUID ( ) ) ;
2022-06-24 14:40:49 +08:00
jobPO . setCreateTime ( new Date ( ) ) ;
jobPO . setShowOrder ( orderNum ) ;
MapperProxyFactory . getProxy ( JobMapper . class ) . insertIgnoreNull ( jobPO ) ;
2022-08-31 14:24:00 +08:00
// 更新组织架构图
2022-10-26 20:12:14 +08:00
new JobTriggerRunnable ( jobPO . getId ( ) ) . run ( ) ;
2022-06-24 14:40:49 +08:00
// 处理子级元素
2022-09-09 14:41:04 +08:00
2022-06-24 14:40:49 +08:00
if ( CollectionUtils . isNotEmpty ( jobsByPid ) ) {
2022-09-09 14:41:04 +08:00
recursionCopyJob ( jobsByPid , parentCompId , parentDeptId , jobPO . getId ( ) , orderNum , timeMillis ) ;
2022-06-24 14:40:49 +08:00
}
}
}
2022-07-13 10:55:44 +08:00
/ * *
* 更新EC表部门
*
* @param departmentPO
* /
private void updateEcDepartment ( DepartmentPO departmentPO ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " dept_name_short " , departmentPO . getDeptNameShort ( ) ) ;
map . put ( " dept_name " , departmentPO . getDeptName ( ) ) ;
map . put ( " parent_comp " , departmentPO . getParentComp ( ) ) ;
map . put ( " parent_dept " , departmentPO . getParentDept ( ) ) ;
map . put ( " show_order " , departmentPO . getShowOrder ( ) ) ;
map . put ( " dept_no " , departmentPO . getDeptNo ( ) ) ;
map . put ( " dept_principal " , departmentPO . getDeptPrincipal ( ) ) ;
map . put ( " id " , departmentPO . getId ( ) ) ;
2022-08-26 15:36:06 +08:00
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . UPDATE , map ) . sync ( ) ;
2022-07-13 10:55:44 +08:00
}
2022-08-17 09:28:04 +08:00
/ * *
* 新增EC表部门
*
* @param departmentPO
2022-08-26 15:36:06 +08:00
* @return
2022-08-17 09:28:04 +08:00
* /
2022-08-26 15:36:06 +08:00
private Map < String , Object > addEcDepartment ( DepartmentPO departmentPO ) {
2022-08-17 09:28:04 +08:00
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " dept_name_short " , departmentPO . getDeptNameShort ( ) ) ;
map . put ( " dept_name " , departmentPO . getDeptName ( ) ) ;
map . put ( " parent_comp " , departmentPO . getParentComp ( ) ) ;
map . put ( " parent_dept " , departmentPO . getParentDept ( ) ) ;
map . put ( " show_order " , departmentPO . getShowOrder ( ) ) ;
map . put ( " dept_no " , departmentPO . getDeptNo ( ) ) ;
map . put ( " dept_principal " , departmentPO . getDeptPrincipal ( ) ) ;
map . put ( " id " , departmentPO . getId ( ) ) ;
2022-08-26 15:36:06 +08:00
return new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . ADD , map ) . sync ( ) ;
2022-08-17 09:28:04 +08:00
}
2022-07-13 10:55:44 +08:00
/ * *
* 封存EC表部门
*
* @param id
* /
private void cancelEcDepartment ( Long id ) {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( " id " , id ) ;
2022-08-26 15:36:06 +08:00
map . put ( " forbiddenTag " , 1 ) ;
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . CANCELED , map ) . sync ( ) ;
2022-07-13 10:55:44 +08:00
}
2022-08-17 09:28:04 +08:00
private void addDisableIds ( Set < Long > disableIds , List < DepartmentPO > deptListByPId ) {
for ( DepartmentPO departmentPO : deptListByPId ) {
disableIds . add ( departmentPO . getId ( ) ) ;
List < DepartmentPO > childDeptPOS = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
addDisableIds ( disableIds , childDeptPOS ) ;
}
}
2022-08-30 10:46:42 +08:00
/ * *
* 更新岗位的所属分部
*
* @param parentDepartment
* @param parentComp
* /
private void refreshJobComp ( Long parentDepartment , Long parentComp ) {
List < JobPO > jobPOS = getJobMapper ( ) . listJobsByDepartmentId ( parentDepartment ) ;
2022-09-09 14:41:04 +08:00
jobPOS = jobPOS . stream ( ) . filter ( item - > null = = item . getParentJob ( ) | | 0 = = item . getParentJob ( ) ) . collect ( Collectors . toList ( ) ) ;
2022-08-30 10:46:42 +08:00
if ( CollectionUtils . isNotEmpty ( jobPOS ) ) {
String ecCompanyId = EcHrmRelationUtil . getEcCompanyId ( parentComp . toString ( ) ) ;
getJobMapper ( ) . updateJobCompany ( jobPOS . stream ( ) . map ( JobPO : : getId ) . collect ( Collectors . toList ( ) ) , parentComp , ecCompanyId ) ;
2022-09-08 17:54:46 +08:00
for ( JobPO jobPO : jobPOS ) {
// 刷新组织架构图
2022-10-26 20:12:14 +08:00
new JobTriggerRunnable ( jobPO . getId ( ) ) . run ( ) ;
2022-09-08 17:54:46 +08:00
}
2022-08-30 10:46:42 +08:00
}
}
2022-05-20 15:00:03 +08:00
}