From c13301a1f81072aac194d0602fe6e744ddb07931 Mon Sep 17 00:00:00 2001 From: Guoqs <123456@jsowell.com> Date: Thu, 18 Jun 2026 15:20:47 +0800 Subject: [PATCH] update --- .../impl/PileReservationInfoServiceImpl.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileReservationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileReservationInfoServiceImpl.java index 5f688ecbe..2826e7edf 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileReservationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileReservationInfoServiceImpl.java @@ -521,7 +521,12 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic log.info("羽信预约替换取消旧预约结果, reservedId:{}, pileConnectorCode:{}, result:{}", oldReservationInfo.getId(), oldReservationInfo.getPileConnectorCode(), cancelOldResult); if (!cancelOldResult) { - return false; + boolean oldReservationEnded = isReservationTimeEnded(oldReservationInfo); + if (!oldReservationEnded) { + return false; + } + log.warn("羽信预约替换取消旧预约失败, 但旧预约时间窗已过期, 继续下发新预约, memberId:{}, oldReservation:{}", + memberId, reservationLogText(oldReservationInfo)); } boolean createNewResult = sendReservationCommand(newReservationInfo, memberId, "01"); log.info("羽信预约替换新预约结果, reservedId:{}, pileConnectorCode:{}, result:{}", @@ -529,6 +534,11 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic if (createNewResult) { return true; } + if (!cancelOldResult) { + log.error("羽信预约替换新预约失败, 旧预约取消失败但已判定过期, 不恢复旧预约, memberId:{}, oldReservation:{}, newReservation:{}", + memberId, reservationLogText(oldReservationInfo), reservationLogText(newReservationInfo)); + return false; + } try { boolean restoreOldResult = sendReservationCommand(oldReservationInfo, memberId, "01"); log.info("羽信预约替换恢复旧预约结果, reservedId:{}, pileConnectorCode:{}, result:{}", @@ -544,6 +554,21 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic return false; } + private boolean isReservationTimeEnded(PileReservationInfo reservationInfo) { + if (reservationInfo == null || reservationInfo.getStartTime() == null || reservationInfo.getEndTime() == null) { + log.warn("羽信旧预约过期判断失败, 预约时间为空, reservation:{}", reservationLogText(reservationInfo)); + return false; + } + LocalTime now = LocalTime.now(); + LocalTime startTime = reservationInfo.getStartTime().toLocalTime(); + LocalTime endTime = reservationInfo.getEndTime().toLocalTime(); + boolean crossDay = endTime.isBefore(startTime); + boolean ended = !crossDay && !endTime.isAfter(now); + log.info("羽信旧预约过期判断, reservedId:{}, pileConnectorCode:{}, now:{}, startTime:{}, endTime:{}, crossDay:{}, ended:{}", + reservationInfo.getId(), reservationInfo.getPileConnectorCode(), now, startTime, endTime, crossDay, ended); + return ended; + } + private boolean isYuxinMainboard(String pileSn) { try { PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);