部门拖拽转移优化

pull/200/head
Mlin 2 years ago
parent 315a67173d
commit 63491e9906

@ -0,0 +1,16 @@
package com.engine.organization.entity.department.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DepartmentDragParam {
private Integer dropPosition;
private String sourcekey;
private String targetkey;
}

@ -166,5 +166,5 @@ public interface DepartmentService {
* @param params * @param params
* @return * @return
*/ */
int dragDepartment(Map<String, Object> params); int dragDepartment(DepartmentDragParam departmentDragParam);
} }

@ -666,13 +666,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
} }
@Override @Override
public int dragDepartment(Map<String, Object> params) { public int dragDepartment(DepartmentDragParam departmentDragParam) {
// OrganizationAssert.notNull(params.get("sourcekey"), "请选择一个拖拽源"); // OrganizationAssert.notNull(params.get("sourcekey"), "请选择一个拖拽源");
// OrganizationAssert.notNull(params.get("targetkey"), "请选择一个拖拽目的地"); // OrganizationAssert.notNull(params.get("targetkey"), "请选择一个拖拽目的地");
String sourceKey = Util.null2String(params.get("sourcekey"));// 原目标 String sourceKey = Util.null2String(departmentDragParam.getSourcekey());// 原目标
String targetKey = Util.null2String(params.get("targetkey"));// 目的地 String targetKey = Util.null2String(departmentDragParam.getTargetkey());// 目的地
String dragPostion = Util.null2String(params.get("dragpostion"));// 0:目的里面 1目的外边 String dragPostion = Util.null2String(departmentDragParam.getDropPosition());// 0:目的里面 1目的外边
DepartmentPO deptById = getDepartmentMapper().getDeptById(Util.getIntValue(sourceKey.substring(1))); DepartmentPO deptById = getDepartmentMapper().getDeptById(Util.getIntValue(sourceKey.substring(1)));
@ -682,21 +682,24 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
String targetType = targetKey.substring(0, 1); String targetType = targetKey.substring(0, 1);
String targetId = targetKey.substring(1); String targetId = targetKey.substring(1);
String supId = null; String supComId = "";
String querySupIdSql = null; String supId = "";
String querySupIdSql;
if ("s".equals(targetType)) {// 分部 if ("s".equals(targetType)) {// 分部
querySupIdSql = "select supsubcomid as supId from hrmsubcompany where id = ?"; querySupIdSql = "select companyId as supComId,supsubcomid as supId from hrmsubcompany where id = ?";
} else {
querySupIdSql = "select supdepid as supId from hrmdepartment where id = ?"; }else {
querySupIdSql = "select subcompanyid1 as supComId,supdepid as supId from hrmdepartment where id = ?";
} }
if ("1".equals(dragPostion)) { if ("1".equals(dragPostion)) {
recordSet.executeQuery(querySupIdSql, targetId); recordSet.executeQuery(querySupIdSql, targetId);
if (recordSet.next()) { if (recordSet.next()) {
supId = Util.null2String(recordSet.getString("supId")); supId = Util.null2String(recordSet.getString("supId"));
supComId = Util.null2String(recordSet.getString("supComId"));
} }
OrganizationAssert.isFalse("0".equals(supId), "部门不能直接拖拽至集团下");
if ("s".equals(targetType)) { if ("s".equals(targetType)) {
OrganizationAssert.isFalse("0".equals(supId), "部门不能直接拖拽至集团下");
// 转移到分部外 // 转移到分部外
deptById.setSubCompanyId1(Util.getIntValue(supId)); deptById.setSubCompanyId1(Util.getIntValue(supId));
deptById.setSupDepId(null); deptById.setSupDepId(null);
@ -708,9 +711,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if (CollectionUtils.isNotEmpty(deptListByPId)) { if (CollectionUtils.isNotEmpty(deptListByPId)) {
addDisableIds(disableIds, deptListByPId); addDisableIds(disableIds, deptListByPId);
} }
OrganizationAssert.isFalse(disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门"); // OrganizationAssert.isFalse(disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
deptById.setSupDepId(Util.getIntValue(supId)); deptById.setSupDepId(Util.getIntValue(supId));
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(supId)); DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(supId)==0 ? Util.getIntValue(supComId) : Util.getIntValue(supId));
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1()); deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
} }

@ -335,11 +335,11 @@ public class DepartmentController {
@POST @POST
@Path("/dragDepartment") @Path("/dragDepartment")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public ReturnResult dragDepartment(@Context HttpServletRequest request, @Context HttpServletResponse response) { public ReturnResult dragDepartment(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DepartmentDragParam departmentDragParam) {
try { try {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request); Map<String, Object> params = ParamUtil.request2Map(request);
return ReturnResult.successed(getDepartmentWrapper(user).dragDepartment(params)); return ReturnResult.successed(getDepartmentWrapper(user).dragDepartment(departmentDragParam));
} catch (Exception e) { } catch (Exception e) {
return ReturnResult.exceptionHandle(e); return ReturnResult.exceptionHandle(e);
} }

@ -268,11 +268,11 @@ public class DepartmentWrapper extends OrganizationWrapper {
* @return * @return
*/ */
@Log(operateType = OperateTypeEnum.MOVE, operateDesc = "拖拽转移部门", operateModule = LogModuleNameEnum.DEPARTMENT) @Log(operateType = OperateTypeEnum.MOVE, operateDesc = "拖拽转移部门", operateModule = LogModuleNameEnum.DEPARTMENT)
public int dragDepartment(Map<String, Object> params) { public int dragDepartment(DepartmentDragParam departmentDragParam) {
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Util.getIntValue(Util.null2String(params.get("sourceKey")).substring(1))); DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Util.getIntValue(Util.null2String(departmentDragParam.getSourcekey()).substring(1)));
int moveDepartment = getDepartmentService(user).dragDepartment(params); int moveDepartment = getDepartmentService(user).dragDepartment(departmentDragParam);
writeOperateLog(new Object() { writeOperateLog(new Object() {
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(params), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId())); }.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(departmentDragParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
return moveDepartment; return moveDepartment;
} }
} }

Loading…
Cancel
Save