|
|
|
@ -468,6 +468,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int copyDepartment(DeptCopyParam copyParam) {
|
|
|
|
|
// TODO 是否复制子部门信息,是否复制子部门岗位信息
|
|
|
|
|
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
|
|
|
|
OrganizationAssert.notBlank(copyParam.getCompany(), "请指定需要复制的公司/分部");
|
|
|
|
|
int insertCount = 0;
|
|
|
|
@ -476,10 +477,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
maxShowOrder = null == maxShowOrder ? 0 : maxShowOrder;
|
|
|
|
|
for (int i = 0; i < idList.size(); i++) {
|
|
|
|
|
DepartmentPO deptById = getDepartmentMapper().getDeptById(idList.get(i));
|
|
|
|
|
deptById.setDeptName(deptById.getDeptName() + "[复制]");
|
|
|
|
|
deptById.setDeptNameShort(deptById.getDeptNameShort() + "[复制]");
|
|
|
|
|
long timeMillis = System.currentTimeMillis();
|
|
|
|
|
deptById.setDeptName(deptById.getDeptName() + "_" + timeMillis);
|
|
|
|
|
deptById.setDeptNameShort(deptById.getDeptNameShort());
|
|
|
|
|
// 处理自动编号
|
|
|
|
|
deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), false));
|
|
|
|
|
deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), timeMillis));
|
|
|
|
|
deptById.setParentComp(EcHrmRelationUtil.getJclCompanyId(copyParam.getCompany()).getId());
|
|
|
|
|
deptById.setEcCompany(Long.parseLong(copyParam.getCompany()));
|
|
|
|
|
deptById.setParentDept(null);
|
|
|
|
@ -504,7 +506,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
if (maxJobOrder == null) {
|
|
|
|
|
maxJobOrder = 0;
|
|
|
|
|
}
|
|
|
|
|
recursionCopyJob((long) user.getUID(), jobPOS, deptById.getParentComp(), deptById.getId(), maxJobOrder);
|
|
|
|
|
recursionCopyJob((long) user.getUID(), jobPOS, deptById.getParentComp(), deptById.getId(), maxJobOrder, timeMillis);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return insertCount;
|
|
|
|
@ -771,11 +773,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
* @param parentDeptId
|
|
|
|
|
* @param orderNum
|
|
|
|
|
*/
|
|
|
|
|
private void recursionCopyJob(Long creator, List<JobPO> jobPOS, Long parentCompId, Long parentDeptId, int orderNum) {
|
|
|
|
|
private void recursionCopyJob(Long creator, List<JobPO> jobPOS, Long parentCompId, Long parentDeptId, int orderNum, long timeMillis) {
|
|
|
|
|
for (JobPO jobPO : jobPOS) {
|
|
|
|
|
orderNum++;
|
|
|
|
|
// 处理自动编号
|
|
|
|
|
jobPO.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobPO.getJobNo(), false));
|
|
|
|
|
jobPO.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobPO.getJobNo(), timeMillis));
|
|
|
|
|
jobPO.setParentDept(parentDeptId);
|
|
|
|
|
jobPO.setCreator(creator);
|
|
|
|
|
jobPO.setCreateTime(new Date());
|
|
|
|
@ -787,7 +789,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
// 处理子级元素
|
|
|
|
|
List<JobPO> jobsByPid = MapperProxyFactory.getProxy(JobMapper.class).getJobsByPid(jobPO.getId());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(jobsByPid)) {
|
|
|
|
|
recursionCopyJob(creator, jobsByPid, parentCompId, parentDeptId, orderNum);
|
|
|
|
|
recursionCopyJob(creator, jobsByPid, parentCompId, parentDeptId, orderNum, timeMillis);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|