From 3bb8c35fb54212bd83685f07a4ae14171e1eb727 Mon Sep 17 00:00:00 2001 From: Mlin Date: Wed, 2 Aug 2023 11:29:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E6=8B=96=E6=8B=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=960802?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DepartmentServiceImpl.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index bbcff0dc..bc5f97a1 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -667,35 +667,29 @@ public class DepartmentServiceImpl extends Service implements DepartmentService @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 sourceType = sourceKey.substring(0,1); + // 部门不能到集团下 + String sourceType = sourceKey.substring(0, 1); String sourceId = sourceKey.substring(1); String targetType = targetKey.substring(0, 1); String targetId = targetKey.substring(1); String supComId = ""; String supId = ""; 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 from hrmsubcompany where id = ?"; - - }else { + } else { querySupIdSql = "select subcompanyid1 as supComId,supdepid as supId from hrmdepartment where id = ?"; } - OrganizationAssert.isFalse("-1".equals(dragPostion),"分部、部门不能转移至与集团平级"); if ("1".equals(dragPostion)) { recordSet.executeQuery(querySupIdSql, targetId); if (recordSet.next()) { @@ -718,32 +712,31 @@ 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)); + DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(supId) == 0 ? Util.getIntValue(supComId) : Util.getIntValue(supId)); deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1()); } - } else { if ("s".equals(targetType)) { - //转移到分部下 + // 转移到分部下 Map params = new HashMap<>(); - params.put("id",sourceId); - params.put("supsubcomid",targetId); + params.put("id", sourceId); + params.put("supsubcomid", targetId); new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync(); } else if ("c".equals(targetType)) { - OrganizationAssert.isFalse("d".equals(sourceType),"部门不能拖拽到集团下"); + OrganizationAssert.isFalse("d".equals(sourceType), "部门不能拖拽到集团下"); Map params = new HashMap<>(); - params.put("id",sourceId); - params.put("supsubcomid","0"); + params.put("id", sourceId); + params.put("supsubcomid", "0"); new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, params).sync(); } else { - //转移到部门下 + // 转移到部门下 List deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(targetId)); Set disableIds = new HashSet<>(); disableIds.add(Util.getIntValue(sourceKey.substring(1))); if (CollectionUtils.isNotEmpty(deptListByPId)) { addDisableIds(disableIds, deptListByPId); } - OrganizationAssert.isFalse( "d".equals(targetType)&&disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门"); + 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());