diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index 8f10abcc..b421e863 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -140,4 +140,22 @@ public interface CompMapper { * @return */ int getMaxShowOrder(); + + /** + * 根据名称和上级查找ID + * + * @param companyName + * @param parentCompany + * @return + */ + Long getIdByNameAndPid(@Param("companyName") String companyName, @Param("parentCompany") Long parentCompany); + + /** + * 统计顶层分部个数 + * + * @param parentCompany + * @return + */ + Integer countTopCompany(@Param("parentCompany") Long parentCompany); + } diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index ad99cb0a..2abb7f43 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -52,6 +52,21 @@ and NVL(parent_company,'0')='0' + + and ifnull(parent_company,0) = + #{parentCompany} + + + + and isnull(parent_company,0) = + #{parentCompany} + + + + and NVL(parent_company,0) = + #{parentCompany} + + INSERT INTO jcl_org_comp @@ -263,6 +278,16 @@ select max(show_order) from jcl_org_comp + + update jcl_org_comp diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.java b/src/com/engine/organization/mapper/department/DepartmentMapper.java index 8445ee0e..6b4c470c 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.java +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.java @@ -114,4 +114,13 @@ public interface DepartmentMapper { * @return */ int getMaxShowOrder(); + + /** + * 根据名称、上级 查询部门元素 + * @param departmentName + * @param parentCompany + * @param parentDepartment + * @return + */ + Long getIdByNameAndPid(@Param("departmentName") String departmentName, @Param("parentCompany") Long parentCompany, @Param("parentDepartment") Long parentDepartment); } diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index ea6e20ed..d316c68e 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -140,6 +140,27 @@ select max(show_order) from jcl_org_dept + + + and ifnull(parent_dept,0) = + #{parentDepartment} + + + + and isnull(parent_dept,0) = + #{parentDepartment} + + + + and NVL(parent_dept,0) = + #{parentDepartment} + getKeyMapByKetField(@Param("keyField") String keyField); } diff --git a/src/com/engine/organization/mapper/hrmresource/HrmResourceMapper.xml b/src/com/engine/organization/mapper/hrmresource/HrmResourceMapper.xml index 3b201228..f96be2e4 100644 --- a/src/com/engine/organization/mapper/hrmresource/HrmResourceMapper.xml +++ b/src/com/engine/organization/mapper/hrmresource/HrmResourceMapper.xml @@ -32,4 +32,14 @@ where delete_type = 0 and id = #{id} + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java new file mode 100644 index 00000000..54983f57 --- /dev/null +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java @@ -0,0 +1,26 @@ +package com.engine.organization.mapper.hrmresource; + + +import com.alibaba.fastjson.JSONObject; + +import java.util.List; + +/** + * @author:dxfeng + * @createTime: 2022/06/30 + * @version: 1.0 + */ +public interface SystemDataMapper { + + JSONObject getSysLanguageByLicense(); + + List getSysLanguageByActivable(); + + List getHrmEducationLevelData(); + + List getHrmJobCallData(); + + List getHrmLocationsByCountryId(); + + List getHrmUseKindData(); +} diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml new file mode 100644 index 00000000..b45522f7 --- /dev/null +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/job/JobMapper.java b/src/com/engine/organization/mapper/job/JobMapper.java index 059548f3..ca39a750 100644 --- a/src/com/engine/organization/mapper/job/JobMapper.java +++ b/src/com/engine/organization/mapper/job/JobMapper.java @@ -131,4 +131,15 @@ public interface JobMapper { * @return */ int getMaxShowOrder(); + + /** + * 根据名字和上级查询岗位信息 + * + * @param jobName + * @param parentCompany + * @param parentDepartment + * @param parentJob + * @return + */ + Long getIdByNameAndPid(@Param("jobName") String jobName, @Param("parentCompany") Long parentCompany, @Param("parentDepartment") Long parentDepartment, @Param("parentJob") Long parentJob); } diff --git a/src/com/engine/organization/mapper/job/JobMapper.xml b/src/com/engine/organization/mapper/job/JobMapper.xml index d6956616..43688af8 100644 --- a/src/com/engine/organization/mapper/job/JobMapper.xml +++ b/src/com/engine/organization/mapper/job/JobMapper.xml @@ -337,6 +337,29 @@ select max(show_order) from jcl_org_job + + + + and ifnull(parent_job,0) = + #{parentJob} + + + + and isnull(parent_job,0) = + #{parentJob} + + + + and NVL(parent_job,0) = + #{parentJob} + diff --git a/src/com/engine/organization/util/saveimport/HrmResourceImportAdaptUtil.java b/src/com/engine/organization/util/saveimport/HrmResourceImportAdaptUtil.java index 0c049b99..0dc8dbea 100644 --- a/src/com/engine/organization/util/saveimport/HrmResourceImportAdaptUtil.java +++ b/src/com/engine/organization/util/saveimport/HrmResourceImportAdaptUtil.java @@ -563,7 +563,6 @@ public class HrmResourceImportAdaptUtil { * @param rowNum 行号 * @param cellNum 列号 * @param cellValue 单元格值 - * @return */ public boolean valExcelDataFormate(int rowNum, int cellNum, String cellValue) { @@ -867,7 +866,6 @@ public class HrmResourceImportAdaptUtil { * * @param cellIndex 列号 * @param rowNum 行号 - * @return */ public String getCellPosition(int cellIndex, int rowNum) { @@ -957,7 +955,6 @@ public class HrmResourceImportAdaptUtil { * 获取excel单元格值 * * @param cell 要读取的单元格对象 - * @return */ public String getCellValue(Cell cell) { String cellValue = ""; @@ -1007,7 +1004,6 @@ public class HrmResourceImportAdaptUtil { /** * 获取指定行、列的单元格值 * - * @param rowNum * @param cellNum * @return */ diff --git a/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java b/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java index 97880b03..9515b003 100644 --- a/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java +++ b/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java @@ -1,9 +1,8 @@ package com.engine.organization.util.saveimport; -import com.engine.common.entity.EncryptFieldEntity; +import com.alibaba.fastjson.JSONObject; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; -import com.engine.encrypt.biz.EncryptFieldConfigComInfo; import com.engine.hrm.entity.RuleCodeType; import com.engine.hrm.service.ImportLogService; import com.engine.hrm.service.impl.ImportLogServiceImpl; @@ -14,6 +13,7 @@ import com.engine.hrm.util.face.ValidateFieldManager; import com.engine.hrm.util.face.bean.CheckItemBean; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.extend.param.ExtendInfoParams; import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam; import com.engine.organization.entity.hrmresource.po.HrmResourcePO; import com.engine.organization.entity.job.po.JobPO; @@ -21,7 +21,9 @@ import com.engine.organization.entity.postion.po.PostInfoPO; import com.engine.organization.entity.postion.po.PostPO; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; +import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.hrmresource.HrmResourceMapper; +import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.post.PostInfoMapper; import com.engine.organization.mapper.post.PostMapper; @@ -30,20 +32,15 @@ import com.engine.organization.util.db.MapperProxyFactory; import ln.LN; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; import weaver.common.DateUtil; import weaver.common.StringUtil; import weaver.conn.RecordSet; -import weaver.encrypt.EncryptUtil; import weaver.general.BaseBean; import weaver.general.PasswordUtil; import weaver.general.Util; import weaver.hrm.User; -import weaver.hrm.common.database.dialect.DbDialectFactory; -import weaver.hrm.common.database.dialect.DialectUtil; import weaver.hrm.definedfield.HrmFieldManager; import weaver.hrm.passwordprotection.manager.HrmResourceManager; -import weaver.hrm.resource.ResourceComInfo; import weaver.hrm.settings.ChgPasswdReminder; import weaver.hrm.settings.RemindSettings; import weaver.join.hrm.in.ImportLog; @@ -73,8 +70,6 @@ public class HrmResourceImportProcessUtil { private final String[] checkKeys = new String[]{"login_id", "work_code"}; - private Map baseTypeMap; //基础信息自定义字段数据库类型与字段名称映射 - private final String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); private final int userlanguage = 7; //登录语言 @@ -129,14 +124,23 @@ public class HrmResourceImportProcessUtil { private PostMapper getPostMapper() { return MapperProxyFactory.getProxy(PostMapper.class); + + } + + private SystemDataMapper getSystemDataMapper() { + return MapperProxyFactory.getProxy(SystemDataMapper.class); + } + + private ExtMapper getExtMapper() { + return MapperProxyFactory.getProxy(ExtMapper.class); } public void setUser(User user) { this.user = user; } - public Map init(HttpServletRequest request) { - Map retmap = new HashMap<>(); + public void init(HttpServletRequest request) { + Map retmap; try { this.user = (User) request.getSession(true).getAttribute("weaver_user@bean"); this.keyField = Util.null2String(request.getParameter("keyField")); @@ -172,68 +176,45 @@ public class HrmResourceImportProcessUtil { int type = StringUtil.parseToInt(license.getScType(), F_N); scCount = StringUtil.parseToInt(license.getScCount(), 0); scCount = type == F_Y ? (Math.max(scCount, 0)) : 0; - RecordSet recordSet = new RecordSet(); + JSONObject sysLanguageByLicense = getSystemDataMapper().getSysLanguageByLicense(); + if (null != sysLanguageByLicense) { + multilanguage = sysLanguageByLicense.getString("multilanguage"); + cnLanguageId = sysLanguageByLicense.getInteger("cnLanguageId"); + } - String sql = "select multilanguage,(select id from syslanguage where language='简体中文' or language='中文') as cnLanguageId from license "; - recordSet.execute(sql); - recordSet.next(); - multilanguage = recordSet.getString("multilanguage"); - cnLanguageId = recordSet.getInt(2); sysLanguage = new HashMap<>(); - recordSet.execute("select id,language from syslanguage where activable=1"); - while (recordSet.next()) { - sysLanguage.put(recordSet.getString(2), recordSet.getInt(1)); + List sysLanguageByActivables = getSystemDataMapper().getSysLanguageByActivable(); + for (JSONObject sysLanguageByActivable : sysLanguageByActivables) { + sysLanguage.put(sysLanguageByActivable.getString("language"), sysLanguageByActivable.getInteger("id")); } - educationlevelMap = new HashMap<>(); - - String educationName = "convToMultiLang(name,7)"; - if ("sqlserver".equalsIgnoreCase(recordSet.getDBType())) { - educationName = "dbo.convToMultiLang(name,7)"; + List hrmEducationLevelDatas = getSystemDataMapper().getHrmEducationLevelData(); + for (JSONObject hrmEducationLevelData : hrmEducationLevelDatas) { + educationlevelMap.put(hrmEducationLevelData.getString("name"), hrmEducationLevelData.getInteger("id")); } - - recordSet.execute(String.format("select id,%s from HrmEducationLevel", educationName)); - - while (recordSet.next()) { - educationlevelMap.put(recordSet.getString(2), recordSet.getInt(1)); - } jobcallMap = new HashMap<>(); - if ("sqlserver".equalsIgnoreCase(recordSet.getDBType())) { - recordSet.execute("select id,dbo.convToMultiLang(name,7) from HrmJobCall"); - } else { - recordSet.execute("select id,convToMultiLang(name,7) from HrmJobCall"); - } - while (recordSet.next()) { - jobcallMap.put(recordSet.getString(2), recordSet.getInt(1)); + List hrmJobCallDatas = getSystemDataMapper().getHrmJobCallData(); + for (JSONObject hrmJobCallData : hrmJobCallDatas) { + jobcallMap.put(hrmJobCallData.getString("name"), hrmJobCallData.getInteger("id")); } locationMap = new HashMap<>(); - if ("sqlserver".equalsIgnoreCase(recordSet.getDBType())) { - recordSet.execute("select id,dbo.convToMultiLang(locationname,7) from HrmLocations where countryid=1"); - } else { - recordSet.execute("select id,convToMultiLang(locationname,7) from HrmLocations where countryid=1"); - } - while (recordSet.next()) { - locationMap.put(recordSet.getString(2), recordSet.getInt(1)); + List hrmLocations = getSystemDataMapper().getHrmLocationsByCountryId(); + for (JSONObject hrmLocation : hrmLocations) { + locationMap.put(hrmLocation.getString("locationname"), hrmLocation.getInteger("id")); } usekindMap = new HashMap<>(); - if ("sqlserver".equalsIgnoreCase(recordSet.getDBType())) { - recordSet.execute("select id,dbo.convToMultiLang(name,7) from HrmUseKind"); - } else { - recordSet.execute("select id,convToMultiLang(name,7) from HrmUseKind"); - } - while (recordSet.next()) { - usekindMap.put(recordSet.getString(2), recordSet.getInt(1)); + List hrmUseKindDatas = getSystemDataMapper().getHrmUseKindData(); + for (JSONObject hrmUseKindData : hrmUseKindDatas) { + usekindMap.put(hrmUseKindData.getString("name"), hrmUseKindData.getInteger("id")); } - } catch (Exception e) { new BaseBean().writeLog(e); } - return retmap; } /** @@ -449,7 +430,7 @@ public class HrmResourceImportProcessUtil { // 助理id if (hrmResourceImportParam.getAssistant_id() != null) { - int assistantId = getAssistantid(hrmResourceImportParam.getAssistant_id(), keyField); + int assistantId = getAssistantId(hrmResourceImportParam.getAssistant_id(), keyField); hrmResourcePO.setAssistantId(assistantId); if (!hrmResourceImportParam.getAssistant_id().equals("") && assistantId == 0) { resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(24678, userlanguage))); @@ -459,7 +440,7 @@ public class HrmResourceImportProcessUtil { // 办公地点 if (hrmResourceImportParam.getLocation_id() != null) { - hrmResourcePO.setLocationId(getLocationid(hrmResourceImportParam.getLocation_id())); + hrmResourcePO.setLocationId(getLocationId(hrmResourceImportParam.getLocation_id())); } else { resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(83533, userlanguage))); continue; @@ -472,7 +453,7 @@ public class HrmResourceImportProcessUtil { } else if ("".equals(hrmResourceImportParam.getEmail().trim())) { hrmResourcePO.setEmail(""); } else { - Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); + Pattern pattern = Pattern.compile("^([a-zA-Z\\d_\\-.]+)@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.)|(([a-zA-Z\\d\\-]+\\.)+))([a-zA-Z]{2,4}|\\d{1,3})(]?)$"); Matcher matcher = pattern.matcher(hrmResourceImportParam.getEmail()); if (!matcher.matches()) { resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(24570, userlanguage))); @@ -491,7 +472,7 @@ public class HrmResourceImportProcessUtil { //工资银行-sunjsh if (hrmResourceImportParam.getBank_id() != null && !"".equals(hrmResourceImportParam.getBank_id())) { - JSONObject jsonObject = new JSONObject(); + org.json.JSONObject jsonObject = new org.json.JSONObject(); jsonObject.put("fieldid", 0); jsonObject.put("fieldhtmltype", 3); jsonObject.put("type", 284); @@ -521,12 +502,12 @@ public class HrmResourceImportProcessUtil { // 职称 if (hrmResourceImportParam.getJob_call() != null) { - int jobcall = getJobcall(hrmResourceImportParam.getJob_call()); + int jobcall = getJobCall(hrmResourceImportParam.getJob_call()); hrmResourcePO.setJobCall(jobcall); } // 系统语言,默认简体中文 if (hrmResourceImportParam.getSystem_language() != null) { - int systemlanguage = getSystemlanguage(hrmResourceImportParam.getSystem_language()); + int systemlanguage = getSystemLanguage(hrmResourceImportParam.getSystem_language()); if (systemlanguage == -1) { //只能选择简体中文|Englisth|繁体中文 resultList.add(createLog(hrmResourceImportParam, "创建", "失败", SystemEnv.getHtmlLabelName(518929, userlanguage))); @@ -560,7 +541,7 @@ public class HrmResourceImportProcessUtil { } // 学历 if (hrmResourceImportParam.getEducation_level() != null) { - int educationLevel = getEducationlevel(hrmResourceImportParam.getEducation_level()); + int educationLevel = getEducationLevel(hrmResourceImportParam.getEducation_level()); hrmResourcePO.setEducationLevel(educationLevel); } @@ -570,7 +551,7 @@ public class HrmResourceImportProcessUtil { // 健康状况 if (hrmResourceImportParam.getHealth_info() != null) { - String healthinfo = getHealthinfo(hrmResourceImportParam.getHealth_info()); + String healthinfo = getHealthInfo(hrmResourceImportParam.getHealth_info()); hrmResourcePO.setHealthInfo(healthinfo); } else { hrmResourcePO.setHealthInfo("0"); @@ -607,6 +588,7 @@ public class HrmResourceImportProcessUtil { } else { hrmResourcePO.setJobLevel(0L); } + // 职务分类 Long jobGroupId = null; if (hrmResourceImportParam.getJob_group_id() != null) { List postPOS = getPostMapper().listByName(hrmResourceImportParam.getJob_group_id()); @@ -923,7 +905,7 @@ public class HrmResourceImportProcessUtil { // 助理id if (!"".equals(Util.null2String(hrmResourceImportParam.getAssistant_id()))) { int assistantId; - assistantId = getAssistantid(hrmResourceImportParam.getAssistant_id(), keyField); + assistantId = getAssistantId(hrmResourceImportParam.getAssistant_id(), keyField); if (hrmResourceImportParam.getAssistant_id() != null && !hrmResourceImportParam.getAssistant_id().equals("") && assistantId == 0) { resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(24678, userlanguage))); continue; @@ -932,7 +914,7 @@ public class HrmResourceImportProcessUtil { } // 办公地点 if (!"".equals(Util.null2String(hrmResourceImportParam.getLocation_id()))) { - int locationid = getLocationid(hrmResourceImportParam.getLocation_id()); + int locationid = getLocationId(hrmResourceImportParam.getLocation_id()); hrmResourcePO.setLocationId(locationid); } @@ -943,7 +925,7 @@ public class HrmResourceImportProcessUtil { } else if ("".equals(hrmResourceImportParam.getEmail().trim())) { hrmResourcePO.setEmail(""); } else { - Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); + Pattern pattern = Pattern.compile("^([a-zA-Z\\d_\\-.]+)@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.)|(([a-zA-Z\\d\\-]+\\.)+))([a-zA-Z]{2,4}|\\d{1,3})(]?)$"); Matcher matcher = pattern.matcher(hrmResourceImportParam.getEmail()); if (!matcher.matches()) { resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(24570, userlanguage))); @@ -963,7 +945,7 @@ public class HrmResourceImportProcessUtil { //工资银行-sunjsh if (hrmResourceImportParam.getBank_id() != null && !"".equals(hrmResourceImportParam.getBank_id())) { - JSONObject jsonObject = new JSONObject(); + org.json.JSONObject jsonObject = new org.json.JSONObject(); jsonObject.put("fieldid", 0); jsonObject.put("fieldhtmltype", 3); jsonObject.put("type", 284); @@ -993,11 +975,11 @@ public class HrmResourceImportProcessUtil { } // 职称 if (!"".equals(Util.null2String(hrmResourceImportParam.getJob_call()))) { - hrmResourcePO.setJobCall(getJobcall(hrmResourceImportParam.getJob_call())); + hrmResourcePO.setJobCall(getJobCall(hrmResourceImportParam.getJob_call())); } // 系统语言,默认简体中文 if (!"".equals(Util.null2String(hrmResourceImportParam.getSystem_language()))) { - int systemlanguage = getSystemlanguage(hrmResourceImportParam.getSystem_language()); + int systemlanguage = getSystemLanguage(hrmResourceImportParam.getSystem_language()); if (systemlanguage == -1) { //只能选择简体中文|Englisth|繁体中文 resultList.add(createLog(hrmResourceImportParam, "更新", "失败", SystemEnv.getHtmlLabelName(518929, userlanguage))); @@ -1041,7 +1023,7 @@ public class HrmResourceImportProcessUtil { // 学历 if (!"".equals(Util.null2String(hrmResourceImportParam.getEducation_level()))) { - int educationlevel = getEducationlevel(hrmResourceImportParam.getEducation_level()); + int educationlevel = getEducationLevel(hrmResourceImportParam.getEducation_level()); hrmResourcePO.setEducationLevel(educationlevel); } @@ -1053,7 +1035,7 @@ public class HrmResourceImportProcessUtil { // 健康状况 if (!"".equals(Util.null2String(hrmResourceImportParam.getHealth_info()))) { - String healthinfo = getHealthinfo(hrmResourceImportParam.getHealth_info()); + String healthinfo = getHealthInfo(hrmResourceImportParam.getHealth_info()); hrmResourcePO.setHealthInfo(healthinfo); } @@ -1075,10 +1057,6 @@ public class HrmResourceImportProcessUtil { } else { hrmResourcePO.setSecLevel(Util.getIntValue(hrmResourceImportParam.getSec_level())); } - } else { - // TODO - //安全级别为空时取缓存类中的安全级别 - // hrmResourcePO.setSecLevel(Integer.parseInt(resourcecominfo.getSeclevel(hrmId))); } //职级 @@ -1225,150 +1203,11 @@ public class HrmResourceImportProcessUtil { } } - /** - * 插入基础自定义字段信息 - * - * @param baseFild 存储人员自定义数据的字段 - * @param baseValue 自定义数据值 - * @param id 需要添加自定义信息的人员id - * @return - */ - public boolean addBaseData(String baseFild, String baseValue, int id) { - if (baseFild == null || baseFild.equals("")) return true; - String[] baseValues = baseValue.split(";"); - String[] baseFields = baseFild.split(","); - String fielddbType; - String sql = ""; - RecordSet recordSet = new RecordSet(); - try { - if (baseTypeMap == null) { - baseTypeMap = new HashMap<>(); - String baseSql = "select t1.fieldid,t1.hrm_fieldlable,t1.ismand,t2.fielddbtype,t2.fieldhtmltype,t2.type,t1.dmlurl from cus_formfield t1, cus_formdict t2 where t1.scope='HrmCustomFieldByInfoType' and t1.scopeid=-1 and t1.fieldid=t2.id order by t1.fieldorder"; - recordSet.execute(baseSql); - while (recordSet.next()) { - String fieldid = Util.null2String(recordSet.getString("fieldid")); - String fielddbtype = Util.null2String(recordSet.getString("fielddbtype")); - String fieldhtmltype = Util.null2String(recordSet.getString("fieldhtmltype")); - String type = Util.null2String(recordSet.getString("type")); - String dmlurl = Util.null2String(recordSet.getString("dmlurl")); - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("fieldid", fieldid); - jsonObject.put("fielddbtype", fielddbtype); - jsonObject.put("fieldhtmltype", fieldhtmltype); - jsonObject.put("type", type); - jsonObject.put("dmlurl", dmlurl); - baseTypeMap.put("field" + recordSet.getInt("fieldid"), jsonObject); - } - } - - sql = "insert into cus_fielddata "; - StringBuilder valueStr = new StringBuilder(); - for (int i = 0; i < baseFields.length; i++) { - JSONObject jsonObject = baseTypeMap.get(baseFields[i]); - fielddbType = jsonObject.getString("fielddbtype"); - jsonObject.put("fieldvalue", baseValues[i]); - String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); - - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) - valueStr.append(",").append("'").append(!fieldvalue.equals("") ? fieldvalue : "").append("'"); - else valueStr.append(",").append(!fieldvalue.equals("") ? fieldvalue : "NULL"); - } - valueStr = new StringBuilder(valueStr.substring(1)); - sql += "(scope,scopeid,id," + baseFild + ") values('HrmCustomFieldByInfoType'," + -1 + "," + id + "," + valueStr + ")"; - } catch (Exception e) { - new BaseBean().writeLog(e); - } - recordSet.setNoAutoEncrypt(true); - return recordSet.execute(sql); - } - - - /** - * 更新基础自定义字段 - * - * @param baseFild 存储人员自定义数据的字段 - * @param baseValue 自定义数据值 - * @param id 需要添加自定义信息的人员id - * @return - */ - public boolean updateBaseData(String baseFild, String baseValue, int id) { - if (baseFild == null || baseFild.equals("")) { - return true; - } - - //检查cus_fielddata表中是否存在,对应id人员的基础自定义信息,如果不存在则向数据库添加 - RecordSet recordSet = new RecordSet(); - String checkbaseInfo = "select id from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=" + id; - recordSet.execute(checkbaseInfo); - if (!recordSet.next()) { - return addBaseData(baseFild, baseValue, id); - } - - String[] baseValues = baseValue.split(";"); - String[] baseFields = baseFild.split(","); - String fielddbType; - String sql = ""; - String scopeId = "-1"; - EncryptUtil encryptUtil = new EncryptUtil(); - boolean flag = false; - try { - if (baseTypeMap == null) { - baseTypeMap = new HashMap<>(); - String personSql = "select t1.fieldid,t1.hrm_fieldlable,t1.ismand,t2.fielddbtype,t2.fieldhtmltype,t2.type,t1.dmlurl from cus_formfield t1, cus_formdict t2 where t1.scope='HrmCustomFieldByInfoType' and t1.scopeid=-1 and t1.fieldid=t2.id order by t1.fieldorder"; - recordSet.execute(personSql); - while (recordSet.next()) { - String fieldid = Util.null2String(recordSet.getString("fieldid")); - String fielddbtype = Util.null2String(recordSet.getString("fielddbtype")); - String fieldhtmltype = Util.null2String(recordSet.getString("fieldhtmltype")); - String type = Util.null2String(recordSet.getString("type")); - String dmlurl = Util.null2String(recordSet.getString("dmlurl")); - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("fieldid", fieldid); - jsonObject.put("fielddbtype", fielddbtype); - jsonObject.put("fieldhtmltype", fieldhtmltype); - jsonObject.put("type", type); - jsonObject.put("dmlurl", dmlurl); - baseTypeMap.put("field" + recordSet.getInt("fieldid"), jsonObject); - } - } - - sql = "update cus_fielddata set "; - StringBuilder setStr = new StringBuilder(); - for (int i = 0; i < baseFields.length; i++) { - String fieldname = baseFields[i]; - JSONObject jsonObject = baseTypeMap.get(baseFields[i]); - fielddbType = jsonObject.getString("fielddbtype"); - jsonObject.put("fieldvalue", baseValues[i]); - String fieldvalue = HrmFieldManager.getReallyFieldvalue(jsonObject); - EncryptFieldEntity encryptFieldEntity = new EncryptFieldConfigComInfo().getFieldEncryptConfig("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId); - if (encryptFieldEntity != null && encryptFieldEntity.getIsEncrypt().equals("1")) { - //是否需要加密 - fieldvalue = Util.null2String(encryptUtil.encryt("cus_fielddata", fieldname, "HrmCustomFieldByInfoType", scopeId, fieldvalue, fieldvalue)); - } - if (fieldvalue.startsWith(",")) fieldvalue = fieldvalue.substring(1); - if (fieldvalue.endsWith(",")) fieldvalue = fieldvalue.substring(0, fieldvalue.length() - 1); - if (!fieldvalue.equals("")) { - flag = true; - if (fielddbType.toLowerCase().startsWith("char") || fielddbType.toLowerCase().startsWith("varchar") || fielddbType.toLowerCase().startsWith("text")) - setStr.append(",").append(baseFields[i]).append("='").append(fieldvalue).append("'"); - else setStr.append(",").append(baseFields[i]).append("=").append(fieldvalue); - } - } - sql += setStr.substring(1) + " where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=" + id; - } catch (Exception e) { - new BaseBean().writeLog(e); - } - recordSet.setNoAutoEncrypt(true); - return (!flag || recordSet.execute(sql)); - } /** * 根据分部名称获取分部Id,不存在就创建 * * @param subCompanyName 分部名称 eg:泛微广东>泛微深圳 - * @return */ public Long getSubCompanyId(String subCompanyName) { @@ -1380,27 +1219,17 @@ public class HrmResourceImportProcessUtil { long parentId = 0L; int curCount = 0; - String currentidsql; - String sql; - RecordSet recordSet = new RecordSet(); - - String supsubcomidConditon = DbDialectFactory.get(recordSet.getDBType()).isNull("parent_company", 0); - for (String companyName : subCompanyNames) { - if (StringUtil.isNull(companyName)) continue; - - sql = "select id from jcl_org_comp where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(comp_name))," + userlanguage + ")))='" + companyName.trim() + "' and " + supsubcomidConditon + "=" + parentId; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - sql = "select id from jcl_org_comp where ltrim(rtrim(convToMultiLang(ltrim(rtrim(comp_name))," + userlanguage + ")))='" + companyName.trim() + "' and " + supsubcomidConditon + "=" + parentId; + if (StringUtil.isNull(companyName)) { + continue; } - currentidsql = sql + " and (delete_type = 0)"; - currentId = getResultSetId(currentidsql); + + Long companyId = getCompMapper().getIdByNameAndPid(companyName.trim(), parentId); + currentId = null == companyId ? 0 : companyId; if (parentId == 0 && currentId == 0) { - recordSet.execute("select COUNT(id) from jcl_org_comp where " + supsubcomidConditon + " = 0 "); - if (recordSet.next()) { - curCount = recordSet.getInt(1); - } + curCount = getCompMapper().countTopCompany(0L); + } //added by wcd 2015-02-06 [限制分部数] @@ -1439,7 +1268,6 @@ public class HrmResourceImportProcessUtil { * * @param deptNames 部门名称 * @param companyId 所属分部id - * @return */ public Long getDeptId(String deptNames, long companyId) { @@ -1447,24 +1275,12 @@ public class HrmResourceImportProcessUtil { long currentId = 0L; long parentId = 0L; - String currentIdSql; - String sql; - - RecordSet recordSet = new RecordSet(); - - String supdepidConditon = DbDialectFactory.get(recordSet.getDBType()).isNull("parent_dept", 0); - for (String deptName : deptNameArray) { if (deptName == null || deptName.equals("")) { continue; } - - sql = "select id from jcl_org_dept where parent_comp=" + companyId + " and ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(dept_name))," + userlanguage + ")))='" + deptName.trim() + "' and " + supdepidConditon + "=" + parentId; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - sql = "select id from jcl_org_dept where parent_comp=" + companyId + " and ltrim(rtrim(convToMultiLang(ltrim(rtrim(dept_name))," + userlanguage + ")))='" + deptName.trim() + "' and " + supdepidConditon + "=" + parentId; - } - currentIdSql = sql + " and delete_type = 0"; - currentId = getResultSetId(currentIdSql); + Long departmentId = getDepartmentMapper().getIdByNameAndPid(deptName.trim(), companyId, parentId); + currentId = null == departmentId ? 0 : departmentId; if (currentId == 0) { // 如果编码为空 自动生成编码 @@ -1499,22 +1315,13 @@ public class HrmResourceImportProcessUtil { String[] jobNameArray = jobNames.split(">"); long currentId = 0L; long parentId = 0L; - String currentIdSql; - String sql; - RecordSet recordSet = new RecordSet(); - String parentJobConditon = DbDialectFactory.get(recordSet.getDBType()).isNull("parent_job", 0); for (String jobName : jobNameArray) { if (jobName == null || jobName.equals("")) { continue; } - sql = "select id from jcl_org_job where parent_comp=" + companyId + " and parent_dept = " + departmentId + " and ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(job_name))," + userlanguage + ")))='" + jobName.trim() + "' and " + parentJobConditon + "=" + parentId; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - sql = "select id from jcl_org_job where parent_comp=" + companyId + " and parent_dept = " + departmentId + " and ltrim(rtrim(convToMultiLang(ltrim(rtrim(job_name))," + userlanguage + ")))='" + jobName.trim() + "' and " + parentJobConditon + "=" + parentId; - } - currentIdSql = sql + " and delete_type = 0"; - currentId = getResultSetId(currentIdSql); - + Long jobId = getJobMapper().getIdByNameAndPid(jobName.trim(), companyId, departmentId, parentId); + currentId = null == jobId ? 0 : jobId; if (currentId == 0) { // 如果编码为空 自动生成编码 String jobNo = ""; @@ -1543,63 +1350,18 @@ public class HrmResourceImportProcessUtil { } - public static boolean needCheckLicenseForUpdate(ResourceComInfo resourceComInfo, String hrmId, - HrmResourceImportParam importParam) { - String statusOfHrmId = resourceComInfo.getStatus(hrmId); - String loginidOfHrmId = resourceComInfo.getLoginID(hrmId); - String accouttypeOfHrmId = resourceComInfo.getAccountType(hrmId); - - String statusOfExcel = importParam.getStatus(); - String loginidOfExcel = importParam.getLogin_id(); - String accouttypeOfExcel = importParam.getAccount_type(); - - // 1. 历史状态算license 不检查 - if ("0,1,2,3".contains(statusOfHrmId) && StringUtils.isNotBlank(loginidOfHrmId) && !"1".equals(accouttypeOfHrmId)) { - return false; - } - boolean isStatus; - if (StringUtils.isBlank(statusOfExcel)) { - isStatus = "0,1,2,3".contains(statusOfHrmId); - } else { - isStatus = "正式,试用,临时,试用延期".contains(statusOfExcel); - } - boolean isLoginid; - if (StringUtils.isBlank(loginidOfExcel)) { - isLoginid = StringUtils.isNotBlank(loginidOfHrmId); - } else { - isLoginid = StringUtils.isNotBlank(loginidOfExcel); - } - boolean isAccouttype; - if (StringUtils.isBlank(accouttypeOfExcel)) { - isAccouttype = !"1".equals(accouttypeOfHrmId); - } else { - isAccouttype = "主账号".equals(accouttypeOfExcel); - } - - return isStatus && isLoginid && isAccouttype; - - } - /** * 获取直接上级Id和所有上级 * * @param keyFieldValue 上级标记值,eg:编号 * @param keyField 关键字段 - * @return */ public int getManagerId(String keyFieldValue, String keyField) { int managerId = 0; - RecordSet recordSet = new RecordSet(); if (!keyFieldValue.equals("")) { - String selSql = "select id from jcl_org_hrmresource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - selSql = "select id from jcl_org_hrmresource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - } - recordSet.execute(selSql); - while (recordSet.next()) { - managerId = recordSet.getInt("id"); - } + Integer userId = getResourceMapper().getIdByKeyField(keyField, keyFieldValue); + managerId = null == userId ? 0 : userId; } return managerId; } @@ -1609,20 +1371,17 @@ public class HrmResourceImportProcessUtil { * * @param keyFieldValue 助理标记 * @param keyField 关键字段 - * @return */ - public int getAssistantid(String keyFieldValue, String keyField) { + public int getAssistantId(String keyFieldValue, String keyField) { + return getResourceId(keyFieldValue, keyField, 0); + } - int getAssistantid = 0; - RecordSet recordSet = new RecordSet(); + private int getResourceId(String keyFieldValue, String keyField, int resourceId) { if (!keyFieldValue.equals("")) { - String selSql = "select id from jcl_org_hrmresource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - selSql = "select id from jcl_org_hrmresource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - } - getAssistantid = getResultSetId(selSql); + Integer userId = getResourceMapper().getIdByKeyField(keyField, keyFieldValue); + resourceId = null == userId ? 0 : userId; } - return getAssistantid; + return resourceId; } /** @@ -1630,58 +1389,51 @@ public class HrmResourceImportProcessUtil { * * @param keyFieldValue 主账号标记 * @param keyField 关键字段 - * @return */ public Long getBelongId(String keyFieldValue, String keyField) { - int getAssistantid = -1; - RecordSet recordSet = new RecordSet(); - if (!keyFieldValue.equals("")) { - String selSql = "select id from jcl_org_hrmresource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - if (recordSet.getDBType().equalsIgnoreCase("oracle") || DialectUtil.isMySql(recordSet.getDBType()) || recordSet.getDBType().equalsIgnoreCase("postgresql")) { - selSql = "select id from jcl_org_hrmresource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))= '" + keyFieldValue + "'"; - } - getAssistantid = getResultSetId(selSql); - } - return (long) getAssistantid; + return (long) getResourceId(keyFieldValue, keyField, -1); } /** * 办公地点id * - * @param locationname 办公地点名称 - * @return + * @param locationName 办公地点名称 */ - public int getLocationid(String locationname) { - int locationid = 0; - if (!locationname.equals("")) { - locationid = locationMap.getOrDefault(locationname, 0); - if (locationid == 0) { - String insertSql = "insert into HrmLocations(locationname,locationdesc,countryid) values('" + locationname + "','" + locationname + "',1)"; - execSql(insertSql); - String selSql = "select id from HrmLocations where countryid=1 and locationname='" + locationname + "'"; - locationid = getResultSetId(selSql); - locationMap.put(locationname, locationid); + public int getLocationId(String locationName) { + int locationId = 0; + if (!locationName.equals("")) { + locationId = locationMap.getOrDefault(locationName, 0); + if (locationId == 0) { + Map hrmLocationsMap = new HashMap<>(); + hrmLocationsMap.put("locationname", locationName); + hrmLocationsMap.put("locationdesc", locationName); + hrmLocationsMap.put("countryid", 1); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmLocationsMap).build(); + getExtMapper().insertExt(extendInfoParams); + locationId = extendInfoParams.getId().intValue(); + locationMap.put(locationName, locationId); } } - return locationid; + return locationId; } /** * 用工性质id * - * @param usekindname 用工性质名称 - * @return + * @param useKindName 用工性质名称 */ - public int getUseKind(String usekindname) { + public int getUseKind(String useKindName) { int usekindid = 0; - if (!usekindname.equals("")) { - usekindid = usekindMap.getOrDefault(usekindname, 0); + if (!useKindName.equals("")) { + usekindid = usekindMap.getOrDefault(useKindName, 0); if (usekindid == 0) { - String insertSql = "insert into HrmUseKind(name,description) values('" + usekindname + "','" + usekindname + "')"; - execSql(insertSql); - String selSql = "select id from HrmUseKind where name='" + usekindname + "'"; - usekindid = getResultSetId(selSql); - usekindMap.put(usekindname, usekindid); + Map hrmUseKindMap = new HashMap<>(); + hrmUseKindMap.put("name", useKindName); + hrmUseKindMap.put("description", useKindName); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmUseKindMap).build(); + getExtMapper().insertExt(extendInfoParams); + usekindid = extendInfoParams.getId().intValue(); + usekindMap.put(useKindName, usekindid); } } return usekindid; @@ -1690,42 +1442,39 @@ public class HrmResourceImportProcessUtil { /** * 职称 * - * @param jobcall 职称名称 - * @return + * @param jobCall 职称名称 */ - public int getJobcall(String jobcall) { - - int jobcalld = 0; - if (!jobcall.equals("")) { - jobcalld = jobcallMap.getOrDefault(jobcall, 0); - if (jobcalld == 0) { - String insertSql = "insert into HrmJobCall(name) values('" + jobcall + "')"; - execSql(insertSql); - String selSql = "select id from HrmJobCall where name='" + jobcall + "'"; - jobcalld = getResultSetId(selSql); - jobcallMap.put(jobcall, jobcalld); + public int getJobCall(String jobCall) { + int jobCallId = 0; + if (!jobCall.equals("")) { + jobCallId = jobcallMap.getOrDefault(jobCall, 0); + if (jobCallId == 0) { + Map hrmJobCallMap = new HashMap<>(); + hrmJobCallMap.put("name", jobCall); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmJobCallMap).build(); + getExtMapper().insertExt(extendInfoParams); + jobCallId = extendInfoParams.getId().intValue(); + jobcallMap.put(jobCall, jobCallId); } } - return jobcalld; + return jobCallId; } /** * 系统语言 * * @param language 语言 eg:简体中文,English,繁體中文 - * @return */ - public int getSystemlanguage(String language) { + public int getSystemLanguage(String language) { int systemlanguageid = 7; //系统语言默认为中文 - - //如果系统不支持多语言,则返回0 - if ((language.equals("English") || language.equals("繁體中文")) && !multilanguage.equalsIgnoreCase("y")) + if ((language.equals("English") || language.equals("繁體中文")) && !multilanguage.equalsIgnoreCase("y")) { return 0; - + } if (!language.equals("")) { - if (language.equals("简体中文")) systemlanguageid = cnLanguageId; - else { + if (language.equals("简体中文")) { + systemlanguageid = cnLanguageId; + } else { systemlanguageid = sysLanguage.getOrDefault(language, -1); } } @@ -1735,16 +1484,17 @@ public class HrmResourceImportProcessUtil { /** * 工资银行id * - * @param bank1 办公地点名称 - * @return + * @param bank 办公地点名称 */ - public int getBankId(String bank1) { + public int getBankId(String bank) { int id = 0; - if (!bank1.equals("")) { - String insertSql = "insert into hrmbank(bankname,bankdesc) values('" + bank1 + "','" + bank1 + "')"; - execSql(insertSql); - String selSql = "select id from hrmbank where bankname='" + bank1 + "'"; - id = getResultSetId(selSql); + if (!bank.equals("")) { + Map hrmBankMap = new HashMap<>(); + hrmBankMap.put("bankname", bank); + hrmBankMap.put("bankdesc", bank); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmBankMap).build(); + getExtMapper().insertExt(extendInfoParams); + id = extendInfoParams.getId().intValue(); } return id; } @@ -1753,112 +1503,103 @@ public class HrmResourceImportProcessUtil { * 获取员工状态 * * @param status 员工状态值 - * @return */ public int getStatus(String status) { - - int statusid; + int statusId; switch (status) { case "试用": - statusid = 0; + statusId = 0; break; case "临时": - statusid = 2; + statusId = 2; break; case "试用延期": - statusid = 3; + statusId = 3; break; case "解聘": - statusid = 4; + statusId = 4; break; case "离职": - statusid = 5; + statusId = 5; break; case "退休": - statusid = 6; + statusId = 6; break; case "无效": - statusid = 7; + statusId = 7; break; default: - statusid = 1; + statusId = 1; break; } - return statusid; + return statusId; } /** * 获取人员密级 - * - * @return */ public int getClassification(String classification) { - int classificationid; + int classificationId; switch (classification) { case "核心": - classificationid = 0; + classificationId = 0; break; case "重要": - classificationid = 1; + classificationId = 1; break; case "一般": - classificationid = 2; + classificationId = 2; break; default: - classificationid = 3; + classificationId = 3; break; } - return classificationid; + return classificationId; } /** * 获取学历Id * - * @param educationlevel 学历值 - * @return + * @param educationLevel 学历值 */ - public int getEducationlevel(String educationlevel) { - int educationlevelid = 0; - if (!educationlevel.equals("")) { - educationlevelid = educationlevelMap.getOrDefault(educationlevel, 0); - if (educationlevelid == 0) { - String insertSql = "insert into HrmEducationLevel(name,description) values('" + educationlevel + "','" + educationlevel + "')"; - execSql(insertSql); - String selSql = "select id from HrmEducationLevel where name='" + educationlevel + "'"; - educationlevelid = getResultSetId(selSql); - educationlevelMap.put(educationlevel, educationlevelid); + public int getEducationLevel(String educationLevel) { + int educationLevelId = 0; + if (!educationLevel.equals("")) { + educationLevelId = educationlevelMap.getOrDefault(educationLevel, 0); + if (educationLevelId == 0) { + Map hrmEducationLevelMap = new HashMap<>(); + hrmEducationLevelMap.put("name", educationLevel); + hrmEducationLevelMap.put("description", educationLevel); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmEducationLevelMap).build(); + getExtMapper().insertExt(extendInfoParams); + educationLevelId = extendInfoParams.getId().intValue(); + educationlevelMap.put(educationLevel, educationLevelId); } } - return educationlevelid; + return educationLevelId; } /** * 获取身体状况 - * - * @param healthinfo - * @return */ - public String getHealthinfo(String healthinfo) { - - String healthinfoid; - - switch (healthinfo) { + public String getHealthInfo(String healthInfo) { + String healthInfoId; + switch (healthInfo) { case "良好": - healthinfoid = "1"; + healthInfoId = "1"; break; case "一般": - healthinfoid = "2"; + healthInfoId = "2"; break; case "较差": - healthinfoid = "3"; + healthInfoId = "3"; break; default: - healthinfoid = "0"; + healthInfoId = "0"; break; } - - return healthinfoid; + return healthInfoId; } /** @@ -1867,35 +1608,30 @@ public class HrmResourceImportProcessUtil { * @param keyField key值,重复性验证字段 */ public void getKeyMap(String keyField) { - // TODO - RecordSet recordSet = new RecordSet(); - String sql = "select id, account_type, certificate_num, login_id, work_code, ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + "))) as " + keyField + " from jcl_org_hrmresource"; - if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { - sql = "select id, account_type, certificate_num, login_id, work_code, ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + "))) as " + keyField + " from jcl_org_hrmresource"; - } - recordSet.execute(sql); + List keyMaps = getResourceMapper().getKeyMapByKetField(keyField); String cerNum; - while (recordSet.next()) { - for (String key : checkKeys) { - Map checkInfo = checkInfos.get(key); - if (checkInfo == null) { - checkInfo = new HashMap<>(); + for (JSONObject map : keyMaps) { + { + for (String key : checkKeys) { + Map checkInfo = checkInfos.get(key); + if (checkInfo == null) { + checkInfo = new HashMap<>(); + checkInfos.put(key, checkInfo); + } else { + checkInfo = checkInfos.get(key); + } + String val = Util.null2String(map.getString(key)); + checkInfo.put(val, map.getString("id")); checkInfos.put(key, checkInfo); - } else { - checkInfo = checkInfos.get(key); } - String val = Util.null2String(recordSet.getString(key)); - checkInfo.put(val, recordSet.getString("id")); - checkInfos.put(key, checkInfo); - } - cerNum = recordSet.getString("certificate_num"); - keyMap.put(recordSet.getString(keyField), recordSet.getInt("id")); - // TODO - String accounttype = recordSet.getString("account_type"); - if (!"1".equalsIgnoreCase(accounttype)) { - if (StringUtil.isNotNull(cerNum)) { - certificateNums.put(StringUtil.vString(cerNum), recordSet.getInt("id")); + cerNum = map.getString("certificate_num"); + keyMap.put(map.getString(keyField), map.getInteger("id")); + String accountType = map.getString("account_type"); + if (!"1".equalsIgnoreCase(accountType)) { + if (StringUtil.isNotNull(cerNum)) { + certificateNums.put(StringUtil.vString(cerNum), map.getInteger("id")); + } } } } @@ -1904,9 +1640,6 @@ public class HrmResourceImportProcessUtil { /** * 执行插入操作 - * - * @param sql - * @return */ public boolean execSql(String sql) { @@ -1914,26 +1647,6 @@ public class HrmResourceImportProcessUtil { return recordSet.execute(sql); } - /** - * 获得查询结果Id - * - * @param sql 查询语句 - * @return - */ - public int getResultSetId(String sql) { - int currentId = 0; - RecordSet recordSet = new RecordSet(); - recordSet.execute(sql); - try { - while (recordSet.next()) { - currentId = recordSet.getInt("id"); - } - } catch (Exception e) { - e.printStackTrace(); - } - return currentId; - } - /** * 创建日志对象 * @@ -1987,7 +1700,7 @@ public class HrmResourceImportProcessUtil { //整数判断 public static boolean isInteger(String str) { if (str == null) return false; - Pattern pattern = Pattern.compile("[0-9]+"); + Pattern pattern = Pattern.compile("\\d+"); return pattern.matcher(str).matches(); }