指派司机

master
ljw 2025-12-24 14:06:00 +08:00
parent 7f1c44c489
commit 3acc966fca
2 changed files with 39 additions and 4 deletions

View File

@ -22,6 +22,6 @@ public class AssignmentOrgParam {
/** /**
* Id * Id
*/ */
private Long transCompanyId; private Long transOrgId;
} }

View File

@ -10,6 +10,10 @@ import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult; import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.common.security.util.SecurityUtil; import com.njzscloud.common.security.util.SecurityUtil;
import com.njzscloud.common.sn.support.SnUtil; import com.njzscloud.common.sn.support.SnUtil;
import com.njzscloud.dispose.cst.customer.mapper.CustomerMapper;
import com.njzscloud.dispose.cst.customer.pojo.entity.CustomerEntity;
import com.njzscloud.dispose.cst.driver.mapper.DriverMapper;
import com.njzscloud.dispose.cst.driver.pojo.entity.DriverEntity;
import com.njzscloud.dispose.cst.order.constant.*; import com.njzscloud.dispose.cst.order.constant.*;
import com.njzscloud.dispose.cst.order.mapper.OrderMapper; import com.njzscloud.dispose.cst.order.mapper.OrderMapper;
import com.njzscloud.dispose.cst.order.mapper.OrderTransMapper; import com.njzscloud.dispose.cst.order.mapper.OrderTransMapper;
@ -49,6 +53,8 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
private final OrderCargoPlaceService orderCargoPlaceService; private final OrderCargoPlaceService orderCargoPlaceService;
private final OrderTransMapper orderTransMapper; private final OrderTransMapper orderTransMapper;
private final ExpenseItemService expenseItemService; private final ExpenseItemService expenseItemService;
private final DriverMapper driverMapper;
private final CustomerMapper customerMapper;
private final OrderExpenseItemsService orderExpenseItemsService; private final OrderExpenseItemsService orderExpenseItemsService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -117,21 +123,32 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
public void assignmentOrg(AssignmentOrgParam orgParam) { public void assignmentOrg(AssignmentOrgParam orgParam) {
Assert.notNull(orgParam, () -> Exceptions.clierr("请填写参数")); Assert.notNull(orgParam, () -> Exceptions.clierr("请填写参数"));
Assert.notNull(orgParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空")); Assert.notNull(orgParam.getOrderTransId(), () -> Exceptions.clierr("订单运输ID不可为空"));
Assert.notNull(orgParam.getTransCompanyId(), () -> Exceptions.clierr("清运公司ID不可为空")); Assert.notNull(orgParam.getTransOrgId(), () -> Exceptions.clierr("清运公司ID不可为空"));
OrderTransResult result = orderTransMapper.getById(orgParam.getOrderTransId()); OrderTransResult result = orderTransMapper.getById(orgParam.getOrderTransId());
Assert.notNull(result, () -> Exceptions.clierr("订单不存在")); Assert.notNull(result, () -> Exceptions.clierr("订单不存在"));
Assert.isNull(result.getTransOrgId(), () -> Exceptions.clierr("当前订单已分配清运公司,无需重复分配")); Assert.isNull(result.getTransOrgId(), () -> Exceptions.clierr("当前订单已分配清运公司,无需重复分配"));
Assert.isTrue(OrderStatus.YiYuYue.getVal().equals(result.getOrderStatus()), () -> Exceptions.clierr("当前订单状态,无法分配清运公司")); Assert.isTrue(OrderStatus.YiYuYue.getVal().equals(result.getOrderStatus()), () -> Exceptions.clierr("当前订单状态,无法分配清运公司"));
CustomerEntity customer = customerMapper.selectOne(Wrappers.<CustomerEntity>lambdaQuery()
.eq(CustomerEntity::getOrgId, orgParam.getTransOrgId())
.eq(CustomerEntity::getManager, Boolean.TRUE));
Assert.notNull(customer, () -> Exceptions.clierr("该企业管理员不存在"));
// 更新订单表 cst_order 的运输公司与状态信息 // 更新订单表 cst_order 的运输公司与状态信息
OrderEntity orderEntity = new OrderEntity(); OrderEntity orderEntity = new OrderEntity();
orderEntity.setTransOrgId(orgParam.getTransCompanyId()) orderEntity.setTransOrgId(orgParam.getTransOrgId())
.setTransCustomerId(orgParam.getTransCompanyId()) .setTransCustomerId(customer.getId())
.setAssignmentTransTime(LocalDateTime.now()) .setAssignmentTransTime(LocalDateTime.now())
.setOrderStatus(OrderStatus.JinXingZhong.getVal()) .setOrderStatus(OrderStatus.JinXingZhong.getVal())
.setId(result.getOrderId()); .setId(result.getOrderId());
this.updateById(orderEntity); this.updateById(orderEntity);
// 更新运输信息表 cst_trans_order 的运输状态信息
OrderTransEntity transEntity = new OrderTransEntity();
transEntity.setId(orgParam.getOrderTransId());
transEntity.setTransStatus(TransStatus.DaiPaiDan.getVal());
orderTransMapper.updateById(transEntity);
} }
public void assignmentDriver(AssignmentDriverParam driverParam) { public void assignmentDriver(AssignmentDriverParam driverParam) {
@ -144,6 +161,24 @@ public class OrderService extends ServiceImpl<OrderMapper, OrderEntity> {
Assert.isNull(result.getDriverId(), () -> Exceptions.clierr("当前订单已分配司机,无需重复分配")); Assert.isNull(result.getDriverId(), () -> Exceptions.clierr("当前订单已分配司机,无需重复分配"));
Assert.isTrue(TransStatus.DaiPaiDan.getVal().equals(result.getTransStatus()), () -> Exceptions.clierr("当前订单状态,无法分配司机")); Assert.isTrue(TransStatus.DaiPaiDan.getVal().equals(result.getTransStatus()), () -> Exceptions.clierr("当前订单状态,无法分配司机"));
DriverEntity driver = driverMapper.selectById(driverParam.getDriverId());
Assert.notNull(driver, () -> Exceptions.clierr("司机不存在"));
// 更新司机状态
DriverEntity driverEntity = new DriverEntity();
driverEntity.setId(driverParam.getDriverId());
driverEntity.setBusy(Boolean.TRUE);
driverMapper.updateById(driverEntity);
// 更新运输信息表 cst_trans_order 的运输状态等信息
OrderTransEntity transEntity = new OrderTransEntity();
transEntity.setId(driverParam.getOrderTransId());
transEntity.setTransStatus(TransStatus.DaiJieDan.getVal());
transEntity.setAssignmentDriverTime(LocalDateTime.now());
transEntity.setDriverId(driverParam.getDriverId());
transEntity.setDriverCustomerId(driver.getCustomerId());
transEntity.setDriverUserId(driver.getUserId());
orderTransMapper.updateById(transEntity);
} }
/** /**