From 83a1aa3133ce9c35fb428d0cdf4a84adda4ba3ac Mon Sep 17 00:00:00 2001 From: kongdeqiang <123456> Date: 星期三, 24 四月 2024 16:33:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/com/boying/controller/BarrierController.java | 41 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/boying/controller/BarrierController.java b/src/main/java/com/boying/controller/BarrierController.java index 7089007..a05bf04 100644 --- a/src/main/java/com/boying/controller/BarrierController.java +++ b/src/main/java/com/boying/controller/BarrierController.java @@ -5,11 +5,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.boying.common.R; import com.boying.entity.Barrier; +import com.boying.entity.BarrierOpenLog; import com.boying.entity.OutPark; +import com.boying.service.BarrierOpenLogService; import com.boying.service.BarrierService; import com.boying.service.OutParkService; import com.boying.service.ParkService; import com.boying.util.RedisJsonUtil; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.PostMapping; @@ -19,20 +23,24 @@ import java.io.IOException; import java.time.LocalDateTime; import java.time.ZoneOffset; +import java.time.temporal.ChronoUnit; import java.util.List; @RestController @RequestMapping("ffzf/barrier") @RequiredArgsConstructor +@Tag(description = "ffzf/barrier" , name = "閬撻椄鎺ュ彛" ) public class BarrierController { private final BarrierService barrierService; + private final BarrierOpenLogService barrierOpenLogService; private final OutParkService outParkService; private final ParkService parkService; - private StringRedisTemplate redisTemplate; + private final StringRedisTemplate redisTemplate; @PostMapping("findPage") + @Operation(summary = "鏍规嵁鍋滆溅鍦哄垎椤垫煡璇㈤亾闂�" , description = "鏍规嵁鍋滆溅鍦哄垎椤垫煡璇㈤亾闂�" ) public Object findPage(Page page, String parkId) { QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); wrapper.lambda() @@ -40,9 +48,8 @@ Page page1 = barrierService.page(page, wrapper); List<Barrier> records = page1.getRecords(); for(Barrier barrier:records){ - long l = System.currentTimeMillis() - barrier.getUpdateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); - System.out.println(l); - if(l>20000){ + long between = ChronoUnit.SECONDS.between(barrier.getUpdateTime(), LocalDateTime.now()); + if(between>121){ barrier.setStatus(1); } } @@ -51,6 +58,7 @@ } @PostMapping("save") + @Operation(summary = "鏂板閬撻椄" , description = "鏂板閬撻椄" ) public Object save(Barrier barrier) { barrier.setUpdateTime(LocalDateTime.now()); barrierService.saveOrUpdate(barrier); @@ -64,6 +72,7 @@ } @PostMapping("delete") + @Operation(summary = "鍒犻櫎閬撻椄" , description = "鍒犻櫎閬撻椄" ) public Object delete(Integer id) { Barrier byId = barrierService.getById(id); barrierService.removeById(id); @@ -72,6 +81,7 @@ } @PostMapping("findAll") + @Operation(summary = "鏌ヨ鎵�鏈夐亾闂革紙APP锛�" , description = "鏌ヨ鎵�鏈夐亾闂革紙APP锛�" ) public Object findAll(Long parkId) { if (parkId==null) { return R.failed("鏈彂鐜拌鍋滆溅鍦�"); @@ -83,6 +93,7 @@ } @PostMapping("open") + @Operation(summary = "鎵嬪姩寮�闂革紙搴熷純锛�" , description = "鎵嬪姩寮�闂革紙搴熷純锛�" ) public Object open(Long barrierId) { Barrier b= barrierService.getById(barrierId); if (b==null) { @@ -101,6 +112,7 @@ } @PostMapping("getByCode") + @Operation(summary = "鏍规嵁code鏌ヨ閬撻椄" , description = "鏍规嵁code鏌ヨ閬撻椄" ) public Object getByCode(String code) { Barrier b= barrierService.findByCode2(code); if (b==null) { @@ -113,7 +125,8 @@ @PostMapping("openBarrier") - public Object openBarrier(Long barrierId,Integer type) { + @Operation(summary = "鎵嬫寔鎵嬪姩寮�闂�" , description = "鎵嬫寔鎵嬪姩寮�闂�" ) + public Object openBarrier(Long barrierId,Integer type,String carNo,String remark) { Barrier b= barrierService.getById(barrierId); if (b==null) { return R.failed("鏈壘鍒拌閬撻椄"); @@ -127,6 +140,12 @@ try { String jsonValue = JSON.toJSONString(b); redisTemplate.opsForValue().set("barrier-"+b.getCode(), jsonValue); + BarrierOpenLog barrierOpenLog = new BarrierOpenLog(); + barrierOpenLog.setCarNo(carNo); + barrierOpenLog.setRemark(remark); + barrierOpenLog.setParkId(b.getParkId()); + barrierOpenLog.setType(b.getType()); + barrierOpenLogService.save(barrierOpenLog); } catch (Exception e) { e.printStackTrace(); } @@ -148,6 +167,12 @@ try { String jsonValue = JSON.toJSONString(b); redisTemplate.opsForValue().set("barrier-"+b.getCode(), jsonValue); + BarrierOpenLog barrierOpenLog = new BarrierOpenLog(); + barrierOpenLog.setCarNo(carNo); + barrierOpenLog.setRemark(remark); + barrierOpenLog.setParkId(b.getParkId()); + barrierOpenLog.setType(b.getType()); + barrierOpenLogService.save(barrierOpenLog); } catch (Exception e) { e.printStackTrace(); } @@ -160,6 +185,12 @@ try { String jsonValue = JSON.toJSONString(b); redisTemplate.opsForValue().set("barrier-"+b.getCode(), jsonValue); + BarrierOpenLog barrierOpenLog = new BarrierOpenLog(); + barrierOpenLog.setCarNo(carNo); + barrierOpenLog.setRemark(remark); + barrierOpenLog.setParkId(b.getParkId()); + barrierOpenLog.setType(b.getType()); + barrierOpenLogService.save(barrierOpenLog); } catch (Exception e) { e.printStackTrace(); } -- Gitblit v1.9.1