diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/config/timer/AuthTimer.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/config/timer/AuthTimer.java index fe841f3..dfc80dc 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/config/timer/AuthTimer.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/config/timer/AuthTimer.java @@ -63,52 +63,56 @@ public class AuthTimer { @Scheduled(cron = "0 */2 * * * ?") public void autoAuth() { AtomicReference> unAuthPersonRef = new AtomicReference<>(new ArrayList<>()); + AtomicReference imgByteRef = new AtomicReference<>(new byte[0]); + // 需要先设置模拟上下文 SaTokenContextMockUtil.setMockContext(() -> { // 模拟登录 - StpUtil.login(-8); // 模拟登录 + StpUtil.login(1); // 模拟登录 unAuthPersonRef.set(remoteResidentPersonService.queryUnAuthPerson()); - }); + List unAuthPerson = unAuthPersonRef.get(); - List unAuthPerson = unAuthPersonRef.get(); - if (CollUtil.isNotEmpty(unAuthPerson)) { try { - for (RemoteResidentPersonVo person : unAuthPerson) { - log.info("开始定时授权:{}", person.getId()); + if (CollUtil.isNotEmpty(unAuthPerson)) { + for (RemoteResidentPersonVo person : unAuthPerson) { + log.info("开始定时授权:{}", person.getId()); + + // 判断是否已存在授权 + SisAuthRecordVo authRecord = sisAuthRecordService.queryByGroupIdAndPersonId(person.getAuthGroupId(), person.getId()); + if (ObjectUtil.isEmpty(authRecord)) { + // 无授权记录时,补录 + this.syncAuthRecord(person); + } + + imgByteRef.set(remoteFileService.downloadToByteArray(Long.parseLong(person.getOssId()))); + // 读取人像 + byte[] imgByte = imgByteRef.get(); + if (imgByte == null) continue; + + // 写入华为盒子 + Long huaweiId = syncHuaweiBox(person, imgByte); + if (huaweiId == null) continue; + + // 更新人像信息huaweiBoxId + Boolean update = sisPersonLibImgService.updateByPersonId(person.getId(), huaweiId); + if (!update) continue; + + // 同步E8平台 + Long e8Id = syncE8Plat(person, imgByte); + if (e8Id == null) continue; + + // 更新入驻员工E8平台id + remoteResidentPersonService.updateE8Id(person.getId(), e8Id); - // 判断是否已存在授权 - SisAuthRecordVo authRecord = sisAuthRecordService.queryByGroupIdAndPersonId(person.getAuthGroupId(), person.getId()); - if (ObjectUtil.isEmpty(authRecord)) { - // 无授权记录时,补录 - this.syncAuthRecord(person); } - // 读取人像 - byte[] imgByte = remoteFileService.downloadToByteArray(Long.parseLong(person.getOssId())); - if (imgByte == null) continue; - - // 写入华为盒子 - Long huaweiId = syncHuaweiBox(person, imgByte); - if (huaweiId == null) continue; - - // 更新人像信息huaweiBoxId - Boolean update = sisPersonLibImgService.updateByPersonId(person.getId(), huaweiId); - if (!update) continue; - - // 同步E8平台 - Long e8Id = syncE8Plat(person, imgByte); - if (e8Id == null) continue; - - // 更新入驻员工E8平台id - remoteResidentPersonService.updateE8Id(person.getId(), e8Id); - + } else { + log.info("无待授权人员"); } } catch (Exception e) { throw new RuntimeException(e); } - } else { - log.info("无待授权人员"); - } + }); } private void syncAuthRecord(RemoteResidentPersonVo person) {