update 预约充电

This commit is contained in:
Guoqs
2024-09-06 16:13:50 +08:00
parent 8123e350f2
commit 12888c5b1f
3 changed files with 39 additions and 3 deletions

View File

@@ -413,6 +413,8 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
return 0;
}
String redisKey = CacheConstants.UPDATE_RESERVATION_INFO + pileReservationInfo.getPileConnectorCode();
// 是否发指令 false:不发指令 true:发指令, 默认不发指令
boolean sendFlag = false;
if (StringUtils.equals(pileReservationInfo.getStatus(), "1")) {
@@ -488,11 +490,16 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
.build();
String result = pileRemoteService.reservationCharging(command);
sendResult = StringUtils.equals(result, Constants.ONE);
// 设置缓存1分钟, 如果更新数据库就删掉, 如果没有更新数据量缓存70秒
redisCache.setCacheObject(redisKey, JSON.toJSONString(pileReservationInfo), CacheConstants.cache_expire_time_70s);
}
log.info("修改预约充电信息, updateFlag:{}, sendFlag:{}, sendResult:{}", updateFlag, sendFlag, sendResult);
// 更新数据库, 一般情况下是都更新的, 只有在发送指令并发送失败的情况下才不更新
if (updateFlag && (sendFlag == sendResult)) {
log.debug("修改预约充电相应成功, 删除缓存并更新数据库");
redisCache.deleteObject(redisKey);
return this.insertOrUpdateSelective(pileReservationInfo);
}
return 0;