| | |
| | | import com.boying.entity.OutPark; |
| | | import com.boying.service.BarrierService; |
| | | import com.boying.service.OutParkService; |
| | | import com.boying.service.ParkService; |
| | | import com.boying.util.RedisJsonUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("barrier") |
| | | @RequestMapping("ffzf/barrier") |
| | | @RequiredArgsConstructor |
| | | public class BarrierController { |
| | | |
| | | private final BarrierService barrierService; |
| | | private final OutParkService outParkService; |
| | | private final ParkService parkService; |
| | | private final RedisJsonUtil redisJsonUtil; |
| | | |
| | | @PostMapping("findPage") |
| | | public Object findPage(Page page, String parkId) { |
| | |
| | | public Object save(Barrier barrier) { |
| | | barrier.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(barrier); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+barrier.getCode(),barrier); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("保存成功"); |
| | | } |
| | | |
| | | @PostMapping("delete") |
| | | public Object delete(Integer id) { |
| | | Barrier byId = barrierService.getById(id); |
| | | barrierService.removeById(id); |
| | | redisJsonUtil.del("barrier-"+byId.getCode()); |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | |
| | | b.setType2(1); |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |
| | | } |
| | | |
| | | @PostMapping("getByCode") |
| | | public Object getByCode(String code) { |
| | | Barrier b= barrierService.findByCode2(code); |
| | | if (b==null) { |
| | | return R.failed("未找到该道闸"); |
| | | } |
| | | b.setParkName(parkService.getById(b.getParkId()).getName()); |
| | | return R.ok(b,"请求成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("openBarrier") |
| | | public Object openBarrier(Long barrierId,Integer type) { |
| | |
| | | b.setType2(1); |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |
| | | }else { |
| | | System.out.println("手动开出口闸"); |
| | |
| | | b.setType2(1); |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |
| | | }else { |
| | | //计费 |
| | | b.setType2(1); |
| | | b.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(b); |
| | | try { |
| | | redisJsonUtil.set("barrier-"+b.getCode(),b); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok("请求成功"); |
| | | } |
| | | } |