From 421e01bc2af7515bb67df5f7f81652710b403067 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期五, 10 二月 2023 16:41:24 +0800
Subject: [PATCH] 增加功能
---
xboot-modules/xboot-your/src/main/resources/mapper/OrderTaskMapper.xml | 6 +
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderStatusCount.java | 2
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 | 9 ++
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/mapper/CarMapper.java | 11 +++
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ISignCountServiceImpl.java | 30 +++++++++-
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java | 51 +++++++++++------
xboot-modules/xboot-your/src/main/resources/mapper/SignCountMapper.xml | 35 ++++++-----
8 files changed, 105 insertions(+), 43 deletions(-)
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 df00ea4..e5a0da8 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
@@ -129,25 +129,40 @@
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);
}
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderStatusCount.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderStatusCount.java
index e687fdc..f85d9b6 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderStatusCount.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderStatusCount.java
@@ -80,4 +80,6 @@
private String fiveBatch;
@ExcelIgnore
private String sendMonth;
+ @ExcelIgnore
+ private Integer proportionInt;
}
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 0f88580..1db91a0 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
@@ -58,4 +58,13 @@
"from t_car")
Month getCarCount(@Param("year")Integer year);
-}
\ No newline at end of file
+ @Select("SELECT\n" +
+ "\t( MAX( amount ) - MIN( amount ) ) AS amount,\n" +
+ "\tSUM( money ) AS money,\n" +
+ "\t( MAX( mileage ) - MIN( mileage ) ) AS mileage, \n" +
+ "\tSUM(amount) AS allAmount,SUM(money) AS allMoney,(MAX(mileage)) AS allMileage \n"+
+ "FROM\n" +
+ "\t t_add_oil a\n" +
+ "\t WHERE a.car_id = #{carId}")
+ Car getCarInfoByCarId(@Param("carId")String carId);
+}
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 3f1d827..86c8fca 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
@@ -24,4 +24,6 @@
List<Car> getCarInfo2(QueryWrapper<Car> wrapper);
Month getCarCount(Integer year);
-}
\ No newline at end of file
+
+ Car getCarInfoByCarId(String carId);
+}
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 fe0b165..c4c529c 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,10 +37,12 @@
return carMapper.getAll2(initMpPage);
}
+ @Override
public List<Car> getCarInfo(){
return carMapper.getCarInfo();
}
+ @Override
public List<Car> getCarInfo2(QueryWrapper<Car> wrapper){
return carMapper.getCarInfo2(wrapper);
}
@@ -49,4 +51,9 @@
public Month getCarCount(Integer year) {
return carMapper.getCarCount(year);
}
-}
\ No newline at end of file
+
+ @Override
+ public Car getCarInfoByCarId(String carId) {
+ return carMapper.getCarInfoByCarId(carId);
+ }
+}
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ISignCountServiceImpl.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ISignCountServiceImpl.java
index 34fd295..ca87496 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ISignCountServiceImpl.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/serviceimpl/ISignCountServiceImpl.java
@@ -6,6 +6,7 @@
import cn.exrick.xboot.your.entity.SignCount;
import cn.exrick.xboot.your.service.ISignCountService;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jodd.util.StringUtil;
@@ -13,10 +14,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* 鐘舵�佺粺璁¤〃鎺ュ彛瀹炵幇
@@ -41,9 +43,31 @@
page.setSize(-1);
}
if(StringUtil.isNotBlank(orderStatusCount.getStatisticalType())){
+ IPage<OrderStatusCount> orderStatusCountIPage = this.signCountMapper.signCounts(orderStatusCount, page);
+ List<OrderStatusCount> records = orderStatusCountIPage.getRecords();
+ Map<String, List<OrderStatusCount>> collect = records.stream().collect(Collectors.groupingBy(OrderStatusCount::getCarName));
+ for (Map.Entry<String, List<OrderStatusCount>> stringListEntry : collect.entrySet()) {
+ for (Map.Entry<String, List<OrderStatusCount>> listEntry : stringListEntry.getValue().stream().collect(Collectors.groupingBy(OrderStatusCount::getBatch)).entrySet()) {
+ for (Map.Entry<String, List<OrderStatusCount>> listEntry1 : listEntry.getValue().stream().collect(Collectors.groupingBy(OrderStatusCount::getSendDate)).entrySet()) {
+ if(listEntry1.getValue().size() > 0){
+ List<OrderStatusCount> value = listEntry1.getValue();
+ OrderStatusCount orderStatusCount1 = value.get(0);
+ Double prodouble = value.stream().collect(Collectors.averagingInt(OrderStatusCount::getProportionInt));
+ prodouble = (double)Math.round(prodouble*100)/100;
+ orderStatusCount1.setProportion(prodouble + "%");
+ value.clear();
+ value.add(orderStatusCount1);
+ listEntry1.setValue(value);
+ }
+ }
- return this.signCountMapper.signCounts(orderStatusCount,page);
+ }
+
+ }
+ List<OrderStatusCount> collect1 = records.stream().filter(f -> f.getProportion() != null).collect(Collectors.toList());
+ orderStatusCountIPage.setRecords(collect1);
+ return orderStatusCountIPage;
}
return this.signCountMapper.signCount(orderStatusCount,page);
}
-}
\ No newline at end of file
+}
diff --git a/xboot-modules/xboot-your/src/main/resources/mapper/OrderTaskMapper.xml b/xboot-modules/xboot-your/src/main/resources/mapper/OrderTaskMapper.xml
index 638c0d3..0fc3dcd 100644
--- a/xboot-modules/xboot-your/src/main/resources/mapper/OrderTaskMapper.xml
+++ b/xboot-modules/xboot-your/src/main/resources/mapper/OrderTaskMapper.xml
@@ -71,9 +71,11 @@
b.car_no,
c.NAME,
d.NAME,
- a.send_date
+ a.send_date,
+ e.nickname,
+ a.id
ORDER BY
c.NAME ASC,
a.send_date asc
</select>
-</mapper>
\ No newline at end of file
+</mapper>
diff --git a/xboot-modules/xboot-your/src/main/resources/mapper/SignCountMapper.xml b/xboot-modules/xboot-your/src/main/resources/mapper/SignCountMapper.xml
index 7e2b84c..6ff70ab 100644
--- a/xboot-modules/xboot-your/src/main/resources/mapper/SignCountMapper.xml
+++ b/xboot-modules/xboot-your/src/main/resources/mapper/SignCountMapper.xml
@@ -21,7 +21,7 @@
sum(abnormal_sign) AS abnormalSign,
sum(not_sign_count) AS notSignCount,
sum(sign_count )AS signCount,
- CONCAT_WS( '',ROUND(AVG(proportion),0), '%') as proportion,
+ ROUND(AVG(proportion),0) as proportionInt,
</if>
<if test="bo.StatisticalType!=null and bo.StatisticalType !='' and bo.StatisticalType == '4'.toString()">
YEAR(DATE_FORMAT(DATE_SUB(send_date,INTERVAL 1 DAY),'%Y-%m-%d')) sendDate,
@@ -62,21 +62,16 @@
</if>
</where>
GROUP BY
- <if test="bo.StatisticalType!=null and bo.StatisticalType !='' and bo.StatisticalType == '1'.toString()">
- DATE(send_date),
- </if>
- <if test="bo.StatisticalType!=null and bo.StatisticalType !='' and bo.StatisticalType == '2'.toString()">
- WEEK(send_date,1),
- </if>
- <if test="bo.StatisticalType!=null and bo.StatisticalType !='' and bo.StatisticalType == '3'.toString()">
- MONTH(send_date),
- </if>
- <if test="bo.StatisticalType!=null and bo.StatisticalType !='' and bo.StatisticalType == '4'.toString()">
- YEAR(send_date),
- </if>
+ send_date,
car_name,
line,
- batch
+ batch,
+ amount,
+ abnormal_sign,
+ not_sign_count,
+ sign_count,
+ proportion,
+ user_name
ORDER BY
line ASC,
send_date asc
@@ -128,12 +123,18 @@
</if>
</where>
GROUP BY
- DATE(send_date),
+ send_date,
car_name,
line,
- batch
+ batch,
+ amount,
+ abnormal_sign,
+ not_sign_count,
+ sign_count,
+ proportion,
+ user_name
ORDER BY
line ASC,
send_date asc
</select>
-</mapper>
\ No newline at end of file
+</mapper>
--
Gitblit v1.9.1