|
|
|
@ -683,7 +683,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
String supId = "";
|
|
|
|
|
String ftype = "";
|
|
|
|
|
String querySupIdSql;
|
|
|
|
|
OrganizationAssert.isFalse("s".equals(sourceType) && "d".equals(targetType), "分部不能转移到部门下");
|
|
|
|
|
// OrganizationAssert.isFalse("s".equals(sourceType) && "d".equals(targetType), "分部不能转移到部门下");
|
|
|
|
|
OrganizationAssert.isFalse("-1".equals(dragPostion), "分部、部门不能转移至与集团平级");
|
|
|
|
|
if ("s".equals(targetType)) {// 分部
|
|
|
|
|
querySupIdSql = "select companyId as supComId,supsubcomid as supId,'s' as ftype from hrmsubcompany where id = ?";
|
|
|
|
@ -697,63 +697,66 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
supComId = Util.null2String(recordSet.getString("supComId"));
|
|
|
|
|
ftype = Util.null2String(recordSet.getString("ftype"));
|
|
|
|
|
}
|
|
|
|
|
if ("1".equals(dragPostion)) {
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
if ("s".equals(sourceType)) {// 拖拽源是分部
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("id", sourceId);
|
|
|
|
|
if ("0".equals(dragPostion)) {//内部
|
|
|
|
|
OrganizationAssert.isFalse("d".equals(targetType), "分部不能拖拽至部门下");
|
|
|
|
|
if ("c".equals(targetType)) {// 集团下(上级分部为0)
|
|
|
|
|
params.put("supsubcomid", "0");
|
|
|
|
|
}else if ("s".equals(targetType)){
|
|
|
|
|
params.put("supsubcomid", targetId);//上下级关系
|
|
|
|
|
}
|
|
|
|
|
}else{//外部
|
|
|
|
|
if("s".equals(targetType)){// 分部外(平级)
|
|
|
|
|
params.put("supsubcomid",supId);
|
|
|
|
|
}else{// 部门外(找上级)
|
|
|
|
|
OrganizationAssert.isFalse("d".equals(ftype), "分部不能拖拽至部门下");
|
|
|
|
|
params.put("supsubcomid",supId);
|
|
|
|
|
}
|
|
|
|
|
// 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());
|
|
|
|
|
deptById.setSubCompanyId1(Util.getIntValue(supComId));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ("s".equals(targetType)) {
|
|
|
|
|
// 转移到分部下
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("id", sourceId);
|
|
|
|
|
params.put("supsubcomid", targetId);
|
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync();
|
|
|
|
|
if ("d".equals(sourceType)) {
|
|
|
|
|
deptById.setSupDepId(0);
|
|
|
|
|
deptById.setSubCompanyId1("s".equals(ftype) ? Util.getIntValue(targetId) : Util.getIntValue(supComId));
|
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync();
|
|
|
|
|
} else {//拖拽源是部门
|
|
|
|
|
List<DepartmentPO> deptListByPId;
|
|
|
|
|
Set<Integer> disableIds = new HashSet<>();
|
|
|
|
|
if ("0".equals(dragPostion)) {//内部
|
|
|
|
|
OrganizationAssert.isFalse("c".equals(targetType), "部门不能拖拽至集团下");
|
|
|
|
|
if("s".equals(targetType)){
|
|
|
|
|
deptById.setSubCompanyId1(Util.getIntValue(targetId));
|
|
|
|
|
deptById.setSupDepId(null);
|
|
|
|
|
}else{
|
|
|
|
|
deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(targetId));
|
|
|
|
|
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
|
|
|
|
addDisableIds(disableIds, deptListByPId);
|
|
|
|
|
}
|
|
|
|
|
OrganizationAssert.isFalse("d".equals(targetType) && disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
|
|
|
|
|
deptById.setSupDepId(Util.getIntValue(targetId));
|
|
|
|
|
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(targetId));
|
|
|
|
|
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
|
|
|
|
|
}
|
|
|
|
|
} else if ("c".equals(targetType)) {
|
|
|
|
|
OrganizationAssert.isFalse("d".equals(sourceType), "部门不能拖拽到集团下");
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("id", sourceId);
|
|
|
|
|
params.put("supsubcomid", "0");
|
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync();
|
|
|
|
|
} 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);
|
|
|
|
|
}else{//外部
|
|
|
|
|
if("s".equals(targetType)){
|
|
|
|
|
OrganizationAssert.isFalse("0".equals(supId), "部门不能拖拽至集团下");
|
|
|
|
|
deptById.setSubCompanyId1(Util.getIntValue(supId));
|
|
|
|
|
deptById.setSupDepId(null);
|
|
|
|
|
}else{
|
|
|
|
|
// 转移到部门外
|
|
|
|
|
deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(supId));
|
|
|
|
|
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
|
|
|
|
addDisableIds(disableIds, deptListByPId);
|
|
|
|
|
}
|
|
|
|
|
deptById.setSupDepId(Util.getIntValue(supId));
|
|
|
|
|
deptById.setSubCompanyId1(Util.getIntValue(supComId));
|
|
|
|
|
}
|
|
|
|
|
OrganizationAssert.isFalse("d".equals(targetType) && 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);
|
|
|
|
|
}
|
|
|
|
|
// 更新EC部门
|
|
|
|
|
updateEcDepartment(deptById);
|
|
|
|
|
// 刷新岗位分部
|
|
|
|
|
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(deptById.getId());
|
|
|
|
|
forbiddenChildTag(deptById.getSubCompanyId1(), deptList);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|