From 6247129bcf64fc30048c4350b43db5166484750e Mon Sep 17 00:00:00 2001 From: Mlin Date: Wed, 2 Aug 2023 15:04:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=96=E6=8B=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DepartmentServiceImpl.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index bc5f97a1..2345aa79 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -681,21 +681,23 @@ public class DepartmentServiceImpl extends Service implements DepartmentService String targetId = targetKey.substring(1); String supComId = ""; String supId = ""; + String ftype = ""; String querySupIdSql; 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 from hrmsubcompany where id = ?"; + querySupIdSql = "select companyId as supComId,supsubcomid as supId,'s' as ftype from hrmsubcompany where id = ?"; } else { - querySupIdSql = "select subcompanyid1 as supComId,supdepid as supId from hrmdepartment where id = ?"; + querySupIdSql = "select subcompanyid1 as supComId,supdepid as supId,'d' as ftype from hrmdepartment where id = ?"; } + recordSet.executeQuery(querySupIdSql, targetId); + if (recordSet.next()) { + supId = Util.null2String(recordSet.getString("supId")); + supComId = Util.null2String(recordSet.getString("supComId")); + ftype = Util.null2String(recordSet.getString("ftype")); + } 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), "部门不能拖拽至集团下"); @@ -712,8 +714,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService } // 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()); +// 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)) { @@ -722,6 +725,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService 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)); + } } else if ("c".equals(targetType)) { OrganizationAssert.isFalse("d".equals(sourceType), "部门不能拖拽到集团下"); Map params = new HashMap<>(); @@ -740,13 +747,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService deptById.setSupDepId(Util.getIntValue(targetId)); DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(targetId)); deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1()); - // 更新EC部门 - updateEcDepartment(deptById); - // 刷新岗位分部 - List deptList = getDepartmentMapper().getDeptListByPId(deptById.getId()); - forbiddenChildTag(deptById.getSubCompanyId1(), deptList); } } + // 更新EC部门 + updateEcDepartment(deptById); + // 刷新岗位分部 + List deptList = getDepartmentMapper().getDeptListByPId(deptById.getId()); + forbiddenChildTag(deptById.getSubCompanyId1(), deptList); return 1; }