@ -13,7 +13,6 @@ import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.service.impl.OrganizationServiceImpl ;
import com.engine.organization.component.OrganizationWeaTable ;
import com.engine.organization.entity.TopTab ;
import com.engine.organization.entity.codesetting.po.CodeRulePO ;
import com.engine.organization.entity.company.bo.CompBO ;
import com.engine.organization.entity.company.po.CompPO ;
import com.engine.organization.entity.department.bo.DepartmentBO ;
@ -29,7 +28,6 @@ import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.enums.LogModuleNameEnum ;
import com.engine.organization.enums.OperateTypeEnum ;
import com.engine.organization.exception.OrganizationRunTimeException ;
import com.engine.organization.mapper.codesetting.CodeRuleMapper ;
import com.engine.organization.mapper.comp.CompMapper ;
import com.engine.organization.mapper.department.DepartmentMapper ;
import com.engine.organization.mapper.job.JobMapper ;
@ -75,10 +73,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
return MapperProxyFactory . getProxy ( DepartmentMapper . class ) ;
}
private static JobMapper getJobMapper ( ) {
return MapperProxyFactory . getProxy ( JobMapper . class ) ;
}
private CompMapper getCompMapper ( ) {
return MapperProxyFactory . getProxy ( CompMapper . class ) ;
}
@ -90,7 +84,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List < DepartmentPO > departmentPOS = MapperProxyFactory . getProxy ( DepartmentMapper . class ) . listAll ( "showOrder" ) ;
PageInfo < DepartmentPO > pageInfo = new PageInfo < > ( departmentPOS ) ;
List < SingleDeptTreeVO > singleDeptTreeVOS = DepartmentBO . buildSingleDeptTreeVOS ( departmentPOS , param . getParentComp ( ) ) ;
PageInfo < SingleDeptTreeVO > pageInfos = new PageInfo < > ( singleDeptTreeVOS, SingleDeptTreeVO . class ) ;
PageInfo < SingleDeptTreeVO > pageInfos = new PageInfo < > ( user, singleDeptTreeVOS, SingleDeptTreeVO . class ) ;
pageInfos . setTotal ( pageInfo . getTotal ( ) ) ;
pageInfos . setPageNum ( param . getCurrent ( ) ) ;
pageInfos . setPageSize ( param . getPageSize ( ) ) ;
@ -103,7 +97,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
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 ) ;
PageInfo < SingleJobTreeVO > pageInfos = new PageInfo < > ( user, singleDeptTreeVOS, SingleJobTreeVO . class ) ;
pageInfos . setTotal ( pageInfo . getTotal ( ) ) ;
pageInfos . setPageNum ( param . getCurrent ( ) ) ;
pageInfos . setPageSize ( param . getPageSize ( ) ) ;
@ -150,13 +144,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
compListDTOS = compListDTOS . stream ( ) . sorted ( Comparator . comparing ( DepartmentListDTO : : getShowOrder ) . reversed ( ) ) . collect ( Collectors . toList ( ) ) ;
}
List < DepartmentListDTO > subList = PageUtil . subList ( param . getCurrent ( ) , param . getPageSize ( ) , compListDTOS ) ;
pageInfos = new PageInfo < > ( DepartmentBO. buildDeptDTOShowNames ( subList ) , DepartmentListDTO . class ) ;
pageInfos = new PageInfo < > ( user, DepartmentBO. buildDeptDTOShowNames ( subList ) , DepartmentListDTO . class ) ;
pageInfos . setTotal ( compListDTOS . size ( ) ) ;
} else {
// 组合list
List < DepartmentListDTO > compListDTOS = DepartmentBO . buildDeptDTOList ( allList , orderType . toString ( ) ) ;
List < DepartmentListDTO > subList = PageUtil . subList ( param . getCurrent ( ) , param . getPageSize ( ) , compListDTOS ) ;
pageInfos = new PageInfo < > ( DepartmentBO. buildDeptDTOShowNames ( subList ) , DepartmentListDTO . class ) ;
pageInfos = new PageInfo < > ( user, DepartmentBO. buildDeptDTOShowNames ( subList ) , DepartmentListDTO . class ) ;
pageInfos . setTotal ( compListDTOS . size ( ) ) ;
}
@ -165,7 +159,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
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 ( ) ) ;
List < WeaTableColumn > weaTableColumn = columns . stream ( ) . map ( v - > new WeaTableColumn ( "100" , SystemEnv. getHtmlLabelName ( v . getLabelId ( ) , user . getLanguage ( ) ) , v . getKey ( ) ) ) . collect ( Collectors . toList ( ) ) ;
table . setColumns ( weaTableColumn ) ;
@ -212,7 +206,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
OrganizationAssert . isFalse ( disableIds . contains ( Integer . parseInt ( supDepId ) ) , "上级部门不能选择部门本身及其下级部门" ) ;
OrganizationAssert . isFalse ( disableIds . contains ( Integer . parseInt ( supDepId ) ) , SystemEnv . getHtmlLabelName ( 547411 , user . getLanguage ( ) ) ) ;
}
new OrganizationSyncEc ( user , LogModuleNameEnum . DEPARTMENT , OperateTypeEnum . UPDATE , params ) . sync ( ) ;
@ -231,13 +225,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > conditionItems = new ArrayList < > ( ) ;
// 编号
SearchConditionItem departmentCodeItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "编号" , "departmentCode" ) ;
SearchConditionItem departmentCodeItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , 547118 , "departmentCode" ) ;
// 名称
SearchConditionItem departmentNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , "名称" , "departmentName" ) ;
SearchConditionItem departmentNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 2 , 50 , 547141 , "departmentName" ) ;
// 所属分部
SearchConditionItem subCompanyId1Item = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "所属分部" , "164" , "subCompanyId1" , "" ) ;
SearchConditionItem subCompanyId1Item = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , 547128 , "164" , "subCompanyId1" , "" ) ;
// 上级部门
SearchConditionItem supDepIdItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "上级部门" , "4" , "supDepId" , "" ) ;
SearchConditionItem supDepIdItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , 547189 , "4" , "supDepId" , "" ) ;
conditionItems . add ( departmentCodeItem ) ;
conditionItems . add ( departmentNameItem ) ;
@ -251,16 +245,16 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override
public Map < String , List < MenuBtn > > getHasRight ( ) {
MenuBtn . builder ( ) . isBatch ( "1" ) . isTop ( "1" ) . menuFun ( "new" ) . menuIcon ( "icon-coms-New-Flow" ) . menuName ( "新增" ) . type ( "BTN_Addnew" ) . build ( ) ;
MenuBtn . builder ( ) . isBatch ( "1" ) . isTop ( "1" ) . menuFun ( "new" ) . menuIcon ( "icon-coms-New-Flow" ) . menuName ( SystemEnv . getHtmlLabelName ( 547117 , user . getLanguage ( ) ) ) . type ( "BTN_Addnew" ) . build ( ) ;
Map < String , List < MenuBtn > > datasNoBtnColum = MenuBtn . getDatasNoBtnColum ( user . getLanguage ( ) ) ;
datasNoBtnColum . get ( "topMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "0" ) . isTop ( "1" ) . menuFun ( "export" ) . menuIcon ( "icon-coms-export" ) . menuName ( "全部导出" ) . type ( "BTN_Export" ) . build ( ) ) ;
datasNoBtnColum . get ( "rightMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "0" ) . isTop ( "0" ) . menuFun ( "export" ) . menuIcon ( "icon-coms-export" ) . menuName ( "全部导出" ) . type ( "BTN_Export" ) . build ( ) ) ;
datasNoBtnColum . get ( "topMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "0" ) . isTop ( "1" ) . menuFun ( "export" ) . menuIcon ( "icon-coms-export" ) . menuName ( SystemEnv . getHtmlLabelName ( 547187 , user . getLanguage ( ) ) ) . type ( "BTN_Export" ) . build ( ) ) ;
datasNoBtnColum . get ( "rightMenu" ) . add ( MenuBtn . builder ( ) . isBatch ( "0" ) . isTop ( "0" ) . menuFun ( "export" ) . menuIcon ( "icon-coms-export" ) . menuName ( SystemEnv . getHtmlLabelName ( 547187 , user . getLanguage ( ) ) ) . type ( "BTN_Export" ) . build ( ) ) ;
return datasNoBtnColum ;
}
@Override
public Map < String , Object > getDeptBaseForm ( Map < String , Object > params ) {
OrganizationAssert . notNull ( params . get ( "viewAttr" ) , "请标识操作类型" ) ;
OrganizationAssert . notNull ( params . get ( "viewAttr" ) , SystemEnv . getHtmlLabelName ( 547260 , user . getLanguage ( ) ) ) ;
// 2编辑 1查看
int viewAttr = Integer . parseInt ( ( String ) params . get ( "viewAttr" ) ) ;
@ -405,7 +399,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
resultMap . put ( "conditions" , groupList ) ;
resultMap . put ( "id" , id ) ;
List < TopTab > topTabs = new ArrayList < > ( ) ;
topTabs . add ( TopTab . builder ( ) . color ( "#000000" ) . groupId ( "4" ) . showcount ( false ) . title ( "部门信息" ) . viewCondition ( "4" ) . build ( ) ) ;
topTabs . add ( TopTab . builder ( ) . color ( "#000000" ) . groupId ( "4" ) . showcount ( false ) . title ( SystemEnv . getHtmlLabelName ( 547412 , user . getLanguage ( ) ) ) . viewCondition ( "4" ) . build ( ) ) ;
resultMap . put ( "tabInfo" , topTabs ) ;
Map < String , Object > apiDatas = new HashMap < > ( ) ;
@ -430,9 +424,9 @@ 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 , "复制到" , "164" , "company" , "" ) ;
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , 547261 , "164" , "company" , "" ) ;
compBrowserItem . setRules ( "required|string" ) ;
SearchConditionItem copySubDeptItem = OrganizationFormItemUtil . selectItem ( user , Lists . newArrayList ( new SearchConditionOption ( "1" , "" ) ) , 2 , 5 , 10 , false , "复制子部门信息" , "copySubDept" ) ;
SearchConditionItem copySubDeptItem = OrganizationFormItemUtil . selectItem ( user , Lists . newArrayList ( new SearchConditionOption ( "1" , "" ) ) , 2 , 5 , 10 , false , SystemEnv . getHtmlLabelName ( 547262 , user . getLanguage ( ) ) , "copySubDept" ) ;
copySubDeptItem . setDetailtype ( 2 ) ;
condition . add ( compBrowserItem ) ;
condition . add ( copySubDeptItem ) ;
@ -450,7 +444,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
public int copyDepartment ( DeptCopyParam copyParam ) {
// 批量复制,后续优化
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
OrganizationAssert . notBlank ( copyParam . getCompany ( ) , "请指定需要复制的公司/分部" ) ;
OrganizationAssert . notBlank ( copyParam . getCompany ( ) , SystemEnv . getHtmlLabelName ( 547263 , user . getLanguage ( ) ) ) ;
int insertCount = 0 ;
// 需复制的部门
List < Integer > idList = Arrays . stream ( copyParam . getIds ( ) . split ( "," ) ) . map ( Integer : : parseInt ) . collect ( Collectors . toList ( ) ) ;
@ -466,7 +460,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
private void recursionCopyDept ( Integer originalDeptId , Integer parentDepartmentId , Integer companyId , Double maxShowOrder , String copyJob , String copySubDept , String copySubJob ) {
// 源部门
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( originalDeptId ) ;
long timeMillis = System . currentTimeMillis ( ) ;
// 处理自动编号
deptById . setDepartmentCode ( null ) ;
// 设置上级分部
@ -480,19 +473,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
Map < String , Object > syncMap = addEcDepartment ( deptById ) ;
String ecDepartmentID = Util . null2String ( syncMap . get ( "id" ) ) ;
OrganizationAssert . isTrue ( StringUtils . isNotBlank ( ecDepartmentID ) , syncMap . get ( "message" ) . toString ( ) ) ;
// 更新组织架构图
// new DepartmentTriggerRunnable(deptById.getId()).run();
// 复制当前部门岗位信息
//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, Integer.parseInt(ecDepartmentID), null, maxJobOrder, timeMillis);
//}
// 是否复制子部门信息
if ( "1" . equals ( copySubDept ) ) {
@ -509,9 +489,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
public List < SearchConditionGroup > getMergeForm ( ) {
List < SearchConditionGroup > addGroups = new ArrayList < > ( ) ;
List < SearchConditionItem > condition = new ArrayList < > ( ) ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , "合并到部门" , "4" , "department" , "" ) ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 3 , false , 547264 , "4" , "department" , "" ) ;
deptBrowserItem . setRules ( "required|string" ) ;
SearchConditionItem mergeNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , "合并后名称" , "mergeName" ) ;
SearchConditionItem mergeNameItem = OrganizationFormItemUtil . inputItem ( user , 2 , 16 , 3 , 50 , 547265 , "mergeName" ) ;
mergeNameItem . setRules ( "required|string" ) ;
condition . add ( deptBrowserItem ) ;
@ -529,10 +509,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 断言判断
OrganizationAssert . isFalse ( null = = targetDepartment , "被合并部门数据有误,暂时无法合并" ) ;
OrganizationAssert . isFalse ( mergeParam . getId ( ) . equals ( targetDepartment . getId ( ) ) , "所选部门与待合并部门一致,无需操作" ) ;
OrganizationAssert . notNull ( mergeParam . getDepartment ( ) , "请选择需要合并的部门" ) ;
OrganizationAssert . notBlank ( mergeParam . getMergeName ( ) , "请输入合并后的名称" ) ;
OrganizationAssert . isFalse ( null = = targetDepartment , SystemEnv . getHtmlLabelName ( 547266 , user . getLanguage ( ) ) ) ;
OrganizationAssert . isFalse ( mergeParam . getId ( ) . equals ( targetDepartment . getId ( ) ) , SystemEnv . getHtmlLabelName ( 547267 , user . getLanguage ( ) ) ) ;
OrganizationAssert . notNull ( mergeParam . getDepartment ( ) , SystemEnv . getHtmlLabelName ( 547268 , user . getLanguage ( ) ) ) ;
OrganizationAssert . notBlank ( mergeParam . getMergeName ( ) , SystemEnv . getHtmlLabelName ( 547270 , user . getLanguage ( ) ) ) ;
// 不可选择合并的数据,本身及子部门
Set < Integer > disableIds = new HashSet < > ( ) ;
@ -542,7 +522,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
OrganizationAssert . isFalse ( disableIds . contains ( targetDepartment . getId ( ) ) , "请勿选择当前部门本身及其子部门" ) ;
OrganizationAssert . isFalse ( disableIds . contains ( targetDepartment . getId ( ) ) , SystemEnv . getHtmlLabelName ( 547271 , user . getLanguage ( ) ) ) ;
// 查询该部门下一级部门
List < DepartmentPO > firstChildDeptList = getDepartmentMapper ( ) . getDeptListByPId ( mergeParam . getId ( ) ) ;
@ -551,41 +531,24 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
departmentPO . setSupDepId ( targetDepartment . getId ( ) ) ;
departmentPO . setSubCompanyId1 ( targetDepartment . getSubCompanyId1 ( ) ) ;
updateEcDepartment ( departmentPO ) ;
// 更新组织架构图
// new DepartmentTriggerRunnable(departmentPO.getId()).run();
}
// 查询该部门一级岗位、更新岗位所属分部、所属部门
//List<JobPO> firstChildJobList = getJobMapper().listJobsByDepartmentId(mergeParam.getId());
//firstChildJobList = firstChildJobList.stream().filter(item -> null == item.getParentJob() || 0 == item.getParentJob()).collect(Collectors.toList());
// 批量更新部门、所属分部
RecordSet rs = new RecordSet ( ) ;
String targetEcDeptId = targetDepartment . getId ( ) . toString ( ) ;
String mergeEcDeptId = mergeParam . getId ( ) . toString ( ) ;
//rs.executeUpdate("update jcl_org_job set parent_comp =?,ec_company =?,parent_dept =?,ec_department =? where ec_department =?", targetDepartment.getSubCompanyId1(), targetDepartment.getSubCompanyId1(), targetDepartment.getId(), targetEcDeptId, mergeParam.getId());
// 更新岗位组织架构图
//for (JobPO jobPO : firstChildJobList) {
// // 刷新组织架构图
// new JobTriggerRunnable(jobPO.getId()).run();
//}
// 更新当前部门下的人员
rs . executeUpdate ( "update hrmresource set SUBCOMPANYID1 =?,DEPARTMENTID =? where DEPARTMENTID =?" , targetDepartment . getSubCompanyId1 ( ) , targetEcDeptId , mergeEcDeptId ) ;
//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());
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(mergeParam.getId().toString());
//// 更新人员组织架构图
//for (Long hrmResourceId : hrmResourceIds) {
// new HrmResourceTriggerRunnable(hrmResourceId).run();
//}
// 更新子部门下岗位的所属分部
for ( DepartmentPO departmentPO : firstChildDeptList ) {
List < DepartmentPO > deptList = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
forbiddenChildTag ( targetDepartment . getSubCompanyId1 ( ) , deptList ) ;
}
// 原部门删除
// DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
// 删除部门(先更改原部门名称,释放原部门名称,然后删除)
DepartmentPO sourceDepartmentPO = getDepartmentMapper ( ) . getDeptById ( mergeParam . getId ( ) ) ;
sourceDepartmentPO . setDepartmentName ( sourceDepartmentPO . getDepartmentName ( ) + "_被合并" ) ;
sourceDepartmentPO . setDepartmentMark ( sourceDepartmentPO . getDepartmentMark ( ) + "_被合并" ) ;
sourceDepartmentPO . setDepartmentName ( sourceDepartmentPO . getDepartmentName ( ) + SystemEnv . getHtmlLabelName ( 547272 , user . getLanguage ( ) ) ) ;
sourceDepartmentPO . setDepartmentMark ( sourceDepartmentPO . getDepartmentMark ( ) + SystemEnv . getHtmlLabelName ( 547272 , user . getLanguage ( ) ) ) ;
updateEcDepartment ( sourceDepartmentPO ) ;
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "id" , Util . null2String ( mergeParam . getId ( ) ) ) ;
@ -593,14 +556,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 删除原部门下的岗位
// 更新组织架构图
// new DepartmentTriggerRunnable(mergeDepartment).run();
// 更新部门合并后名称
targetDepartment . setDepartmentName ( mergeParam . getMergeName ( ) ) ;
targetDepartment . setDepartmentMark ( mergeParam . getMergeName ( ) ) ;
updateEcDepartment ( targetDepartment ) ;
// 更新组织架构图
// new DepartmentTriggerRunnable(oldFParentId, targetDepartment.getId()).run();
return 0 ;
}
@ -608,8 +569,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 , "选择分部" , "164" , "company" , "" ) ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , "选择部门" , "4" , "department" , "" ) ;
SearchConditionItem compBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , 547273 , "164" , "company" , "" ) ;
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil . browserItem ( user , 2 , 16 , 2 , false , 547274 , "4" , "department" , "" ) ;
List < SearchConditionOption > selectOptions = new ArrayList < > ( ) ;
@ -617,7 +578,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
SearchConditionOption deptOption = new SearchConditionOption ( "1" , "部门" ) ;
selectOptions . add ( compOption ) ;
selectOptions . add ( deptOption ) ;
SearchConditionItem moveTypeItem = OrganizationFormItemUtil . selectItem ( user , selectOptions , 2 , 16 , 6 , false , "转移到" , "moveType" ) ;
SearchConditionItem moveTypeItem = OrganizationFormItemUtil . selectItem ( user , selectOptions , 2 , 16 , 6 , false , 547275 , "moveType" ) ;
moveTypeItem . setDetailtype ( 3 ) ;
moveTypeItem . setValue ( "0" ) ;
@ -631,47 +592,34 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override
public int moveDepartment ( DepartmentMoveParam moveParam ) {
HasRightUtil . hasRight ( user , RIGHT_NAME , false ) ;
OrganizationAssert . notBlank ( moveParam . getMoveType ( ) , "请选择转移类型" ) ;
OrganizationAssert . notBlank ( moveParam . getMoveType ( ) , SystemEnv . getHtmlLabelName ( 547276 , user . getLanguage ( ) ) ) ;
DepartmentPO deptById = getDepartmentMapper ( ) . getDeptById ( moveParam . getId ( ) ) ;
// 0: 公司/分部 1: 部门
if ( "0" . equals ( moveParam . getMoveType ( ) ) ) {
Integer company = moveParam . getCompany ( ) ;
OrganizationAssert . notNull ( company , "请选择要转移到的分部" ) ;
OrganizationAssert . notNull ( company , SystemEnv . getHtmlLabelName ( 547277 , user . getLanguage ( ) ) ) ;
deptById . setSubCompanyId1 ( company ) ;
deptById . setSupDepId ( null ) ;
// 更新组织架构图
// new DepartmentTriggerRunnable(company.toString(), deptById).run();
} else if ( "1" . equals ( moveParam . getMoveType ( ) ) ) {
Integer departmentId = moveParam . getDepartment ( ) ;
OrganizationAssert . notNull ( departmentId , "请选择要转移到的部门" ) ;
OrganizationAssert . notNull ( departmentId , SystemEnv . getHtmlLabelName ( 547278 , user . getLanguage ( ) ) ) ;
List < DepartmentPO > deptListByPId = getDepartmentMapper ( ) . getDeptListByPId ( moveParam . getId ( ) ) ;
Set < Integer > disableIds = new HashSet < > ( ) ;
disableIds . add ( moveParam . getId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
OrganizationAssert . isFalse ( disableIds . contains ( departmentId ) , "请勿选择当前部门本身及其子部门" ) ;
OrganizationAssert . isFalse ( disableIds . contains ( departmentId ) , SystemEnv . getHtmlLabelName ( 547271 , user . getLanguage ( ) ) ) ;
deptById . setSupDepId ( departmentId ) ;
DepartmentPO parentDepartment = getDepartmentMapper ( ) . getDeptById ( departmentId ) ;
deptById . setSubCompanyId1 ( parentDepartment . getSubCompanyId1 ( ) ) ;
// 更新组织架构图
// new DepartmentTriggerRunnable(Integer.toString(100000000 + department.intValue()), deptById).run();
}
// 更新EC部门
updateEcDepartment ( deptById ) ;
// 刷新岗位分部
//refreshJobComp(deptById.getId(), deptById.getSubCompanyId1());
List < DepartmentPO > deptList = getDepartmentMapper ( ) . getDeptListByPId ( deptById . getId ( ) ) ;
// 更新当前部门下的人员
// new RecordSet().executeUpdate("update hrmresource set SUBCOMPANYID1 =? where DEPARTMENTID = ?", deptById.getSubCompanyId1(), deptById.getId());
//// 更新人员组织架构图
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(deptById.getId().toString());
//for (Long hrmResourceId : hrmResourceIds) {
// new HrmResourceTriggerRunnable(hrmResourceId).run();
//}
forbiddenChildTag ( deptById . getSubCompanyId1 ( ) , deptList ) ;
// 递归更新下级部门、岗位
return 1 ;
@ -695,8 +643,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
String supId = "" ;
String ftype = "" ;
String querySupIdSql ;
// OrganizationAssert.isFalse("s".equals(sourceType) && "d".equals(targetType), "分部不能转移到部门下");
OrganizationAssert . isFalse ( "-1" . equals ( dragPostion ) , "分部、部门不能转移至与集团平级" ) ;
OrganizationAssert . isFalse ( "-1" . equals ( dragPostion ) , SystemEnv . getHtmlLabelName ( 547279 , user . getLanguage ( ) ) ) ;
if ( "s" . equals ( targetType ) ) { // 分部
querySupIdSql = "select companyId as supComId,supsubcomid as supId,'s' as ftype from hrmsubcompany where id = ?" ;
} else {
@ -713,7 +660,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
Map < String , Object > params = new HashMap < > ( ) ;
params . put ( "id" , sourceId ) ;
if ( "0" . equals ( dragPostion ) ) { //内部
OrganizationAssert . isFalse ( "d" . equals ( targetType ) , "分部不能拖拽至部门下" ) ;
OrganizationAssert . isFalse ( "d" . equals ( targetType ) , SystemEnv . getHtmlLabelName ( 547280 , user . getLanguage ( ) ) ) ;
if ( "c" . equals ( targetType ) ) { // 集团下( 上级分部为0)
params . put ( "supsubcomid" , "0" ) ;
} else if ( "s" . equals ( targetType ) ) {
@ -723,7 +670,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( "s" . equals ( targetType ) ) { // 分部外(平级)
params . put ( "supsubcomid" , supId ) ;
} else { // 部门外(找上级)
OrganizationAssert . isFalse ( "d" . equals ( ftype ) , "分部不能拖拽至部门下" ) ;
OrganizationAssert . isFalse ( "d" . equals ( ftype ) , SystemEnv . getHtmlLabelName ( 547280 , user . getLanguage ( ) ) ) ;
params . put ( "supsubcomid" , supId ) ;
}
}
@ -732,7 +679,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List < DepartmentPO > deptListByPId ;
Set < Integer > disableIds = new HashSet < > ( ) ;
if ( "0" . equals ( dragPostion ) ) { //内部
OrganizationAssert . isFalse ( "c" . equals ( targetType ) , "部门不能拖拽至集团下" ) ;
OrganizationAssert . isFalse ( "c" . equals ( targetType ) , SystemEnv . getHtmlLabelName ( 547281 , user . getLanguage ( ) ) ) ;
if ( "s" . equals ( targetType ) ) {
deptById . setSubCompanyId1 ( Util . getIntValue ( targetId ) ) ;
deptById . setSupDepId ( null ) ;
@ -742,14 +689,14 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if ( CollectionUtils . isNotEmpty ( deptListByPId ) ) {
addDisableIds ( disableIds , deptListByPId ) ;
}
OrganizationAssert . isFalse ( "d" . equals ( targetType ) & & disableIds . contains ( Util . getIntValue ( targetId ) ) , "请勿选择当前部门本身及其子部门" ) ;
OrganizationAssert . isFalse ( "d" . equals ( targetType ) & & disableIds . contains ( Util . getIntValue ( targetId ) ) , SystemEnv . getHtmlLabelName ( 547271 , user . getLanguage ( ) ) ) ;
deptById . setSupDepId ( Util . getIntValue ( targetId ) ) ;
DepartmentPO parentDepartment = getDepartmentMapper ( ) . getDeptById ( Util . getIntValue ( targetId ) ) ;
deptById . setSubCompanyId1 ( parentDepartment . getSubCompanyId1 ( ) ) ;
}
} else { //外部
if ( "s" . equals ( targetType ) ) {
OrganizationAssert . isFalse ( "0" . equals ( supId ) , "部门不能拖拽至集团下" ) ;
OrganizationAssert . isFalse ( "0" . equals ( supId ) , SystemEnv . getHtmlLabelName ( 547281 , user . getLanguage ( ) ) ) ;
deptById . setSubCompanyId1 ( Util . getIntValue ( supId ) ) ;
deptById . setSupDepId ( null ) ;
} else {
@ -785,19 +732,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 更新EC表部门
updateEcDepartment ( departmentPO ) ;
// 更新组织架构图
// new DepartmentTriggerRunnable(departmentPO.getId()).run();
// 刷新岗位所属分部
//refreshJobComp(departmentPO.getId(), subCompanyId1);
// 更新当前部门下的人员
// String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(departmentPO.getId().toString());
//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());
//List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIdsByDept(departmentPO.getId().toString());
//// 更新人员组织架构图
//for (Long hrmResourceId : hrmResourceIds) {
// new HrmResourceTriggerRunnable(hrmResourceId).run();
//}
List < DepartmentPO > childList = getDepartmentMapper ( ) . getDeptListByPId ( departmentPO . getId ( ) ) ;
forbiddenChildTag ( subCompanyId1 , childList ) ;
}
@ -859,23 +793,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
}
}
/ * *
* 判 断 编 号 是 否 重 复
*
* @return
* /
public String repeatDetermine ( String deptNo ) {
CodeRulePO codeRuleByType = MapperProxyFactory . getProxy ( CodeRuleMapper . class ) . getCodeRuleByType ( RuleCodeType . DEPARTMENT . getValue ( ) ) ;
if ( StringUtils . isNotBlank ( deptNo ) ) {
deptNo = CodeRuleUtil . generateCode ( RuleCodeType . DEPARTMENT , deptNo ) ;
List < DepartmentPO > list = getDepartmentMapper ( ) . listByNo ( Util . null2String ( deptNo ) ) ;
OrganizationAssert . isEmpty ( list , SystemEnv . getHtmlLabelName ( 547137 , user . getLanguage ( ) ) ) ;
} else {
OrganizationAssert . isTrue ( null ! = codeRuleByType & & "1" . equals ( codeRuleByType . getSerialEnable ( ) ) , "编号不允许为空" ) ;
deptNo = autoCreateCompanyNo ( ) ;
}
return deptNo ;
}
/ * *
* 自 动 编 号 处 理
@ -935,19 +852,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
}
}
/ * *
* 更 新 岗 位 的 所 属 分 部
*
* @param parentDepartment
* @param parentComp
* /
private void refreshJobComp ( Integer parentDepartment , Integer parentComp ) {
List < JobPO > jobPOS = getJobMapper ( ) . listJobsByDepartmentId ( parentDepartment ) ;
jobPOS = jobPOS . stream ( ) . filter ( item - > null = = item . getParentJob ( ) | | 0 = = item . getParentJob ( ) ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtils . isNotEmpty ( jobPOS ) ) {
getJobMapper ( ) . updateJobCompany ( jobPOS . stream ( ) . map ( JobPO : : getId ) . collect ( Collectors . toList ( ) ) , parentComp , parentComp ) ;
}
}
private List < SearchConditionGroup > getDepartmentConditionGroups ( Boolean showAll , Map < String , Object > params ) {
List < SearchConditionGroup > groupList = new ArrayList < > ( ) ;