|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|