| | |
| | | package com.boying.controller; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.boying.common.R; |
| | | import com.boying.common.SystemConfigProperties; |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | |
| | | @PostMapping("/findPage") |
| | | public Object findPage(Page page, String carNo,Long parkId,String payCode,String date) throws ParseException { |
| | | List<OutPark> list = outParkService.getList(page.getCurrent(), page.getSize(), carNo,parkId,payCode, date); |
| | | System.out.println(list); |
| | | long count = outParkService.getCount(carNo,parkId,payCode, date); |
| | | for (OutPark record : list) { |
| | | record.setParkName(parkService.getById(record.getParkId()).getName()); |
| | |
| | | //道闸code |
| | | @PostMapping("/findByBarrierCode") |
| | | public Object findById(String code) { |
| | | if(StringUtils.isBlank(code)){ |
| | | return R.failed(null,"参数错误"); |
| | | } |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Barrier::getCode2,code); |
| | | System.out.println("code :" +code); |
| | | List<Barrier> all = barrierService.list(wrapper); |
| | | if(all.size()==0){ |
| | | return R.failed("未找到该设备"); |
| | |
| | | //道闸code |
| | | @PostMapping("/findByBarrierCode2") |
| | | public Object findById2(String code2) { |
| | | if(StringUtils.isBlank(code2)){ |
| | | return R.failed(null,"参数错误"); |
| | | } |
| | | System.out.println("code2 :"+code2); |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Barrier::getCode2,code2); |
| | |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getByCarAndPark") |
| | | public Object getByCarAndPark(String carNo ,Integer parkId) { |
| | | QueryWrapper<OutPark> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(OutPark::getCarNo,carNo) |
| | | .eq(OutPark::getParkId,parkId) |
| | | .orderByDesc(OutPark::getCreateTime); |
| | | List<OutPark> list = outParkService.list(wrapper); |
| | | if(list.size() > 0){ |
| | | OutPark outPark = list.get(0); |
| | | if(outPark.getTime() > 0){ |
| | | outPark.setTimeStr(DateUtilOther.millisToDayHrMinSec(new Double(outPark.getTime()).longValue())); |
| | | }else { |
| | | outPark.setTimeStr("不足一分钟"); |
| | | } |
| | | return R.ok(outPark,"找到数据"); |
| | | }else { |
| | | return R.failed(null,"未找到数据"); |
| | | } |
| | | } |
| | | |
| | | //扫码修改出场(模糊车牌) |
| | | @GetMapping("/getLikeCar") |
| | | public Object getLikeCar(Integer outParkId) { |
| | | OutPark byId = outParkService.getById(outParkId); |
| | | List<Map<String, Object>> likeCar = outParkService.getLikeCar(byId.getCarNo(), byId.getParkId(), byId.getCreateTime()); |
| | | if (CollectionUtils.isNotEmpty(likeCar)) { |
| | | Collections.sort(likeCar, (m1, m2)-> String.valueOf(m2.get("createTime")).compareTo(String.valueOf(m1.get("createTime")))); |
| | | } |
| | | return R.ok(likeCar); |
| | | } |
| | | |
| | | //扫码修改出场(模糊车牌) |
| | | @GetMapping("/editOutPark") |
| | | public Object editOutPark(Integer outParkId,Integer enterParkId,Integer type) { |
| | | double money = 0.0; |
| | | OutPark outPark = outParkService.getById(outParkId); |
| | | EnterPark enterPark = enterParkService.getById(enterParkId); |
| | | Barrier barrier =barrierService.getById(outPark.getBarrierId()); |
| | | if(type == 0){ //入场正确,替换出场,更新出场记录 |
| | | outPark.setCarNo(enterPark.getCarNo()); |
| | | barrier.setCarNo(enterPark.getCarNo()); |
| | | barrierService.saveOrUpdate(barrier); |
| | | String jsonValue = JSON.toJSONString(barrier); |
| | | redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); |
| | | }else { //出场正确,替换入场,更新出场记录 |
| | | enterPark.setCarNo(outPark.getCarNo()); |
| | | } |
| | | outPark.setEnterTime(enterPark.getCreateTime()); |
| | | try { |
| | | long l = outPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() - enterPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
| | | outPark.setTime(l/(1000*60)); |
| | | if(outPark.getTime() > 0){ |
| | | outPark.setTimeStr(DateUtilOther.millisToDayHrMinSec(new Double(outPark.getTime()).longValue())); |
| | | }else { |
| | | outPark.setTimeStr("不足一分钟"); |
| | | } |
| | | money = costRuleService.getMoney(outPark.getParkId(), outPark.getEnterTime(), outPark.getCreateTime(), 1); |
| | | //入场记录保存一下 |
| | | enterPark.setPrice(money); |
| | | enterPark.setIsPay(0); |
| | | enterParkService.updateById(enterPark); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | outPark.setPrice(money); |
| | | outParkService.saveOrUpdate(outPark); |
| | | outPark.setParkName(barrier.getName()); |
| | | return R.ok(outPark,"更新成功"); |
| | | } |
| | | |
| | | @GetMapping("/editEnterPark") |
| | | public Object editEnterPark(String carNo ,Integer parkId,String time) { |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Barrier::getParkId,parkId) |
| | | .eq(Barrier::getType,1); |
| | | List<Barrier> list = barrierService.list(wrapper); |
| | | EnterPark enterPark = new EnterPark(); |
| | | enterPark.setCreateTime(LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | enterPark.setCarNo(carNo); |
| | | enterPark.setParkId(parkId); |
| | | enterPark.setBarrierId(list.get(0).getId()); |
| | | enterPark.setStatus(0); |
| | | enterPark.setIsAdd(1); |
| | | enterPark.setIsPay(0); |
| | | enterParkService.saveOrUpdate(enterPark); |
| | | |
| | | OutPark outPark = null; |
| | | QueryWrapper<OutPark> wrapper1 = new QueryWrapper<>(); |
| | | wrapper1.lambda() |
| | | .eq(OutPark::getParkId,parkId) |
| | | .eq(OutPark::getCarNo,carNo) |
| | | .ge(OutPark::getCreateTime,enterPark.getCreateTime()) |
| | | .ne(OutPark::getStatus,1); |
| | | List<OutPark> list1 = outParkService.list(wrapper1); |
| | | if(list1 !=null&&list1.size()>0){ |
| | | outPark = list1.get(0); |
| | | outPark.setEnterTime(enterPark.getCreateTime()); |
| | | long l = outPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() - enterPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
| | | outPark.setTime(l/(1000*60)); |
| | | try { |
| | | outPark.setPrice(costRuleService.getMoney(parkId, outPark.getEnterTime(), outPark.getCreateTime(), 1)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | outParkService.saveOrUpdate(outPark); |
| | | return R.ok(null,"修改出场记录成功"); |
| | | }else { |
| | | return R.ok(null,"新增入场记录成功"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public Barrier findBarrier(String code2) { |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |