From 973f7a2b420dddb06553489d72d4aa6fdea3c1c0 Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期三, 05 八月 2026 15:17:22 +0800
Subject: [PATCH] fix:提交
---
src/main/java/com/boying/controller/phone/YCPayController.java | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/boying/controller/phone/YCPayController.java b/src/main/java/com/boying/controller/phone/YCPayController.java
index c556217..c6e6dd3 100644
--- a/src/main/java/com/boying/controller/phone/YCPayController.java
+++ b/src/main/java/com/boying/controller/phone/YCPayController.java
@@ -13,6 +13,7 @@
import com.boying.service.*;
import com.boying.util.DateUtilOther;
import com.google.gson.Gson;
+
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
@@ -34,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
/**
@@ -713,7 +715,48 @@
outParkService.saveOrUpdate(outPark);
//缂撳瓨鍦╮edis閲�
String jsonValue = JSON.toJSONString(outPark);
- redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
+ String redisKey = "outPark-"+outPark.getBarrierId();
+ String parkChangeKey = "park_change_in_"+outPark.getParkId();
+ int retryCount = 0;
+ int maxRetry = 3;
+ boolean cacheSuccess = false;
+
+ while(retryCount < maxRetry && !cacheSuccess){
+ try {
+ redisTemplate.opsForValue().set(redisKey, jsonValue);
+ redisTemplate.opsForValue().set(parkChangeKey,"true",1, TimeUnit.DAYS);
+ cacheSuccess = true;
+ String logs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
+ " 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+
+ ",Redis缂撳瓨璁剧疆鎴愬姛锛岄亾闂窱D锛�"+outPark.getBarrierId()+"\n";
+ writeTxt2(logs);
+ } catch (Exception e) {
+ retryCount++;
+ String errorLogs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
+ " 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+
+ ",Redis缂撳瓨璁剧疆澶辫触锛岀"+retryCount+"娆¢噸璇曪紝閿欒淇℃伅锛�"+e.getMessage()+"\n";
+ writeTxt2(errorLogs);
+ e.printStackTrace();
+ if(retryCount < maxRetry){
+ try {
+ Thread.sleep(100); // 绛夊緟100ms鍚庨噸璇�
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+ }
+
+ if(!cacheSuccess){
+ String errorLogs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
+ " 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+
+ ",Redis缂撳瓨璁剧疆澶辫触锛屽凡閲嶈瘯"+maxRetry+"娆★紝璇锋鏌edis鏈嶅姟鐘舵�侊紒\n";
+ writeTxt2(errorLogs);
+ // 铏界劧Redis缂撳瓨澶辫触锛屼絾鏁版嵁搴撳凡鏇存柊锛屽績璺虫帴鍙e彲浠ラ�氳繃鏁版嵁搴撴煡璇㈣幏鍙栨暟鎹�
+ }
+
+// redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
+// redisTemplate.opsForValue().set("park_change_in_"+outPark.getParkId(),"true",1, TimeUnit.DAYS);
}
}
}
--
Gitblit v1.9.1