| | |
| | | public Result<List<Car>> getInfo(String beginTime,String endTime) { |
| | | java.text.DecimalFormat df =new java.text.DecimalFormat("#.##"); |
| | | |
| | | QueryWrapper<Car> wrapper = new QueryWrapper<>(); |
| | | wrapper.ge(beginTime!=null && beginTime!="","a.add_date",beginTime); |
| | | wrapper.le(endTime!=null && endTime!="","a.add_date",endTime); |
| | | wrapper.groupBy("car_no"); |
| | | List<Car> list2 = iCarService.getCarInfo2(wrapper); |
| | | List<Car> list = iCarService.getCarInfo(); |
| | | for (Car car:list2){ |
| | | for (Car car1:list){ |
| | | if (car.getId().equals(car1.getId())){ |
| | | car1.setAmount(Double.parseDouble(df.format(car.getAmount()))); |
| | | car1.setMileage(Double.parseDouble(df.format(car.getMileage()))); |
| | | car1.setMoney(Double.parseDouble(df.format(car.getMoney()))); |
| | | car1.setAllAmount(Double.parseDouble(df.format(car1.getAllAmount()))); |
| | | car1.setAllMileage(Double.parseDouble(df.format(car1.getAllMileage()))); |
| | | car1.setAllMoney(Double.parseDouble(df.format(car1.getAllMoney()))); |
| | | continue; |
| | | } |
| | | } |
| | | QueryWrapper<AddOil> wrapper = new QueryWrapper<>(); |
| | | wrapper.ge(beginTime!=null && beginTime!="","add_date",beginTime); |
| | | wrapper.le(endTime!=null && endTime!="","add_date",endTime); |
| | | // wrapper.groupBy("car_id"); |
| | | List<AddOil> addOilList = iAddOilService.list(wrapper); |
| | | List<Car> list = new ArrayList<>(); |
| | | Map<String, List<AddOil>> collect = addOilList.stream().collect(Collectors.groupingBy(AddOil::getCarId)); |
| | | for (Map.Entry<String, List<AddOil>> stringListEntry : collect.entrySet()) { |
| | | String key = stringListEntry.getKey(); |
| | | Car car = iCarService.getById(key); |
| | | Car carInfoByCarId = iCarService.getCarInfoByCarId(key); |
| | | car.setAmount(Double.parseDouble(df.format(carInfoByCarId.getAmount()))); |
| | | car.setMileage(Double.parseDouble(df.format(carInfoByCarId.getMileage()))); |
| | | car.setMoney(Double.parseDouble(df.format(carInfoByCarId.getMoney()))); |
| | | car.setAllAmount(Double.parseDouble(df.format(carInfoByCarId.getAllAmount()))); |
| | | car.setAllMileage(Double.parseDouble(df.format(carInfoByCarId.getAllMileage()))); |
| | | car.setAllMoney(Double.parseDouble(df.format(carInfoByCarId.getAllMoney()))); |
| | | list.add(car); |
| | | } |
| | | // List<Car> list2 = iCarService.getCarInfo2(wrapper); |
| | | // List<Car> list = iCarService.getCarInfo(); |
| | | // for (Car car:list2){ |
| | | // for (Car car1:list){ |
| | | // if (car.getId().equals(car1.getId())){ |
| | | // car1.setAmount(Double.parseDouble(df.format(car.getAmount()))); |
| | | // car1.setMileage(Double.parseDouble(df.format(car.getMileage()))); |
| | | // car1.setMoney(Double.parseDouble(df.format(car.getMoney()))); |
| | | // car1.setAllAmount(Double.parseDouble(df.format(car1.getAllAmount()))); |
| | | // car1.setAllMileage(Double.parseDouble(df.format(car1.getAllMileage()))); |
| | | // car1.setAllMoney(Double.parseDouble(df.format(car1.getAllMoney()))); |
| | | // continue; |
| | | // } |
| | | // } |
| | | // } |
| | | return new ResultUtil<List<Car>>().setData(list); |
| | | } |
| | | |