Commit b2c710e1901924cd300997fc997dc280985ac920
1 parent
4a34ada4
1.更新分公司信息
Showing
1 changed file
with
26 additions
and
6 deletions
src/main/java/com/bsth/handler/personnelUpdateHandler.java
| @@ -225,6 +225,23 @@ public class personnelUpdateHandler { | @@ -225,6 +225,23 @@ public class personnelUpdateHandler { | ||
| 225 | unit2company.put("KD01.0111", "22-金高公司"); | 225 | unit2company.put("KD01.0111", "22-金高公司"); |
| 226 | unit2company.put("KD01.0112", "26-南汇公司"); | 226 | unit2company.put("KD01.0112", "26-南汇公司"); |
| 227 | unit2company.put("KD01.0113", "05-杨高公司"); | 227 | unit2company.put("KD01.0113", "05-杨高公司"); |
| 228 | + final Map<String, String> unit2bcompany = new HashMap<>(); | ||
| 229 | + unit2bcompany.put("杨高分公司", "5-杨高分公司"); | ||
| 230 | + unit2bcompany.put("周浦分公司", "6-周浦分公司"); | ||
| 231 | + unit2bcompany.put("川沙分公司", "1-川沙分公司"); | ||
| 232 | + unit2bcompany.put("金桥分公司", "2-金桥分公司"); | ||
| 233 | + unit2bcompany.put("上南六分", "3-上南六分公司"); | ||
| 234 | + unit2bcompany.put("上南三分", "2-上南三分公司"); | ||
| 235 | + unit2bcompany.put("上南一分", "4-上南一分公司"); | ||
| 236 | + unit2bcompany.put("上南二分", "1-上南二分公司"); | ||
| 237 | + unit2bcompany.put("金高二分", "2-二分公司"); | ||
| 238 | + unit2bcompany.put("金高四分", "1-四分公司"); | ||
| 239 | + unit2bcompany.put("金高三分", "3-三分公司"); | ||
| 240 | + unit2bcompany.put("金高一分", "5-一分公司"); | ||
| 241 | + unit2bcompany.put("南汇一分", "1-南汇一分"); | ||
| 242 | + unit2bcompany.put("南汇二分", "2-南汇二分"); | ||
| 243 | + unit2bcompany.put("南汇三分", "3-南汇三分"); | ||
| 244 | + unit2bcompany.put("南汇六分", "6-南汇六分"); | ||
| 228 | 245 | ||
| 229 | PJDataSerivce ss = new PJDataSerivce(PJDataSerivce.WSDL_LOCATION, SERVICE_NAME); | 246 | PJDataSerivce ss = new PJDataSerivce(PJDataSerivce.WSDL_LOCATION, SERVICE_NAME); |
| 230 | PJDataSerivceSoap port = ss.getPJDataSerivceSoap12(); | 247 | PJDataSerivceSoap port = ss.getPJDataSerivceSoap12(); |
| @@ -245,12 +262,13 @@ public class personnelUpdateHandler { | @@ -245,12 +262,13 @@ public class personnelUpdateHandler { | ||
| 245 | logger.info(unintCode + ":" + employeeXml); | 262 | logger.info(unintCode + ":" + employeeXml); |
| 246 | JSONObject json = XmlToJson.xml2Json(employeeXml); | 263 | JSONObject json = XmlToJson.xml2Json(employeeXml); |
| 247 | final JSONArray emps = (JSONArray)json.get("Emp"); | 264 | final JSONArray emps = (JSONArray)json.get("Emp"); |
| 248 | - jdbcTemplate.batchUpdate("insert into bsth_c_employee values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() { | 265 | + jdbcTemplate.batchUpdate("insert into bsth_c_employee values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() { |
| 249 | @Override | 266 | @Override |
| 250 | public void setValues(PreparedStatement ps, int i) throws SQLException { | 267 | public void setValues(PreparedStatement ps, int i) throws SQLException { |
| 251 | JSONObject emp = emps.getJSONObject(i); | 268 | JSONObject emp = emps.getJSONObject(i); |
| 252 | - String jobCode = emp.getString("Code"), company = unit2company.get(unintCode), positName = emp.getString("PositName"); | ||
| 253 | - String[] jobCodeSplit = jobCode.split("-"), companySplit = company.split("-"); | 269 | + String jobCode = emp.getString("Code"), company = unit2company.get(unintCode), positName = emp.getString("PositName"), bcompany = unit2bcompany.get(emp.getString("HRMS_USERFIELD_45")); |
| 270 | + String[] jobCodeSplit = jobCode.split("-"), companySplit = company.split("-"), bcompanySplit = bcompany == null ? null : bcompany.split("-"); | ||
| 271 | + | ||
| 254 | ps.setString(1, jobCode); | 272 | ps.setString(1, jobCode); |
| 255 | ps.setString(2, companySplit[0] + "-" + jobCodeSplit[1]); | 273 | ps.setString(2, companySplit[0] + "-" + jobCodeSplit[1]); |
| 256 | ps.setString(3, jobCodeSplit[1]); | 274 | ps.setString(3, jobCodeSplit[1]); |
| @@ -262,6 +280,8 @@ public class personnelUpdateHandler { | @@ -262,6 +280,8 @@ public class personnelUpdateHandler { | ||
| 262 | ps.setString(9, emp.getString("EnterDeptDate")); | 280 | ps.setString(9, emp.getString("EnterDeptDate")); |
| 263 | ps.setString(10, emp.getString("EnterGroupDate")); | 281 | ps.setString(10, emp.getString("EnterGroupDate")); |
| 264 | ps.setString(11, emp.getString("InpositionDate")); | 282 | ps.setString(11, emp.getString("InpositionDate")); |
| 283 | + ps.setString(12, bcompanySplit == null ? null : bcompanySplit[0]); | ||
| 284 | + ps.setString(13, bcompanySplit == null ? null : bcompanySplit[1]); | ||
| 265 | } | 285 | } |
| 266 | 286 | ||
| 267 | @Override | 287 | @Override |
| @@ -271,10 +291,10 @@ public class personnelUpdateHandler { | @@ -271,10 +291,10 @@ public class personnelUpdateHandler { | ||
| 271 | }); | 291 | }); |
| 272 | } | 292 | } |
| 273 | // 根据工号关联更新姓名、公司、工种、身份证号 | 293 | // 根据工号关联更新姓名、公司、工种、身份证号 |
| 274 | - int rows = jdbcTemplate.update("update bsth_c_personnel a inner join bsth_c_employee b on a.job_code = b.job_code1 set a.personnel_name = b.employee_name,a.personnel_type = b.job_type,a.company = b.company_name,a.company_code = b.company_code,a.card = b.id_card where a.destroy = 0"); | 294 | + int rows = jdbcTemplate.update("update bsth_c_personnel a inner join bsth_c_employee b on a.job_code = b.job_code1 set a.personnel_name = b.employee_name,a.personnel_type = b.job_type,a.company = b.company_name,a.company_code = b.company_code,a.card = b.id_card,a.branche_company_code = b.branche_company_code,a.branche_company = b.branche_company where a.destroy = 0"); |
| 275 | logger.info(String.format("根据工号关联更新姓名、公司、工种、身份证号,记录数%d",rows)); | 295 | logger.info(String.format("根据工号关联更新姓名、公司、工种、身份证号,记录数%d",rows)); |
| 276 | // 未匹配上工号的数据 用身份证号关联更新工号、姓名、公司、工种 | 296 | // 未匹配上工号的数据 用身份证号关联更新工号、姓名、公司、工种 |
| 277 | - rows = jdbcTemplate.update("update bsth_c_personnel a inner join bsth_c_employee b on a.card = b.id_card set a.job_code = b.job_code1,a.personnel_name = b.employee_name,a.personnel_type = b.job_type,a.company = b.company_name,a.company_code = b.company_code where a.destroy = 0 and a.job_code <> b.job_code1"); | 297 | + rows = jdbcTemplate.update("update bsth_c_personnel a inner join bsth_c_employee b on a.card = b.id_card set a.job_code = b.job_code1,a.personnel_name = b.employee_name,a.personnel_type = b.job_type,a.company = b.company_name,a.company_code = b.company_code,a.branche_company_code = b.branche_company_code,a.branche_company = b.branche_company where a.destroy = 0 and a.job_code <> b.job_code1"); |
| 278 | logger.info(String.format("根据身份证号关联更新工号、姓名、公司、工种,记录数%d",rows)); | 298 | logger.info(String.format("根据身份证号关联更新工号、姓名、公司、工种,记录数%d",rows)); |
| 279 | // 可能会出现数据异常情况 如一个是最新的工号无身份证号,一个是老的工号有身份证号,最后更新的结果会造成工号和身份证号重复 | 299 | // 可能会出现数据异常情况 如一个是最新的工号无身份证号,一个是老的工号有身份证号,最后更新的结果会造成工号和身份证号重复 |
| 280 | // 将更早创建的人员信息更新为停用 | 300 | // 将更早创建的人员信息更新为停用 |
| @@ -284,7 +304,7 @@ public class personnelUpdateHandler { | @@ -284,7 +304,7 @@ public class personnelUpdateHandler { | ||
| 284 | rows = jdbcTemplate.update("update bsth_c_personnel a left join bsth_c_employee b on a.job_code = b.job_code1 set a.destroy = 1 where a.destroy = 0 and b.job_code1 is null"); | 304 | rows = jdbcTemplate.update("update bsth_c_personnel a left join bsth_c_employee b on a.job_code = b.job_code1 set a.destroy = 1 where a.destroy = 0 and b.job_code1 is null"); |
| 285 | logger.info(String.format("调度系统未匹配数据标记为停用,记录数%d",rows)); | 305 | logger.info(String.format("调度系统未匹配数据标记为停用,记录数%d",rows)); |
| 286 | // 仍未匹配上的金蝶数据作为新人员 | 306 | // 仍未匹配上的金蝶数据作为新人员 |
| 287 | - rows = jdbcTemplate.update("insert into bsth_c_personnel (job_code,personnel_name,personnel_type,company,company_code,job_codeori) select b.job_code1,b.employee_name,b.job_type,b.company_name,b.company_code,b.job_code2 from bsth_c_employee b left join bsth_c_personnel a on b.job_code1 = a.job_code where a.job_code is null"); | 307 | + rows = jdbcTemplate.update("insert into bsth_c_personnel (job_code,personnel_name,personnel_type,company,company_code,job_codeori,branche_company_code,branche_company) select b.job_code1,b.employee_name,b.job_type,b.company_name,b.company_code,b.job_code2,b.branche_company_code,b.branche_company from bsth_c_employee b left join bsth_c_personnel a on b.job_code1 = a.job_code where a.job_code is null"); |
| 288 | logger.info(String.format("金蝶未匹配数据插入,记录数%d",rows)); | 308 | logger.info(String.format("金蝶未匹配数据插入,记录数%d",rows)); |
| 289 | // 赋值分公司编码1 不然无法查询 | 309 | // 赋值分公司编码1 不然无法查询 |
| 290 | rows = jdbcTemplate.update("update bsth_c_personnel set branche_company_code = '1' where branche_company_code is null"); | 310 | rows = jdbcTemplate.update("update bsth_c_personnel set branche_company_code = '1' where branche_company_code is null"); |