From 39533344a85c31ae338236763cdd174308fa8fb0 Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期二, 19 三月 2024 09:09:43 +0800
Subject: [PATCH] 提交更新

---
 src/main/java/com/boying/service/impl/OutParkServiceImpl.java |   68 ++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/src/main/java/com/boying/service/impl/OutParkServiceImpl.java b/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
index a18bfbc..affe3db 100644
--- a/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
+++ b/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
@@ -1,8 +1,10 @@
 package com.boying.service.impl;
 
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.boying.entity.Barrier;
 import com.boying.entity.OutPark;
 import com.boying.entity.Park;
 import com.boying.entity.Statistic;
@@ -11,7 +13,9 @@
 import com.boying.service.OutParkService;
 import com.boying.service.StatisticService;
 import com.boying.util.RedisJsonUtil;
+import com.boying.util.StringUtil;
 import lombok.AllArgsConstructor;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
@@ -30,7 +34,8 @@
 @AllArgsConstructor
 public class OutParkServiceImpl extends ServiceImpl<OutParkMapper, OutPark> implements OutParkService {
     private final OutParkMapper outParkMapper;
-    private final RedisJsonUtil redisJsonUtil;
+    private StringRedisTemplate redisTemplate;
+
 
     @Override
     public int count1() {
@@ -113,30 +118,45 @@
 
     @Override
     public OutPark count4(Integer bId) {
-        OutPark outPark = null;
-        try {
-            outPark =  redisJsonUtil.get("outPark-"+bId, OutPark.class);
-            if(outPark != null){
-                return outPark;
-            }else {
-                QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
-                wrapper.lambda()
-                        .eq(OutPark::getBarrierId,bId)
-                        .eq(OutPark::getStatus,1)
-                        .eq(OutPark::getStatus2,0)
-                        .orderByDesc(OutPark::getCreateTime);
-                List<OutPark> outParks = outParkMapper.selectList(wrapper);
-                if(outParks.size()>0){
-                    redisJsonUtil.set("outPark-"+bId, outParks.get(0));
-                    return outParks.get(0);
-                }else{
-                    return null;
-                }
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
+//        OutPark outPark = null;
+//        try {
+//            String s  =  redisTemplate.opsForValue().get("outPark-"+bId);
+//            if(!StringUtil.isNullOrEmpty(s)){
+//                outPark =  JSON.parseObject(s, OutPark.class);
+//                return outPark;
+//            }else {
+//                QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+//                wrapper.lambda()
+//                        .eq(OutPark::getBarrierId,bId)
+//                        .eq(OutPark::getStatus,1)
+//                        .eq(OutPark::getStatus2,0)
+//                        .orderByDesc(OutPark::getCreateTime);
+//                List<OutPark> outParks = outParkMapper.selectList(wrapper);
+//                if(outParks.size()>0){
+//                    String jsonValue = JSON.toJSONString(outParks.get(0));
+//                    redisTemplate.opsForValue().set("outPark-"+bId, jsonValue);
+//                    return outParks.get(0);
+//                }else{
+//                    return null;
+//                }
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return null;
+
+        QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+        wrapper.lambda()
+                .eq(OutPark::getBarrierId,bId)
+                .eq(OutPark::getStatus,1)
+                .eq(OutPark::getStatus2,0)
+                .orderByDesc(OutPark::getCreateTime);
+        List<OutPark> outParks = outParkMapper.selectList(wrapper);
+        if(outParks.size()>0){
+            return outParks.get(0);
+        }else{
+            return null;
         }
-        return null;
     }
 
     @Override

--
Gitblit v1.9.1