From c788ca1640f080f821cb1cbe07da741302d355ef Mon Sep 17 00:00:00 2001
From: longz <longzhaoz@qq.com>
Date: 星期四, 02 七月 2026 14:43:08 +0800
Subject: [PATCH] Merge branch 'feature/3.0' into feature/fangxinxing

---
 DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java b/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java
index 67c59d7..6c2aaa7 100644
--- a/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java
+++ b/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 {

--
Gitblit v1.7.1