自动编号

pull/58/MERGE^2
dxfeng 3 years ago
parent 0c2a4a3e68
commit ad73710f0d

@ -29,10 +29,10 @@ public class SingleJobTreeVO {
@TableTitle(title = "编号", dataIndex = "jobNo", key = "jobNo")
private String jobNo;
@TableTitle(title = "编号", dataIndex = "jobName", key = "jobName")
@TableTitle(title = "名称", dataIndex = "jobName", key = "jobName")
private String jobName;
@TableTitle(title = "编号", dataIndex = "parentJobName", key = "parentJobName")
@TableTitle(title = "上级岗位", dataIndex = "parentJobName", key = "parentJobName")
private String parentJobName;
private Long parentJob;

@ -11,7 +11,6 @@ import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.util.CodeRuleManager;
import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.codesetting.po.CodeRulePO;
import com.engine.organization.entity.company.bo.CompBO;
@ -26,6 +25,7 @@ import com.engine.organization.service.ExtService;
import com.engine.organization.util.MenuBtn;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.coderule.CodeRuleUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.page.Column;
import com.engine.organization.util.page.PageInfo;
@ -119,13 +119,8 @@ public class CompServiceImpl extends Service implements CompService {
@Override
public int saveBaseComp(CompSearchParam params) {
try {
// 处理自动编号
String compNo = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.SUBCOMPANY, params.getCompNo());
params.setCompNo(compNo);
} catch (Exception e) {
throw new RuntimeException(e);
}
// 自动编号
params.setCompNo(CodeRuleUtil.generateCode(RuleCodeType.SUBCOMPANY, params.getCompNo()));
List<CompPO> list = getCompMapper().listByNo(Util.null2String(params.getCompNo()));
OrganizationAssert.isEmpty(list, "编号不允许重复");
CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID());
@ -252,14 +247,12 @@ public class CompServiceImpl extends Service implements CompService {
compNoItem.setRules("required|string");
// 判断是否开启自动编号
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.SUBCOMPANY.getValue());
if ("1".equals(codeRuleByType.getSerialEnable())) {
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
compNoItem.setViewAttr(2);
compNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
compNoItem.setRules("");
}
getSameFormItem(conditionItems, compNoItem, null);
addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems));
apiDatas.put("condition", addGroups);

@ -10,7 +10,6 @@ import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.util.CodeRuleManager;
import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.codesetting.po.CodeRulePO;
import com.engine.organization.entity.company.bo.CompBO;
@ -35,6 +34,7 @@ import com.engine.organization.service.ExtService;
import com.engine.organization.util.MenuBtn;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.coderule.CodeRuleUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.page.Column;
import com.engine.organization.util.page.PageInfo;
@ -172,13 +172,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override
public int saveBaseForm(DeptSearchParam params) {
try {
// 处理自动编号
params.setDeptNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
DEPARTMENT, params.getDeptNo()));
} catch (Exception e) {
throw new RuntimeException(e);
}
// 自动编号
params.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, params.getDeptNo()));
List<DepartmentPO> list = getDepartmentMapper().listByNo(Util.null2String(params.getDeptNo()));
OrganizationAssert.isEmpty(list, "编号不允许重复");
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(params, user.getUID());
@ -320,8 +315,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "deptNo");
deptNoItem.setRules("required|string");
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.DEPARTMENT.getValue());
if ("1".equals(codeRuleByType.getSerialEnable())) {
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
deptNoItem.setViewAttr(2);
deptNoItem.setRules("");
deptNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
}
// 名称
@ -392,25 +388,15 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List<Long> idList = Arrays.stream(copyParam.getIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
for (Long id : idList) {
DepartmentPO deptById = getDepartmentMapper().getDeptById(id);
try {
// 处理自动编号
deptById.setDeptNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
DEPARTMENT, ""));
} catch (Exception e) {
throw new RuntimeException(e);
}
// 处理自动编号
deptById.setDeptNo(CodeRuleUtil.generateCode(RuleCodeType.DEPARTMENT, deptById.getDeptNo(), true));
deptById.setParentComp(Long.parseLong(copyParam.getCompany()));
insertCount += getDepartmentMapper().insertIgnoreNull(deptById);
if ("1".equals(copyParam.getCopyJob())) {
List<JobPO> jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(id);
for (JobPO jobPO : jobPOS) {
try {
// 处理自动编号
jobPO.setJobNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
JOBTITLES, ""));
} catch (Exception e) {
throw new RuntimeException(e);
}
// 处理自动编号
jobPO.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobPO.getJobNo(), true));
jobPO.setParentDept(deptById.getId());
jobPO.setCreator((long) user.getUID());
jobPO.setCreateTime(new Date());

@ -10,7 +10,6 @@ import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.util.CodeRuleManager;
import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.DeleteParam;
import com.engine.organization.entity.codesetting.po.CodeRulePO;
@ -44,6 +43,7 @@ import com.engine.organization.service.JobService;
import com.engine.organization.util.MenuBtn;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.coderule.CodeRuleUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.page.Column;
import com.engine.organization.util.page.PageInfo;
@ -267,8 +267,9 @@ public class JobServiceImpl extends Service implements JobService {
SearchConditionItem jobNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "jobNo");
jobNoItem.setRules("required|string");
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.JOBTITLES.getValue());
if ("1".equals(codeRuleByType.getSerialEnable())) {
if (null != codeRuleByType && "1".equals(codeRuleByType.getSerialEnable())) {
jobNoItem.setViewAttr(2);
jobNoItem.setRules("");
jobNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
}
// 名称
@ -364,14 +365,8 @@ public class JobServiceImpl extends Service implements JobService {
@Override
public int saveBaseForm(JobSearchParam params) {
try {
// 处理自动编号
String jobNo = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
DEPARTMENT, params.getJobNo());
params.setJobNo(jobNo);
} catch (Exception e) {
throw new RuntimeException(e);
}
// 处理自动编号
params.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, params.getJobNo()));
List<JobPO> list = getJobMapper().listByNo(Util.null2String(params.getJobNo()));
OrganizationAssert.isEmpty(list, "编号不允许重复");
JobPO jobPO = JobBO.convertParamsToPO(params, user.getUID());
@ -422,13 +417,8 @@ public class JobServiceImpl extends Service implements JobService {
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
for (Long id : idList) {
JobPO jobById = getJobMapper().getJobById(id);
try {
// 处理自动编号
jobById.setJobNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
JOBTITLES, ""));
} catch (Exception e) {
throw new RuntimeException(e);
}
// 处理自动编号
jobById.setJobNo(CodeRuleUtil.generateCode(RuleCodeType.JOBTITLES, jobById.getJobNo(), true));
jobById.setParentDept(Long.parseLong(department));
insertCount += getJobMapper().insertIgnoreNull(jobById);
}

@ -0,0 +1,43 @@
package com.engine.organization.util.coderule;
import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.util.CodeRuleManager;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/06/06
* @version: 1.0
*/
public class CodeRuleUtil {
/**
*
*
* @param ruleCodeType
* @param code
* @return
*/
public static String generateCode(RuleCodeType ruleCodeType, String code) {
try {
return CodeRuleManager.getCodeRuleManager().generateRuleCode(ruleCodeType, code);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
*
*
* @param ruleCodeType
* @param code
* @param isCopy
* @return
*/
public static String generateCode(RuleCodeType ruleCodeType, String code, boolean isCopy) {
if (isCopy) {
return generateCode(ruleCodeType, code);
} else {
return generateCode(ruleCodeType, code + "_cp");
}
}
}
Loading…
Cancel
Save