|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否为搜索查询
|
|
|
|
|
*
|
|
|
|
|