| | |
| | | package com.boying.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.boying.common.R; |
| | |
| | | import com.boying.service.ParkService; |
| | | import com.boying.util.RedisJsonUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | private final BarrierService barrierService; |
| | | private final OutParkService outParkService; |
| | | private final ParkService parkService; |
| | | private final RedisJsonUtil redisJsonUtil; |
| | | private StringRedisTemplate redisTemplate; |
| | | |
| | | |
| | | @PostMapping("findPage") |
| | | public Object findPage(Page page, String parkId) { |
| | |
| | | for(Barrier barrier:records){ |
| | | long l = System.currentTimeMillis() - barrier.getUpdateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
| | | System.out.println(l); |
| | | if(l>10000){ |
| | | if(l>20000){ |
| | | barrier.setStatus(1); |
| | | } |
| | | } |
| | |
| | | barrier.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(barrier); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+barrier.getCode(),barrier); |
| | | } catch (IOException e) { |
| | | String jsonValue = JSON.toJSONString(barrier); |
| | | redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("保存成功"); |
| | |
| | | public Object delete(Integer id) { |
| | | Barrier byId = barrierService.getById(id); |
| | | barrierService.removeById(id); |
| | | redisJsonUtil.del("barrier-"+byId.getCode()); |
| | | redisTemplate.delete("barrier-"+byId.getCode()); |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | String jsonValue = JSON.toJSONString(b); |
| | | redisTemplate.opsForValue().set("barrier-"+b.getCode(), jsonValue); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |
| | |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | String jsonValue = JSON.toJSONString(b); |
| | | redisTemplate.opsForValue().set("barrier-"+b.getCode(), jsonValue); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |
| | |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | String jsonValue = JSON.toJSONString(b); |
| | | redisTemplate.opsForValue().set("barrier-"+b.getCode(), jsonValue); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |
| | |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | String jsonValue = JSON.toJSONString(b); |
| | | redisTemplate.opsForValue().set("barrier-"+b.getCode(), jsonValue); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |