部门合并、转移
This commit is contained in:
parent
076d099715
commit
96e8042156
|
|
@ -5,6 +5,7 @@ import com.engine.organization.entity.department.param.DeptSearchParam;
|
|||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||
import com.engine.organization.entity.searchtree.SearchTree;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||
import com.engine.organization.mapper.employee.EmployeeMapper;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
|
|
@ -32,13 +33,13 @@ public class DepartmentBO {
|
|||
.deptNo(e.getDeptNo())
|
||||
.deptName(e.getDeptName())
|
||||
.deptNameShort(e.getDeptNameShort())
|
||||
.parentComp(e.getParentComp() + "")// 命名
|
||||
.parentComp(null == e.getParentComp() ? "" : MapperProxyFactory.getProxy(CompMapper.class).listById(e.getParentComp()).getCompName())
|
||||
.parentDept(e.getParentDept())
|
||||
.parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept())
|
||||
.getDeptName()).deptPrincipal(getEmployeeNameById(e.getDeptPrincipal()))
|
||||
.parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName())
|
||||
.deptPrincipal(getEmployeeNameById(e.getDeptPrincipal()))
|
||||
.showOrder(null == e.getShowOrder() ? 0 : e.getShowOrder())
|
||||
.forbiddenTag(e.getForbiddenTag())
|
||||
.build()).collect(Collectors.toList());
|
||||
.build() ).collect(Collectors.toList());
|
||||
Map<Long, List<DepartmentListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept));
|
||||
// 处理被引用数据
|
||||
List<String> usedIds = MapperProxyFactory.getProxy(DepartmentMapper.class).listUsedId();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.engine.organization.entity.department.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DepartmentMergeParam {
|
||||
/**
|
||||
* 所选部门
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 合并部门
|
||||
*/
|
||||
private Long department;
|
||||
/**
|
||||
* 合并后名称
|
||||
*/
|
||||
private String mergeName;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.engine.organization.entity.department.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @description: TODO
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DepartmentMoveParam {
|
||||
private Long id;
|
||||
private String moveType;
|
||||
private Long company;
|
||||
private Long department;
|
||||
}
|
||||
|
|
@ -92,6 +92,14 @@ public interface DepartmentMapper {
|
|||
*/
|
||||
int updateForbiddenTagById(DepartmentPO departmentPO);
|
||||
|
||||
/**
|
||||
* 批量禁用部门
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int forbiddenDepartmentByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
|
|
|
|||
|
|
@ -244,6 +244,13 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="forbiddenDepartmentByIds">
|
||||
update jcl_org_dept set forbidden_tag = 1 WHERE delete_type = 0
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
<sql id="likeSQL">
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.api.browser.bean.SearchConditionGroup;
|
||||
import com.engine.organization.entity.department.param.DeptCopyParam;
|
||||
import com.engine.organization.entity.department.param.DeptSearchParam;
|
||||
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||
import com.engine.organization.entity.department.param.*;
|
||||
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.util.page.PageInfo;
|
||||
|
|
@ -122,4 +120,34 @@ public interface DepartmentService {
|
|||
*/
|
||||
int copyDepartment(DeptCopyParam copyParam);
|
||||
|
||||
/**
|
||||
* 获取合并表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SearchConditionGroup> getMergeForm(Long id);
|
||||
|
||||
/**
|
||||
* 合并到指定部门
|
||||
*
|
||||
* @param mergeParam
|
||||
* @return
|
||||
*/
|
||||
int mergeDepartment(DepartmentMergeParam mergeParam);
|
||||
|
||||
/**
|
||||
* 获取转移表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SearchConditionGroup> getMoveForm();
|
||||
|
||||
/**
|
||||
* 转移到指定分部或部门
|
||||
*
|
||||
* @param moveParam
|
||||
* @return
|
||||
*/
|
||||
int moveDepartment(DepartmentMoveParam moveParam);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ import com.engine.organization.entity.company.bo.CompBO;
|
|||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.entity.department.bo.DepartmentBO;
|
||||
import com.engine.organization.entity.department.dto.DepartmentListDTO;
|
||||
import com.engine.organization.entity.department.param.DeptCopyParam;
|
||||
import com.engine.organization.entity.department.param.DeptSearchParam;
|
||||
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||
import com.engine.organization.entity.department.param.*;
|
||||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||
import com.engine.organization.entity.job.po.JobPO;
|
||||
|
|
@ -413,6 +411,104 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
return insertCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchConditionGroup> getMergeForm(Long id) {
|
||||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||||
List<SearchConditionItem> condition = new ArrayList<>();
|
||||
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "合并部门", "161", "department", "deptBrowser");
|
||||
deptBrowserItem.setRules("required|string");
|
||||
SearchConditionItem mergeNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "合并后名称", "mergeName");
|
||||
mergeNameItem.setRules("required|string");
|
||||
String departmentName = getDepartmentMapper().getDeptNameById(id.intValue());
|
||||
mergeNameItem.setValue(departmentName);
|
||||
|
||||
condition.add(deptBrowserItem);
|
||||
condition.add(mergeNameItem);
|
||||
addGroups.add(new SearchConditionGroup("", true, condition));
|
||||
return addGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mergeDepartment(DepartmentMergeParam mergeParam) {
|
||||
int updateCount = 0;
|
||||
OrganizationAssert.isFalse(mergeParam.getId().equals(mergeParam.getDepartment()), "所选部门与待合并部门一致,无需操作");
|
||||
OrganizationAssert.isNull(mergeParam.getDepartment(), "请选择需要合并的部门");
|
||||
OrganizationAssert.isBlank(mergeParam.getMergeName(), "请输入合并后的名称");
|
||||
// 所选部门
|
||||
DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
|
||||
mergeDepartment.setDeptName(mergeParam.getMergeName());
|
||||
mergeDepartment.setDeptNameShort(mergeParam.getMergeName());
|
||||
mergeDepartment.setParentDept(mergeParam.getDepartment());
|
||||
updateCount += getDepartmentMapper().updateBaseDept(mergeDepartment);
|
||||
// 合并后部门及子部门禁用
|
||||
Set<Long> ids = new HashSet<>();
|
||||
ids.add(mergeParam.getId());
|
||||
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(mergeParam.getId());
|
||||
forbiddenChildTag(deptList, ids);
|
||||
updateCount += getDepartmentMapper().forbiddenDepartmentByIds(ids);
|
||||
return updateCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchConditionGroup> getMoveForm() {
|
||||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||||
List<SearchConditionItem> condition = new ArrayList<>();
|
||||
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "请选择部门", "161", "company", "compBrowser");
|
||||
compBrowserItem.setRules("required|string");
|
||||
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "请选择部门", "161", "department", "deptBrowser");
|
||||
deptBrowserItem.setRules("required|string");
|
||||
|
||||
|
||||
List<SearchConditionOption> selectOptions = new ArrayList<>();
|
||||
SearchConditionOption compOption = new SearchConditionOption("0", "公司/分部");
|
||||
SearchConditionOption deptOption = new SearchConditionOption("1", "部门");
|
||||
selectOptions.add(compOption);
|
||||
selectOptions.add(deptOption);
|
||||
SearchConditionItem moveTypeItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "转移到", "moveType");
|
||||
moveTypeItem.setDetailtype(3);
|
||||
|
||||
condition.add(moveTypeItem);
|
||||
condition.add(compBrowserItem);
|
||||
condition.add(deptBrowserItem);
|
||||
addGroups.add(new SearchConditionGroup("", true, condition));
|
||||
return addGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int moveDepartment(DepartmentMoveParam moveParam) {
|
||||
OrganizationAssert.notBlank(moveParam.getMoveType(), "请选择转移类型");
|
||||
DepartmentPO deptById = getDepartmentMapper().getDeptById(moveParam.getId());
|
||||
// 0:公司/分部 1:部门
|
||||
if ("0".equals(moveParam.getMoveType())) {
|
||||
Long company = moveParam.getCompany();
|
||||
OrganizationAssert.notNull(company, "请选择要转移到的公司/分部");
|
||||
deptById.setParentComp(company);
|
||||
deptById.setParentDept(null);
|
||||
} else if ("1".equals(moveParam.getMoveType())) {
|
||||
Long department = moveParam.getDepartment();
|
||||
OrganizationAssert.notNull(department, "请选择要转移到的部门");
|
||||
deptById.setParentDept(department);
|
||||
deptById.setParentComp(null);
|
||||
}
|
||||
return getDepartmentMapper().updateBaseDept(deptById);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有子部门id
|
||||
*
|
||||
* @param deptList
|
||||
* @param ids
|
||||
*/
|
||||
void forbiddenChildTag(List<DepartmentPO> deptList, Set<Long> ids) {
|
||||
if (CollectionUtils.isNotEmpty(deptList)) {
|
||||
for (DepartmentPO departmentPO : deptList) {
|
||||
ids.add(departmentPO.getId());
|
||||
List<DepartmentPO> childList = getDepartmentMapper().getDeptListByPId(departmentPO.getId());
|
||||
forbiddenChildTag(childList, ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为搜索查询
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.DeleteParam;
|
||||
import com.engine.organization.entity.department.param.DeptCopyParam;
|
||||
import com.engine.organization.entity.department.param.DeptSearchParam;
|
||||
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||
import com.engine.organization.entity.department.param.*;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import com.engine.organization.wrapper.DepartmentWrapper;
|
||||
|
|
@ -272,4 +270,54 @@ public class DepartmentController {
|
|||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getMergeForm")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getMergeForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
String id = (String) map.get("id");
|
||||
return ReturnResult.successed(getDepartmentWrapper(user).getMergeForm(Long.parseLong(id)));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/mergeDepartment")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult mergeDepartment(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DepartmentMergeParam mergeParam) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getDepartmentWrapper(user).mergeDepartment(mergeParam));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getMoveForm")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getMoveForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getDepartmentWrapper(user).getMoveForm());
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/moveDepartment")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult moveDepartment(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DepartmentMoveParam moveParam) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getDepartmentWrapper(user).moveDepartment(moveParam));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ package com.engine.organization.wrapper;
|
|||
import com.api.browser.bean.SearchConditionGroup;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.department.param.DeptCopyParam;
|
||||
import com.engine.organization.entity.department.param.DeptSearchParam;
|
||||
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||
import com.engine.organization.entity.department.param.*;
|
||||
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.service.DepartmentService;
|
||||
|
|
@ -151,5 +149,42 @@ public class DepartmentWrapper extends Service {
|
|||
return getDepartmentService(user).copyDepartment(copyParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取合并表单
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public List<SearchConditionGroup> getMergeForm(Long id) {
|
||||
return getDepartmentService(user).getMergeForm(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并到指定部门
|
||||
*
|
||||
* @param mergeParam
|
||||
* @return
|
||||
*/
|
||||
public int mergeDepartment(DepartmentMergeParam mergeParam) {
|
||||
return getDepartmentService(user).mergeDepartment(mergeParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转移表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<SearchConditionGroup> getMoveForm() {
|
||||
return getDepartmentService(user).getMoveForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转移到指定分部或部门
|
||||
*
|
||||
* @param moveParam
|
||||
* @return
|
||||
*/
|
||||
public int moveDepartment(DepartmentMoveParam moveParam) {
|
||||
return getDepartmentService(user).moveDepartment(moveParam);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue