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,9 +144,8 @@ public class GarbageOrderController { | ||
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | @GetMapping("/company") | 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 | @GetMapping("/search/history") | 151 | @GetMapping("/search/history") |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarOrderMapper.java
| @@ -15,7 +15,7 @@ import java.util.List; | @@ -15,7 +15,7 @@ import java.util.List; | ||
| 15 | */ | 15 | */ |
| 16 | public interface GarOrderMapper extends BaseMapper<GarOrder> { | 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 | List<GarOrderDriverVo> queryOrderListByTelWithType(@Param("garUserTel") String garUserTel, @Param("type") Integer type, @Param("cancelFlag") Integer cancelFlag); | 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,7 +65,7 @@ public interface GarOrderService extends IService<GarOrder> { | ||
| 65 | 65 | ||
| 66 | OrderDetailVo queryOrderWebDetail(String id); | 66 | OrderDetailVo queryOrderWebDetail(String id); |
| 67 | 67 | ||
| 68 | - PageInfo queryEnterpriseList(TransportationEnterprise enterprise); | 68 | + PageInfo queryEnterpriseList(TransportationEnterprise dto); |
| 69 | 69 | ||
| 70 | List<GarOrderEvaluate> queryEvaluateDetail(String orderId); | 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,6 +3,7 @@ package com.trash.garbage.service.impl; | ||
| 3 | import java.util.*; | 3 | import java.util.*; |
| 4 | import java.util.stream.Collectors; | 4 | import java.util.stream.Collectors; |
| 5 | 5 | ||
| 6 | +import com.trash.common.utils.ServletUtils; | ||
| 6 | import com.trash.enterprise.domain.TransportationEnterprise; | 7 | import com.trash.enterprise.domain.TransportationEnterprise; |
| 7 | import com.trash.enterprise.service.ITransportationEnterpriseService; | 8 | import com.trash.enterprise.service.ITransportationEnterpriseService; |
| 8 | import com.trash.garbage.custom.BizException; | 9 | import com.trash.garbage.custom.BizException; |
| @@ -491,8 +492,23 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | @@ -491,8 +492,23 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 491 | 492 | ||
| 492 | @Override | 493 | @Override |
| 493 | public PageInfo queryEnterpriseList(TransportationEnterprise enterprise) { | 494 | public PageInfo queryEnterpriseList(TransportationEnterprise enterprise) { |
| 495 | + // 1)支持选择企业“所属区域”(长沙市内的)展示区域内所有企业 | ||
| 496 | + // 2)支持选择车辆“车辆类型”展示有该车辆类型的企业 | ||
| 497 | + // TODO 车辆类型暂时不考虑 | ||
| 494 | List<TransportationEnterprise> list = transportationEnterpriseService.selectTransportationEnterpriseList(enterprise); | 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 | List<Long> enterpriseIds = list.stream().map(TransportationEnterprise::getId).collect(Collectors.toList()); | 512 | List<Long> enterpriseIds = list.stream().map(TransportationEnterprise::getId).collect(Collectors.toList()); |
| 497 | List<GarOrder> orderList = baseMapper.queryCleanNumberByEnterpriseIds(enterpriseIds, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue()); | 513 | List<GarOrder> orderList = baseMapper.queryCleanNumberByEnterpriseIds(enterpriseIds, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue()); |
| 498 | List<GarOrderEvaluate> evaluateList = garOrderEvaluateService.queryEvaluateByEnterpriseIds(enterpriseIds, GlobalStatus.GarOrderStatus.EVALUATE_TYPE_COMPANY.getValue()); | 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,21 +532,30 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 516 | List<GarOrderEvaluate> evaluate = evaluateMap.get(String.valueOf(item.getId())); | 532 | List<GarOrderEvaluate> evaluate = evaluateMap.get(String.valueOf(item.getId())); |
| 517 | handleCleanNumber(vo, orderList); | 533 | handleCleanNumber(vo, orderList); |
| 518 | handleScore(vo, evaluate); | 534 | handleScore(vo, evaluate); |
| 519 | - handleKilometre(vo, address); | 535 | + handleDistance(vo, address); |
| 520 | return vo; | 536 | return vo; |
| 521 | }) | 537 | }) |
| 522 | - .sorted(Comparator.comparing(TransportationEnterpriseVo::getDistance)) | 538 | + // 降序 |
| 539 | + .sorted(comparator.reversed()) | ||
| 523 | .collect(Collectors.toList()); | 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 | PageInfo<TransportationEnterpriseVo> pageInfo = new PageInfo<>(); | 548 | PageInfo<TransportationEnterpriseVo> pageInfo = new PageInfo<>(); |
| 525 | - pageInfo.setList(voList); | 549 | + pageInfo.setList(voList.subList(startPage, endPage)); |
| 526 | pageInfo.setTotal(total); | 550 | pageInfo.setTotal(total); |
| 527 | return pageInfo; | 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 | String[] params = vo.getOfficeAddressGps().split(","); | 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 | private double calculateDistance(double lat1, double lon1, double lat2, double lon2) { | 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,11 +48,16 @@ | ||
| 48 | select gar_order_company_id, count(gar_order_company_id) as count | 48 | select gar_order_company_id, count(gar_order_company_id) as count |
| 49 | from gar_order | 49 | from gar_order |
| 50 | where gar_order_handler_status = #{status} | 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 | </select> | 61 | </select> |
| 57 | <select id="queryOrderListByTelWithType" resultType="com.trash.garbage.pojo.vo.GarOrderDriverVo"> | 62 | <select id="queryOrderListByTelWithType" resultType="com.trash.garbage.pojo.vo.GarOrderDriverVo"> |
| 58 | SELECT | 63 | SELECT |