From 281b8003e2d26451793c22f7c7c0c4d13ea40da1 Mon Sep 17 00:00:00 2001 From: kongdeqiang <kongdeqiang960204@163.com> Date: 星期三, 20 三月 2024 08:30:34 +0800 Subject: [PATCH] 提交更新 --- src/main/java/com/boying/controller/car/PlateServlet3.java | 55 ++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/boying/controller/car/PlateServlet3.java b/src/main/java/com/boying/controller/car/PlateServlet3.java index f921468..b6490e0 100644 --- a/src/main/java/com/boying/controller/car/PlateServlet3.java +++ b/src/main/java/com/boying/controller/car/PlateServlet3.java @@ -34,6 +34,7 @@ import java.io.*; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.Duration; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.Base64; @@ -142,10 +143,13 @@ @PostMapping("/status") public void heart(String serialno,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { Barrier barrier = barrierService.findByCode(serialno); - // Park park = parkService.getOneById(barrier.getParkId()); - Park park = parkService.getById(barrier.getParkId()); - String redis = redisTemplate.opsForValue().get("park_up_" + park.getId()); + Park park = parkService.getOneById(barrier.getParkId()); + // Park park = parkService.getById(barrier.getParkId()); + // String redis = redisTemplate.opsForValue().get("park_up_" + park.getId()); String redisnum = redisTemplate.opsForValue().get("car_park_" + park.getId()); + if(StringUtils.isBlank(redisnum)){ + redisnum = "0"; + } if(barrier!=null){ if(barrier.getType2()==1){ //寰呭紑闂� @@ -175,17 +179,23 @@ barrier.setUpdateTime(LocalDateTime.now()); barrierService.saveOrUpdate(barrier); -// String jsonValue = JSON.toJSONString(barrier); -// redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); + String jsonValue = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); easyOpen(request,response); }else { //涓嶉渶寮�闂� - barrier.setStatus(0); - barrier.setUpdateTime(LocalDateTime.now()); - barrierService.saveOrUpdate(barrier); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime updateTime = barrier.getUpdateTime(); + Duration duration = Duration.between(updateTime,now); + long minutes = duration.toMinutes(); + if(minutes>=2){ + barrier.setStatus(0); + barrier.setUpdateTime(LocalDateTime.now()); + barrierService.saveOrUpdate(barrier); + } -// String jsonValue = JSON.toJSONString(barrier); -// redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); + String jsonValue = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); if(barrier.getType() == 0){ OutPark outPark = outParkService.count4(barrier.getId()); if(outPark!=null){ @@ -211,11 +221,11 @@ byOutPark.setOpenTime(LocalDateTime.now()); outParkLogService.saveOrUpdate(byOutPark); enterParkService.deleteByCarNo(outPark.getCarNo(), barrier.getParkId()); - // redisTemplate.delete("outPark-"+outPark.getBarrierId()); + redisTemplate.delete("outPark-"+outPark.getBarrierId()); } } if(barrier.getType() == 1){ - boolean in = barrierService.getDateDifIn(barrier.getId()); + boolean in = barrierService.getDateDifIn(park.getId()); if(in){ inLedShowDefault(park.getId(),request,response); } @@ -533,6 +543,9 @@ enterPark.setImgId(fileInfo.getId()); } enterParkService.saveOrUpdate(enterPark); + String jsonValue = JSON.toJSONString(enterPark); + redisTemplate.opsForValue().set("enterPark_dif_"+ parkId, jsonValue); + } } @@ -599,6 +612,11 @@ byCarNoAndBarrierId.setStatus(2); byCarNoAndBarrierId.setStatus2(1); outParkService.saveOrUpdate(byCarNoAndBarrierId); + barrierService.saveOrUpdate(barrier); + String jsonValue2 = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); + String jsonValue = JSON.toJSONString(byCarNoAndBarrierId); + redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); return 0.0; }else{ if(StringUtils.isNotBlank(w.getParkIds())){ @@ -613,6 +631,11 @@ byCarNoAndBarrierId.setStatus(2); byCarNoAndBarrierId.setStatus2(1); outParkService.saveOrUpdate(byCarNoAndBarrierId); + barrierService.saveOrUpdate(barrier); + String jsonValue2 = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); + String jsonValue = JSON.toJSONString(byCarNoAndBarrierId); + redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); return 0.0; } } @@ -621,10 +644,15 @@ } } } + barrierService.saveOrUpdate(barrier); + String jsonValue2 = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); if(outPark.getPrice()==0&&outPark.getStatus3()==0){ System.out.println(outPark.getCarNo()+"璇ヨ溅涓嶉渶瑕佺即璐�"); String s= "1."+barrier.getCarNo()+"璇ヨ溅涓嶉渶瑕佺即璐筡n"; writeTxt2(s); + String jsonValue = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); outLedShow(barrier.getCode(),barrier.getCarNo(),outPark.getPrice(),toDayHrMinSec,barrier.getParkId(),request,response,0); }else { //闇�瑕佺即璐规垨鑰呮湁杩濈珷 @@ -635,9 +663,10 @@ byOutPark.setOutTime(outPark.getCreateTime()); byOutPark.setParkId(outPark.getParkId()); outParkLogService.saveOrUpdate(byOutPark); + String jsonValue = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); outLedShow(barrier.getCode(),barrier.getCarNo(),outPark.getPrice(),toDayHrMinSec,barrier.getParkId(),request,response,1); } - barrierService.saveOrUpdate(barrier); return money; } -- Gitblit v1.9.1