Commit 1f3898bf0b4c0968caab604a09185252afa1fcd6

Authored by 王通
1 parent de2ec93d

1.人员信息表加入locked字段

src/main/java/com/bsth/handler/personnelUpdateHandler.java
... ... @@ -291,26 +291,24 @@ public class personnelUpdateHandler {
291 291 });
292 292 }
293 293 // 根据工号关联更新姓名、公司、工种、身份证号
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,a.jd_codeori = b.job_code,a.job_codeori = b.job_code2 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,a.jd_codeori = b.job_code,a.job_codeori = b.job_code2 where a.destroy = 0 and a.locked = 0");
295 295 logger.info(String.format("根据工号关联更新姓名、公司、工种、身份证号,记录数%d",rows));
296 296 // 未匹配上工号的数据 用身份证号关联更新工号、姓名、公司、工种
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,a.jd_codeori = b.job_code,a.job_codeori = b.job_code2 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,a.jd_codeori = b.job_code,a.job_codeori = b.job_code2 where a.destroy = 0 and a.job_code <> b.job_code1 and a.locked = 0");
298 298 logger.info(String.format("根据身份证号关联更新工号、姓名、公司、工种,记录数%d",rows));
299 299 // 可能会出现数据异常情况 如一个是最新的工号无身份证号,一个是老的工号有身份证号,最后更新的结果会造成工号和身份证号重复
300 300 // 将更早创建的人员信息更新为停用
301   - rows = jdbcTemplate.update("update bsth_c_personnel x INNER JOIN (select card,min(id) id from bsth_c_personnel a where destroy = 0 and LENGTH(a.card) > 1 GROUP BY card having count(*) > 1) y on x.id = y.id set destroy = 1");
  301 + rows = jdbcTemplate.update("update bsth_c_personnel x INNER JOIN (select card,min(id) id from bsth_c_personnel a where destroy = 0 and LENGTH(a.card) > 1 and a.locked = 0 GROUP BY card having count(*) > 1) y on x.id = y.id set destroy = 1");
302 302 logger.info(String.format("同一个人,将更早创建的人员停用,记录数%d",rows));
303 303 // 仍未匹配上的调度数据作为停用人员
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");
  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 and a.locked = 0");
305 305 logger.info(String.format("调度系统未匹配数据标记为停用,记录数%d",rows));
306 306 // 仍未匹配上的金蝶数据作为新人员
307 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,jd_codeori) 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,b.job_code from bsth_c_employee b left join bsth_c_personnel a on b.job_code1 = a.job_code where a.job_code is null");
308 308 logger.info(String.format("金蝶未匹配数据插入,记录数%d",rows));
309 309 // 赋值分公司编码1 不然无法查询
310   - 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 and locked = 0");
311 311 logger.info(String.format("分公司代码更新为1,记录数%d",rows));
312   - // 赋值分公司编码1 不然无法查询
313   - rows = jdbcTemplate.update("update bsth_c_personnel set destroy = 0 where company_code = 77");
314 312 logger.info(String.format("临港公交的人员全部启用,记录数%d",rows));
315 313 logger.info("人事数据同步 结束");
316 314 tran.commit(status);
... ...