@ -219,6 +219,26 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
}
params . put ( "show_order" , maxShowOrder + 1 ) ;
}
// 上级分部
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 ( ) ) ;
params . put ( "ec_company" , EcHrmRelationUtil . getEcCompanyId ( jclDepartmentId . getParentComp ( ) + "" ) ) ;
}
}
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 ( ) ) ;
@ -254,10 +274,25 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
deptNo = repeatDetermine ( deptNo ) ;
params . put ( "dept_no" , deptNo ) ;
}
// 根据部门,自动获取正确分部
DepartmentPO parentDept = getDepartmentMapper ( ) . getDeptById ( searchParam . getParentDept ( ) ) ;
if ( null ! = parentDept ) {
params . put ( "parent_comp" , parentDept . getParentComp ( ) ) ;
// 上级分部
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 ( ) ) ;
params . put ( "ec_company" , EcHrmRelationUtil . getEcCompanyId ( jclDepartmentId . getParentComp ( ) + "" ) ) ;
}
}
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . UPDATE , params ) . sync ( ) ;
// 更新主表数据
@ -267,6 +302,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
//更新明细表
getExtService ( user ) . updateExtDT ( user , EXTEND_TYPE , JCL_ORG_DEPTEXT_DT1 , params , searchParam . getId ( ) ) ;
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 ( ) ) ;
forbiddenChildTag ( parentComp , childList , false ) ;
return searchParam . getId ( ) ;
}
@ -299,9 +341,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 简称
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "简称" , "deptNameShort" ) ;
// 所属分部
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属分部" , "16 1", "parentComp" , "compBrowser ") ;
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属分部" , "16 4", "ecCompany" , " ") ;
// 上级部门
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "上级部门" , " 161", "parentDept" , "deptBrowser ") ;
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "上级部门" , " 4", "ecDepartment" , " ") ;
// 部门负责人
SearchConditionItem deptPrincipalBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "部门负责人" , "1" , "deptPrincipal" , "" ) ;
// 显示顺序
@ -405,7 +447,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
public List < SearchConditionGroup > getCopyForm ( ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , "复制到" , "16 1 ", "company" , " compBrowser ") ;
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , "复制到" , "16 4 ", "company" , " ") ;
compBrowserItem . setRules ( "required|string" ) ;
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
SearchConditionOption Option = new SearchConditionOption ( "1" , "" ) ;
@ -426,6 +468,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* /
@Override
public int copyDepartment ( DeptCopyParam copyParam ) {
// TODO 是否复制子部门信息,是否复制子部门岗位信息
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
OrganizationAssert . notBlank ( copyParam . getCompany ( ) , "请指定需要复制的公司/分部" ) ;
int insertCount = 0 ;
@ -434,11 +477,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
maxShowOrder = null = = maxShowOrder ? 0 : maxShowOrder ;
for ( int i = 0 ; i < idList . size ( ) ; i + + ) {
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( idList . get ( i ) ) ;
deptById . setDeptName ( deptById . getDeptName ( ) + "[复制]" ) ;
deptById . setDeptNameShort ( deptById . getDeptNameShort ( ) + "[复制]" ) ;
long timeMillis = System . currentTimeMillis ( ) ;
deptById . setDeptName ( deptById . getDeptName ( ) + "_" + timeMillis ) ;
deptById . setDeptNameShort ( deptById . getDeptNameShort ( ) ) ;
// 处理自动编号
deptById . setDeptNo ( CodeRuleUtil . generateCode ( RuleCodeType . DEPARTMENT , deptById . getDeptNo ( ) , false ) ) ;
deptById . setParentComp ( Long . parseLong ( copyParam . getCompany ( ) ) ) ;
deptById . setDeptNo ( CodeRuleUtil . generateCode ( RuleCodeType . DEPARTMENT , deptById . getDeptNo ( ) , timeMillis ) ) ;
deptById . setParentComp ( EcHrmRelationUtil . getJclCompanyId ( copyParam . getCompany ( ) ) . getId ( ) ) ;
deptById . setEcCompany ( Long . parseLong ( copyParam . getCompany ( ) ) ) ;
deptById . setParentDept ( null ) ;
// 显示顺序字段
deptById . setShowOrder ( maxShowOrder + i + 1 ) ;
@ -461,7 +506,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( maxJobOrder = = null ) {
maxJobOrder = 0 ;
}
recursionCopyJob ( ( long ) user . getUID ( ) , jobPOS , deptById . getParentComp ( ) , deptById . getId ( ) , maxJobOrder );
recursionCopyJob ( ( long ) user . getUID ( ) , jobPOS , deptById . getParentComp ( ) , deptById . getId ( ) , maxJobOrder , timeMillis );
}
}
return insertCount ;
@ -471,7 +516,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
public List < SearchConditionGroup > getMergeForm ( Long id ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , "合并到部门" , " 161 ", "department" , " deptBrowser ") ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , "合并到部门" , " 4 ", "department" , " ") ;
deptBrowserItem . setRules ( "required|string" ) ;
SearchConditionItem mergeNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , "合并后名称" , "mergeName" ) ;
mergeNameItem . setRules ( "required|string" ) ;
@ -487,13 +532,15 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override
public int mergeDepartment ( DepartmentMergeParam mergeParam ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
int updateCount = 0 ;
OrganizationAssert . isFalse ( mergeParam . getId ( ) . equals ( mergeParam . getDepartment ( ) ) , "所选部门与待合并部门一致,无需操作" ) ;
int updateCount ;
Long ecParamDepartment = mergeParam . getDepartment ( ) ;
DepartmentPO jclDepartmentId = EcHrmRelationUtil . getJclDepartmentId ( ecParamDepartment + "" ) ;
Long jclParamDepartment = jclDepartmentId . getId ( ) ;
OrganizationAssert . isFalse ( mergeParam . getId ( ) . equals ( jclParamDepartment ) , "所选部门与待合并部门一致,无需操作" ) ;
OrganizationAssert . notNull ( mergeParam . getDepartment ( ) , "请选择需要合并的部门" ) ;
OrganizationAssert . notBlank ( mergeParam . getMergeName ( ) , "请输入合并后的名称" ) ;
// 合并到的部门
DepartmentPO targetDepartment = getDepartmentMapper ( ) . getDeptById ( mergeParam . getDepartment ( ) ) ;
Long parentComp = targetDepartment . getParentComp ( ) ;
DepartmentPO targetDepartment = getDepartmentMapper ( ) . getDeptById ( jclParamDepartment ) ;
Set < Long > disableIds = new HashSet < > ( ) ;
disableIds . add ( mergeParam . getId ( ) ) ;
@ -507,8 +554,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
DepartmentPO mergeDepartment = getDepartmentMapper ( ) . getDeptById ( mergeParam . getId ( ) ) ;
mergeDepartment . setDeptName ( mergeParam . getMergeName ( ) ) ;
mergeDepartment . setDeptNameShort ( mergeParam . getMergeName ( ) ) ;
mergeDepartment . setParentDept ( mergeParam . getDepartment ( ) ) ;
mergeDepartment . setParentComp ( parentComp ) ;
mergeDepartment . setParentDept ( jclParamDepartment ) ;
mergeDepartment . setEcDepartment ( ecParamDepartment ) ;
mergeDepartment . setParentComp ( targetDepartment . getParentComp ( ) ) ;
mergeDepartment . setEcCompany ( targetDepartment . getEcCompany ( ) ) ;
// 禁用
mergeDepartment . setForbiddenTag ( 1 ) ;
// 更新EC表部门
@ -523,7 +573,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
refreshJobComp ( mergeDepartment . getId ( ) , mergeDepartment . getParentComp ( ) ) ;
// 合并后部门及子部门禁用
List < DepartmentPO > deptList = getDepartmentMapper ( ) . getDeptListByPId ( mergeParam . getId ( ) ) ;
forbiddenChildTag ( parentComp, deptList , true ) ;
forbiddenChildTag ( targetDe partment. getPar entComp( ) , deptList , true ) ;
return updateCount ;
}
@ -531,8 +581,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
public List < SearchConditionGroup > getMoveForm ( ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "选择分部" , "16 1 ", "company" , " compBrowser ") ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "选择部门" , " 161 ", "department" , " deptBrowser ") ;
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "选择分部" , "16 4 ", "company" , " ") ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "选择部门" , " 4 ", "department" , " ") ;
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
@ -560,20 +610,23 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( "0" . equals ( moveParam . getMoveType ( ) ) ) {
Long company = moveParam . getCompany ( ) ;
OrganizationAssert . notNull ( company , "请选择要转移到的分部" ) ;
deptById . setParentComp ( company ) ;
deptById . setEcCompany ( company ) ;
deptById . setParentComp ( Objects . requireNonNull ( EcHrmRelationUtil . getJclCompanyId ( company + "" ) ) . getId ( ) ) ;
deptById . setParentDept ( null ) ;
} else if ( "1" . equals ( moveParam . getMoveType ( ) ) ) {
Long department = moveParam . getDepartment ( ) ;
OrganizationAssert . notNull ( department , "请选择要转移到的部门" ) ;
Long departmentId = Objects . requireNonNull ( EcHrmRelationUtil . getJclDepartmentId ( department + "" ) ) . getId ( ) ;
OrganizationAssert . notNull ( departmentId , "请选择要转移到的部门" ) ;
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( moveParam . getId ( ) ) ;
Set < Long > disableIds = new HashSet < > ( ) ;
disableIds . add ( moveParam . getId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
OrganizationAssert . isFalse ( disableIds . contains ( department ) , "请勿选择当前部门本身及其子部门" ) ;
deptById . setParentDept ( department ) ;
DepartmentPO parentDepartment = getDepartmentMapper ( ) . getDeptById ( department ) ;
OrganizationAssert . isFalse ( disableIds . contains ( departmentId ) , "请勿选择当前部门本身及其子部门" ) ;
deptById . setParentDept ( departmentId ) ;
deptById . setEcDepartment ( department ) ;
DepartmentPO parentDepartment = getDepartmentMapper ( ) . getDeptById ( departmentId ) ;
deptById . setParentComp ( parentDepartment . getParentComp ( ) ) ;
}
// 更新EC部门
@ -599,6 +652,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( CollectionUtils . isNotEmpty ( deptList ) ) {
for ( DepartmentPO departmentPO : deptList ) {
departmentPO . setParentComp ( parentComp ) ;
String ecCompanyId = EcHrmRelationUtil . getEcCompanyId ( parentComp + "" ) ;
if ( StringUtils . isNotBlank ( ecCompanyId ) ) {
departmentPO . setEcCompany ( Long . parseLong ( ecCompanyId ) ) ;
}
if ( isForbidden ) {
departmentPO . setForbiddenTag ( 1 ) ;
// 封存EC表部门
@ -625,7 +682,16 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* @return
* /
private boolean isFilter ( DepartmentPO departmentPO ) {
return ! ( StringUtil . isEmpty ( departmentPO . getDeptNo ( ) ) & & StringUtil . isEmpty ( departmentPO . getDeptName ( ) ) & & StringUtil . isEmpty ( departmentPO . getDeptNameShort ( ) ) & & null = = departmentPO . getParentComp ( ) & & null = = departmentPO . getParentDept ( ) & & null = = departmentPO . getDeptPrincipal ( ) & & null = = departmentPO . getShowOrder ( ) & & null = = departmentPO . getForbiddenTag ( ) ) ;
return ! ( StringUtil . isEmpty ( departmentPO . getDeptNo ( ) )
& & StringUtil . isEmpty ( departmentPO . getDeptName ( ) )
& & StringUtil . isEmpty ( departmentPO . getDeptNameShort ( ) )
& & null = = departmentPO . getEcCompany ( )
& & null = = departmentPO . getEcDepartment ( )
& & null = = departmentPO . getParentComp ( )
& & null = = departmentPO . getParentDept ( )
& & null = = departmentPO . getDeptPrincipal ( )
& & null = = departmentPO . getShowOrder ( )
& & null = = departmentPO . getForbiddenTag ( ) ) ;
}
@ -709,11 +775,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
* @param parentDeptId
* @param orderNum
* /
private void recursionCopyJob ( Long creator , List < JobPO > jobPOS , Long parentCompId , Long parentDeptId , int orderNum ) {
private void recursionCopyJob ( Long creator , List < JobPO > jobPOS , Long parentCompId , Long parentDeptId , int orderNum , long timeMillis ) {
for ( JobPO jobPO : jobPOS ) {
orderNum + + ;
// 处理自动编号
jobPO . setJobNo ( CodeRuleUtil . generateCode ( RuleCodeType . JOBTITLES , jobPO . getJobNo ( ) , false ) ) ;
jobPO . setJobNo ( CodeRuleUtil . generateCode ( RuleCodeType . JOBTITLES , jobPO . getJobNo ( ) , timeMillis ) ) ;
jobPO . setParentDept ( parentDeptId ) ;
jobPO . setCreator ( creator ) ;
jobPO . setCreateTime ( new Date ( ) ) ;
@ -725,7 +791,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 处理子级元素
List < JobPO > jobsByPid = MapperProxyFactory . getProxy ( JobMapper . class ) . getJobsByPid ( jobPO . getId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( jobsByPid ) ) {
recursionCopyJob ( creator , jobsByPid , parentCompId , parentDeptId , orderNum );
recursionCopyJob ( creator , jobsByPid , parentCompId , parentDeptId , orderNum , timeMillis );
}
}
}