|
|
|
@ -578,6 +578,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
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();
|
|
|
|
|
// 更新部门合并后名称
|
|
|
|
@ -662,6 +665,82 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int dragDepartment(Map<String, Object> params) {
|
|
|
|
|
// OrganizationAssert.notNull(params.get("sourcekey"), "请选择一个拖拽源");
|
|
|
|
|
// OrganizationAssert.notNull(params.get("targetkey"), "请选择一个拖拽目的地");
|
|
|
|
|
|
|
|
|
|
String sourceKey = Util.null2String(params.get("sourcekey"));// 原目标
|
|
|
|
|
String targetKey = Util.null2String(params.get("targetkey"));// 目的地
|
|
|
|
|
String dragPostion = Util.null2String(params.get("dragpostion"));// 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 supId = null;
|
|
|
|
|
String querySupIdSql = null;
|
|
|
|
|
if ("s".equals(targetType)) {// 分部
|
|
|
|
|
querySupIdSql = "select supsubcomid as supId from hrmsubcompany where id = ?";
|
|
|
|
|
} else {
|
|
|
|
|
querySupIdSql = "select supdepid as supId from hrmdepartment where id = ?";
|
|
|
|
|
}
|
|
|
|
|
if ("1".equals(dragPostion)) {
|
|
|
|
|
recordSet.executeQuery(querySupIdSql, targetId);
|
|
|
|
|
if (recordSet.next()) {
|
|
|
|
|
supId = Util.null2String(recordSet.getString("supId"));
|
|
|
|
|
}
|
|
|
|
|
OrganizationAssert.isFalse("0".equals(supId), "部门不能直接拖拽至集团下");
|
|
|
|
|
|
|
|
|
|
if ("s".equals(targetType)) {
|
|
|
|
|
// 转移到分部外
|
|
|
|
|
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));
|
|
|
|
|
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
|
|
|
|
|
*
|
|
|
|
|