复制BUG修复

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

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

@ -394,7 +394,7 @@ public class JobServiceImpl extends Service implements JobService {
orderNum++; orderNum++;
JobPO jobById = getJobMapper().getJobById(id); JobPO jobById = getJobMapper().getJobById(id);
// 处理自动编号 // 处理自动编号
jobById.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobById.getJobNo(), false)); jobById.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobById.getJobNo(), System.currentTimeMillis()));
jobById.setParentDept(Long.parseLong(department)); jobById.setParentDept(Long.parseLong(department));
jobById.setShowOrder(orderNum); jobById.setShowOrder(orderNum);
insertCount += getJobMapper().insertIgnoreNull(jobById); insertCount += getJobMapper().insertIgnoreNull(jobById);

@ -2,6 +2,10 @@ package com.engine.organization.util.coderule;
import com.engine.hrm.entity.RuleCodeType; import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.util.CodeRuleManager; import com.engine.hrm.util.CodeRuleManager;
import com.engine.organization.entity.codesetting.po.CodeRulePO;
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
import com.engine.organization.util.db.MapperProxyFactory;
import weaver.general.Util;
/** /**
* @description: * @description:
@ -30,14 +34,19 @@ public class CodeRuleUtil {
* *
* @param ruleCodeType * @param ruleCodeType
* @param code * @param code
* @param isCopy * @param timeMillis
* @return * @return
*/ */
public static String generateCode(RuleCodeType ruleCodeType, String code, boolean isCopy) { public static String generateCode(RuleCodeType ruleCodeType, String code, long timeMillis) {
if (isCopy) { if (isAutoCode(ruleCodeType)) {
return generateCode(ruleCodeType, code); return generateCode(ruleCodeType, "");
} else { } else {
return generateCode(ruleCodeType, code + "_cp"); return generateCode(ruleCodeType, Util.null2String(code) + "_" + timeMillis);
} }
} }
private static boolean isAutoCode(RuleCodeType ruleCodeType) {
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(ruleCodeType.getValue());
return null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable());
}
} }

Loading…
Cancel
Save