Commit d5810458ad09f925b7580597190b505582619f90
1 parent
d9491a6a
fix: 修复驾驶员接单报错,修复继续派发报错。
Showing
1 changed file
with
35 additions
and
18 deletions
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderServiceImpl.java
| @@ -17,7 +17,6 @@ import org.apache.commons.lang3.StringUtils; | @@ -17,7 +17,6 @@ import org.apache.commons.lang3.StringUtils; | ||
| 17 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 19 | import org.springframework.transaction.annotation.Transactional; | 19 | import org.springframework.transaction.annotation.Transactional; |
| 20 | - | ||
| 21 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 20 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 22 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 21 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 23 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 22 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| @@ -30,7 +29,6 @@ import com.trash.driver.service.IDriverService; | @@ -30,7 +29,6 @@ import com.trash.driver.service.IDriverService; | ||
| 30 | import com.trash.garbage.global.GlobalStatus; | 29 | import com.trash.garbage.global.GlobalStatus; |
| 31 | import com.trash.garbage.mapper.GarOrderMapper; | 30 | import com.trash.garbage.mapper.GarOrderMapper; |
| 32 | import com.trash.garbage.pojo.vo.OrderDetailVo; | 31 | import com.trash.garbage.pojo.vo.OrderDetailVo; |
| 33 | - | ||
| 34 | import cn.hutool.core.collection.CollectionUtil; | 32 | import cn.hutool.core.collection.CollectionUtil; |
| 35 | 33 | ||
| 36 | /** | 34 | /** |
| @@ -118,7 +116,7 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | @@ -118,7 +116,7 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 118 | || user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription())) { | 116 | || user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription())) { |
| 119 | return getOrderDetailVoResponsible(id, user); | 117 | return getOrderDetailVoResponsible(id, user); |
| 120 | } | 118 | } |
| 121 | - // TODO 订单分发获取 处理人员 | 119 | + // 订单分发获取 处理人员 |
| 122 | if (user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.DRIVER_USER.getDescription())) { | 120 | if (user.getGarUserType().equals(GlobalStatus.GarUserStatusEnum.DRIVER_USER.getDescription())) { |
| 123 | return getOrderDetailVoDriver(id, user); | 121 | return getOrderDetailVoDriver(id, user); |
| 124 | } | 122 | } |
| @@ -295,8 +293,8 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | @@ -295,8 +293,8 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 295 | || GlobalStatus.GarOrderStatus.NEW_ORDER.getValue().equals(dto.getHandleType())) { | 293 | || GlobalStatus.GarOrderStatus.NEW_ORDER.getValue().equals(dto.getHandleType())) { |
| 296 | LambdaUpdateWrapper<GarOrderMatchHandler> uw = new LambdaUpdateWrapper<>(); | 294 | LambdaUpdateWrapper<GarOrderMatchHandler> uw = new LambdaUpdateWrapper<>(); |
| 297 | uw.eq(GarOrderMatchHandler::getGarOrderId, dto.getGarOrderId()) | 295 | uw.eq(GarOrderMatchHandler::getGarOrderId, dto.getGarOrderId()) |
| 298 | - .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue()) | ||
| 299 | - .set(GarOrderMatchHandler::getGarOrderHandlerTel, user.getGarUserTel()); | 296 | + .eq(GarOrderMatchHandler::getGarOrderHandlerTel, user.getGarUserTel()) |
| 297 | + .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.ACTIVE_ORDER.getValue()); | ||
| 300 | handlerService.update(uw); | 298 | handlerService.update(uw); |
| 301 | return "已接受派单"; | 299 | return "已接受派单"; |
| 302 | } | 300 | } |
| @@ -305,6 +303,7 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | @@ -305,6 +303,7 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 305 | && GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue().equals(dto.getHandleType())) { | 303 | && GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue().equals(dto.getHandleType())) { |
| 306 | LambdaUpdateWrapper<GarOrderMatchHandler> uw = new LambdaUpdateWrapper<>(); | 304 | LambdaUpdateWrapper<GarOrderMatchHandler> uw = new LambdaUpdateWrapper<>(); |
| 307 | uw.eq(GarOrderMatchHandler::getGarOrderId, dto.getGarOrderId()) | 305 | uw.eq(GarOrderMatchHandler::getGarOrderId, dto.getGarOrderId()) |
| 306 | + .eq(GarOrderMatchHandler::getGarOrderHandlerTel, user.getGarUserTel()) | ||
| 308 | .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue()); | 307 | .set(GarOrderMatchHandler::getGarOrderStatus, GlobalStatus.GarOrderStatus.SUCCESS_ORDER.getValue()); |
| 309 | handlerService.update(uw); | 308 | handlerService.update(uw); |
| 310 | } | 309 | } |
| @@ -477,27 +476,45 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | @@ -477,27 +476,45 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> | ||
| 477 | 476 | ||
| 478 | @Override | 477 | @Override |
| 479 | public void dispatchOrder(DispatchDto dto) { | 478 | public void dispatchOrder(DispatchDto dto) { |
| 480 | - // TODO | ||
| 481 | GarOrder order = getById(dto.getGarOrderId()); | 479 | GarOrder order = getById(dto.getGarOrderId()); |
| 482 | List<GarOrderMatchHandler> handlerList = new ArrayList<>(dto.getDispatchList().size()); | 480 | List<GarOrderMatchHandler> handlerList = new ArrayList<>(dto.getDispatchList().size()); |
| 483 | - for (DispatchDto.DispatchDetail detail : dto.getDispatchList()) { | ||
| 484 | - GarOrderMatchHandler handler = new GarOrderMatchHandler(); | ||
| 485 | - handler.setGarOrderHandlerTel(detail.getTel()); | ||
| 486 | - handler.setGarOrderHandlerName(detail.getName()); | ||
| 487 | - handler.setGarHandlerCarCode(detail.getCarCode()); | ||
| 488 | - handler.setGarCancelFlag(order.getGarCancelFlag()); | ||
| 489 | - handler.setGarOrderId(order.getGarOrderId()); | ||
| 490 | - handler.setGarOrderHandlerStatus(order.getGarOrderHandlerStatus()); | ||
| 491 | - handler.setGarOrderHandlerCompanyName(order.getGarOrderCompanyName()); | ||
| 492 | - handler.setGarOrderHandlerCompanyId(order.getGarOrderCompanyId()); | ||
| 493 | - handler.setGarOrderStatus(GlobalStatus.GarOrderStatus.DISPATCH_HANDLE_NEW.getValue()); | ||
| 494 | - handlerList.add(handler); | 481 | + // 已分配 继续下发 |
| 482 | + if (order.getGarOrderMatchFlag().equals(GlobalStatus.GarOrderStatus.MATCH_YES.getValue())) { | ||
| 483 | + LambdaQueryWrapper<GarOrderMatchHandler> qw = new LambdaQueryWrapper<>(); | ||
| 484 | + qw.eq(GarOrderMatchHandler::getGarOrderId, order.getGarOrderId()); | ||
| 485 | + Map<String, GarOrderMatchHandler> handlerMap = handlerService.list(qw).stream().collect(Collectors.toMap(item -> item.getGarOrderHandlerTel(), item -> item)); | ||
| 486 | + for (DispatchDto.DispatchDetail dispatchDetail : dto.getDispatchList()) { | ||
| 487 | + if (handlerMap.containsKey(dispatchDetail.getTel())) { | ||
| 488 | + continue; | ||
| 489 | + } | ||
| 490 | + GarOrderMatchHandler handler = getGarOrderMatchHandler(order, dispatchDetail); | ||
| 491 | + handlerList.add(handler); | ||
| 492 | + } | ||
| 493 | + } else { | ||
| 494 | + for (DispatchDto.DispatchDetail detail : dto.getDispatchList()) { | ||
| 495 | + GarOrderMatchHandler handler = getGarOrderMatchHandler(order, detail); | ||
| 496 | + handlerList.add(handler); | ||
| 497 | + } | ||
| 495 | } | 498 | } |
| 496 | handlerService.saveBatch(handlerList); | 499 | handlerService.saveBatch(handlerList); |
| 497 | order.setGarOrderMatchFlag(GlobalStatus.GarOrderStatus.MATCH_YES.getValue()); | 500 | order.setGarOrderMatchFlag(GlobalStatus.GarOrderStatus.MATCH_YES.getValue()); |
| 498 | updateById(order); | 501 | updateById(order); |
| 499 | } | 502 | } |
| 500 | 503 | ||
| 504 | + private GarOrderMatchHandler getGarOrderMatchHandler(GarOrder order, DispatchDto.DispatchDetail detail) { | ||
| 505 | + GarOrderMatchHandler handler = new GarOrderMatchHandler(); | ||
| 506 | + handler.setGarOrderHandlerTel(detail.getTel()); | ||
| 507 | + handler.setGarOrderHandlerName(detail.getName()); | ||
| 508 | + handler.setGarHandlerCarCode(detail.getCarCode()); | ||
| 509 | + handler.setGarCancelFlag(order.getGarCancelFlag()); | ||
| 510 | + handler.setGarOrderId(order.getGarOrderId()); | ||
| 511 | + handler.setGarOrderHandlerStatus(order.getGarOrderHandlerStatus()); | ||
| 512 | + handler.setGarOrderHandlerCompanyName(order.getGarOrderCompanyName()); | ||
| 513 | + handler.setGarOrderHandlerCompanyId(order.getGarOrderCompanyId()); | ||
| 514 | + handler.setGarOrderStatus(GlobalStatus.GarOrderStatus.DISPATCH_HANDLE_NEW.getValue()); | ||
| 515 | + return handler; | ||
| 516 | + } | ||
| 517 | + | ||
| 501 | @Override | 518 | @Override |
| 502 | @Transactional(rollbackFor = Exception.class) | 519 | @Transactional(rollbackFor = Exception.class) |
| 503 | public List<DispatchDriverVo> queryDispatch(String orderId) { | 520 | public List<DispatchDriverVo> queryDispatch(String orderId) { |