| | |
| | | package com.ruoyi.tms.service.impl; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.SystemDataNoEnum; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.ISystemDataNoService; |
| | | import com.ruoyi.tms.domain.TmsDriverDispatch; |
| | | import com.ruoyi.tms.domain.vo.DriverDispatchVo; |
| | | import com.ruoyi.tms.service.ITmsDriverDispatchService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private TmsDispatchOrderMapper tmsDispatchOrderMapper; |
| | | @Autowired |
| | | ISystemDataNoService systemDataNoService; |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | @Autowired |
| | | private ITmsDriverDispatchService tmsDriverDispatchService; |
| | | |
| | | /** |
| | | * 查询调度单管理 |
| | |
| | | if (tmsDispatchOrder.getStatus() != 0){ |
| | | return AjaxResult.error("该调度单数据状态异常"); |
| | | } |
| | | if (tmsDispatchOrder.getMainDriverId() == null){ |
| | | return AjaxResult.error("请先选择主驾司机"); |
| | | } |
| | | if (tmsDispatchOrder.getVehicleId() == null){ |
| | | return AjaxResult.error("请先选择车辆"); |
| | | } |
| | | |
| | | tmsDispatchOrder.setStatus(1); |
| | | |
| | | tmsDispatchOrder.setUpdateBy(SecurityUtils.getUsername()); |
| | | int i = tmsDispatchOrderMapper.updateTmsDispatchOrder(tmsDispatchOrder); |
| | | TmsDriverDispatch tmsDriverDispatch = new TmsDriverDispatch(); |
| | | tmsDriverDispatch.setDriverId(tmsDispatchOrder.getMainDriverId()); |
| | | tmsDriverDispatch.setDispatchId(tmsDispatchOrder.getId()); |
| | | tmsDriverDispatch.setStatus(0); |
| | | tmsDriverDispatchService.insertTmsDriverDispatch(tmsDriverDispatch); |
| | | if (i > 0){ |
| | | return AjaxResult.success("操作成功"); |
| | | } |
| | |
| | | return AjaxResult.error("操作失败"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult assignedItineraryList() { |
| | | Integer deviceId = userService.getDeviceId(SecurityUtils.getUserId()); |
| | | if (deviceId == null){ |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | DriverDispatchVo vo = new DriverDispatchVo(); |
| | | vo.setDriverId(deviceId); |
| | | vo.setInStatusList(Arrays.asList(0, 1, 2,4)); |
| | | vo.setInTdoStatusList(Arrays.asList(1, 2)); |
| | | List<DriverDispatchVo> driverDispatchVos = tmsDispatchOrderMapper.selectAssignedItineraryList(vo); |
| | | if (driverDispatchVos != null && !driverDispatchVos.isEmpty()){ |
| | | driverDispatchVos.forEach(item ->{ |
| | | if (item.getTddStatus() == 1 ){ |
| | | item.setStatusStr("待甩挂"); |
| | | }else if (item.getTddStatus() == 2){ |
| | | item.setStatusStr("待接挂"); |
| | | }else if (item.getStatus() == 1){ |
| | | item.setStatusStr("待发车"); |
| | | }else if (item.getStatus() == 2){ |
| | | item.setStatusStr("在途"); |
| | | }else { |
| | | item.setStatusStr("完成行程"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | return AjaxResult.success(driverDispatchVos); |
| | | } |
| | | @Override |
| | | public AjaxResult assignedItineraryLogList() { |
| | | Integer deviceId = userService.getDeviceId(SecurityUtils.getUserId()); |
| | | if (deviceId == null){ |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | DriverDispatchVo vo = new DriverDispatchVo(); |
| | | vo.setDriverId(deviceId); |
| | | vo.setInStatusList(Arrays.asList(3,5)); |
| | | // vo.setInTdoStatusList(Arrays.asList(1, 2)); |
| | | List<DriverDispatchVo> driverDispatchVos = tmsDispatchOrderMapper.selectAssignedItineraryList(vo); |
| | | if (driverDispatchVos != null && !driverDispatchVos.isEmpty()){ |
| | | driverDispatchVos.forEach(item ->{ |
| | | item.setStatusStr("完成行程"); |
| | | }); |
| | | } |
| | | |
| | | |
| | | return AjaxResult.success(driverDispatchVos); |
| | | } |
| | | @Override |
| | | public AjaxResult selectAssignedItineraryDetail(Integer dispatchId) { |
| | | Integer deviceId = userService.getDeviceId(SecurityUtils.getUserId()); |
| | | if (deviceId == null){ |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | DriverDispatchVo vo = new DriverDispatchVo(); |
| | | vo.setDriverId(deviceId); |
| | | vo.setDispatchId(dispatchId); |
| | | DriverDispatchVo driverDispatchVo = tmsDispatchOrderMapper.selectAssignedItineraryDetail(vo); |
| | | if (driverDispatchVo != null){ |
| | | if (driverDispatchVo.getTddStatus() == 1 ){ |
| | | driverDispatchVo.setStatusStr("待甩挂"); |
| | | }else if (driverDispatchVo.getTddStatus() == 2){ |
| | | driverDispatchVo.setStatusStr("待接挂"); |
| | | }else if (driverDispatchVo.getStatus() == 1){ |
| | | driverDispatchVo.setStatusStr("待发车"); |
| | | }else if (driverDispatchVo.getStatus() == 2){ |
| | | driverDispatchVo.setStatusStr("在途"); |
| | | }else{ |
| | | driverDispatchVo.setStatusStr("完成行程"); |
| | | } |
| | | } |
| | | return AjaxResult.success(driverDispatchVo); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询调度单管理 记录数 |
| | | * |