| | |
| | | |
| | | @PostMapping("/findCountPage") |
| | | public Object findCountPage(Integer parkId,String startTime,String endTime) throws ParseException { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | QueryWrapper<OutPark> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(parkId != null,OutPark::getParkId,parkId) |
| | | .isNotNull(OutPark::getPayCode) |
| | | .eq(OutPark::getStatus,1); |
| | | if(startTime != null && endTime != null){ |
| | | wrapper.lambda().between(OutPark::getUpdateTime,DateUtil.beginOfDay(sdf.parse(startTime)), DateUtil.endOfDay(sdf.parse(endTime))); |
| | | } |
| | | List<OutPark> list = outParkService.list(wrapper); |
| | | List<OutParkVo> list = outParkService.getVoList(parkId,startTime,endTime); |
| | | List<Map<String,Object>> resultList = new ArrayList<>(); |
| | | if(list.size()>0){ |
| | | Map<Object, List<OutPark>> collect = list.stream().collect( |
| | | Collectors.groupingBy(b -> b.getParkId() |
| | | )); |
| | | for (Map.Entry<Object, List<OutPark>> objectListEntry : collect.entrySet()) { |
| | | Integer key = (Integer) objectListEntry.getKey(); |
| | | List<OutPark> value = objectListEntry.getValue(); |
| | | Double collect1 = value.stream().collect(Collectors.summingDouble(OutPark::getPrice)); |
| | | |
| | | for (Map.Entry<Integer, List<OutParkVo>> entry : list.stream().collect(Collectors.groupingBy(item -> item.getParkId())).entrySet()) { |
| | | Integer pid = entry.getKey(); |
| | | List<OutParkVo> vos = entry.getValue(); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | Park byId = parkService.getById(key); |
| | | Park byId = parkService.getById(pid); |
| | | if(byId != null){ |
| | | map.put("parkName",byId.getName()); |
| | | }else { |
| | | map.put("parkName","未知停车场"); |
| | | } |
| | | map.put("orderNum",value.size()); |
| | | map.put("orderMoney",collect1); |
| | | int sum = vos.stream().mapToInt(item -> item.getNum()).sum(); |
| | | double price = vos.stream().mapToDouble(item -> item.getPrice()).sum(); |
| | | map.put("orderNum",sum); |
| | | map.put("orderMoney",price); |
| | | resultList.add(map); |
| | | |
| | | } |
| | | } |
| | | |
| | | // for (OutParkVo outParkVo : list) { |
| | | // Map<String,Object> map = new HashMap<>(); |
| | | // Park byId = parkService.getById(outParkVo.getParkId()); |
| | | // if(byId != null){ |
| | | // map.put("parkName",byId.getName()); |
| | | // }else { |
| | | // map.put("parkName","未知停车场"); |
| | | // } |
| | | // map.put("orderNum",outParkVo.getNum()); |
| | | // map.put("orderMoney",outParkVo.getPrice()); |
| | | // resultList.add(map); |
| | | // } |
| | | return R.ok(resultList); |
| | | } |
| | | |