| | |
| | | } |
| | | return ResultUtil.success(result); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Integer autoCancelExpiredNoOrderShifts() throws Exception { |
| | | List<Integer> shiftIds = lineShiftDriverMapper.queryExpiredNoOrderShiftIds(); |
| | | if (shiftIds == null || shiftIds.isEmpty()) { |
| | | return 0; |
| | | } |
| | | int cancelCount = 0; |
| | | for (Integer shiftId : shiftIds) { |
| | | if (shiftId == null) { |
| | | continue; |
| | | } |
| | | LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(shiftId); |
| | | if (lineShiftDriver == null) { |
| | | continue; |
| | | } |
| | | if (lineShiftDriver.getLineShiftId() != null |
| | | && lineShiftDriver.getLineShiftId() == -1 |
| | | && lineShiftDriver.getCustomerId() != null) { |
| | | DriverSelfTrip trip = driverSelfTripMapper.selectById(lineShiftDriver.getCustomerId()); |
| | | if (trip != null && trip.getState() != null && trip.getState() == 1) { |
| | | trip.setState(2); |
| | | trip.setUpdateTime(new Date()); |
| | | driverSelfTripMapper.updateById(trip); |
| | | } |
| | | } |
| | | lineShiftDriverMapper.deleteById(shiftId); |
| | | cancelCount++; |
| | | } |
| | | return cancelCount; |
| | | } |
| | | } |