| | |
| | | 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; |
| | |
| | | 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<>(); |