Commit acdc81a7 authored by 赵啸非's avatar 赵啸非

修改同步

parent 951fc619
...@@ -511,62 +511,62 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta ...@@ -511,62 +511,62 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
try { try {
for (DoorEntity doorEntity : doorEntities) { for (DoorEntity doorEntity : doorEntities) {
StaffReq staffReq = new StaffReq(); StaffReq staffReq = new StaffReq();
Rest<UserSearchInfo> personCountRest = hikStaffService.getPersonCount(staffReq, doorEntity); Rest<UserSearchInfo> personCountRest = hikStaffService.getPersonCount(staffReq, doorEntity);
if (personCountRest.getCode() == YesNoEnum.YES.getValue()) { if (personCountRest.getCode() == YesNoEnum.YES.getValue()) {
int totalNum = personCountRest.getData().getUserInfoSearch().getTotalMatches(); int totalNum = personCountRest.getData().getUserInfoSearch().getTotalMatches();
int size = 30; int size = 30;
int pages = totalNum / size; int pages = totalNum / size;
for (int i = 0; i <= pages; i++) { for (int i = 0; i <= pages; i++) {
StaffReq searchReq = new StaffReq(); StaffReq searchReq = new StaffReq();
searchReq.setPageNo(i); searchReq.setPageNo(i);
searchReq.setPageSize(size); searchReq.setPageSize(size);
Rest<UserSearchInfo> rest = hikStaffService.getPersonList(searchReq, doorEntity); Rest<UserSearchInfo> rest = hikStaffService.getPersonList(searchReq, doorEntity);
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (rest.getCode() == YesNoEnum.YES.getValue()) {
//做差集 更新本地用户为离职员工 //做差集 更新本地用户为离职员工
UserInfoSearch userInfoSearch = rest.getData().getUserInfoSearch(); UserInfoSearch userInfoSearch = rest.getData().getUserInfoSearch();
List<UserInfoItem> userInfoList = userInfoSearch.getUserInfo(); List<UserInfoItem> userInfoList = userInfoSearch.getUserInfo();
for (UserInfoItem userInfoItem : userInfoList) { for (UserInfoItem userInfoItem : userInfoList) {
if (ObjectUtils.isEmpty(userInfoItem.getEmployeeNo())) { if (ObjectUtils.isEmpty(userInfoItem.getEmployeeNo())) {
log.info("EmployeeNo is null ==>{}", JSON.toJSONString(userInfoItem)); log.info("EmployeeNo is null ==>{}", JSON.toJSONString(userInfoItem));
continue; continue;
} }
if (staffCollect.containsKey(userInfoItem.getEmployeeNo())) { if (staffCollect.containsKey(userInfoItem.getEmployeeNo())) {
staffCollect.remove(userInfoItem.getEmployeeNo()); staffCollect.remove(userInfoItem.getEmployeeNo());
} }
StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(userInfoItem.getEmployeeNo(), 8, "0")); StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(userInfoItem.getEmployeeNo(), 8, "0"));
//设置到默认部门 //设置到默认部门
//判断本地数据是否为空 //判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) { if (ObjectUtils.isEmpty(staffEntity)) {
//新增员工信息 //新增员工信息
staffEntity = new StaffEntity(); staffEntity = new StaffEntity();
staffEntity.initAttrValue(); staffEntity.initAttrValue();
DeptQuery deptQuery = new DeptQuery(); DeptQuery deptQuery = new DeptQuery();
deptQuery.setParentId(0L); deptQuery.setParentId(0L);
DeptEntity deptEntity = deptService.selectOne(deptQuery); DeptEntity deptEntity = deptService.selectOne(deptQuery);
if (!ObjectUtils.isEmpty(deptEntity)) { if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId()); staffEntity.setDeptId(deptEntity.getId());
staffEntity.setDeptName(deptEntity.getDeptName()); staffEntity.setDeptName(deptEntity.getDeptName());
}
staffEntity.setName(userInfoItem.getName());
staffEntity.setGender("male".equals(userInfoItem.getGender()) ? 1 : 2);
staffEntity.setWorkNum(userInfoItem.getEmployeeNo());
staffEntity.setStatus(StaffSatusEnum.正式.getValue());
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
this.save(staffEntity);
} }
staffEntity.setName(userInfoItem.getName());
staffEntity.setGender("male".equals(userInfoItem.getGender()) ? 1 : 2);
staffEntity.setWorkNum(userInfoItem.getEmployeeNo());
staffEntity.setStatus(StaffSatusEnum.正式.getValue());
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
this.save(staffEntity);
} }
} }
} }
} }
} }
} } catch (Exception e) {
}catch (Exception e){ log.error("同步人员信息失败:{}", e.getMessage());
log.error("同步人员信息失败:{}",e.getMessage()); staffCollect = new HashMap<>();
staffCollect=List
} }
if (staffCollect.size() > 0) { if (staffCollect.size() > 0) {
//需要将此人员变更为离职 //需要将此人员变更为离职
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment