|
|
|
@ -219,6 +219,26 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
}
|
|
|
|
|
params.put("show_order", maxShowOrder + 1);
|
|
|
|
|
}
|
|
|
|
|
// 上级分部
|
|
|
|
|
String ecCompany = Util.null2String(params.get("ec_company"));
|
|
|
|
|
if (StringUtils.isNotBlank(ecCompany)) {
|
|
|
|
|
CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecCompany);
|
|
|
|
|
if (null != jclCompanyId) {
|
|
|
|
|
params.put("parent_comp", jclCompanyId.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 上级部门
|
|
|
|
|
String ecDepartment = Util.null2String(params.get("ec_department"));
|
|
|
|
|
if (StringUtils.isNotBlank(ecDepartment)) {
|
|
|
|
|
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecDepartment);
|
|
|
|
|
if (null != jclDepartmentId) {
|
|
|
|
|
params.put("parent_dept", jclDepartmentId.getId());
|
|
|
|
|
// 部门不为空,自动指定所属分部
|
|
|
|
|
params.put("parent_comp", jclDepartmentId.getParentComp());
|
|
|
|
|
params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(jclDepartmentId.getParentComp() + ""));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, params).sync();
|
|
|
|
|
String ecCompanyID = Util.null2String(syncMap.get("id"));
|
|
|
|
|
OrganizationAssert.isTrue(StringUtils.isNotBlank(ecCompanyID), syncMap.get("message").toString());
|
|
|
|
@ -254,10 +274,25 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
deptNo = repeatDetermine(deptNo);
|
|
|
|
|
params.put("dept_no", deptNo);
|
|
|
|
|
}
|
|
|
|
|
// 根据部门,自动获取正确分部
|
|
|
|
|
DepartmentPO parentDept = getDepartmentMapper().getDeptById(searchParam.getParentDept());
|
|
|
|
|
if (null != parentDept) {
|
|
|
|
|
params.put("parent_comp", parentDept.getParentComp());
|
|
|
|
|
// 上级分部
|
|
|
|
|
String ecCompany = Util.null2String(params.get("ec_company"));
|
|
|
|
|
if (StringUtils.isNotBlank(ecCompany)) {
|
|
|
|
|
CompPO jclCompanyId = EcHrmRelationUtil.getJclCompanyId(ecCompany);
|
|
|
|
|
if (null != jclCompanyId) {
|
|
|
|
|
params.put("parent_comp", jclCompanyId.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 上级部门
|
|
|
|
|
String ecDepartment = Util.null2String(params.get("ec_department"));
|
|
|
|
|
if (StringUtils.isNotBlank(ecDepartment)) {
|
|
|
|
|
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecDepartment);
|
|
|
|
|
if (null != jclDepartmentId) {
|
|
|
|
|
params.put("parent_dept", jclDepartmentId.getId());
|
|
|
|
|
// 部门不为空,自动指定所属分部
|
|
|
|
|
params.put("parent_comp", jclDepartmentId.getParentComp());
|
|
|
|
|
params.put("ec_company", EcHrmRelationUtil.getEcCompanyId(jclDepartmentId.getParentComp() + ""));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, params).sync();
|
|
|
|
|
// 更新主表数据
|
|
|
|
@ -267,6 +302,13 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
//更新明细表
|
|
|
|
|
getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_DEPTEXT_DT1, params, searchParam.getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long parentComp = StringUtils.isNotEmpty(Util.null2String(params.get("parent_comp"))) ? Long.parseLong(Util.null2String(params.get("parent_comp"))) : null;
|
|
|
|
|
// 刷新岗位所属分部
|
|
|
|
|
refreshJobComp(searchParam.getId(), parentComp);
|
|
|
|
|
List<DepartmentPO> childList = getDepartmentMapper().getDeptListByPId(searchParam.getId());
|
|
|
|
|
forbiddenChildTag(parentComp, childList, false);
|
|
|
|
|
|
|
|
|
|
return searchParam.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -299,9 +341,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
// 简称
|
|
|
|
|
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "deptNameShort");
|
|
|
|
|
// 所属分部
|
|
|
|
|
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser");
|
|
|
|
|
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "164", "ecCompany", "");
|
|
|
|
|
// 上级部门
|
|
|
|
|
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级部门", "161", "parentDept", "deptBrowser");
|
|
|
|
|
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级部门", "4", "ecDepartment", "");
|
|
|
|
|
// 部门负责人
|
|
|
|
|
SearchConditionItem deptPrincipalBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门负责人", "1", "deptPrincipal", "");
|
|
|
|
|
// 显示顺序
|
|
|
|
@ -405,7 +447,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
public List<SearchConditionGroup> getCopyForm() {
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
List<SearchConditionItem> condition = new ArrayList<>();
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "复制到", "161", "company", "compBrowser");
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "复制到", "164", "company", "");
|
|
|
|
|
compBrowserItem.setRules("required|string");
|
|
|
|
|
List<SearchConditionOption> selectOptions = new ArrayList<>();
|
|
|
|
|
SearchConditionOption Option = new SearchConditionOption("1", "");
|
|
|
|
@ -438,7 +480,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
deptById.setDeptNameShort(deptById.getDeptNameShort() + "[复制]");
|
|
|
|
|
// 处理自动编号
|
|
|
|
|
deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), false));
|
|
|
|
|
deptById.setParentComp(Long.parseLong(copyParam.getCompany()));
|
|
|
|
|
deptById.setParentComp(EcHrmRelationUtil.getJclCompanyId(copyParam.getCompany()).getId());
|
|
|
|
|
deptById.setEcCompany(Long.parseLong(copyParam.getCompany()));
|
|
|
|
|
deptById.setParentDept(null);
|
|
|
|
|
// 显示顺序字段
|
|
|
|
|
deptById.setShowOrder(maxShowOrder + i + 1);
|
|
|
|
@ -471,7 +514,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
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");
|
|
|
|
|
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "合并到部门", "4", "department", "");
|
|
|
|
|
deptBrowserItem.setRules("required|string");
|
|
|
|
|
SearchConditionItem mergeNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "合并后名称", "mergeName");
|
|
|
|
|
mergeNameItem.setRules("required|string");
|
|
|
|
@ -487,13 +530,15 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
@Override
|
|
|
|
|
public int mergeDepartment(DepartmentMergeParam mergeParam) {
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
int updateCount = 0;
|
|
|
|
|
OrganizationAssert.isFalse(mergeParam.getId().equals(mergeParam.getDepartment()), "所选部门与待合并部门一致,无需操作");
|
|
|
|
|
int updateCount;
|
|
|
|
|
Long ecParamDepartment = mergeParam.getDepartment();
|
|
|
|
|
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecParamDepartment + "");
|
|
|
|
|
Long jclParamDepartment = jclDepartmentId.getId();
|
|
|
|
|
OrganizationAssert.isFalse(mergeParam.getId().equals(jclParamDepartment), "所选部门与待合并部门一致,无需操作");
|
|
|
|
|
OrganizationAssert.notNull(mergeParam.getDepartment(), "请选择需要合并的部门");
|
|
|
|
|
OrganizationAssert.notBlank(mergeParam.getMergeName(), "请输入合并后的名称");
|
|
|
|
|
// 合并到的部门
|
|
|
|
|
DepartmentPO targetDepartment = getDepartmentMapper().getDeptById(mergeParam.getDepartment());
|
|
|
|
|
Long parentComp = targetDepartment.getParentComp();
|
|
|
|
|
DepartmentPO targetDepartment = getDepartmentMapper().getDeptById(jclParamDepartment);
|
|
|
|
|
|
|
|
|
|
Set<Long> disableIds = new HashSet<>();
|
|
|
|
|
disableIds.add(mergeParam.getId());
|
|
|
|
@ -507,8 +552,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
|
|
|
|
|
mergeDepartment.setDeptName(mergeParam.getMergeName());
|
|
|
|
|
mergeDepartment.setDeptNameShort(mergeParam.getMergeName());
|
|
|
|
|
mergeDepartment.setParentDept(mergeParam.getDepartment());
|
|
|
|
|
mergeDepartment.setParentComp(parentComp);
|
|
|
|
|
|
|
|
|
|
mergeDepartment.setParentDept(jclParamDepartment);
|
|
|
|
|
mergeDepartment.setEcDepartment(ecParamDepartment);
|
|
|
|
|
mergeDepartment.setParentComp(targetDepartment.getParentComp());
|
|
|
|
|
mergeDepartment.setEcCompany(targetDepartment.getEcCompany());
|
|
|
|
|
// 禁用
|
|
|
|
|
mergeDepartment.setForbiddenTag(1);
|
|
|
|
|
// 更新EC表部门
|
|
|
|
@ -523,7 +571,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
refreshJobComp(mergeDepartment.getId(), mergeDepartment.getParentComp());
|
|
|
|
|
// 合并后部门及子部门禁用
|
|
|
|
|
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(mergeParam.getId());
|
|
|
|
|
forbiddenChildTag(parentComp, deptList, true);
|
|
|
|
|
forbiddenChildTag(targetDepartment.getParentComp(), deptList, true);
|
|
|
|
|
return updateCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -531,8 +579,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
public List<SearchConditionGroup> getMoveForm() {
|
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
|
List<SearchConditionItem> condition = new ArrayList<>();
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "选择分部", "161", "company", "compBrowser");
|
|
|
|
|
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "选择部门", "161", "department", "deptBrowser");
|
|
|
|
|
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "选择分部", "164", "company", "");
|
|
|
|
|
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "选择部门", "4", "department", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SearchConditionOption> selectOptions = new ArrayList<>();
|
|
|
|
@ -560,20 +608,23 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
if ("0".equals(moveParam.getMoveType())) {
|
|
|
|
|
Long company = moveParam.getCompany();
|
|
|
|
|
OrganizationAssert.notNull(company, "请选择要转移到的分部");
|
|
|
|
|
deptById.setParentComp(company);
|
|
|
|
|
deptById.setEcCompany(company);
|
|
|
|
|
deptById.setParentComp(Objects.requireNonNull(EcHrmRelationUtil.getJclCompanyId(company + "")).getId());
|
|
|
|
|
deptById.setParentDept(null);
|
|
|
|
|
} else if ("1".equals(moveParam.getMoveType())) {
|
|
|
|
|
Long department = moveParam.getDepartment();
|
|
|
|
|
OrganizationAssert.notNull(department, "请选择要转移到的部门");
|
|
|
|
|
Long departmentId = Objects.requireNonNull(EcHrmRelationUtil.getJclDepartmentId(department + "")).getId();
|
|
|
|
|
OrganizationAssert.notNull(departmentId, "请选择要转移到的部门");
|
|
|
|
|
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(moveParam.getId());
|
|
|
|
|
Set<Long> disableIds = new HashSet<>();
|
|
|
|
|
disableIds.add(moveParam.getId());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deptListByPId)) {
|
|
|
|
|
addDisableIds(disableIds, deptListByPId);
|
|
|
|
|
}
|
|
|
|
|
OrganizationAssert.isFalse(disableIds.contains(department), "请勿选择当前部门本身及其子部门");
|
|
|
|
|
deptById.setParentDept(department);
|
|
|
|
|
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(department);
|
|
|
|
|
OrganizationAssert.isFalse(disableIds.contains(departmentId), "请勿选择当前部门本身及其子部门");
|
|
|
|
|
deptById.setParentDept(departmentId);
|
|
|
|
|
deptById.setEcDepartment(department);
|
|
|
|
|
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(departmentId);
|
|
|
|
|
deptById.setParentComp(parentDepartment.getParentComp());
|
|
|
|
|
}
|
|
|
|
|
// 更新EC部门
|
|
|
|
@ -599,6 +650,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
if (CollectionUtils.isNotEmpty(deptList)) {
|
|
|
|
|
for (DepartmentPO departmentPO : deptList) {
|
|
|
|
|
departmentPO.setParentComp(parentComp);
|
|
|
|
|
String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(parentComp + "");
|
|
|
|
|
if (StringUtils.isNotBlank(ecCompanyId)) {
|
|
|
|
|
departmentPO.setEcCompany(Long.parseLong(ecCompanyId));
|
|
|
|
|
}
|
|
|
|
|
if (isForbidden) {
|
|
|
|
|
departmentPO.setForbiddenTag(1);
|
|
|
|
|
// 封存EC表部门
|
|
|
|
@ -625,7 +680,14 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean isFilter(DepartmentPO departmentPO) {
|
|
|
|
|
return !(StringUtil.isEmpty(departmentPO.getDeptNo()) && StringUtil.isEmpty(departmentPO.getDeptName()) && StringUtil.isEmpty(departmentPO.getDeptNameShort()) && null == departmentPO.getParentComp() && null == departmentPO.getParentDept() && null == departmentPO.getDeptPrincipal() && null == departmentPO.getShowOrder() && null == departmentPO.getForbiddenTag());
|
|
|
|
|
return !(StringUtil.isEmpty(departmentPO.getDeptNo())
|
|
|
|
|
&& StringUtil.isEmpty(departmentPO.getDeptName())
|
|
|
|
|
&& StringUtil.isEmpty(departmentPO.getDeptNameShort())
|
|
|
|
|
&& null == departmentPO.getEcCompany()
|
|
|
|
|
&& null == departmentPO.getEcDepartment()
|
|
|
|
|
&& null == departmentPO.getDeptPrincipal()
|
|
|
|
|
&& null == departmentPO.getShowOrder()
|
|
|
|
|
&& null == departmentPO.getForbiddenTag());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|