Commit 9a7134df authored by 赵啸非's avatar 赵啸非

修改人员同步 不存在的人离职问题

parent 098c7693
......@@ -44,8 +44,8 @@ public class HikStaffServiceImpl extends AbstractHikService implements IHikStaff
try {
int lHandler = hCNetSDK.NET_DVR_StartRemoteConfig(userID, HCNetSDK.NET_DVR_JSON_CONFIG, ptrByteArray.getPointer(), strInBuffer.length(), null, null);
if (lHandler < 0) {
log.info("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为==>{}", hCNetSDK.NET_DVR_GetLastError());
throw new AppException(String.format("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为==>%s", hCNetSDK.NET_DVR_GetLastError()));
log.info("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为==>{},deviceName:{}", hCNetSDK.NET_DVR_GetLastError(),doorEntity.getDeviceName());
throw new AppException(String.format("SearchUserInfo NET_DVR_StartRemoteConfig 失败,错误码为==>%s,deviceName==>%s", hCNetSDK.NET_DVR_GetLastError(),doorEntity.getDeviceName()));
} else {
JSONObject jsonObject = new JSONObject();
JSONObject jsonSearchCond = new JSONObject();
......
......@@ -116,9 +116,9 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
@Override
protected void updateBefore(StaffEntity entity, Context context) throws AppException {
super.updateBefore(entity, context);
if(!ObjectUtils.isEmpty(entity.getDeptId())){
if (!ObjectUtils.isEmpty(entity.getDeptId())) {
DeptEntity deptEntity = deptService.get(entity.getDeptId());
entity.setDeptName(deptEntity==null?"":deptEntity.getDeptName());
entity.setDeptName(deptEntity == null ? "" : deptEntity.getDeptName());
}
}
......@@ -129,15 +129,14 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
throw new AppException("工号重复!工号:" + entity.getWorkNum());
}
if(!ObjectUtils.isEmpty(entity.getDeptId())){
if (!ObjectUtils.isEmpty(entity.getDeptId())) {
DeptEntity deptEntity = deptService.get(entity.getDeptId());
entity.setDeptName(deptEntity==null?"":deptEntity.getDeptName());
entity.setDeptName(deptEntity == null ? "" : deptEntity.getDeptName());
}
}
@Override
public StaffInfoVo queryAll(Context context) {
StaffInfoVo staffInfoVo = new StaffInfoVo();
......@@ -522,10 +521,10 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
Map<String, StaffEntity> staffCollect = this.find(staffQuery).stream().collect(Collectors.toMap(x -> x.getWorkNum(), y -> y, (o, n) -> n));
List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
if(ObjectUtils.isEmpty(doorEntities)) return Rest.fail("未找到门禁设备!");
if (ObjectUtils.isEmpty(doorEntities)) return Rest.fail("未找到门禁设备!");
try {
DoorEntity doorEntity = doorEntities.get(0);
//for (DoorEntity doorEntity : doorEntities) {
// DoorEntity doorEntity = doorEntities.get(0);
for (DoorEntity doorEntity : doorEntities) {
StaffReq staffReq = new StaffReq();
Rest<UserSearchInfo> personCountRest = hikStaffService.getPersonCount(staffReq, doorEntity);
if (personCountRest.getCode() == YesNoEnum.YES.getValue()) {
......@@ -572,7 +571,7 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
this.save(staffEntity);
}else{
} else {
//更新员工状态
staffEntity.setStatus(StaffSatusEnum.正式.getValue());
staffEntity.setUpdateUserId(1L);
......@@ -582,18 +581,18 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
StaffLeaveQuery staffLeaveQuery = new StaffLeaveQuery();
staffLeaveQuery.setWorkNum(staffEntity.getWorkNum());
StaffLeaveEntity staffLeaveEntity = staffLeaveService.selectOne(staffLeaveQuery, null);
if(!ObjectUtils.isEmpty(staffEntity)){
staffLeaveService.remove(staffLeaveEntity.getId(),null);
if (!ObjectUtils.isEmpty(staffEntity)) {
staffLeaveService.remove(staffLeaveEntity.getId(), null);
}
}
}
}
}
}else {
} else {
log.info("人员信息为空");
throw new AppException(personCountRest.getMsg());
}
// }
}
} catch (Exception e) {
log.error("同步人员信息失败:{}", e.getMessage());
staffCollect = new HashMap<>();
......
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