| | |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.service.ICarService; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IReassignService; |
| | | import com.stylefeng.guns.modular.system.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private ILineService lineService; |
| | | @Autowired |
| | | private IReassignService reassignService; |
| | | @Resource |
| | | private LineMapper lineMapper; |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<OtherDriverShiftWarpper> queryOtherDriverShiftListWithShiftId(Long driverShiftId) throws Exception { |
| | | public List<OtherDriverShiftWarpper> queryOtherDriverShiftListWithShiftId(Long driverShiftId, String orderIds) throws Exception { |
| | | if (driverShiftId == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | |
| | | if (current == null || (current.getLineShiftId() != null && current.getLineShiftId() == -1)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | List<Map<String, Object>> rows = lineShiftDriverMapper.queryOtherDriverShiftListWithShiftId(driverShiftId); |
| | | // 同批次司机不需要确认。 |
| | | Set<Integer> driverIds = new HashSet<>(); |
| | | for (Map<String, Object> row : rows) { |
| | | row.put("needConfirm", 1); |
| | | if (row.get("driverId") != null) { |
| | | driverIds.add(Integer.valueOf(row.get("driverId").toString())); |
| | | } |
| | | } |
| | | |
| | | // 扩展内容:对应时间段无订单且无其他预约批次的同公司其他司机,需要确认。 |
| | | Integer firstOrderId = getFirstOrderId(orderIds); |
| | | if (firstOrderId != null) { |
| | | List<Map<String, Object>> extraRows = lineShiftDriverMapper.queryAvailableCompanyDriversForShift(driverShiftId, firstOrderId); |
| | | for (Map<String, Object> row : extraRows) { |
| | | if (row.get("driverId") == null) { |
| | | continue; |
| | | } |
| | | Integer extraDriverId = Integer.valueOf(row.get("driverId").toString()); |
| | | if (driverIds.contains(extraDriverId)) { |
| | | continue; |
| | | } |
| | | row.put("needConfirm", 2); |
| | | rows.add(row); |
| | | driverIds.add(extraDriverId); |
| | | } |
| | | } |
| | | return OtherDriverShiftWarpper.fromMaps(rows); |
| | | } |
| | | |
| | | private Integer getFirstOrderId(String orderIds) { |
| | | if (ToolUtil.isEmpty(orderIds)) { |
| | | return null; |
| | | } |
| | | try { |
| | | String firstOrderId = orderIds.split(",")[0].trim(); |
| | | return ToolUtil.isEmpty(firstOrderId) ? null : Integer.valueOf(firstOrderId); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResultUtil<Map<String, Object>> addSelfTrip(Integer driverId, AddSelfTripWarpper warpper) throws Exception { |