debug:归零记录(获取用户信息失败,因为是系统自动关闭)

This commit is contained in:
磷叶 2024-10-16 23:04:45 +08:00
parent 0727da1bd3
commit 23313ec463

View File

@ -518,8 +518,14 @@ public class DeviceServiceImpl implements DeviceService
}
private void resetRecord(DeviceVO device, RecordTimeType type, String reason) {
LoginUser loginUser = SecurityUtils.getLoginUser();
LoginUser loginUser;
try {
loginUser = SecurityUtils.getLoginUser();
} catch (Exception e) {
loginUser = null;
}
LoginUser finalLoginUser = loginUser;
scheduledExecutorService.schedule(() -> {
RecordTime record = null;
// 电量
@ -529,7 +535,7 @@ public class DeviceServiceImpl implements DeviceService
device,
amount,
reason,
loginUser,
finalLoginUser,
RecordTimeType.ELE.getType()
);
}
@ -537,7 +543,7 @@ public class DeviceServiceImpl implements DeviceService
else if (RecordTimeType.TIME.equals(type)) {
Duration duration = Duration.between(LocalDateTime.now(), device.getExpireTime());
long seconds = duration.getSeconds() > 0 ? duration.getSeconds() : 0;
record = recordTimeConverter.toRecordTime(device, -seconds, "设备归零", loginUser, RecordTimeType.TIME.getType());
record = recordTimeConverter.toRecordTime(device, -seconds, "设备归零", finalLoginUser, RecordTimeType.TIME.getType());
}
if (record != null) {
recordTimeService.insertRecordTime(record);