|
|
@ -281,58 +281,56 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
DeptSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), DeptSearchParam.class);
|
|
|
|
DeptSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), DeptSearchParam.class);
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
String groupId = (String) params.get("viewCondition");
|
|
|
|
if ("0".equals(groupId)) {
|
|
|
|
if ("0".equals(groupId) || GROUP_ID.toString().equals(groupId)) {
|
|
|
|
groupId = GROUP_ID.toString();
|
|
|
|
DepartmentPO oldDept = getDepartmentMapper().getDeptById(searchParam.getId());
|
|
|
|
}
|
|
|
|
String deptNo = searchParam.getDeptNo();
|
|
|
|
|
|
|
|
if (!deptNo.equals(oldDept.getDeptNo())) {
|
|
|
|
DepartmentPO oldDept = getDepartmentMapper().getDeptById(searchParam.getId());
|
|
|
|
deptNo = repeatDetermine(deptNo);
|
|
|
|
String deptNo = searchParam.getDeptNo();
|
|
|
|
params.put("dept_no", deptNo);
|
|
|
|
if (!deptNo.equals(oldDept.getDeptNo())) {
|
|
|
|
|
|
|
|
deptNo = repeatDetermine(deptNo);
|
|
|
|
|
|
|
|
params.put("dept_no", deptNo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 上级分部
|
|
|
|
|
|
|
|
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 ecCompany = Util.null2String(params.get("ec_company"));
|
|
|
|
String ecDepartment = Util.null2String(params.get("ec_department"));
|
|
|
|
if (StringUtils.isNotBlank(ecCompany)) {
|
|
|
|
if (StringUtils.isNotBlank(ecDepartment)) {
|
|
|
|
CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecCompany);
|
|
|
|
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecDepartment);
|
|
|
|
if (null != jclCompanyId) {
|
|
|
|
if (null != jclDepartmentId) {
|
|
|
|
params.put("parent_comp", jclCompanyId.getId());
|
|
|
|
// 上级部门不能选择本身
|
|
|
|
}
|
|
|
|
OrganizationAssert.isFalse(jclDepartmentId.getId().equals(searchParam.getId()), "上级部门不能选择本身");
|
|
|
|
|
|
|
|
params.put("parent_dept", jclDepartmentId.getId());
|
|
|
|
|
|
|
|
// 部门不为空,自动指定所属分部
|
|
|
|
|
|
|
|
params.put("parent_comp", jclDepartmentId.getParentComp());
|
|
|
|
|
|
|
|
params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(jclDepartmentId.getParentComp())));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 上级部门
|
|
|
|
|
|
|
|
String ecDepartment = Util.null2String(params.get("ec_department"));
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(ecDepartment)) {
|
|
|
|
|
|
|
|
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecDepartment);
|
|
|
|
|
|
|
|
if (null != jclDepartmentId) {
|
|
|
|
|
|
|
|
// 上级部门不能选择本身
|
|
|
|
|
|
|
|
OrganizationAssert.isFalse(jclDepartmentId.getId().equals(searchParam.getId()), "上级部门不能选择本身");
|
|
|
|
|
|
|
|
params.put("parent_dept", jclDepartmentId.getId());
|
|
|
|
|
|
|
|
// 部门不为空,自动指定所属分部
|
|
|
|
|
|
|
|
params.put("parent_comp", jclDepartmentId.getParentComp());
|
|
|
|
|
|
|
|
params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(Util.null2String(jclDepartmentId.getParentComp())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
params.put("parent_dept", "");
|
|
|
|
params.put("parent_dept", "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, params).sync();
|
|
|
|
|
|
|
|
// 更新主表数据
|
|
|
|
|
|
|
|
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPT, params, "", searchParam.getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DepartmentPO newDeptById = getDepartmentMapper().getDeptById(searchParam.getId());
|
|
|
|
|
|
|
|
new DepartmentTriggerRunnable(oldDept, newDeptById).run();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(Util.null2String(parentComp));
|
|
|
|
|
|
|
|
forbiddenChildTag(parentComp, ecCompanyId, childList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, params).sync();
|
|
|
|
|
|
|
|
// 更新主表数据
|
|
|
|
|
|
|
|
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPT, params, "", searchParam.getId());
|
|
|
|
|
|
|
|
// 更新主表拓展表
|
|
|
|
// 更新主表拓展表
|
|
|
|
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPTEXT, params, groupId, searchParam.getId());
|
|
|
|
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPTEXT, params, "", searchParam.getId());
|
|
|
|
//更新明细表
|
|
|
|
//更新明细表
|
|
|
|
getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_DEPTEXT_DT1, params, searchParam.getId());
|
|
|
|
getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_DEPTEXT_DT1, params, searchParam.getId());
|
|
|
|
|
|
|
|
|
|
|
|
DepartmentPO newDeptById = getDepartmentMapper().getDeptById(searchParam.getId());
|
|
|
|
|
|
|
|
new DepartmentTriggerRunnable(oldDept, newDeptById).run();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(Util.null2String(parentComp));
|
|
|
|
|
|
|
|
forbiddenChildTag(parentComp, ecCompanyId, childList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return searchParam.getId();
|
|
|
|
return searchParam.getId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -642,7 +640,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
updateEcDepartment(departmentPO);
|
|
|
|
updateEcDepartment(departmentPO);
|
|
|
|
getDepartmentMapper().updateBaseDept(departmentPO);
|
|
|
|
getDepartmentMapper().updateBaseDept(departmentPO);
|
|
|
|
// 更新组织架构图
|
|
|
|
// 更新组织架构图
|
|
|
|
new DepartmentTriggerRunnable(departmentPO.getId()).run();
|
|
|
|
new DepartmentTriggerRunnable(departmentPO.getId()).run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 查询该部门一级岗位、更新岗位所属分部、所属部门
|
|
|
|
// 查询该部门一级岗位、更新岗位所属分部、所属部门
|
|
|
|
List<JobPO> firstChildJobList = getJobMapper().listJobsByDepartmentId(mergeParam.getId());
|
|
|
|
List<JobPO> firstChildJobList = getJobMapper().listJobsByDepartmentId(mergeParam.getId());
|
|
|
@ -687,7 +685,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
updateEcDepartment(targetDepartment);
|
|
|
|
updateEcDepartment(targetDepartment);
|
|
|
|
getDepartmentMapper().updateBaseDept(targetDepartment);
|
|
|
|
getDepartmentMapper().updateBaseDept(targetDepartment);
|
|
|
|
// 更新组织架构图
|
|
|
|
// 更新组织架构图
|
|
|
|
new DepartmentTriggerRunnable(oldFParentId,targetDepartment.getId()).run();
|
|
|
|
new DepartmentTriggerRunnable(oldFParentId, targetDepartment.getId()).run();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -730,7 +728,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
deptById.setEcDepartment(null);
|
|
|
|
deptById.setEcDepartment(null);
|
|
|
|
|
|
|
|
|
|
|
|
// 更新组织架构图
|
|
|
|
// 更新组织架构图
|
|
|
|
new DepartmentTriggerRunnable(company.toString(),deptById).run();
|
|
|
|
new DepartmentTriggerRunnable(company.toString(), deptById).run();
|
|
|
|
} else if ("1".equals(moveParam.getMoveType())) {
|
|
|
|
} else if ("1".equals(moveParam.getMoveType())) {
|
|
|
|
Long department = moveParam.getDepartment();
|
|
|
|
Long department = moveParam.getDepartment();
|
|
|
|
Long departmentId = Objects.requireNonNull(EcHrmRelationUtil.getJclDepartmentId(Util.null2String(department))).getId();
|
|
|
|
Long departmentId = Objects.requireNonNull(EcHrmRelationUtil.getJclDepartmentId(Util.null2String(department))).getId();
|
|
|
@ -749,7 +747,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
deptById.setEcCompany(parentDepartment.getEcCompany());
|
|
|
|
deptById.setEcCompany(parentDepartment.getEcCompany());
|
|
|
|
|
|
|
|
|
|
|
|
// 更新组织架构图
|
|
|
|
// 更新组织架构图
|
|
|
|
new DepartmentTriggerRunnable(Integer.toString(100000000+department.intValue()),deptById).run();
|
|
|
|
new DepartmentTriggerRunnable(Integer.toString(100000000 + department.intValue()), deptById).run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 更新EC部门
|
|
|
|
// 更新EC部门
|
|
|
|
updateEcDepartment(deptById);
|
|
|
|
updateEcDepartment(deptById);
|
|
|
@ -847,7 +845,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
|
|
|
|
|
|
|
Set<CompPO> builderComps = new HashSet<>();
|
|
|
|
Set<CompPO> builderComps = new HashSet<>();
|
|
|
|
for (CompPO compPO : filterComps) {
|
|
|
|
for (CompPO compPO : filterComps) {
|
|
|
|
buildParentComps(compPO, builderComps,allMaps);
|
|
|
|
buildParentComps(compPO, builderComps, allMaps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps));
|
|
|
|
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps));
|
|
|
|
|
|
|
|
|
|
|
|