部门、岗位 合并
This commit is contained in:
parent
db4e066294
commit
d0ea50cec5
|
|
@ -0,0 +1,31 @@
|
|||
package com.engine.organization.entity.job.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/06/02
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class JobMergeParam {
|
||||
/**
|
||||
* 所选分部
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 合并分部
|
||||
*/
|
||||
private Long targetJob;
|
||||
/**
|
||||
* 合并后名称
|
||||
*/
|
||||
private String mergeName;
|
||||
}
|
||||
|
|
@ -94,14 +94,6 @@ public interface DepartmentMapper {
|
|||
*/
|
||||
int updateForbiddenTagById(DepartmentPO departmentPO);
|
||||
|
||||
/**
|
||||
* 批量禁用部门
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int forbiddenDepartmentByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
|
|
|
|||
|
|
@ -238,6 +238,9 @@
|
|||
dept_principal=#{deptPrincipal},
|
||||
show_order=#{showOrder},
|
||||
description=#{description},
|
||||
<if test="forbiddenTag !=null">
|
||||
forbidden_tag=#{forbiddenTag},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
|
@ -259,13 +262,6 @@
|
|||
#{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">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public interface JobMapper {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
List<JobListDTO> listByFilter(@Param("jobPO")JobPO jobPO,@Param("orderSql") String orderSql);
|
||||
List<JobListDTO> listByFilter(@Param("jobPO") JobPO jobPO, @Param("orderSql") String orderSql);
|
||||
|
||||
/**
|
||||
* 展示所有列表数据
|
||||
|
|
@ -36,7 +36,7 @@ public interface JobMapper {
|
|||
* @param jobPO
|
||||
* @return
|
||||
*/
|
||||
List<JobPO> listPOsByFilter(@Param("jobPO")JobPO jobPO);
|
||||
List<JobPO> listPOsByFilter(@Param("jobPO") JobPO jobPO);
|
||||
|
||||
/**
|
||||
* 查询所有数据
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@
|
|||
work_duty=#{workDuty},
|
||||
work_authority=#{workAuthority},
|
||||
show_order=#{showOrder},
|
||||
<if test="forbiddenTag != null">
|
||||
forbidden_tag=#{forbiddenTag},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.api.browser.bean.SearchConditionGroup;
|
||||
import com.engine.organization.entity.job.param.JobMergeParam;
|
||||
import com.engine.organization.entity.job.param.JobSearchParam;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -98,4 +101,19 @@ public interface JobService {
|
|||
int deleteByIds(Collection<Long> ids);
|
||||
|
||||
Map<String, Object> getHrmListByJobId(Long jobId);
|
||||
|
||||
/**
|
||||
* 合并表单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SearchConditionGroup> getMergeForm();
|
||||
|
||||
/**
|
||||
* 合并岗位
|
||||
*
|
||||
* @param mergeParam
|
||||
* @return
|
||||
*/
|
||||
int mergeJob(JobMergeParam mergeParam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,18 +424,22 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
OrganizationAssert.isFalse(mergeParam.getId().equals(mergeParam.getDepartment()), "所选部门与待合并部门一致,无需操作");
|
||||
OrganizationAssert.notNull(mergeParam.getDepartment(), "请选择需要合并的部门");
|
||||
OrganizationAssert.notBlank(mergeParam.getMergeName(), "请输入合并后的名称");
|
||||
// 合并到的部门
|
||||
DepartmentPO targetDepartment = getDepartmentMapper().getDeptById(mergeParam.getDepartment());
|
||||
Long parentComp = targetDepartment.getParentComp();
|
||||
|
||||
// 所选部门
|
||||
DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
|
||||
mergeDepartment.setDeptName(mergeParam.getMergeName());
|
||||
mergeDepartment.setDeptNameShort(mergeParam.getMergeName());
|
||||
mergeDepartment.setParentDept(mergeParam.getDepartment());
|
||||
mergeDepartment.setParentComp(parentComp);
|
||||
// 禁用
|
||||
mergeDepartment.setForbiddenTag(1);
|
||||
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);
|
||||
forbiddenChildTag(parentComp, deptList);
|
||||
return updateCount;
|
||||
}
|
||||
|
||||
|
|
@ -486,15 +490,17 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
/**
|
||||
* 获取所有子部门id
|
||||
*
|
||||
* @param parentComp
|
||||
* @param deptList
|
||||
* @param ids
|
||||
*/
|
||||
void forbiddenChildTag(List<DepartmentPO> deptList, Set<Long> ids) {
|
||||
void forbiddenChildTag(Long parentComp, List<DepartmentPO> deptList) {
|
||||
if (CollectionUtils.isNotEmpty(deptList)) {
|
||||
for (DepartmentPO departmentPO : deptList) {
|
||||
ids.add(departmentPO.getId());
|
||||
departmentPO.setParentComp(parentComp);
|
||||
departmentPO.setForbiddenTag(1);
|
||||
getDepartmentMapper().updateBaseDept(departmentPO);
|
||||
List<DepartmentPO> childList = getDepartmentMapper().getDeptListByPId(departmentPO.getId());
|
||||
forbiddenChildTag(childList, ids);
|
||||
forbiddenChildTag(parentComp, childList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.engine.organization.entity.extend.param.ExtendInfoParams;
|
|||
import com.engine.organization.entity.extend.po.ExtendGroupPO;
|
||||
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
||||
import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
||||
import com.engine.organization.enums.ModuleTypeEnum;
|
||||
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
||||
import com.engine.organization.mapper.extend.*;
|
||||
import com.engine.organization.service.ExtService;
|
||||
|
|
@ -32,13 +33,6 @@ import java.util.stream.Collectors;
|
|||
public class ExtServiceImpl extends Service implements ExtService {
|
||||
|
||||
private static final Integer BROWSER_TYPE = 3;
|
||||
/**
|
||||
* 分组类型
|
||||
* 1:分部
|
||||
* 2:部门
|
||||
* 3:岗位
|
||||
*/
|
||||
private static final String TYPE_JOB = "3";
|
||||
|
||||
private ExtendInfoMapper getExtendInfoMapper() {
|
||||
return MapperProxyFactory.getProxy(ExtendInfoMapper.class);
|
||||
|
|
@ -87,6 +81,10 @@ public class ExtServiceImpl extends Service implements ExtService {
|
|||
item.setRules("required");
|
||||
}
|
||||
}
|
||||
// 分部,上级部门添加提示信息
|
||||
if (1 != viewAttr && ModuleTypeEnum.departmentfielddefined.getValue().toString().equals(groupId) && "parent_dept".equalsIgnoreCase(extendInfoPO.getFieldName())) {
|
||||
item.setHelpfulTip("请先选择所属分部再选择" + extendInfoPO.getFieldNameDesc());
|
||||
}
|
||||
conditionItems.add(item);
|
||||
}
|
||||
return conditionItems;
|
||||
|
|
@ -107,7 +105,7 @@ public class ExtServiceImpl extends Service implements ExtService {
|
|||
item.setViewAttr(3);
|
||||
item.setRules("required");
|
||||
}
|
||||
if (null != autoNoField && extendInfoPO.getFieldName().equals(autoNoField)) {
|
||||
if (StringUtils.isNotBlank(autoNoField) && extendInfoPO.getFieldName().equals(autoNoField)) {
|
||||
// 判断是否开启自动编号
|
||||
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(serialType);
|
||||
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
|
||||
|
|
@ -116,6 +114,10 @@ public class ExtServiceImpl extends Service implements ExtService {
|
|||
item.setRules("");
|
||||
}
|
||||
}
|
||||
// 分部,上级部门添加提示信息
|
||||
if (ModuleTypeEnum.departmentfielddefined.getValue().toString().equals(groupId) && "parent_dept".equalsIgnoreCase(extendInfoPO.getFieldName())) {
|
||||
item.setHelpfulTip("请先选择所属分部再选择" + extendInfoPO.getFieldNameDesc());
|
||||
}
|
||||
conditionItems.add(item);
|
||||
}
|
||||
return conditionItems;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
|||
import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
||||
import com.engine.organization.entity.job.bo.JobBO;
|
||||
import com.engine.organization.entity.job.dto.JobListDTO;
|
||||
import com.engine.organization.entity.job.param.JobMergeParam;
|
||||
import com.engine.organization.entity.job.param.JobSearchParam;
|
||||
import com.engine.organization.entity.job.po.JobDTPO;
|
||||
import com.engine.organization.entity.job.po.JobPO;
|
||||
|
|
@ -438,6 +439,48 @@ public class JobServiceImpl extends Service implements JobService {
|
|||
return result.getResultMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchConditionGroup> getMergeForm() {
|
||||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||||
List<SearchConditionItem> condition = new ArrayList<>();
|
||||
SearchConditionItem deptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "合并到岗位", "161", "targetJob", "jobBrowser");
|
||||
deptBrowserItem.setRules("required");
|
||||
condition.add(deptBrowserItem);
|
||||
addGroups.add(new SearchConditionGroup("", true, condition));
|
||||
return addGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mergeJob(JobMergeParam mergeParam) {
|
||||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||||
int updateCount = 0;
|
||||
OrganizationAssert.notNull(mergeParam.getTargetJob(), "请选择需要合并的部门");
|
||||
Set<Long> disableIds = new HashSet<>();
|
||||
disableIds.add(mergeParam.getId());
|
||||
List<JobPO> jobs = getJobMapper().getJobsByPid(mergeParam.getId());
|
||||
if (CollectionUtils.isNotEmpty(jobs)) {
|
||||
addDisableIds(disableIds, jobs);
|
||||
}
|
||||
OrganizationAssert.isFalse(disableIds.contains(mergeParam.getTargetJob()), "请勿选择当前岗位本身及其子岗位");
|
||||
|
||||
// 合并到的岗位
|
||||
JobPO targetJob = getJobMapper().getJobById(mergeParam.getTargetJob());
|
||||
Long parentDept = targetJob.getParentDept();
|
||||
Long parentComp = targetJob.getParentComp();
|
||||
|
||||
// 原岗位禁用
|
||||
JobPO mergeJob = getJobMapper().getJobById(mergeParam.getId());
|
||||
mergeJob.setForbiddenTag(1);
|
||||
updateCount += getJobMapper().updateBaseJob(mergeJob);
|
||||
|
||||
//TODO 合并该刚岗位下的人员
|
||||
|
||||
// 合并后岗位及子岗位禁用
|
||||
List<JobPO> jobList = getJobMapper().getJobsByPid(mergeParam.getId());
|
||||
forbiddenChildTag(parentComp, parentDept, targetJob.getId(), jobList);
|
||||
return updateCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加查询元素的父级元素
|
||||
*
|
||||
|
|
@ -588,4 +631,39 @@ public class JobServiceImpl extends Service implements JobService {
|
|||
return generateCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有子部门id
|
||||
*
|
||||
* @param parentComp
|
||||
* @param parentDept
|
||||
* @param jobList
|
||||
*/
|
||||
void forbiddenChildTag(Long parentComp, Long parentDept, Long parentJob, List<JobPO> jobList) {
|
||||
if (CollectionUtils.isNotEmpty(jobList)) {
|
||||
for (JobPO job : jobList) {
|
||||
job.setParentComp(parentComp);
|
||||
job.setParentDept(parentDept);
|
||||
job.setParentJob(parentJob);
|
||||
job.setForbiddenTag(1);
|
||||
getJobMapper().updateBaseJob(job);
|
||||
List<JobPO> childJobs = getJobMapper().getJobsByPid(job.getId());
|
||||
forbiddenChildTag(parentComp, parentDept, job.getId(), childJobs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加子元素ID
|
||||
*
|
||||
* @param disableIds
|
||||
* @param jobPOS
|
||||
*/
|
||||
private void addDisableIds(Set<Long> disableIds, List<JobPO> jobPOS) {
|
||||
for (JobPO jobPO : jobPOS) {
|
||||
disableIds.add(jobPO.getId());
|
||||
List<JobPO> jobsByPid = getJobMapper().getJobsByPid(jobPO.getId());
|
||||
addDisableIds(disableIds, jobsByPid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.engine.common.util.ParamUtil;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.DeleteParam;
|
||||
import com.engine.organization.entity.job.param.JobCopyParam;
|
||||
import com.engine.organization.entity.job.param.JobMergeParam;
|
||||
import com.engine.organization.entity.job.param.JobSearchParam;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
|
|
@ -274,5 +275,28 @@ public class JobController {
|
|||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getMergeForm")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult getMergeForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getJobWrapper(user).getMergeForm());
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/mergeJob")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult mergeJob(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody JobMergeParam param) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getJobWrapper(user).mergeJob(param));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.api.browser.bean.SearchConditionGroup;
|
|||
import com.api.browser.bean.SearchConditionItem;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.job.param.JobMergeParam;
|
||||
import com.engine.organization.entity.job.param.JobSearchParam;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.service.JobService;
|
||||
|
|
@ -158,4 +159,12 @@ public class JobWrapper extends Service {
|
|||
Map<String, Object> hrmListByJobId = getJobService(user).getHrmListByJobId(jobId);
|
||||
return ReturnResult.successed(hrmListByJobId);
|
||||
}
|
||||
|
||||
public List<SearchConditionGroup> getMergeForm() {
|
||||
return getJobService(user).getMergeForm();
|
||||
}
|
||||
|
||||
public int mergeJob(JobMergeParam mergeParam) {
|
||||
return getJobService(user).mergeJob(mergeParam);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue