From bccd25039a08f8833b72ff906d156da63018db98 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期二, 19 三月 2024 15:10:13 +0800
Subject: [PATCH] 新增心跳缓存
---
src/main/java/com/boying/service/impl/OutParkServiceImpl.java | 75 +++++++++++++++++++++++++++++++------
1 files changed, 63 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/boying/service/impl/OutParkServiceImpl.java b/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
index 99b5036..bd3bbbc 100644
--- a/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
+++ b/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
@@ -1,17 +1,24 @@
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;
import com.boying.mapper.OutParkMapper;
import com.boying.mapper.StatisticMapper;
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;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -27,6 +34,8 @@
@AllArgsConstructor
public class OutParkServiceImpl extends ServiceImpl<OutParkMapper, OutPark> implements OutParkService {
private final OutParkMapper outParkMapper;
+ private StringRedisTemplate redisTemplate;
+
@Override
public int count1() {
@@ -109,18 +118,32 @@
@Override
public OutPark count4(Integer bId) {
- 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;
+ OutPark outPark = null;
+ try {
+ String s = redisTemplate.opsForValue().get("outPark-"+bId);
+ if(!StringUtil.isNullOrEmpty(s)){
+ outPark = JSON.parseObject(s, OutPark.class);
+ return outPark;
+ }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;
+// }
}
@Override
@@ -139,8 +162,36 @@
}
@Override
+ public OutPark findByPayCode(String payCode) {
+ QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(OutPark::getCode2,payCode)
+ .orderByDesc(OutPark::getCreateTime);
+ List<OutPark> outParks = outParkMapper.selectList(wrapper);
+ if(outParks.size()>0){
+ return outParks.get(0);
+ }else{
+ return null;
+ }
+ }
+
+ @Override
+ public OutPark findByOrderId(String txnOrderId) {
+ QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(OutPark::getTxnOrderId,txnOrderId)
+ .orderByDesc(OutPark::getCreateTime);
+ List<OutPark> outParks = outParkMapper.selectList(wrapper);
+ if(outParks.size()>0){
+ return outParks.get(0);
+ }else{
+ return null;
+ }
+ }
+
+ @Override
public List<OutPark> getList(long current, long size, String carNo, Long parkId, String payCode, String date) {
- return outParkMapper.getList(current-1,size,carNo,parkId,payCode,date);
+ return outParkMapper.getList((current-1)*size,size,carNo,parkId,payCode,date);
}
@Override
--
Gitblit v1.9.1