|
@@ -91,7 +91,12 @@ public class DoorRecordServiceImpl extends ServiceImpl<DoorRecordMapper, DoorRec
|
|
|
int result = baseMapper.updateDoorStatus(activityId, DeviceDoorStatus.CLOSED.getCode(), closeTime);
|
|
int result = baseMapper.updateDoorStatus(activityId, DeviceDoorStatus.CLOSED.getCode(), closeTime);
|
|
|
|
|
|
|
|
if (result > 0) {
|
|
if (result > 0) {
|
|
|
- log.info("更新门状态为已关门 - activityId: {}, 持续时长:{}秒", activityId, record.getDuration());
|
|
|
|
|
|
|
+ // duration 由 SQL TIMESTAMPDIFF 计算写入 DB,此处用 Java 计算日志输出值
|
|
|
|
|
+ // (record 是 UPDATE 前查询的,getDuration() 为 null,需自行计算)
|
|
|
|
|
+ long durationSeconds = record.getOpenTime() != null
|
|
|
|
|
+ ? java.time.temporal.ChronoUnit.SECONDS.between(record.getOpenTime(), closeTime)
|
|
|
|
|
+ : 0;
|
|
|
|
|
+ log.info("更新门状态为已关门 - activityId: {}, 持续时长:{}秒", activityId, durationSeconds);
|
|
|
|
|
|
|
|
// 同时更新 Redis
|
|
// 同时更新 Redis
|
|
|
updateRedisDoorStatus(activityId, DeviceDoorStatus.CLOSED.getCode(), closeTime);
|
|
updateRedisDoorStatus(activityId, DeviceDoorStatus.CLOSED.getCode(), closeTime);
|