自动生成编号
This commit is contained in:
parent
a35d211a25
commit
d53365aba3
|
|
@ -65,7 +65,23 @@ public class CompBO {
|
|||
if (null == param) {
|
||||
return null;
|
||||
}
|
||||
return CompPO.builder().id(param.getId() == null ? 0 : param.getId()).compNo(param.getCompNo()).compName(param.getCompName()).compNameShort(param.getCompNameShort()).parentCompany(param.getParentCompany()).orgCode(param.getOrgCode()).industry(param.getIndustry()).compPrincipal(param.getCompPrincipal()).description(param.getDescription()).forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1).deleteType(0).createTime(new Date()).updateTime(new Date()).creator(employeeId).build();
|
||||
return CompPO
|
||||
.builder()
|
||||
.id(param.getId() == null ? 0 : param.getId())
|
||||
.compNo(param.getCompNo())
|
||||
.compName(param.getCompName())
|
||||
.compNameShort(param.getCompNameShort())
|
||||
.parentCompany(param.getParentCompany())
|
||||
.orgCode(param.getOrgCode())
|
||||
.industry(param.getIndustry())
|
||||
.compPrincipal(param.getCompPrincipal())
|
||||
.description(param.getDescription())
|
||||
.forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1)
|
||||
.deleteType(0)
|
||||
.createTime(new Date())
|
||||
.updateTime(new Date())
|
||||
.creator(employeeId)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package com.engine.organization.mapper.codesetting;
|
||||
|
||||
import com.engine.organization.entity.codesetting.po.CodeRuleDetailPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
|
|
@ -9,4 +14,12 @@ package com.engine.organization.mapper.codesetting;
|
|||
public interface CodeRuleDetailMapper {
|
||||
|
||||
void delete(Long codeRuleId);
|
||||
|
||||
/**
|
||||
* 批量插入明细表数据
|
||||
*
|
||||
* @param codeRuleDetailPOs
|
||||
* @return
|
||||
*/
|
||||
void batchInsert(@Param("codeRuleDetailPOs") List<CodeRuleDetailPO> codeRuleDetailPOs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,17 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.codesetting.CodeRuleDetailMapper">
|
||||
|
||||
<insert id="batchInsert">
|
||||
insert into hrm_coderuledetail (coderuleid, ruletype, rulevalue, showorder) values
|
||||
<foreach collection="codeRuleDetailPOs" item="CodeRuleDetailPO">
|
||||
(#{CodeRuleDetailPO.coderuleId},#{CodeRuleDetailPO.ruleType},#{CodeRuleDetailPO.ruleValue},#{CodeRuleDetailPO.showOrder})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<delete id="delete">
|
||||
delete from JCL_CODERULE_DETAIL where coderule_id = #{codeRuleId}
|
||||
delete
|
||||
from JCL_CODERULE_DETAIL
|
||||
where coderule_id = #{codeRuleId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
@ -13,6 +13,8 @@ public interface CodeRuleMapper {
|
|||
|
||||
Long getCodeRuleId(@Param("serialType") String serialType);
|
||||
|
||||
CodeRulePO getCodeRuleByType(@Param("serialType") String serialType);
|
||||
|
||||
void updateCodeRule(@Param("codeRulePO") CodeRulePO codeRulePO);
|
||||
|
||||
void insertCodeRule(CodeRulePO codeRulePO);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@
|
|||
where serial_type = #{serialType}
|
||||
</select>
|
||||
|
||||
<select id="getCodeRuleByType" resultType="com.engine.organization.entity.codesetting.po.CodeRulePO">
|
||||
select *
|
||||
from hrm_coderule
|
||||
where serialtype = #{serialType}
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateCodeRule" parameterType="com.engine.organization.entity.codesetting.po.CodeRulePO">
|
||||
update JCL_CODERULE
|
||||
|
|
@ -21,7 +27,8 @@
|
|||
</update>
|
||||
|
||||
|
||||
<insert id="insertCodeRule" parameterType="com.engine.organization.entity.codesetting.po.CodeRulePO" keyProperty="id"
|
||||
<insert id="insertCodeRule" parameterType="com.engine.organization.entity.codesetting.po.CodeRulePO"
|
||||
keyProperty="id"
|
||||
keyColumn="id" useGeneratedKeys="true">
|
||||
INSERT INTO JCL_CODERULE
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
|
|||
|
|
@ -197,9 +197,9 @@
|
|||
d.scheme_name,
|
||||
<include refid="baseColumns"/>
|
||||
FROM jcl_org_job t
|
||||
inner join jcl_org_comp a on
|
||||
left join jcl_org_comp a on
|
||||
t.parent_comp = a.id
|
||||
inner join jcl_org_dept b on
|
||||
left join jcl_org_dept b on
|
||||
t.parent_dept = b.id
|
||||
left join jcl_org_sequence c on
|
||||
t.sequence_id = c.id
|
||||
|
|
@ -235,9 +235,9 @@
|
|||
d.scheme_name,
|
||||
<include refid="baseColumns"/>
|
||||
FROM jcl_org_job t
|
||||
inner join jcl_org_comp a on
|
||||
left join jcl_org_comp a on
|
||||
t.parent_comp = a.id
|
||||
inner join jcl_org_dept b on
|
||||
left join jcl_org_dept b on
|
||||
t.parent_dept = b.id
|
||||
left join jcl_org_sequence c on
|
||||
t.sequence_id = c.id
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public interface CodeSettingService {
|
|||
* 保存更新
|
||||
* @param params
|
||||
*/
|
||||
void saveOrUpdateCodeSetting(CodeSaveParam params);
|
||||
String saveOrUpdateCodeSetting(CodeSaveParam params);
|
||||
|
||||
/**
|
||||
* 获取主表id
|
||||
|
|
@ -30,4 +30,10 @@ public interface CodeSettingService {
|
|||
* @return
|
||||
*/
|
||||
Long getCodeRuleId(String serialType);
|
||||
|
||||
/**
|
||||
* 获取编码规则配置信息
|
||||
* @return
|
||||
*/
|
||||
String getCodeSetting(String serialType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.organization.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.hrm.entity.RuleCodeType;
|
||||
|
|
@ -13,6 +14,9 @@ import com.engine.organization.service.CodeSettingService;
|
|||
import com.engine.organization.util.OrganizationAssert;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -29,7 +33,7 @@ import java.util.Map;
|
|||
public class CodeSettingServiceImpl extends Service implements CodeSettingService {
|
||||
|
||||
public CodeSettingService getCodeSettingService(User user) {
|
||||
return ServiceUtil.getService(CodeSettingServiceImpl.class,user);
|
||||
return ServiceUtil.getService(CodeSettingServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -55,27 +59,78 @@ public class CodeSettingServiceImpl extends Service implements CodeSettingServic
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdateCodeSetting(CodeSaveParam params) {
|
||||
OrganizationAssert.notNull(params,"参数不能为空");
|
||||
public String saveOrUpdateCodeSetting(CodeSaveParam params) {
|
||||
OrganizationAssert.notNull(params, "参数不能为空");
|
||||
Long codeRuleId = getCodeSettingService(user).getCodeRuleId(params.getSerialType());
|
||||
CodeRulePO codeRulePO = CodeSettingBO.buildCodeRule(params,(long)user.getUID(),codeRuleId);
|
||||
CodeRulePO codeRulePO = CodeSettingBO.buildCodeRule(params, (long) user.getUID(), codeRuleId);
|
||||
//1.新增或更新主表
|
||||
if (codeRulePO != null) {
|
||||
if (codeRuleId != null) {
|
||||
MapperProxyFactory.getProxy(CodeRuleMapper.class).updateCodeRule(codeRulePO);
|
||||
}else {
|
||||
} else {
|
||||
MapperProxyFactory.getProxy(CodeRuleMapper.class).insertCodeRule(codeRulePO);
|
||||
}
|
||||
|
||||
//2.插入明细表
|
||||
codeRuleId = getCodeSettingService(user).getCodeRuleId(params.getSerialType());
|
||||
MapperProxyFactory.getProxy(CodeRuleDetailMapper.class).delete(codeRuleId);
|
||||
List<CodeRuleDetailPO> codeRuleDetailPO = CodeSettingBO.bulidCodeDetailList(params.getCodeSaveDetailParams(),(long)user.getUID(),codeRuleId);
|
||||
|
||||
|
||||
List<CodeRuleDetailPO> codeRuleDetailPOs = CodeSettingBO.bulidCodeDetailList(params.getCodeSaveDetailParams(), (long) user.getUID(), codeRuleId);
|
||||
if (CollectionUtils.isEmpty(codeRuleDetailPOs)) {
|
||||
MapperProxyFactory.getProxy(CodeRuleDetailMapper.class).batchInsert(codeRuleDetailPOs);
|
||||
}
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
apidatas.put("coderuleid", codeRuleId);
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCodeRuleId(String serialType) {
|
||||
return MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleId(serialType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCodeSetting(String serialType) {
|
||||
Map<String, Object> datas = new HashMap<>();
|
||||
CodeRulePO codeRulePO = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(serialType);
|
||||
if (null != codeRulePO) {
|
||||
datas.put("serialtype", serialType);
|
||||
datas.put("serialenable", Util.null2String(codeRulePO.getSerialEnable(), "0"));
|
||||
String oneselftype = Util.null2String(codeRulePO.getOneselfType(), "");
|
||||
if (StringUtils.isNotEmpty(oneselftype)) {
|
||||
String[] oneselftypes = oneselftype.split(",");
|
||||
// 日期流水
|
||||
Map<String, String> dateSerialMap = new HashMap<>();
|
||||
dateSerialMap.put("enable", "0");
|
||||
// 机构流水
|
||||
Map<String, String> deptSerialMap = new HashMap<>();
|
||||
deptSerialMap.put("enable", "0");
|
||||
// 岗位
|
||||
Map<String, String> jobtitlesSerialMap = new HashMap<>();
|
||||
jobtitlesSerialMap.put("enable", "0");
|
||||
for (String type : oneselftypes) {
|
||||
switch (RuleCodeType.getByValue(type)) {
|
||||
case YEAR:
|
||||
case MONTH:
|
||||
case DAY:
|
||||
dateSerialMap.put("enable", "1");
|
||||
dateSerialMap.put("key", type);
|
||||
break;
|
||||
case SUBCOMPANY:
|
||||
case DEPARTMENT:
|
||||
deptSerialMap.put("enable", "1");
|
||||
deptSerialMap.put("key", type);
|
||||
break;
|
||||
case JOBTITLES:
|
||||
jobtitlesSerialMap.put("enable", "1");
|
||||
jobtitlesSerialMap.put("key", type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
datas.put("dateSerial", dateSerialMap);
|
||||
datas.put("deptSerial", deptSerialMap);
|
||||
datas.put("jobtitlesSerial", jobtitlesSerialMap);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,15 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|||
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;
|
||||
import com.engine.organization.entity.company.dto.CompListDTO;
|
||||
import com.engine.organization.entity.company.param.CompSearchParam;
|
||||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.extend.ExtendGroupMapper;
|
||||
import com.engine.organization.service.CompService;
|
||||
|
|
@ -115,6 +119,13 @@ 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);
|
||||
}
|
||||
List<CompPO> list = getCompMapper().listByNo(Util.null2String(params.getCompNo()));
|
||||
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
||||
CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID());
|
||||
|
|
@ -253,6 +264,13 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
// 编号
|
||||
SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "compNo");
|
||||
compNoItem.setRules("required|string");
|
||||
// 判断是否开启自动编号
|
||||
CodeRulePO codeRuleByType = MapperProxyFactory.getProxy(CodeRuleMapper.class).getCodeRuleByType(RuleCodeType.SUBCOMPANY.getValue());
|
||||
if ("1".equals(codeRuleByType.getSerialEnable())) {
|
||||
compNoItem.setViewAttr(2);
|
||||
compNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
|
||||
}
|
||||
|
||||
// 名称
|
||||
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName");
|
||||
compNameItem.setRules("required|string");
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|||
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;
|
||||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.entity.department.bo.DepartmentBO;
|
||||
|
|
@ -23,6 +26,7 @@ import com.engine.organization.entity.job.po.JobPO;
|
|||
import com.engine.organization.entity.job.vo.SingleJobTreeVO;
|
||||
import com.engine.organization.entity.searchtree.SearchTree;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||
import com.engine.organization.mapper.extend.ExtendGroupMapper;
|
||||
|
|
@ -196,6 +200,14 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
|
||||
@Override
|
||||
public int saveBaseForm(DeptSearchParam params) {
|
||||
try {
|
||||
// 处理自动编号
|
||||
String departmentNo = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
|
||||
DEPARTMENT, params.getDeptNo());
|
||||
params.setDeptNo(departmentNo);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
List<DepartmentPO> list = getDepartmentMapper().listByNo(Util.null2String(params.getDeptNo()));
|
||||
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
||||
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(params, user.getUID());
|
||||
|
|
@ -337,6 +349,11 @@ 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())) {
|
||||
deptNoItem.setViewAttr(2);
|
||||
deptNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
|
||||
}
|
||||
// 名称
|
||||
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "departmentName");
|
||||
deptNameItem.setRules("required|string");
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|||
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;
|
||||
import com.engine.organization.entity.company.bo.CompBO;
|
||||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.entity.department.bo.DepartmentBO;
|
||||
|
|
@ -27,6 +30,7 @@ import com.engine.organization.entity.job.po.JobPO;
|
|||
import com.engine.organization.entity.scheme.po.GradePO;
|
||||
import com.engine.organization.entity.searchtree.SearchTree;
|
||||
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
||||
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||
import com.engine.organization.mapper.extend.ExtendGroupMapper;
|
||||
|
|
@ -284,6 +288,11 @@ 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())) {
|
||||
jobNoItem.setViewAttr(2);
|
||||
jobNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
|
||||
}
|
||||
// 名称
|
||||
SearchConditionItem jobNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "jobName");
|
||||
jobNameItem.setRules("required|string");
|
||||
|
|
@ -377,6 +386,14 @@ 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);
|
||||
}
|
||||
List<JobPO> list = getJobMapper().listByNo(Util.null2String(params.getJobNo()));
|
||||
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
||||
JobPO jobPO = JobBO.convertParamsToPO(params, user.getUID());
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import weaver.hrm.User;
|
|||
public class CodeSettingWrapper extends Service {
|
||||
|
||||
public CodeSettingService getCodeSettingService(User user) {
|
||||
return ServiceUtil.getService(CodeSettingServiceImpl.class,user);
|
||||
return ServiceUtil.getService(CodeSettingServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public ReturnResult getHasRight(String serialtype) {
|
||||
|
|
@ -25,7 +25,6 @@ public class CodeSettingWrapper extends Service {
|
|||
}
|
||||
|
||||
public ReturnResult saveOrUpdateCodeSetting(CodeSaveParam params) {
|
||||
getCodeSettingService(user).saveOrUpdateCodeSetting(params);
|
||||
return ReturnResult.successed();
|
||||
return ReturnResult.successed(getCodeSettingService(user).saveOrUpdateCodeSetting(params));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue