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 | 88 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 77 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/boying/controller/phone/YCPayController.java b/src/main/java/com/boying/controller/phone/YCPayController.java
index f5ec8c0..c6e6dd3 100644
--- a/src/main/java/com/boying/controller/phone/YCPayController.java
+++ b/src/main/java/com/boying/controller/phone/YCPayController.java
@@ -2,7 +2,6 @@
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -13,17 +12,15 @@
import com.boying.entity.*;
import com.boying.service.*;
import com.boying.util.DateUtilOther;
-import com.boying.util.HTTPEntityUtil;
-import com.boying.util.RedisJsonUtil;
import com.google.gson.Gson;
+
import lombok.RequiredArgsConstructor;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -39,6 +36,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
+
/**
* @author kdq
@@ -63,7 +61,7 @@
private final EnterParkService enterParkService;
private final WXService wxService;
private final OutParkLogService outParkLogService;
- private final RedisJsonUtil redisJsonUtil;
+ private final StringRedisTemplate redisTemplate;
/**
@@ -150,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,"璇锋彁浜ゆ敮浠�");
+ }
+
/**
* 鍒ゆ柇鏄惁缂磋垂
@@ -166,7 +195,6 @@
updateOutPark(outPark.getId(),"03");
return R.failed("鏈鍋滆溅鏃犻渶鏀粯璐圭敤");
}
-
//鍒ゆ柇鏄惁鍦ㄧ櫧鍚嶅崟
QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
wrapper.lambda()
@@ -686,11 +714,49 @@
outPark.setStatus(1);
outParkService.saveOrUpdate(outPark);
//缂撳瓨鍦╮edis閲�
- try {
- redisJsonUtil.set("outPark-"+outPark.getBarrierId(), outPark);
- } catch (IOException e) {
- e.printStackTrace();
+ String jsonValue = JSON.toJSONString(outPark);
+ 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