From 99778d8dd53c80c5da4cf2d5d06835b9f3b7e205 Mon Sep 17 00:00:00 2001
From: zhangzeli <123456>
Date: 星期五, 26 十一月 2021 08:37:54 +0800
Subject: [PATCH] 报表
---
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AddOilController.java | 4 +-
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarService.java | 4 ++
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarServiceImpl.java | 8 ++++
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarMapper.java | 15 +++++++
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java | 24 ++++++++++++
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/Car.java | 25 ++++++++++++
6 files changed, 78 insertions(+), 2 deletions(-)
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AddOilController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AddOilController.java
index 3fe62e0..8fd4cf0 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AddOilController.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AddOilController.java
@@ -99,11 +99,11 @@
addOilList.add(new AddOil());
});
-
-
return new ResultUtil<List<AddOil>>().setData(addOilList);
}
+
+
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ApiOperation(value = "鑾峰彇鍏ㄩ儴鏁版嵁")
public Result<List<AddOil>> getAll() {
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java
index e261f9d..7fd6d1d 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java
@@ -24,8 +24,11 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* @author zhangzeli
@@ -101,6 +104,27 @@
}
return new ResultUtil<List<CarVo>>().setData(carVos);
}
+ @RequestMapping(value = "/getInfo", method = RequestMethod.GET)
+ @ApiOperation(value = "閫氳繃杞﹁締id鑾峰彇")
+ public Result<List<Car>> getInfo(String beginTime,String endTime) {
+ 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(car.getAmount());
+ car1.setMileage(car.getMileage());
+ car1.setMoney(car.getMoney());
+ continue;
+ }
+ }
+ }
+ return new ResultUtil<List<Car>>().setData(list);
+ }
@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "鍒嗛〉鑾峰彇")
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/Car.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/Car.java
index 8f99b63..1062720 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/Car.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/Car.java
@@ -83,4 +83,29 @@
@TableField(exist = false)
private String areaName;
+ @Transient
+ @TableField(exist = false)
+ private double mileage;
+
+ @Transient
+ @TableField(exist = false)
+ private double money;
+
+ @Transient
+ @TableField(exist = false)
+ private double amount;
+
+ @Transient
+ @TableField(exist = false)
+ private double allMileage;
+
+ @Transient
+ @TableField(exist = false)
+ private double allMoney;
+
+ @Transient
+ @TableField(exist = false)
+ private double allAmount;
+
+
}
\ No newline at end of file
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarMapper.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarMapper.java
index 8ba94ee..935ceaf 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarMapper.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarMapper.java
@@ -28,4 +28,19 @@
@Select("SELECT c.*,u.nickname,a.`name` AS area_name FROM t_car c LEFT JOIN t_user AS u ON c.user_id=u.id LEFT JOIN t_area AS a ON a.user_id=u.id")
List<Car> getAll2();
+
+ @Select("SELECT\n" +
+ "\tc.*,(SUM(amount)) AS allAmount,SUM(money) AS allMoney,(MAX(mileage)) AS allMileage\n" +
+ "FROM\n" +
+ "\tt_car c\n" +
+ "LEFT JOIN t_add_oil a ON c.id = a.car_id GROUP BY car_no\n")
+ List<Car> getCarInfo();
+
+ @Select("SELECT\n" +
+ "\tc.*,(MAX(amount)-MIN(amount)) AS amount,SUM(money) AS money,(MAX(mileage)-MIN(mileage)) AS mileage\n" +
+ "FROM\n" +
+ "\tt_car c\n" +
+ "LEFT JOIN t_add_oil a ON c.id = a.car_id ${ew.customSqlSegment}")
+ List<Car> getCarInfo2(@Param(Constants.WRAPPER) QueryWrapper<Car> wrapper);
+
}
\ No newline at end of file
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarService.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarService.java
index a5d8d54..39c0aea 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarService.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/service/ICarService.java
@@ -18,4 +18,8 @@
IPage<Car> page2(Page initMpPage, QueryWrapper<Car> wrapper);
List<Car> getAll2();
+
+ List<Car> getCarInfo();
+
+ List<Car> getCarInfo2(QueryWrapper<Car> wrapper);
}
\ No newline at end of file
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarServiceImpl.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarServiceImpl.java
index 41a4d28..1182a63 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarServiceImpl.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ICarServiceImpl.java
@@ -37,4 +37,12 @@
public List<Car> getAll2() {
return carMapper.getAll2();
}
+
+ public List<Car> getCarInfo(){
+ return carMapper.getCarInfo();
+ }
+
+ public List<Car> getCarInfo2(QueryWrapper<Car> wrapper){
+ return carMapper.getCarInfo2(wrapper);
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1