| | |
| | | package com.ruoyi.tms.service.impl; |
| | | |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | 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.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.*; |
| | |
| | | ); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> tmsTripListPage(Integer dispatchId, Integer pageNum, Integer pageSize) { |
| | | Integer deviceId = userService.getDeviceId(SecurityUtils.getUserId()); |
| | | if (deviceId == null) { |
| | | Map<String, Object> empty = new HashMap<>(); |
| | | empty.put("rows", Collections.emptyList()); |
| | | empty.put("total", 0); |
| | | return empty; |
| | | } |
| | | |
| | | LambdaQueryWrapper<TmsTrip> wrapper = new LambdaQueryWrapper<TmsTrip>() |
| | | .eq(TmsTrip::getDriverId, deviceId); |
| | | // dispatchId 可选,不传时查该司机全部行程 |
| | | if (dispatchId != null) { |
| | | wrapper.eq(TmsTrip::getDispatchOrderId, dispatchId); |
| | | } |
| | | // 按行程时间倒序 |
| | | wrapper.orderByDesc(TmsTrip::getTripTime); |
| | | |
| | | Page<TmsTrip> page = new Page<>(pageNum, pageSize); |
| | | Page<TmsTrip> result = tmsTripMapper.selectPage(page, wrapper); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("rows", result.getRecords()); |
| | | map.put("total", result.getTotal()); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 查询行程列表 异步 导出 |
| | | * |
| | |
| | | if (tmsDispatchOrder.getStatus() != 1 && tmsDispatchOrder.getStatus() != 2){ |
| | | throw new RuntimeException("调度单数据状态异常"); |
| | | } |
| | | |
| | | TmsTrip tmsTrip1 = tmsTripMapper.selectOne(new LambdaQueryWrapper<TmsTrip>() |
| | | .eq(TmsTrip::getDispatchOrderId, dispatchOrderId) |
| | | .orderByDesc(TmsTrip::getId) |
| | | .last("limit 1") |
| | | ); |
| | | if (tmsTrip1 != null){ |
| | | BigDecimal currentOdometer = tmsTrip.getOdometer(); |
| | | BigDecimal lastOdometer = tmsTrip1.getOdometer(); |
| | | if (currentOdometer!=null && lastOdometer != null && currentOdometer.compareTo(lastOdometer) < 0) { |
| | | throw new IllegalArgumentException("车辆里程数异常,当前里程必须大于上一行程"); |
| | | } |
| | | } |
| | | |
| | | TmsDriver tmsDriver = tmsDriverMapper.selectTmsDriverById(tmsDispatchOrder.getMainDriverId()); |
| | | if (tmsDriver == null){ |
| | | throw new RuntimeException("未找到司机数据"); |
| | |
| | | if (tmsTrip.getTripType() == 8 || tmsTrip.getTripType() == 100){ |
| | | if (status == 2){ |
| | | tmsDispatchOrder.setStatus(3); |
| | | tmsDispatchOrder.setOkTime(DateUtils.getNowDate()); |
| | | tmsDispatchOrder.setUpdateBy(SecurityUtils.getUsername()); |
| | | } |
| | | } |
| | | if (tmsTrip.getTripType() == 5){ |
| | | tmsDispatchOrder.setIscc(tmsTrip.getIscc()); |
| | | } |
| | | if (tmsTrip.getTripType() == 100){ |
| | | tmsDispatchOrder.setIsfk(0); |
| | | } |
| | | |
| | | tmsDispatchOrderMapper.updateTmsDispatchOrder(tmsDispatchOrder); |
| | | tmsTrip.setDriverName(tmsDispatchOrder.getMainDriverName()); |
| | | tmsTrip.setVehicleId(tmsDispatchOrder.getVehicleId()); |
| | |
| | | asyncPdfService.generateTripPdfAsync(tmsTrip,tmsDispatchOrder,tmsDriver); |
| | | } |
| | | // 完成身体检查 |
| | | if (tmsTrip.getTripType() == 1){ |
| | | if (tmsTrip.getTripType() == 1 && tmsDispatchOrder.getOperationMode() == 0){ |
| | | // 添加 领钥匙 指令记录 |
| | | TmsVehicle tmsVehicle = tmsVehicleServiceImpl.selectTmsVehicleById(tmsDispatchOrder.getVehicleId()); |
| | | |
| | | logger.info("添加 领钥匙 指令记录,{},{}",tmsDispatchOrder.getVehicleId(),tmsVehicle.getCarKeyNo()); |
| | | TmsCarKeyDispatch tmsCarKeyDispatch = new TmsCarKeyDispatch(); |
| | | tmsCarKeyDispatch.setDispatchOrderId(dispatchOrderId); |
| | | tmsCarKeyDispatch.setDispatchOrderNo(tmsDispatchOrder.getDispatchNo()); |