| | |
| | | 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 java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | public class BarrierController { |
| | | |
| | | private final BarrierService barrierService; |
| | | private final BarrierOpenLogService barrierOpenLogService; |
| | | private final OutParkService outParkService; |
| | | private final ParkService parkService; |
| | | private StringRedisTemplate redisTemplate; |
| | |
| | | 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>25000){ |
| | | long between = ChronoUnit.SECONDS.between(barrier.getUpdateTime(), LocalDateTime.now()); |
| | | if(between>121){ |
| | | barrier.setStatus(1); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | @PostMapping("openBarrier") |
| | | public Object openBarrier(Long barrierId,Integer type) { |
| | | public Object openBarrier(Long barrierId,Integer type,String carNo,String remark) { |
| | | Barrier b= barrierService.getById(barrierId); |
| | | if (b==null) { |
| | | return R.failed("未找到该道闸"); |
| | |
| | | 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(); |
| | | } |
| | |
| | | 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(); |
| | | } |
| | |
| | | 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(); |
| | | } |