|
|
|
@ -570,10 +570,17 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
}
|
|
|
|
|
// 原部门删除
|
|
|
|
|
// DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
|
|
|
|
|
// 删除部门(先更改原部门名称,释放原部门名称,然后删除)
|
|
|
|
|
DepartmentPO sourceDepartmentPO = getDepartmentMapper().getDeptById(mergeParam.getId());
|
|
|
|
|
sourceDepartmentPO.setDepartmentName(sourceDepartmentPO.getDepartmentName() + "_被合并");
|
|
|
|
|
sourceDepartmentPO.setDepartmentMark(sourceDepartmentPO.getDepartmentMark() + "_被合并");
|
|
|
|
|
updateEcDepartment(sourceDepartmentPO);
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("id", Util.null2String(mergeParam.getId()));
|
|
|
|
|
// 删除部门
|
|
|
|
|
ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentCancel(map, user);
|
|
|
|
|
// 删除原部门下的岗位
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新组织架构图
|
|
|
|
|
// new DepartmentTriggerRunnable(mergeDepartment).run();
|
|
|
|
|
// 更新部门合并后名称
|
|
|
|
@ -658,6 +665,85 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int dragDepartment(DepartmentDragParam departmentDragParam) {
|
|
|
|
|
// OrganizationAssert.notNull(params.get("sourcekey"), "请选择一个拖拽源");
|
|
|
|
|
// OrganizationAssert.notNull(params.get("targetkey"), "请选择一个拖拽目的地");
|
|
|
|
|
|
|
|
|
|
String sourceKey = Util.null2String(departmentDragParam.getSourcekey());// 原目标
|
|
|
|
|
String targetKey = Util.null2String(departmentDragParam.getTargetkey());// 目的地
|
|
|
|
|
String dragPostion = Util.null2String(departmentDragParam.getDropPosition());// 0:目的里面 1:目的外边
|
|
|
|
|
|
|
|
|
|
DepartmentPO deptById = getDepartmentMapper().getDeptById(Util.getIntValue(sourceKey.substring(1)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
// 部门不能到集团下
|
|
|
|
|
|
|
|
|
|
String targetType = targetKey.substring(0, 1);
|
|
|
|
|
String targetId = targetKey.substring(1);
|
|
|
|
|
String supComId = "";
|
|
|
|
|
String supId = "";
|
|
|
|
|
String querySupIdSql;
|
|
|
|
|
if ("s".equals(targetType)) {// 分部
|
|
|
|
|
querySupIdSql = "select companyId as supComId,supsubcomid as supId from hrmsubcompany where id = ?";
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
querySupIdSql = "select subcompanyid1 as supComId,supdepid as supId from hrmdepartment where id = ?";
|
|
|
|
|
}
|
|
|
|
|
if ("1".equals(dragPostion)) {
|
|
|
|
|
recordSet.executeQuery(querySupIdSql, targetId);
|
|
|
|
|
if (recordSet.next()) {
|
|
|
|
|
supId = Util.null2String(recordSet.getString("supId"));
|
|
|
|
|
supComId = Util.null2String(recordSet.getString("supComId"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("s".equals(targetType)) {
|
|
|
|
|
OrganizationAssert.isFalse("0".equals(supId), "部门不能直接拖拽至集团下");
|
|
|
|
|
// 转移到分部外
|
|
|
|
|
deptById.setSubCompanyId1(Util.getIntValue(supId));
|
|
|
|
|
deptById.setSupDepId(null);
|
|
|
|
|
} else {
|
|
|
|
|
// 转移到部门外
|
|
|
|
|
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(supId));
|
|
|
|
|
Set<Integer> disableIds = new HashSet<>();
|
|
|
|
|
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
|
|
|
|
addDisableIds(disableIds, deptListByPId);
|
|
|
|
|
}
|
|
|
|
|
// OrganizationAssert.isFalse(disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
|
|
|
|
|
deptById.setSupDepId(Util.getIntValue(supId));
|
|
|
|
|
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(supId)==0 ? Util.getIntValue(supComId) : Util.getIntValue(supId));
|
|
|
|
|
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if ("s".equals(targetType)) {
|
|
|
|
|
//转移到分部下
|
|
|
|
|
deptById.setSubCompanyId1(Util.getIntValue(targetId));
|
|
|
|
|
deptById.setSupDepId(null);
|
|
|
|
|
} else {
|
|
|
|
|
//转移到部门下
|
|
|
|
|
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(targetId));
|
|
|
|
|
Set<Integer> disableIds = new HashSet<>();
|
|
|
|
|
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
|
|
|
|
addDisableIds(disableIds, deptListByPId);
|
|
|
|
|
}
|
|
|
|
|
OrganizationAssert.isFalse(disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
|
|
|
|
|
deptById.setSupDepId(Util.getIntValue(targetId));
|
|
|
|
|
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(targetId));
|
|
|
|
|
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 更新EC部门
|
|
|
|
|
updateEcDepartment(deptById);
|
|
|
|
|
// 刷新岗位分部
|
|
|
|
|
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(deptById.getId());
|
|
|
|
|
forbiddenChildTag(deptById.getSubCompanyId1(), deptList);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有子部门id
|
|
|
|
|
*
|
|
|
|
|