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; }