Commit 974717b5539d69ff0783c5fc3a7dcc13e1238191
1 parent
75386fb4
feat: 地址排序出错
Showing
1 changed file
with
17 additions
and
13 deletions
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderServiceImpl.java
| @@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 32 | import javax.annotation.Resource; | 32 | import javax.annotation.Resource; |
| 33 | import java.util.*; | 33 | import java.util.*; |
| 34 | import java.util.stream.Collectors; | 34 | import java.util.stream.Collectors; |
| 35 | +import java.util.stream.Stream; | ||
| 35 | 36 | ||
| 36 | /** | 37 | /** |
| 37 | * @author 20412 | 38 | * @author 20412 |
| @@ -581,7 +582,6 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | @@ -581,7 +582,6 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 581 | Integer pageNum = ServletUtils.getParameterToInt("pageNum"); | 582 | Integer pageNum = ServletUtils.getParameterToInt("pageNum"); |
| 582 | Integer pageSize = ServletUtils.getParameterToInt("pageSize"); | 583 | Integer pageSize = ServletUtils.getParameterToInt("pageSize"); |
| 583 | Integer orderByColumn = ServletUtils.getParameterToInt("orderByColumn"); | 584 | Integer orderByColumn = ServletUtils.getParameterToInt("orderByColumn"); |
| 584 | - | ||
| 585 | Comparator<TransportationEnterpriseVo> comparator; | 585 | Comparator<TransportationEnterpriseVo> comparator; |
| 586 | if (1 == orderByColumn) { | 586 | if (1 == orderByColumn) { |
| 587 | comparator = Comparator.comparing(TransportationEnterpriseVo::getCleanNumber); | 587 | comparator = Comparator.comparing(TransportationEnterpriseVo::getCleanNumber); |
| @@ -609,19 +609,23 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | @@ -609,19 +609,23 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 609 | qw.eq(GarAddress::getGarUserId, SecurityUtils.getLoginUser().getUser().getUserId()) | 609 | qw.eq(GarAddress::getGarUserId, SecurityUtils.getLoginUser().getUser().getUserId()) |
| 610 | .eq(GarAddress::getGarUserDefault, GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue()); | 610 | .eq(GarAddress::getGarUserDefault, GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue()); |
| 611 | GarAddress address = garAddressService.getOne(qw); | 611 | GarAddress address = garAddressService.getOne(qw); |
| 612 | - List<TransportationEnterpriseVo> voList = list.stream().map(item -> { | ||
| 613 | - TransportationEnterpriseVo vo = new TransportationEnterpriseVo(); | ||
| 614 | - BeanUtils.copyProperties(item, vo); | ||
| 615 | - List<GarOrderEvaluate> evaluate = evaluateMap.get(String.valueOf(item.getId())); | ||
| 616 | - handleCleanNumber(vo, orderList); | ||
| 617 | - handleScore(vo, evaluate); | ||
| 618 | - handleDistance(vo, address); | ||
| 619 | - return vo; | ||
| 620 | - }) | ||
| 621 | - // 降序 | ||
| 622 | - .sorted(comparator.reversed()) | ||
| 623 | - .collect(Collectors.toList()); | ||
| 624 | 612 | ||
| 613 | + Stream<TransportationEnterpriseVo> stream = list.stream().map(item -> { | ||
| 614 | + TransportationEnterpriseVo vo = new TransportationEnterpriseVo(); | ||
| 615 | + BeanUtils.copyProperties(item, vo); | ||
| 616 | + List<GarOrderEvaluate> evaluate = evaluateMap.get(String.valueOf(item.getId())); | ||
| 617 | + handleCleanNumber(vo, orderList); | ||
| 618 | + handleScore(vo, evaluate); | ||
| 619 | + handleDistance(vo, address); | ||
| 620 | + return vo; | ||
| 621 | + }); | ||
| 622 | + List<TransportationEnterpriseVo> voList; | ||
| 623 | + if ( orderByColumn != 0){ | ||
| 624 | + // 降序 | ||
| 625 | + voList= stream.sorted(comparator.reversed()).collect(Collectors.toList()); | ||
| 626 | + }else { | ||
| 627 | + voList= stream.sorted(comparator).collect(Collectors.toList()); | ||
| 628 | + } | ||
| 625 | int total = voList.size(); | 629 | int total = voList.size(); |
| 626 | int remainder = total % pageSize; | 630 | int remainder = total % pageSize; |
| 627 | int currentPage = pageNum > 0 ? (pageNum - 1) * pageSize : pageNum * pageSize; | 631 | int currentPage = pageNum > 0 ? (pageNum - 1) * pageSize : pageNum * pageSize; |