From 1a1646e8185cbbe25800247e62302f3fdc1cd670 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Fri, 1 Jul 2022 15:37:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HrmResourceImportProcessUtil.java | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java b/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java index 9515b003..dfa0e849 100644 --- a/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java +++ b/src/com/engine/organization/util/saveimport/HrmResourceImportProcessUtil.java @@ -693,9 +693,7 @@ public class HrmResourceImportProcessUtil { boolean flag = true; /*添加人员信息*/ - String insertStr = "insert into jcl_org_hrmresource("; - StringBuilder insertFields = new StringBuilder(); - StringBuilder insertValues = new StringBuilder(); + Map resourceParams = new HashMap<>(); String workCode = hrmResourceImportParam.getWork_code(); workCode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.USER, workCode); @@ -715,40 +713,40 @@ public class HrmResourceImportProcessUtil { boolean isNumber = hrmFieldType.endsWith("Long") || hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float"); if (resourcePOClassField.get(hrmResourcePO) != null) { if (hrmFieldType.endsWith("String")) { - insertFields.append(s).append(","); - insertValues.append("'").append(resourcePOClassField.get(hrmResourcePO)).append("',"); + resourceParams.put(s, resourcePOClassField.get(hrmResourcePO)); } else if (isNumber) { - insertFields.append(s).append(","); String insertValueStr = Util.null2String(resourcePOClassField.get(hrmResourcePO)); if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) { - insertValues.append("null,"); + resourceParams.put(s, null); } else { - insertValues.append(resourcePOClassField.get(hrmResourcePO)).append(","); + resourceParams.put(s, resourcePOClassField.get(hrmResourcePO)); } } } else if (paramClassDeclaredField.get(hrmResourceImportParam) != null) { if (voFieldType.endsWith("String")) { if (Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam)).equals("")) { - insertFields.append(s).append(","); - insertValues.append("null,"); + resourceParams.put(s, null); } else { - insertFields.append(s).append(","); - insertValues.append("'").append(paramClassDeclaredField.get(hrmResourceImportParam)).append("',"); + resourceParams.put(s, paramClassDeclaredField.get(hrmResourceImportParam)); } } else if (isNumber) { - insertFields.append(s).append(","); String insertValueStr = Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam)); if ("".equals(insertValueStr) && recordSet.getDBType().equalsIgnoreCase("postgresql")) { - insertValues.append("null,"); + resourceParams.put(s, null); } else { - insertValues.append(paramClassDeclaredField.get(hrmResourceImportParam)).append(","); + resourceParams.put(s, paramClassDeclaredField.get(hrmResourceImportParam)); } } } } - insertStr = insertStr + insertFields + "creator,delete_type,create_time) values(" + insertValues + createrid + ",'" + 0 + "','" + date + "')"; - if (!execSql(insertStr)) {//添加人员信息 + resourceParams.put("creator", createrid); + resourceParams.put("delete_type", 0); + resourceParams.put("create_time", date); + ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("jcl_org_hrmresource").params(resourceParams).build(); + int insertCount = getExtMapper().insertExt(infoParams); + //添加人员信息 + if (insertCount != 1) { flag = false; } @@ -887,8 +885,9 @@ public class HrmResourceImportProcessUtil { String jobNames = hrmResourceImportParam.getJob_title(); hrmResourcePO.setJobTitle(getJobTitles(companyId, departmentId, jobNames)); } - if (Util.getIntValue(hrmId) < 0) continue; - + if (Util.getIntValue(hrmId) < 0) { + continue; + } // 级序列 if (!"".equals(Util.null2String(hrmResourceImportParam.getManager_id()))) { @@ -1140,7 +1139,7 @@ public class HrmResourceImportProcessUtil { HrmFaceCheckManager.setUserPassowrd(keyMap.get(key) + "", orgPwd); } - StringBuilder updateStr = new StringBuilder("update jcl_org_hrmresource set "); + Map resourceParams = new HashMap<>(); for (int k = 1; k < fields.length; k++) { Field hrmField = resourcePOClass.getDeclaredField(PageInfoSortUtil.underlineToHump(fields[k])); @@ -1154,29 +1153,29 @@ public class HrmResourceImportProcessUtil { if (Util.null2String(hrmField.get(hrmResourcePO)).trim().length() > 0) { if (hrmFieldType.endsWith("String")) { - updateStr.append(fields[k]).append("='").append(hrmField.get(hrmResourcePO)).append("',"); + resourceParams.put(fields[k], hrmField.get(hrmResourcePO)); } else if (hrmFieldType.endsWith("Long") || hrmFieldType.endsWith("Integer") || hrmFieldType.endsWith("Short") || hrmFieldType.endsWith("Float")) { - updateStr.append(fields[k]).append("=").append(hrmField.get(hrmResourcePO)).append(","); + resourceParams.put(fields[k], hrmField.get(hrmResourcePO)); } } else if (Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam)).trim().length() > 0) { if (voFieldType.endsWith("String")) { if (Util.null2String(paramClassDeclaredField.get(hrmResourceImportParam)).equals("")) { - updateStr.append(fields[k]).append("=null,"); + resourceParams.put(fields[k], null); } else { - updateStr.append(fields[k]).append("='").append(paramClassDeclaredField.get(hrmResourceImportParam)).append("',"); + resourceParams.put(fields[k], paramClassDeclaredField.get(hrmResourceImportParam)); } } else if (voFieldType.endsWith("Long") || voFieldType.endsWith("Integer") || voFieldType.endsWith("Short") || voFieldType.endsWith("Float")) { if (voFieldType.endsWith("Integer") && (paramClassDeclaredField.get(hrmResourceImportParam).equals(0x7fffffff))) { - updateStr.append(fields[k]).append("=null,"); + resourceParams.put(fields[k], null); } else { - updateStr.append(fields[k]).append("=").append(paramClassDeclaredField.get(hrmResourceImportParam)).append(","); + resourceParams.put(fields[k], paramClassDeclaredField.get(hrmResourceImportParam)); } } } } - - updateStr.append(" update_time ='").append(DateUtil.getCurrentDate()).append("' where id=").append(keyMap.get(key)); - execSql(updateStr.toString()); + resourceParams.put("update_time", DateUtil.getCurrentDate()); + ExtendInfoParams infoParams = ExtendInfoParams.builder().id((long) keyMap.get(key)).tableName("jcl_org_hrmresource").params(resourceParams).build(); + getExtMapper().updateExt(infoParams); } } catch (Exception e) { //数据异常 @@ -1408,7 +1407,7 @@ public class HrmResourceImportProcessUtil { hrmLocationsMap.put("locationname", locationName); hrmLocationsMap.put("locationdesc", locationName); hrmLocationsMap.put("countryid", 1); - ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmLocationsMap).build(); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmLocationsMap).tableName("HrmLocations").build(); getExtMapper().insertExt(extendInfoParams); locationId = extendInfoParams.getId().intValue(); locationMap.put(locationName, locationId); @@ -1430,7 +1429,7 @@ public class HrmResourceImportProcessUtil { Map hrmUseKindMap = new HashMap<>(); hrmUseKindMap.put("name", useKindName); hrmUseKindMap.put("description", useKindName); - ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmUseKindMap).build(); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmUseKindMap).tableName("HrmUseKind").build(); getExtMapper().insertExt(extendInfoParams); usekindid = extendInfoParams.getId().intValue(); usekindMap.put(useKindName, usekindid); @@ -1451,7 +1450,7 @@ public class HrmResourceImportProcessUtil { if (jobCallId == 0) { Map hrmJobCallMap = new HashMap<>(); hrmJobCallMap.put("name", jobCall); - ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmJobCallMap).build(); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmJobCallMap).tableName("HrmJobCall").build(); getExtMapper().insertExt(extendInfoParams); jobCallId = extendInfoParams.getId().intValue(); jobcallMap.put(jobCall, jobCallId); @@ -1492,7 +1491,7 @@ public class HrmResourceImportProcessUtil { Map hrmBankMap = new HashMap<>(); hrmBankMap.put("bankname", bank); hrmBankMap.put("bankdesc", bank); - ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmBankMap).build(); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmBankMap).tableName("hrmbank").build(); getExtMapper().insertExt(extendInfoParams); id = extendInfoParams.getId().intValue(); } @@ -1571,7 +1570,7 @@ public class HrmResourceImportProcessUtil { Map hrmEducationLevelMap = new HashMap<>(); hrmEducationLevelMap.put("name", educationLevel); hrmEducationLevelMap.put("description", educationLevel); - ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmEducationLevelMap).build(); + ExtendInfoParams extendInfoParams = ExtendInfoParams.builder().params(hrmEducationLevelMap).tableName("HrmEducationLevel").build(); getExtMapper().insertExt(extendInfoParams); educationLevelId = extendInfoParams.getId().intValue(); educationlevelMap.put(educationLevel, educationLevelId);