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 | 79 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/boying/controller/phone/YCPayController.java b/src/main/java/com/boying/controller/phone/YCPayController.java
index f2872ab..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;
/**
@@ -59,7 +61,7 @@
private final EnterParkService enterParkService;
private final WXService wxService;
private final OutParkLogService outParkLogService;
- private StringRedisTemplate redisTemplate;
+ private final StringRedisTemplate redisTemplate;
/**
@@ -146,6 +148,37 @@
}
}
+ /**
+ * 鍒ゆ柇鏀粯绔槸鍚﹀凡缁忔敮浠樿繃
+ * @param id
+ * @return
+ */
+ @PostMapping("parkJudg")
+ public Object parkJudg(Long id){
+ if(id == null){
+ return R.failed("鏈壘鍒版暟鎹紝璇风◢鍚庨噸鏂扮偣鍑�");
+ }
+ OutPark outPark = outParkService.getById(id);
+ if(outPark == null){
+ return R.failed("鏈壘鍒版暟鎹紝璇风◢鍚庨噸鏂扮偣鍑�");
+ }
+ if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){
+ return R.ok(1,"璁㈠崟宸叉彁浜ゆ敮浠樿姹�");
+ }
+ if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 1){
+ return R.failed(0,"璁㈠崟宸茬即璐�");
+ }
+ if(StringUtils.isBlank(outPark.getPayCode())){
+ OutPark by10min = outParkService.findBy10min(outPark.getCarNo(), outPark.getParkId(), outPark.getCreateTime(),outPark.getId());
+ if(by10min !=null){
+ return R.ok(1,"璁㈠崟宸叉彁浜ゆ敮浠樿姹�");
+ }else {
+ return R.ok(0,"璇锋彁浜ゆ敮浠�");
+ }
+ }
+ return R.failed(0,"璇锋彁浜ゆ敮浠�");
+ }
+
/**
* 鍒ゆ柇鏄惁缂磋垂
@@ -162,7 +195,6 @@
updateOutPark(outPark.getId(),"03");
return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤");
}
-
//鍒ゆ柇鏄惁鍦ㄧ櫧鍚嶅崟
QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
wrapper.lambda()
@@ -683,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