| | |
| | | package com.ruoyi.tms.service.impl; |
| | | |
| | | import java.io.File; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | |
| | | import com.ruoyi.common.utils.uuid.Seq; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.tms.domain.*; |
| | | import com.ruoyi.tms.mapper.TmsDispatchOrderMapper; |
| | | import com.ruoyi.tms.mapper.TmsDriverDispatchMapper; |
| | | import com.ruoyi.tms.mapper.TmsDriverMapper; |
| | | import com.ruoyi.tms.mapper.*; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import com.ruoyi.common.enums.DataSourceType; |
| | | import com.ruoyi.common.core.service.BaseService; |
| | | |
| | | import com.ruoyi.tms.mapper.TmsTripMapper; |
| | | import com.ruoyi.tms.service.ITmsTripService; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | |
| | |
| | | private TmsDriverMapper tmsDriverMapper; |
| | | @Autowired |
| | | private TmsVehicleServiceImpl tmsVehicleServiceImpl; |
| | | @Resource |
| | | private TmsCarKeyDispatchMapper tmsCarKeyDispatchMapper; |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | @Autowired |
| | | private AsyncPdfService asyncPdfService; |
| | |
| | | throw new RuntimeException("未找到司机数据"); |
| | | } |
| | | |
| | | |
| | | tmsDispatchOrder.setStatus(2); |
| | | tmsDispatchOrderMapper.updateTmsDispatchOrder(tmsDispatchOrder); |
| | | tmsTrip.setDriverName(tmsDispatchOrder.getMainDriverName()); |
| | |
| | | if (StringUtils.isNotEmpty(tmsTrip.getSignImg())){ |
| | | asyncPdfService.generateTripPdfAsync(tmsTrip,tmsDispatchOrder,tmsDriver); |
| | | } |
| | | // 完成身体检查 |
| | | if (tmsTrip.getTripType() == 1){ |
| | | // 添加 领钥匙 指令记录 |
| | | TmsVehicle tmsVehicle = tmsVehicleServiceImpl.selectTmsVehicleById(tmsDispatchOrder.getVehicleId()); |
| | | |
| | | TmsCarKeyDispatch tmsCarKeyDispatch = new TmsCarKeyDispatch(); |
| | | tmsCarKeyDispatch.setDispatchOrderId(dispatchOrderId); |
| | | tmsCarKeyDispatch.setDispatchOrderNo(tmsDispatchOrder.getDispatchNo()); |
| | | tmsCarKeyDispatch.setDriverId(tmsDriver.getId()); |
| | | tmsCarKeyDispatch.setDriverMobile(tmsDriver.getMobile()); |
| | | tmsCarKeyDispatch.setDriverName(tmsDriver.getDriverName()); |
| | | |
| | | tmsCarKeyDispatch.setVehicleId(tmsDispatchOrder.getVehicleId()); |
| | | tmsCarKeyDispatch.setVehicleLicensePlate(tmsDispatchOrder.getLicensePlate()); |
| | | tmsCarKeyDispatch.setVehicleCarKeyNo(tmsVehicle.getCarKeyNo()); |
| | | |
| | | LocalDateTime plus2Hours = LocalDateTime.now().plusHours(2); |
| | | Date date = Date.from(plus2Hours.atZone(ZoneId.systemDefault()).toInstant()); |
| | | |
| | | tmsCarKeyDispatch.setCarKeyExpirationTime(date); |
| | | tmsCarKeyDispatch.setStatus(0); |
| | | tmsCarKeyDispatchMapper.insertTmsCarKeyDispatch(tmsCarKeyDispatch); |
| | | |
| | | sendCarKeyDelayMessage(tmsCarKeyDispatch.getId(), 2 * 60 * 60 * 1000L); |
| | | |
| | | } |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 发送延迟消息 |
| | | * @param carKeyId car_key id |
| | | * @param delayMillis 延迟毫秒数 |
| | | */ |
| | | public void sendCarKeyDelayMessage(Integer carKeyId, long delayMillis) { |
| | | rabbitTemplate.convertAndSend( |
| | | "car_key_delay_exchange", |
| | | "car_key_delay", |
| | | carKeyId, |
| | | message -> { |
| | | message.getMessageProperties().setExpiration(String.valueOf(delayMillis)); |
| | | return message; |
| | | } |
| | | ); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult submitDropHook(TmsTrip tmsTrip){ |
| | | Integer dispatchOrderId = tmsTrip.getDispatchOrderId(); |
| | |
| | | } |
| | | |
| | | |
| | | TmsVehicle tmsVehicle = tmsVehicleServiceImpl.selectTmsVehicleById(driverDispatch.getDriverId()); |
| | | TmsVehicle tmsVehicle = tmsVehicleServiceImpl.selectTmsVehicleById(driverDispatch.getVehicleId()); |
| | | |
| | | tmsDispatchOrderMapper.update( |
| | | new LambdaUpdateWrapper<TmsDispatchOrder>() |