部门拖拽转移

pull/200/head
Mlin 2 years ago
parent 50ee698cc2
commit 32029788c4

@ -160,4 +160,11 @@ public interface DepartmentService {
*/
int moveDepartment(DepartmentMoveParam moveParam);
/**
*
* @param params
* @return
*/
int dragDepartment(Map<String, Object> params);
}

@ -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
*

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

@ -21,6 +21,7 @@ import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.page.PageInfo;
import com.engine.organization.util.response.ReturnResult;
import org.apache.commons.lang.StringUtils;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.Collection;
@ -259,4 +260,19 @@ public class DepartmentWrapper extends OrganizationWrapper {
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(moveParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
return moveDepartment;
}
/**
*
*
* @param moveParam
* @return
*/
@Log(operateType = OperateTypeEnum.MOVE, operateDesc = "拖拽转移部门", operateModule = LogModuleNameEnum.DEPARTMENT)
public int dragDepartment(Map<String, Object> params) {
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Util.getIntValue(Util.null2String(params.get("sourceKey")).substring(1)));
int moveDepartment = getDepartmentService(user).dragDepartment(params);
writeOperateLog(new Object() {
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(params), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
return moveDepartment;
}
}

Loading…
Cancel
Save