From fb050c0dafa5363a73540dd9e52b78487e25ba0a Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期二, 09 四月 2024 17:32:46 +0800
Subject: [PATCH] fix:新增手动抬杆记录
---
src/main/java/com/boying/service/impl/BarrierServiceImpl.java | 69 +++++++++++++++++++++++++---------
1 files changed, 51 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/boying/service/impl/BarrierServiceImpl.java b/src/main/java/com/boying/service/impl/BarrierServiceImpl.java
index 6303eac..bb86265 100644
--- a/src/main/java/com/boying/service/impl/BarrierServiceImpl.java
+++ b/src/main/java/com/boying/service/impl/BarrierServiceImpl.java
@@ -2,7 +2,9 @@
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boying.entity.Barrier;
import com.boying.entity.EnterPark;
@@ -15,6 +17,7 @@
import com.boying.service.BarrierService;
import com.boying.service.EnterParkService;
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;
@@ -39,13 +42,15 @@
private OutParkMapper outParkMapper;
private StringRedisTemplate redisTemplate;
private ParkMapper parkMapper;
- private RedisJsonUtil redisJsonUtil;
+
+
@Override
public Barrier findByCode(String code) {
Barrier barrier = null;
try {
- barrier = redisJsonUtil.get("barrier-"+code,Barrier.class);
- if(barrier != null){
+ String s = redisTemplate.opsForValue().get("barrier-"+code);
+ if(!StringUtil.isNullOrEmpty(s)){
+ barrier = JSON.parseObject(s, Barrier.class);
return barrier;
}else {
QueryWrapper<Barrier> wrapper = new QueryWrapper<>();
@@ -53,15 +58,26 @@
.eq(Barrier::getCode,code);
List<Barrier> list = list(wrapper);
if(list.size()>0){
- redisJsonUtil.set("barrier-"+code,list.get(0));
+ String jsonValue = JSON.toJSONString(list.get(0));
+ redisTemplate.opsForValue().set("barrier-"+code, jsonValue);
return list.get(0);
}
}
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
return null;
+
+// QueryWrapper<Barrier> wrapper = new QueryWrapper<>();
+// wrapper.lambda()
+// .eq(Barrier::getCode,code);
+// List<Barrier> list = list(wrapper);
+// if(list.size()>0){
+// return list.get(0);
+// }else {
+// return null;
+// }
}
@Override
@@ -78,13 +94,22 @@
}
@Override
- public boolean getDateDifIn(Integer barrierId) {
- QueryWrapper<EnterPark> wrapper = new QueryWrapper<>();
- wrapper.lambda()
- .eq(EnterPark::getBarrierId,barrierId)
- .orderByDesc(EnterPark::getId)
- .last(" limit 1");
- EnterPark enterPark = enterParkMapper.selectOne(wrapper);
+ public boolean getDateDifIn(Integer parkId) {
+ EnterPark enterPark=null;
+ String s1 = redisTemplate.opsForValue().get("enterPark_dif_" + parkId);
+ if(StringUtils.isBlank(s1)){
+ QueryWrapper<EnterPark> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(EnterPark::getParkId,parkId)
+ .orderByDesc(EnterPark::getId)
+ .last(" limit 1");
+ enterPark = enterParkMapper.selectOne(wrapper);
+ String jsonValue = JSON.toJSONString(enterPark);
+ redisTemplate.opsForValue().set("enterPark_dif_"+ parkId, jsonValue);
+ }else {
+ enterPark = JSON.parseObject(s1, EnterPark.class);
+ }
+
if(enterPark != null){
long dif = DateUtil.between(Date.from( enterPark.getCreateTime().atZone( ZoneId.systemDefault()).toInstant()), new Date(), DateUnit.SECOND, false);
if(dif >= 5 && dif <= 7){
@@ -108,12 +133,20 @@
@Override
public boolean getDateDifOut(Integer barrierId) {
- QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
- wrapper.lambda()
- .eq(OutPark::getBarrierId,barrierId)
- .orderByDesc(OutPark::getId)
- .last(" limit 1");
- OutPark outPark = outParkMapper.selectOne(wrapper);
+ OutPark outPark=null;
+ String s1 = redisTemplate.opsForValue().get("outPark_dif_" + barrierId);
+ if(StringUtils.isBlank(s1)){
+ QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(OutPark::getBarrierId,barrierId)
+ .orderByDesc(OutPark::getId)
+ .last(" limit 1");
+ outPark = outParkMapper.selectOne(wrapper);
+ String jsonValue = JSON.toJSONString(outPark);
+ redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue);
+ }else {
+ outPark = JSON.parseObject(s1, OutPark.class);
+ }
if(outPark != null){
long dif = DateUtil.between(Date.from( outPark.getCreateTime().atZone( ZoneId.systemDefault()).toInstant()), new Date(), DateUnit.SECOND, false);
if(dif >= 20 && dif <= 23){
--
Gitblit v1.9.1