部门管理,更新为EC

pull/227/MERGE^2
dxfeng 3 years ago
parent 4fa38f704c
commit b1b2a9a88a

@ -84,7 +84,9 @@ public class DepartmentBO {
.deptName(param.getDepartmentName())
.deptNameShort(param.getDeptNameShort())
.parentComp(null == param.getParentComp() ? param.getSubcompanyid1() : param.getParentComp())
.ecCompany(param.getEcCompany())
.parentDept(null == param.getParentDept() ? param.getDepartmentid() : param.getParentDept())
.ecDepartment(param.getEcDepartment())
.deptPrincipal(param.getDeptPrincipal())
.showOrder(param.getShowOrder())
.forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1)

@ -26,8 +26,10 @@ public class DeptSearchParam extends BaseQueryParam {
private String deptNameShort;
private Long parentComp;
private Long ecCompany;
private Long parentDept;
private Long ecDepartment;
private Long deptPrincipal;

@ -28,8 +28,10 @@ public class DepartmentPO {
private String deptNameShort;
private Long parentComp;
private Long ecCompany;
private Long parentDept;
private Long ecDepartment;
private Long deptPrincipal; //部门负责人

@ -7,7 +7,9 @@
<result column="dept_name" property="deptName"/>
<result column="dept_name_short" property="deptNameShort"/>
<result column="parent_comp" property="parentComp"/>
<result column="ec_company" property="ecCompany"/>
<result column="parent_dept" property="parentDept"/>
<result column="ec_department" property="ecDepartment"/>
<result column="dept_principal" property="deptPrincipal"/>
<result column="show_order" property="showOrder"/>
<result column="description" property="description"/>
@ -30,7 +32,9 @@
t.dept_name,
t.dept_name_short,
t.parent_comp,
t.ec_company,
t.parent_dept,
t.ec_department,
t.dept_principal,
t.show_order,
t.description,
@ -39,17 +43,19 @@
</sql>
<select id="getDeptListByCompId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select t.id, t.dept_name, t.parent_dept, t.dept_principal, t.parent_dept, t.parent_comp
select
<include refid="baseColumns"/>
from jcl_org_dept t
where delete_type = 0
and parent_comp = #{parentComp}
and parent_comp = #{parentComp}
</select>
<select id="getDeptListByPId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select t.id, t.dept_name, t.parent_dept, t.dept_principal
select
<include refid="baseColumns"/>
from jcl_org_dept t
where delete_type = 0
and parent_dept = #{PId}
and parent_dept = #{PId}
</select>
<select id="getDeptNameById" resultType="string">
@ -65,11 +71,11 @@
from jcl_org_dept t
where delete_type = 0
<include refid="likeSQL"/>
<if test=" departmentPO.parentComp != null ">
and t.parent_comp = #{departmentPO.parentComp}
<if test=" departmentPO.ecCompany != null ">
and t.ec_company = #{departmentPO.ecCompany}
</if>
<if test=" departmentPO.parentDept != null ">
and t.parent_dept = #{departmentPO.parentDept}
<if test=" departmentPO.ecDepartment != null ">
and t.ec_department = #{departmentPO.ecDepartment}
</if>
<if test=" departmentPO.deptPrincipal != null ">
and t.dept_principal = #{departmentPO.deptPrincipal}
@ -211,9 +217,15 @@
<if test="parentComp != null ">
parent_comp,
</if>
<if test="ecCompany != null ">
ec_company,
</if>
<if test="parentDept != null ">
parent_dept,
</if>
<if test="ecDepartment != null ">
ec_department,
</if>
<if test="deptPrincipal != null ">
dept_principal,
</if>
@ -253,9 +265,15 @@
<if test="parentComp != null ">
#{parentComp},
</if>
<if test="ecCompany != null ">
#{ecCompany},
</if>
<if test="parentDept != null ">
#{parentDept},
</if>
<if test="ecDepartment != null ">
#{ecDepartment},
</if>
<if test="deptPrincipal != null ">
#{deptPrincipal},
</if>
@ -303,9 +321,15 @@
<if test="parentComp != null ">
parent_comp,
</if>
<if test="ecCompany != null ">
ec_company,
</if>
<if test="parentDept != null ">
parent_dept,
</if>
<if test="ecDepartment != null ">
ec_department,
</if>
<if test="deptPrincipal != null ">
dept_principal,
</if>
@ -345,9 +369,15 @@
<if test="parentComp != null ">
#{parentComp},
</if>
<if test="ecCompany != null ">
#{ecCompany},
</if>
<if test="parentDept != null ">
#{parentDept},
</if>
<if test="ecDepartment != null ">
#{ecDepartment},
</if>
<if test="deptPrincipal != null ">
#{deptPrincipal},
</if>
@ -372,7 +402,9 @@
dept_name=#{deptName},
dept_name_short=#{deptNameShort},
parent_comp=#{parentComp},
ec_company=#{ecCompany},
parent_dept=#{parentDept},
ec_department=#{ecDepartment},
dept_principal=#{deptPrincipal},
show_order=#{showOrder},
description=#{description},

@ -367,6 +367,8 @@ public class CompServiceImpl extends Service implements CompService {
OrganizationAssert.isFalse(disableIds.contains(targetCompanyId), "请勿选择当前分部本身及其子分部");
CompPO compPO = getCompMapper().listById(companyId);
compPO.setParentCompany(targetCompanyId);
String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(targetCompanyId + "");
compPO.setEcCompany(StringUtils.isNotBlank(ecCompanyId) ? Long.parseLong(ecCompanyId) : null);
Map<String, Object> map = new HashMap<>();
map.put("id", compPO.getId());
map.put("parent_company", compPO.getParentCompany());

@ -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());
}

Loading…
Cancel
Save