复制部门、岗位
This commit is contained in:
parent
2ea923f9c9
commit
ff5b1a2e1b
|
|
@ -382,23 +382,19 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
OrganizationAssert.notBlank(copyParam.getCompany(), "请指定需要复制的公司/分部");
|
OrganizationAssert.notBlank(copyParam.getCompany(), "请指定需要复制的公司/分部");
|
||||||
int insertCount = 0;
|
int insertCount = 0;
|
||||||
List<Long> idList = Arrays.stream(copyParam.getIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
List<Long> idList = Arrays.stream(copyParam.getIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||||
for (Long id : idList) {
|
int maxShowOrder = getDepartmentMapper().getMaxShowOrder();
|
||||||
DepartmentPO deptById = getDepartmentMapper().getDeptById(id);
|
for (int i = 0; i < idList.size(); i++) {
|
||||||
|
DepartmentPO deptById = getDepartmentMapper().getDeptById(idList.get(i));
|
||||||
// 处理自动编号
|
// 处理自动编号
|
||||||
deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), true));
|
deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), false));
|
||||||
deptById.setParentComp(Long.parseLong(copyParam.getCompany()));
|
deptById.setParentComp(Long.parseLong(copyParam.getCompany()));
|
||||||
|
// 显示顺序字段
|
||||||
|
deptById.setShowOrder(maxShowOrder + i + 1);
|
||||||
insertCount += getDepartmentMapper().insertIgnoreNull(deptById);
|
insertCount += getDepartmentMapper().insertIgnoreNull(deptById);
|
||||||
if ("1".equals(copyParam.getCopyJob())) {
|
if ("1".equals(copyParam.getCopyJob())) {
|
||||||
List<JobPO> jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(id);
|
List<JobPO> jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(idList.get(i));
|
||||||
for (JobPO jobPO : jobPOS) {
|
int maxJobOrder = MapperProxyFactory.getProxy(JobMapper.class).getMaxShowOrder();
|
||||||
// 处理自动编号
|
recursionCopyJob((long) user.getUID(), jobPOS, deptById.getParentComp(), deptById.getId(), maxJobOrder);
|
||||||
jobPO.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobPO.getJobNo(), true));
|
|
||||||
jobPO.setParentDept(deptById.getId());
|
|
||||||
jobPO.setCreator((long) user.getUID());
|
|
||||||
jobPO.setCreateTime(new Date());
|
|
||||||
jobPO.setParentComp(deptById.getParentComp());
|
|
||||||
insertCount += MapperProxyFactory.getProxy(JobMapper.class).insertIgnoreNull(jobPO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return insertCount;
|
return insertCount;
|
||||||
|
|
@ -585,4 +581,32 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
return generateCode;
|
return generateCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归复制岗位信息
|
||||||
|
*
|
||||||
|
* @param creator
|
||||||
|
* @param jobPOS
|
||||||
|
* @param parentCompId
|
||||||
|
* @param parentDeptId
|
||||||
|
* @param orderNum
|
||||||
|
*/
|
||||||
|
private void recursionCopyJob(Long creator, List<JobPO> jobPOS, Long parentCompId, Long parentDeptId, int orderNum) {
|
||||||
|
for (JobPO jobPO : jobPOS) {
|
||||||
|
orderNum++;
|
||||||
|
// 处理自动编号
|
||||||
|
jobPO.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobPO.getJobNo(), false));
|
||||||
|
jobPO.setParentDept(parentDeptId);
|
||||||
|
jobPO.setCreator(creator);
|
||||||
|
jobPO.setCreateTime(new Date());
|
||||||
|
jobPO.setParentComp(parentCompId);
|
||||||
|
jobPO.setShowOrder(orderNum);
|
||||||
|
MapperProxyFactory.getProxy(JobMapper.class).insertIgnoreNull(jobPO);
|
||||||
|
// 处理子级元素
|
||||||
|
List<JobPO> jobsByPid = MapperProxyFactory.getProxy(JobMapper.class).getJobsByPid(jobPO.getId());
|
||||||
|
if (CollectionUtils.isNotEmpty(jobsByPid)) {
|
||||||
|
recursionCopyJob(creator, jobsByPid, parentCompId, parentDeptId, orderNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
// 通过子级遍历父级元素
|
// 通过子级遍历父级元素
|
||||||
if (filter) {
|
if (filter) {
|
||||||
// 根据条件获取元素
|
// 根据条件获取元素
|
||||||
List<JobListDTO> filterJobPOs = getJobMapper().listByFilter(jobPO,orderSql);
|
List<JobListDTO> filterJobPOs = getJobMapper().listByFilter(jobPO, orderSql);
|
||||||
// 添加父级元素
|
// 添加父级元素
|
||||||
List<JobListDTO> jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs);
|
List<JobListDTO> jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs);
|
||||||
List<JobListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS);
|
List<JobListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS);
|
||||||
|
|
@ -401,11 +401,14 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
OrganizationAssert.notBlank(department, "请指定需要复制的部门");
|
OrganizationAssert.notBlank(department, "请指定需要复制的部门");
|
||||||
int insertCount = 0;
|
int insertCount = 0;
|
||||||
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||||
|
int orderNum = getJobMapper().getMaxShowOrder();
|
||||||
for (Long id : idList) {
|
for (Long id : idList) {
|
||||||
|
orderNum++;
|
||||||
JobPO jobById = getJobMapper().getJobById(id);
|
JobPO jobById = getJobMapper().getJobById(id);
|
||||||
// 处理自动编号
|
// 处理自动编号
|
||||||
jobById.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobById.getJobNo(), true));
|
jobById.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobById.getJobNo(), false));
|
||||||
jobById.setParentDept(Long.parseLong(department));
|
jobById.setParentDept(Long.parseLong(department));
|
||||||
|
jobById.setShowOrder(orderNum);
|
||||||
insertCount += getJobMapper().insertIgnoreNull(jobById);
|
insertCount += getJobMapper().insertIgnoreNull(jobById);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue