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

修改同步人员接口

parent 0a2b8d27
......@@ -100,12 +100,8 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
}
} else {
//todo 设备直连
deptService.syncDeptByDevice(null);
// deptService.syncDeptByDevice(null);
staffService.syncPersonsByDevices(null);
}
......
......@@ -505,6 +505,11 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
public Rest<Void> syncPersonsByDevices(Context context) {
log.info("同步人员!");
//todo 门禁获取人员
StaffQuery staffQuery = new StaffQuery();
staffQuery.setSource(1);
staffQuery.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
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());
for (DoorEntity doorEntity : doorEntities) {
StaffReq staffReq = new StaffReq();
......@@ -519,14 +524,7 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
searchReq.setPageSize(size);
Rest<UserSearchInfo> rest = hikStaffService.getPersonList(searchReq, doorEntity);
if (rest.getCode() == YesNoEnum.YES.getValue()) {
//做差集 更新本地用户为离职员工
StaffQuery staffQuery = new StaffQuery();
staffQuery.setSource(1);
staffQuery.setStatusNotList(Arrays.asList(StaffSatusEnum.离职.getValue()));
Map<String, StaffEntity> staffCollect = this.find(staffQuery).stream().collect(Collectors.toMap(x -> x.getWorkNum(), y -> y, (o, n) -> n));
UserInfoSearch userInfoSearch = rest.getData().getUserInfoSearch();
List<UserInfoItem> userInfoList = userInfoSearch.getUserInfo();
for (UserInfoItem userInfoItem : userInfoList) {
......@@ -539,35 +537,31 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
staffCollect.remove(userInfoItem.getEmployeeNo());
}
StaffEntity staffEntity = this.getExtCache(StrUtil.padPre(userInfoItem.getEmployeeNo(), 8, "0"));
DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(userInfoItem.getBelongGroup()));
//DeptEntity deptEntity = deptService.selectOne(new DeptQuery().deptCode(userInfoItem.getBelongGroup()));
//设置到默认部门
//判断本地数据是否为空
if (ObjectUtils.isEmpty(staffEntity)) {
//新增员工信息
staffEntity = new StaffEntity();
staffEntity.initAttrValue();
DeptQuery deptQuery = new DeptQuery();
deptQuery.setParentId(0L);
DeptEntity deptEntity = deptService.selectOne(deptQuery);
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
staffEntity.setDeptName(deptEntity.getDeptName());
}
staffEntity.setName(userInfoItem.getName());
staffEntity.setDeptName(userInfoItem.getBelongGroup());
staffEntity.setGender("male".equals(userInfoItem.getGender()) ? 1 : 2);
staffEntity.setWorkNum(userInfoItem.getEmployeeNo());
staffEntity.setCreateUserId(1L);
staffEntity.setCreateTime(new Date());
this.save(staffEntity);
} else {
//更新
if (!ObjectUtils.isEmpty(deptEntity)) {
staffEntity.setDeptId(deptEntity.getId());
}
staffEntity.setName(userInfoItem.getName());
staffEntity.setDeptName(userInfoItem.getBelongGroup());
staffEntity.setGender("male".equals(userInfoItem.getGender()) ? 1 : 2);
staffEntity.setWorkNum(userInfoItem.getEmployeeNo());
staffEntity.setUpdateUserId(1L);
staffEntity.setUpdateTime(new Date());
this.update(staffEntity);
}
}
}
}
}
......@@ -620,15 +614,10 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
}
});
}
}
}
}
}
return Rest.ok();
}
@Override
public Rest<Void> syncRegisterUsersPhotos() {
List<StaffEntity> staffList = this.find(new StaffQuery().source(1)).stream()
......
......@@ -33,6 +33,7 @@ import com.mortals.xhx.module.staff.model.vo.StaffCheckAuthorizePdu;
import com.mortals.xhx.module.staff.model.vo.StaffInfoVo;
import com.mortals.xhx.module.staff.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -70,6 +71,9 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
@Autowired
private AttendanceLeaveRecordService leaveRecordService;
@Value("${hik.host:}")
protected String hikhost;
public StaffController() {
super.setModuleDesc("员工基本信息");
......@@ -227,12 +231,16 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
JSONObject jsonObject = new JSONObject();
String busiDesc = this.getModuleDesc() + "同步";
try {
if (!ObjectUtils.isEmpty(hikhost)) {
//同步部门
deptService.syncDept(getContext());
Rest<Void> rest = this.service.syncPersons(getContext());
if (rest.getCode() == YesNoEnum.NO.getValue()) {
throw new AppException("同步异常!");
}
}else{
this.service.syncPersonsByDevices(null);
}
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + " 【成功】");
......
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