复制部门、岗位

pull/120/MERGE^2
dxfeng 3 years ago
parent 2ea923f9c9
commit ff5b1a2e1b

@ -382,23 +382,19 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
OrganizationAssert.notBlank(copyParam.getCompany(), "请指定需要复制的公司/分部");
int insertCount = 0;
List<Long> idList = Arrays.stream(copyParam.getIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
for (Long id : idList) {
DepartmentPO deptById = getDepartmentMapper().getDeptById(id);
int maxShowOrder = getDepartmentMapper().getMaxShowOrder();
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.setShowOrder(maxShowOrder + i + 1);
insertCount += getDepartmentMapper().insertIgnoreNull(deptById);
if ("1".equals(copyParam.getCopyJob())) {
List<JobPO> jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(id);
for (JobPO jobPO : jobPOS) {
// 处理自动编号
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);
}
List<JobPO> jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(idList.get(i));
int maxJobOrder = MapperProxyFactory.getProxy(JobMapper.class).getMaxShowOrder();
recursionCopyJob((long) user.getUID(), jobPOS, deptById.getParentComp(), deptById.getId(), maxJobOrder);
}
}
return insertCount;
@ -585,4 +581,32 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
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) {
// 根据条件获取元素
List<JobListDTO> filterJobPOs = getJobMapper().listByFilter(jobPO,orderSql);
List<JobListDTO> filterJobPOs = getJobMapper().listByFilter(jobPO, orderSql);
// 添加父级元素
List<JobListDTO> jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs);
List<JobListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS);
@ -401,11 +401,14 @@ public class JobServiceImpl extends Service implements JobService {
OrganizationAssert.notBlank(department, "请指定需要复制的部门");
int insertCount = 0;
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
int orderNum = getJobMapper().getMaxShowOrder();
for (Long id : idList) {
orderNum++;
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.setShowOrder(orderNum);
insertCount += getJobMapper().insertIgnoreNull(jobById);
}

Loading…
Cancel
Save