| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.boying.common.R; |
| | | import com.boying.common.SystemConfigProperties; |
| | | import com.boying.entity.*; |
| | |
| | | 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; |
| | | |
| | | @RestController |
| | | @RequestMapping("outPark") |
| | | @RequestMapping("ffzf/outpark") |
| | | @RequiredArgsConstructor |
| | | public class OutParkController { |
| | | |
| | |
| | | private StringRedisTemplate redisTemplate; |
| | | |
| | | @PostMapping("/findPage") |
| | | public Object findPage(Page page,OutPark outPark) { |
| | | QueryWrapper<OutPark> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().orderByDesc(OutPark::getId); |
| | | return R.ok(outParkService.page(page,wrapper)); |
| | | 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()); |
| | | if(record.getEnterTime() != null){ |
| | | record.setTimeStr(DateUtilOther.millisToDayHrMinSec(new Double(record.getTime()).longValue())); |
| | | }else { |
| | | record.setTimeStr("未发现入场记录"); |
| | | } |
| | | if(record.getImgId() != null){ |
| | | record.setImgPath("/ffzf/fileinfo/showImgById/"+record.getImgId()); |
| | | } |
| | | } |
| | | page.setRecords(list); |
| | | page.setTotal(count); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | //getById |
| | | @PostMapping("/getById") |
| | | public Object getById(Long id) { |
| | | return R.ok(outParkService.getById(id)); |
| | | } |
| | | //道闸code |
| | | @PostMapping("findByBarrierCode") |
| | | @PostMapping("/findByBarrierCode") |
| | | public Object findById(String code) { |
| | | 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("未找到该设备"); |
| | |
| | | if(outPark.getTime() > 0){ |
| | | outPark.setTimeStr(DateUtilOther.millisToDayHrMinSec(new Double(outPark.getTime()).longValue())); |
| | | }else { |
| | | outPark.setTimeStr("0"); |
| | | outPark.setTimeStr("不足一分钟"); |
| | | } |
| | | return R.ok(outPark); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //道闸code |
| | | @PostMapping("/findByBarrierCode2") |
| | | public Object findById2(String code2) { |
| | | System.out.println("code2 :"+code2); |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Barrier::getCode2,code2); |
| | | List<Barrier> all = barrierService.list(wrapper); |
| | | if(all.size()==0){ |
| | | return R.failed("未找到该设备"); |
| | | }else{ |
| | | Barrier barrier = all.get(0); |
| | | String carNo = barrier.getCarNo(); |
| | | |
| | | OutPark outPark = outParkService.findByCarNoAndBarrierId(carNo,barrier.getId()); |
| | | if(outPark==null){ |
| | | return R.failed("未识别到车牌号"); |
| | | }else{ |
| | | outPark.setParkName(barrier.getName()); |
| | | if(outPark.getTime() > 0){ |
| | | outPark.setTimeStr(DateUtilOther.millisToDayHrMinSec(new Double(outPark.getTime()).longValue())); |
| | | }else { |
| | | outPark.setTimeStr("不足一分钟"); |
| | | } |
| | | return R.ok(outPark); |
| | | } |
| | |
| | | return R.ok(outPark); |
| | | } |
| | | |
| | | @GetMapping("/statisticParkOrder") |
| | | public Object statisticParkOrder(Integer userId) { |
| | | User byId = userService.getById(userId); |
| | | @GetMapping("/statisticParkOrder/count") |
| | | public R statisticParkOrder(String parkIds) { |
| | | Map<String,Object> resultMap = new HashMap<>(); |
| | | if(byId != null){ |
| | | String parkIds = byId.getParkIds(); |
| | | if(parkIds != null){ |
| | | String[] split = parkIds.split(","); |
| | | int[] array = Arrays.stream(split).mapToInt(Integer::parseInt).toArray(); |
| | | List<Integer> parkIdList = new ArrayList<>(); |
| | | for (int i : array) { |
| | | parkIdList.add(i); |
| | | } |
| | | QueryWrapper<OutPark> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .between(OutPark::getCreateTime, DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date())) |
| | | .eq(OutPark::getStatus,1) |
| | | .in(OutPark::getParkId,parkIdList); |
| | | wrapper.select("IFNULL(ROUND(SUM(price)),0) as num"); |
| | | Map<String, Object> map = outParkService.getMap(wrapper); |
| | | String a = map.get("num").toString(); |
| | | if(a != null){ |
| | | resultMap.put("money",Double.parseDouble(a)); |
| | | }else { |
| | | resultMap.put("money",0.0); |
| | | } |
| | | wrapper.clear(); |
| | | wrapper.lambda() |
| | | .between(OutPark::getCreateTime, DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date())) |
| | | .eq(OutPark::getStatus,1) |
| | | .in(OutPark::getParkId,parkIdList); |
| | | int count = outParkService.count(wrapper); |
| | | resultMap.put("count",count); |
| | | return R.ok(resultMap); |
| | | }else { |
| | | return R.failed(null,"该用户未管理停车场"); |
| | | if(StringUtils.isNotBlank(parkIds)){ |
| | | String[] split = parkIds.split(","); |
| | | long[] array = Arrays.stream(split).mapToLong(Long::parseLong).toArray(); |
| | | List<Long> parkIdList = new ArrayList<>(); |
| | | for (long i : array) { |
| | | parkIdList.add(i); |
| | | } |
| | | QueryWrapper<OutPark> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .between(OutPark::getCreateTime, DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date())) |
| | | .eq(OutPark::getStatus,1) |
| | | .in(OutPark::getParkId,parkIdList); |
| | | wrapper.select("IFNULL(ROUND(SUM(price)),0) as num"); |
| | | Map<String, Object> map = outParkService.getMap(wrapper); |
| | | String a = map.get("num").toString(); |
| | | if(a != null){ |
| | | resultMap.put("money",Double.parseDouble(a)); |
| | | }else { |
| | | resultMap.put("money",0.0); |
| | | } |
| | | wrapper.clear(); |
| | | wrapper.lambda() |
| | | .between(OutPark::getCreateTime, DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date())) |
| | | .eq(OutPark::getStatus,1) |
| | | .in(OutPark::getParkId,parkIdList); |
| | | long count = outParkService.count(wrapper); |
| | | resultMap.put("count",count); |
| | | return R.ok(resultMap); |
| | | }else { |
| | | return R.failed(null,"未查询到该用户"); |
| | | return R.failed(null,"该用户未管理停车场"); |
| | | } |
| | | } |
| | | |
| | |
| | | public Object isJS(String carNo ,Integer parkId) { |
| | | List<EnterPark> byCarNo = enterParkService.findByCarNo(carNo, parkId); |
| | | if(byCarNo.size() > 0){ |
| | | return R.ok(byCarNo.get(0)); |
| | | return R.ok(byCarNo.get(0),"true"); |
| | | }else { |
| | | return R.failed(); |
| | | return R.ok(null,"false"); |
| | | } |
| | | } |
| | | |
| | | @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("/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.setIsPay(0); |
| | | enterPark.setImgId(null); |
| | | enterParkService.saveOrUpdate(enterPark); |
| | | return R.ok("修改成功"); |
| | | } |
| | | |
| | | |
| | | public Barrier findBarrier(String code2) { |
| | | QueryWrapper<Barrier> wrapper = new QueryWrapper<>(); |