From 86c29c1a7d83b8fca6ff26f1171dde89989af5f9 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期一, 22 四月 2024 10:50:32 +0800
Subject: [PATCH] fix : 新增模糊车牌匹配功能
---
src/main/java/com/boying/service/impl/OutParkServiceImpl.java | 148 +++++++++++++++++++++++++++++++++++--------------
1 files changed, 106 insertions(+), 42 deletions(-)
diff --git a/src/main/java/com/boying/service/impl/OutParkServiceImpl.java b/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
index affe3db..e5c929e 100644
--- a/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
+++ b/src/main/java/com/boying/service/impl/OutParkServiceImpl.java
@@ -4,14 +4,13 @@
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.entity.*;
+import com.boying.mapper.EnterParkMapper;
import com.boying.mapper.OutParkMapper;
import com.boying.mapper.StatisticMapper;
import com.boying.service.OutParkService;
import com.boying.service.StatisticService;
+import com.boying.util.PlateComparator;
import com.boying.util.RedisJsonUtil;
import com.boying.util.StringUtil;
import lombok.AllArgsConstructor;
@@ -19,6 +18,7 @@
import org.springframework.stereotype.Service;
import java.io.IOException;
+import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -34,6 +34,7 @@
@AllArgsConstructor
public class OutParkServiceImpl extends ServiceImpl<OutParkMapper, OutPark> implements OutParkService {
private final OutParkMapper outParkMapper;
+ private final EnterParkMapper enterParkMapper;
private StringRedisTemplate redisTemplate;
@@ -118,45 +119,32 @@
@Override
public OutPark count4(Integer bId) {
-// 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;
+ 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
@@ -203,6 +191,82 @@
}
@Override
+ public OutPark findBy5min(String carNo, Integer parkId,LocalDateTime dateTime) {
+ LocalDateTime localDateTime = dateTime.minusMinutes(5);
+ QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(OutPark::getCarNo,carNo)
+ .eq(OutPark::getParkId,parkId)
+ .ge(OutPark::getCreateTime,localDateTime)
+ .isNotNull(OutPark::getEnterTime);
+ List<OutPark> outParks = outParkMapper.selectList(wrapper);
+ if(outParks != null && outParks.size()>0){
+ for (OutPark outPark : outParks) {
+ if(outPark.getPrice() == 0){
+ return outPark;
+ }
+ if(outPark.getPrice() != 0 && outPark.getStatus() == 1){
+ return outPark;
+ }
+ }
+ }
+ return null;
+ }
+ @Override
+ public OutPark findBy10min(String carNo, Integer parkId,LocalDateTime dateTime,Integer outParkId) {
+ LocalDateTime localDateTime = dateTime.minusMinutes(10);
+ QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(OutPark::getCarNo,carNo)
+ .eq(OutPark::getParkId,parkId)
+ .ge(OutPark::getCreateTime,localDateTime)
+ .ge(OutPark::getPrice,0)
+ .ne(OutPark::getId,outParkId)
+ .isNotNull(OutPark::getPayCode)
+ .isNotNull(OutPark::getEnterTime);
+ List<OutPark> outParks = outParkMapper.selectList(wrapper);
+ if(outParks != null && outParks.size()>0){
+ return outParks.get(0);
+ }
+ return null;
+ }
+
+ @Override
+ public List<Map<String, Object>> getLikeCar(String carNo, Integer parkId, LocalDateTime dateTime) {
+ QueryWrapper<EnterPark> wrapper = new QueryWrapper<>();
+ wrapper.select(" id,car_no,park_id,create_time ");
+ wrapper.lambda()
+ .eq(EnterPark::getParkId,parkId)
+ .lt(EnterPark::getCreateTime,dateTime);
+ List<EnterPark> enterParks = enterParkMapper.selectList(wrapper);
+ if(enterParks !=null && enterParks.size()>0){
+ List<Map<String, Object>> list = PlateComparator.getList(carNo, enterParks);
+ return list;
+ }else {
+ return null;
+ }
+ }
+
+ @Override
+ public OutPark findBy5min2(String carNo, Integer parkId,LocalDateTime dateTime) {
+ LocalDateTime localDateTime = dateTime.minusMinutes(7);
+ QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(OutPark::getCarNo,carNo)
+ .eq(OutPark::getParkId,parkId)
+ .ge(OutPark::getCreateTime,localDateTime)
+ .ge(OutPark::getPrice,0)
+ .ne(OutPark::getStatus,1)
+ .isNotNull(OutPark::getPayCode)
+ .isNotNull(OutPark::getEnterTime);
+ List<OutPark> outParks = outParkMapper.selectList(wrapper);
+ if(outParks != null && outParks.size()>0){
+ return outParks.get(0);
+ }
+ 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,size,carNo,parkId,payCode,date);
}
--
Gitblit v1.9.1