Merge branch 'master' of http://47.109.37.87:3000/by2025/SmartParks
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
dy 2025-07-27 22:54:10 +08:00
commit bee90b70d1

View File

@ -63,52 +63,56 @@ public class AuthTimer {
@Scheduled(cron = "0 */2 * * * ?")
public void autoAuth() {
AtomicReference<List<RemoteResidentPersonVo>> unAuthPersonRef = new AtomicReference<>(new ArrayList<>());
AtomicReference<byte[]> imgByteRef = new AtomicReference<>(new byte[0]);
// 需要先设置模拟上下文
SaTokenContextMockUtil.setMockContext(() -> {
// 模拟登录
StpUtil.login(-8); // 模拟登录
StpUtil.login(1); // 模拟登录
unAuthPersonRef.set(remoteResidentPersonService.queryUnAuthPerson());
});
List<RemoteResidentPersonVo> unAuthPerson = unAuthPersonRef.get();
List<RemoteResidentPersonVo> 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) {