From 64a292f39cd13b6e508335ca91e1264a3428bdf2 Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 1 Jul 2024 16:48:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E5=B9=B4=E5=BA=A6=E9=87=8C=E7=A8=8B=E7=BB=9F=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java | 4 ++++ .../main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml | 5 ++--- .../hnac/hzims/safeproduct/service/impl/CarServiceImpl.java | 11 ++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java index c73f78e..b9355a2 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; +import java.util.Date; /** * @author liwen @@ -78,4 +79,7 @@ public class CarMilesYearVO { @ExcelProperty(value = "合计里程/km", order = 15) @ApiModelProperty("合计里程数") private BigDecimal sumMiles; + + @ApiModelProperty("创建时间") + private Date createTime; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml index 6080ea6..61bea9f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml @@ -4,7 +4,7 @@ SELECT - t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles, - t1.create_user, t1.create_dept + t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles FROM hzims_car t1 LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java index a46457a..90fadf4 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java @@ -15,6 +15,7 @@ import com.hnac.hzims.safeproduct.entity.CarEntity; import com.hnac.hzims.safeproduct.mapper.CarMapper; import com.hnac.hzims.safeproduct.service.*; import com.hnac.hzims.safeproduct.vo.CarMilesYearVO; +import org.apache.commons.collections4.map.HashedMap; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -29,6 +30,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -71,7 +73,7 @@ public class CarServiceImpl extends ServiceImpl implements } List carList = records.stream().map(CarMilesYearVO::getPlateNumber).collect(Collectors.toList()); List milesList = baseMapper.selectMilesByCar(carList, year); - List res = new ArrayList<>(); + HashedMap map = new HashedMap<>(); milesList.forEach(data -> { CarMilesYearVO carMilesYearVO = records.stream().filter(x -> x.getPlateNumber().equals(data.getPlateNumber())) .collect(Collectors.toList()).get(0); @@ -127,11 +129,14 @@ public class CarServiceImpl extends ServiceImpl implements carMilesYearVO.setSumMiles(sum.add(data.getMiles())); } if (!carMilesYearVO.getSumMiles().equals(new BigDecimal(0))) { - res.add(carMilesYearVO); + map.put(carMilesYearVO.getPlateNumber(), carMilesYearVO); } }); + List list = new ArrayList<>(map.values()); + List res = list.stream().sorted(Comparator.comparing(CarMilesYearVO::getCreateTime).reversed()) + .collect(Collectors.toList()); page.setRecords(res); - page.setTotal(res.size()); + page.setTotal(carPage.getTotal()); return page; }