From ee83188936c8ac306144f6c8cd119b6d7574dfc6 Mon Sep 17 00:00:00 2001 From: kongdeqiang <123456> Date: 星期四, 02 三月 2023 22:44:11 +0800 Subject: [PATCH] 默认变更列表 --- src/main/java/com/boying/service/impl/BarrierServiceImpl.java | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/boying/service/impl/BarrierServiceImpl.java b/src/main/java/com/boying/service/impl/BarrierServiceImpl.java index 69755c2..26419ed 100644 --- a/src/main/java/com/boying/service/impl/BarrierServiceImpl.java +++ b/src/main/java/com/boying/service/impl/BarrierServiceImpl.java @@ -7,12 +7,15 @@ import com.boying.entity.Barrier; import com.boying.entity.EnterPark; import com.boying.entity.OutPark; +import com.boying.entity.Park; import com.boying.mapper.BarrierMapper; import com.boying.mapper.EnterParkMapper; import com.boying.mapper.OutParkMapper; +import com.boying.mapper.ParkMapper; import com.boying.service.BarrierService; import com.boying.service.EnterParkService; import lombok.AllArgsConstructor; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import java.time.ZoneId; @@ -31,6 +34,8 @@ public class BarrierServiceImpl extends ServiceImpl<BarrierMapper, Barrier> implements BarrierService { private EnterParkMapper enterParkMapper; private OutParkMapper outParkMapper; + private StringRedisTemplate redisTemplate; + private ParkMapper parkMapper; @Override public Barrier findByCode(String code) { QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); @@ -53,10 +58,21 @@ .last(" limit 1"); EnterPark enterPark = enterParkMapper.selectOne(wrapper); long dif = DateUtil.between(Date.from( enterPark.getCreateTime().atZone( ZoneId.systemDefault()).toInstant()), new Date(), DateUnit.SECOND, false); - if(dif >= 5 && dif <= 10){ + if(dif >= 5 && dif <= 7){ return true; }else { - return false; + //鍒ゆ柇鍋滆溅鍦烘槸鍚︽湁浜嗚溅浣� + String num = redisTemplate.opsForValue().get("car_park_" + enterPark.getParkId()); + if(num == null){ + num = "0"; + } + Park byId = parkMapper.selectById(enterPark.getParkId()); + int i = byId.getNum() - Integer.parseInt(num); + if(i<=0){ + return false; + }else { + return true; + } } } @@ -70,7 +86,7 @@ .last(" limit 1"); OutPark outPark = outParkMapper.selectOne(wrapper); long dif = DateUtil.between(Date.from( outPark.getCreateTime().atZone( ZoneId.systemDefault()).toInstant()), new Date(), DateUnit.SECOND, false); - if(dif >= 20 && dif <= 30){ + if(dif >= 20 && dif <= 23){ return true; }else { return false; -- Gitblit v1.9.1