Commit 32468c7ef60822f76ef1880fa54f40394603c69b
1 parent
8008e620
feat: 公司接口查询条件修改,新增位置排序,所属区域筛选
Showing
6 changed files
with
46 additions
and
21 deletions
trash-garbage/src/main/java/com/trash/garbage/controller/GarbageOrderController.java
| ... | ... | @@ -144,9 +144,8 @@ public class GarbageOrderController { |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | @GetMapping("/company") |
| 147 | - public Result<?> queryEnterpriseList(TransportationEnterprise enterprise) { | |
| 148 | - startPage(); | |
| 149 | - return Result.OK(garOrderService.queryEnterpriseList(enterprise)); | |
| 147 | + public Result<?> queryEnterpriseList(TransportationEnterprise dto) { | |
| 148 | + return Result.OK(garOrderService.queryEnterpriseList(dto)); | |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | 151 | @GetMapping("/search/history") | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarOrderMapper.java
| ... | ... | @@ -15,7 +15,7 @@ import java.util.List; |
| 15 | 15 | */ |
| 16 | 16 | public interface GarOrderMapper extends BaseMapper<GarOrder> { |
| 17 | 17 | |
| 18 | - List<GarOrder> queryCleanNumberByEnterpriseIds(@Param("list") List<Long> enterpriseIds,@Param("status") Integer value); | |
| 18 | + List<GarOrder> queryCleanNumberByEnterpriseIds(@Param("list") List<Long> list,@Param("status") Integer value); | |
| 19 | 19 | |
| 20 | 20 | List<GarOrderDriverVo> queryOrderListByTelWithType(@Param("garUserTel") String garUserTel, @Param("type") Integer type, @Param("cancelFlag") Integer cancelFlag); |
| 21 | 21 | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/pojo/dto/EnterpriseDto.java deleted
100644 → 0
trash-garbage/src/main/java/com/trash/garbage/service/GarOrderService.java
| ... | ... | @@ -65,7 +65,7 @@ public interface GarOrderService extends IService<GarOrder> { |
| 65 | 65 | |
| 66 | 66 | OrderDetailVo queryOrderWebDetail(String id); |
| 67 | 67 | |
| 68 | - PageInfo queryEnterpriseList(TransportationEnterprise enterprise); | |
| 68 | + PageInfo queryEnterpriseList(TransportationEnterprise dto); | |
| 69 | 69 | |
| 70 | 70 | List<GarOrderEvaluate> queryEvaluateDetail(String orderId); |
| 71 | 71 | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderServiceImpl.java
| ... | ... | @@ -3,6 +3,7 @@ package com.trash.garbage.service.impl; |
| 3 | 3 | import java.util.*; |
| 4 | 4 | import java.util.stream.Collectors; |
| 5 | 5 | |
| 6 | +import com.trash.common.utils.ServletUtils; | |
| 6 | 7 | import com.trash.enterprise.domain.TransportationEnterprise; |
| 7 | 8 | import com.trash.enterprise.service.ITransportationEnterpriseService; |
| 8 | 9 | import com.trash.garbage.custom.BizException; |
| ... | ... | @@ -491,8 +492,23 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> |
| 491 | 492 | |
| 492 | 493 | @Override |
| 493 | 494 | public PageInfo queryEnterpriseList(TransportationEnterprise enterprise) { |
| 495 | + // 1)支持选择企业“所属区域”(长沙市内的)展示区域内所有企业 | |
| 496 | + // 2)支持选择车辆“车辆类型”展示有该车辆类型的企业 | |
| 497 | + // TODO 车辆类型暂时不考虑 | |
| 494 | 498 | List<TransportationEnterprise> list = transportationEnterpriseService.selectTransportationEnterpriseList(enterprise); |
| 495 | - long total = new PageInfo<>(list).getTotal(); | |
| 499 | + Integer pageNum = ServletUtils.getParameterToInt("pageNum"); | |
| 500 | + Integer pageSize = ServletUtils.getParameterToInt("pageSize"); | |
| 501 | + Integer orderByColumn = ServletUtils.getParameterToInt("orderByColumn"); | |
| 502 | + | |
| 503 | + Comparator<TransportationEnterpriseVo> comparator; | |
| 504 | + if (1 == orderByColumn) { | |
| 505 | + comparator = Comparator.comparing(TransportationEnterpriseVo::getCleanNumber); | |
| 506 | + } else if (2 == orderByColumn) { | |
| 507 | + comparator = Comparator.comparing(TransportationEnterpriseVo::getScore); | |
| 508 | + } else { | |
| 509 | + comparator = Comparator.comparing(TransportationEnterpriseVo::getDistance); | |
| 510 | + } | |
| 511 | + | |
| 496 | 512 | List<Long> enterpriseIds = list.stream().map(TransportationEnterprise::getId).collect(Collectors.toList()); |
| 497 | 513 | List<GarOrder> orderList = baseMapper.queryCleanNumberByEnterpriseIds(enterpriseIds, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue()); |
| 498 | 514 | List<GarOrderEvaluate> evaluateList = garOrderEvaluateService.queryEvaluateByEnterpriseIds(enterpriseIds, GlobalStatus.GarOrderStatus.EVALUATE_TYPE_COMPANY.getValue()); |
| ... | ... | @@ -516,21 +532,30 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> |
| 516 | 532 | List<GarOrderEvaluate> evaluate = evaluateMap.get(String.valueOf(item.getId())); |
| 517 | 533 | handleCleanNumber(vo, orderList); |
| 518 | 534 | handleScore(vo, evaluate); |
| 519 | - handleKilometre(vo, address); | |
| 535 | + handleDistance(vo, address); | |
| 520 | 536 | return vo; |
| 521 | 537 | }) |
| 522 | - .sorted(Comparator.comparing(TransportationEnterpriseVo::getDistance)) | |
| 538 | + // 降序 | |
| 539 | + .sorted(comparator.reversed()) | |
| 523 | 540 | .collect(Collectors.toList()); |
| 541 | + | |
| 542 | + int total = voList.size(); | |
| 543 | + int remainder = total % pageSize; | |
| 544 | + int currentPage = pageNum > 0 ? (pageNum - 1) * pageSize : pageNum * pageSize; | |
| 545 | + // 怕页码超出界限了 超出界限就通过currenPage (3 * 10) > total (25) ? currentPage (20) - (pageSize (10) - remainder (3)) : currentPage | |
| 546 | + int startPage = currentPage > total ? currentPage - (pageSize - remainder) : currentPage; | |
| 547 | + int endPage = Math.min(startPage + pageSize, total); | |
| 524 | 548 | PageInfo<TransportationEnterpriseVo> pageInfo = new PageInfo<>(); |
| 525 | - pageInfo.setList(voList); | |
| 549 | + pageInfo.setList(voList.subList(startPage, endPage)); | |
| 526 | 550 | pageInfo.setTotal(total); |
| 527 | 551 | return pageInfo; |
| 528 | 552 | } |
| 529 | 553 | |
| 530 | - private void handleKilometre(TransportationEnterpriseVo vo, GarAddress address) { | |
| 554 | + | |
| 555 | + private void handleDistance(TransportationEnterpriseVo vo, GarAddress address) { | |
| 531 | 556 | String[] params = vo.getOfficeAddressGps().split(","); |
| 532 | - double kilometre = calculateDistance(Double.parseDouble(params[1]), Double.parseDouble(params[0]), address.getGarLatitude(), address.getGarLongitude()); | |
| 533 | - vo.setDistance(kilometre); | |
| 557 | + double distance = calculateDistance(Double.parseDouble(params[1]), Double.parseDouble(params[0]), address.getGarLatitude(), address.getGarLongitude()); | |
| 558 | + vo.setDistance(distance); | |
| 534 | 559 | } |
| 535 | 560 | |
| 536 | 561 | private double calculateDistance(double lat1, double lon1, double lat2, double lon2) { | ... | ... |
trash-garbage/src/main/resources/mapper/GarOrderMapper.xml
| ... | ... | @@ -48,11 +48,16 @@ |
| 48 | 48 | select gar_order_company_id, count(gar_order_company_id) as count |
| 49 | 49 | from gar_order |
| 50 | 50 | where gar_order_handler_status = #{status} |
| 51 | - and gar_order_company_id in | |
| 52 | - <foreach collection="list" item="item" open="(" separator="," close=")"> | |
| 53 | - #{item} | |
| 54 | - </foreach> | |
| 55 | - group by gar_order_company_id | |
| 51 | + <if test="list != null and list.size() > 0"> | |
| 52 | + and gar_order_company_id in | |
| 53 | + <foreach collection="list" item="item" open="(" separator="," close=")"> | |
| 54 | + #{item} | |
| 55 | + </foreach> | |
| 56 | + group by gar_order_company_id | |
| 57 | + </if> | |
| 58 | + <if test="list == null or list.size() == 0"> | |
| 59 | + and 1 = 0 | |
| 60 | + </if> | |
| 56 | 61 | </select> |
| 57 | 62 | <select id="queryOrderListByTelWithType" resultType="com.trash.garbage.pojo.vo.GarOrderDriverVo"> |
| 58 | 63 | SELECT | ... | ... |