longz
2026-07-02 c788ca1640f080f821cb1cbe07da741302d355ef
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java
@@ -24,6 +24,7 @@
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;
@@ -77,6 +78,8 @@
    @Autowired
    private ILineService lineService;
    @Autowired
    private IReassignService reassignService;
    @Resource
    private LineMapper lineMapper;
@@ -435,7 +438,7 @@
    }
    @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<>();
        }
@@ -443,10 +446,49 @@
        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 {