Эх сурвалжийг харах

Merge remote-tracking branch 'origin/dev_20260131' into dev_20260131_youshen430

donglang 1 сар өмнө
parent
commit
f9f9a19aff

+ 0 - 9
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillV1Enum.java

@@ -27,11 +27,6 @@ public enum CarWaybillV1Enum {
      */
      */
     EXIT_COMPLETED(10,  "已装货"),
     EXIT_COMPLETED(10,  "已装货"),
 
 
-    /**
-     * 离场过磅:  弃用
-     */
-    WEIGHT_TRAFFIC(110, "离场过磅"),
-
 
 
     /**
     /**
      * 空载待离场
      * 空载待离场
@@ -74,10 +69,6 @@ public enum CarWaybillV1Enum {
      */
      */
     WAIT_LOADING(18,  "已离场"),
     WAIT_LOADING(18,  "已离场"),
 
 
-    /**
-     * 卸货入场  弃用
-     */
-    INTO_UNLOADING(19,  "卸货入场"),
 
 
     /**
     /**
      * 已卸货
      * 已卸货

+ 8 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/repository/KwfTruckEntRepository.java

@@ -9,6 +9,7 @@ import com.sckw.fleet.model.KwfTruckEnt;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
 import java.util.List;
 import java.util.List;
+import java.util.Set;
 
 
 /**
 /**
  * @author PC
  * @author PC
@@ -22,4 +23,11 @@ public class KwfTruckEntRepository extends ServiceImpl<KwfTruckEntMapper, KwfTru
                 .eq(KwfTruckEnt::getEntId,entId)
                 .eq(KwfTruckEnt::getEntId,entId)
                 .orderByDesc(BaseModel::getCreateTime));
                 .orderByDesc(BaseModel::getCreateTime));
     }
     }
+
+    public List<KwfTruckEnt> findTruckEntByEntIds(Set<Long> entId) {
+        return list(Wrappers.<KwfTruckEnt>lambdaQuery()
+                .eq(BaseModel::getDelFlag,0)
+                .eq(KwfTruckEnt::getEntId,entId)
+                .orderByDesc(BaseModel::getCreateTime));
+    }
 }
 }

+ 87 - 6
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.common.enums.enums.ErrorCodeEnum;
 import com.sckw.core.common.enums.enums.ErrorCodeEnum;
 import com.sckw.core.common.enums.enums.FileEnum;
 import com.sckw.core.common.enums.enums.FileEnum;
@@ -49,10 +50,9 @@ import com.sckw.fleet.model.vo.*;
 import com.sckw.fleet.repository.*;
 import com.sckw.fleet.repository.*;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteUserService;
 import com.sckw.system.api.RemoteUserService;
-import com.sckw.system.api.model.dto.res.EntCacheResDto;
-import com.sckw.system.api.model.dto.res.KwsEnterpriseResDto;
-import com.sckw.system.api.model.dto.res.SysDictResDto;
-import com.sckw.system.api.model.dto.res.UserCacheResDto;
+import com.sckw.system.api.feign.DataPermissionFeignService;
+import com.sckw.system.api.model.dto.req.DataPermissionFilterReqDto;
+import com.sckw.system.api.model.dto.res.*;
 import com.sckw.transport.api.dubbo.TransportRemoteService;
 import com.sckw.transport.api.dubbo.TransportRemoteService;
 import com.sckw.transport.api.feign.VehicleTraceClient;
 import com.sckw.transport.api.feign.VehicleTraceClient;
 import com.sckw.transport.api.model.dto.RWaybillOrderDto;
 import com.sckw.transport.api.model.dto.RWaybillOrderDto;
@@ -109,6 +109,8 @@ public class KwfTruckService {
     private final KwfTruckEntRepository truckEntRepository;
     private final KwfTruckEntRepository truckEntRepository;
 
 
     private final KwfFleetTruckRepository kwfFleetTruckRepository;
     private final KwfFleetTruckRepository kwfFleetTruckRepository;
+
+    private final DataPermissionFeignService dataPermissionFeignService;
     private final VehicleTraceClient vehicleTraceClient;
     private final VehicleTraceClient vehicleTraceClient;
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
     private RemoteSystemService remoteSystemService;
     private RemoteSystemService remoteSystemService;
@@ -2051,6 +2053,9 @@ public class KwfTruckService {
     public PageDataResult<TruckResp> pageQueryTruck(TruckQueryParam param) {
     public PageDataResult<TruckResp> pageQueryTruck(TruckQueryParam param) {
         log.info("查询司机信息列表:{}", JSON.toJSONString(param));
         log.info("查询司机信息列表:{}", JSON.toJSONString(param));
         List<Long> validTruckIds = new ArrayList<>();
         List<Long> validTruckIds = new ArrayList<>();
+        ///获取当前数据权限
+        Set<Long> entIds = applyDataPermissionFilterToLogOrderIds(LoginUserHolder.getEntId());
+
         if (StringUtils.isNotBlank(param.getDriverName())) {
         if (StringUtils.isNotBlank(param.getDriverName())) {
             //1.1 先根据司机名字模糊查询司机ID
             //1.1 先根据司机名字模糊查询司机ID
             List<KwfDriver> drivers = kwfDriverRepository.list(Wrappers.<KwfDriver>lambdaQuery()
             List<KwfDriver> drivers = kwfDriverRepository.list(Wrappers.<KwfDriver>lambdaQuery()
@@ -2064,7 +2069,7 @@ public class KwfTruckService {
                 List<KwfTruckReport> reports = kwfTruckReportRepository.list(
                 List<KwfTruckReport> reports = kwfTruckReportRepository.list(
                         Wrappers.<KwfTruckReport>lambdaQuery()
                         Wrappers.<KwfTruckReport>lambdaQuery()
                                 .in(KwfTruckReport::getDriverId, driverIds)
                                 .in(KwfTruckReport::getDriverId, driverIds)
-                                .eq(KwfTruckReport::getEntId, LoginUserHolder.getEntId())
+                                .in(KwfTruckReport::getEntId, entIds)
                                 .eq(BaseModel::getDelFlag, 0)
                                 .eq(BaseModel::getDelFlag, 0)
                 );
                 );
                 if (CollectionUtils.isNotEmpty(reports)) {
                 if (CollectionUtils.isNotEmpty(reports)) {
@@ -2081,8 +2086,14 @@ public class KwfTruckService {
                 return PageDataResult.empty(param.getPageNum(), param.getPageSize());
                 return PageDataResult.empty(param.getPageNum(), param.getPageSize());
             }
             }
         }
         }
-
+        //根据企业id查询车辆信息
+        List<KwfTruckEnt> truckEntByEntIds = truckEntRepository.findTruckEntByEntIds(entIds);
+        Set<Long> truckIds = Optional.ofNullable(truckEntByEntIds).orElse(Collections.emptyList())
+                .stream()
+                .map(KwfTruckEnt::getTruckId)
+                .collect(Collectors.toSet());
         LambdaQueryWrapper<KwfTruck> wrapper = Wrappers.<KwfTruck>lambdaQuery()
         LambdaQueryWrapper<KwfTruck> wrapper = Wrappers.<KwfTruck>lambdaQuery()
+                .in(org.apache.commons.collections4.CollectionUtils.isNotEmpty(truckIds), KwfTruck::getId, truckIds)
                 .like(StringUtils.isNotBlank(param.getTruckNo()), KwfTruck::getTruckNo, param.getTruckNo())
                 .like(StringUtils.isNotBlank(param.getTruckNo()), KwfTruck::getTruckNo, param.getTruckNo())
                 .eq(param.getType() != null, KwfTruck::getType, param.getType())
                 .eq(param.getType() != null, KwfTruck::getType, param.getType())
                 .eq(param.getCarAxis() != null, KwfTruck::getCarAxis, param.getCarAxis())
                 .eq(param.getCarAxis() != null, KwfTruck::getCarAxis, param.getCarAxis())
@@ -2111,7 +2122,77 @@ public class KwfTruckService {
         List<TruckResp> truckPageResult = getTruckResp(records);
         List<TruckResp> truckPageResult = getTruckResp(records);
         return PageDataResult.success(param.getPageNum(), param.getPageSize(), pageByStatus.getTotal(), truckPageResult);
         return PageDataResult.success(param.getPageNum(), param.getPageSize(), pageByStatus.getTotal(), truckPageResult);
     }
     }
+    /**
+     * 应用数据权限过滤,获取允许访问的企业ID集合
+     * <p>
+     * 该方法根据当前登录用户的数据权限配置,对传入的企业ID进行过滤。
+     * 如果用户拥有全部数据权限或无需过滤,则返回包含原始企业ID的集合;
+     * 否则,返回用户有权访问的企业ID与原始企业ID的并集(注:原逻辑为addAll,此处保持原意,通常权限过滤应为交集或替换,但根据原代码逻辑是保留原始并添加可见的,
+     * 实际上原代码逻辑可能是想表达:基础是当前entId,如果有限制,则限制在可见范围内。但原代码使用了addAll,这可能导致权限扩大。
+     * 鉴于指令是“添加详细注释以及日志”,我将忠实于原有逻辑进行注释补充,并增加关键节点的日志记录,以便排查权限问题。)
+     * </p>
+     *
+     * @param entId 当前上下文中的基础企业ID
+     * @return 经过数据权限过滤后的企业ID集合
+     */
+    private Set<Long> applyDataPermissionFilterToLogOrderIds(Long entId) {
+        log.debug("开始应用数据权限过滤,基础企业ID: {}", entId);
+
+        // 1. 获取当前用户的数据权限配置
+        DataPermissionDTO perm = fetchDataPermissionForCurrentUser();
+        
+        // 初始化结果集合,默认包含传入的基础企业ID
+        Set<Long> entIds = Sets.newHashSet(entId);
+
+        // 如果未获取到权限配置对象,或者配置表明不需要进行数据过滤,则直接返回包含基础企业ID的集合
+        if (perm == null || !perm.needFilter()) {
+            log.debug("无需进行数据权限过滤,直接返回基础企业ID: {}", entId);
+            return entIds;
+        }
+
+        // 创建用于存储过滤后结果的集合
+        Set<Long> result = new HashSet<>(entIds);
+
+        // 2. 处理企业维度数据权限
+        // 判断是否对所有企业数据可见
+        if (!perm.isAllVisible()) {
+            log.debug("当前用户非全部数据可见,进入企业维度权限过滤逻辑");
+
+            // 获取用户可见的企业ID列表
+            Set<Long> visibleEntIds = perm.getVisibleEntIds();
+            
+            // 如果可见企业ID列表为空,说明该用户无权查看任何企业数据,返回空集合
+            if (CollectionUtils.isEmpty(visibleEntIds)) {
+                log.warn("数据权限过滤:用户无可见企业权限,返回空集合。用户ID: {}", LoginUserHolder.getUserId());
+                return Sets.newHashSet();
+            }
+
+            // 原逻辑:将可见的企业ID添加到结果集中。
+            // 注意:此处逻辑为 addAll,意味着结果集 = {基础entId} U {可见entIds}。
+            // 如果业务意图是“仅保留基础entId且在可见范围内的”,则应使用 retainAll 或 intersection。
+            // 此处保持原有代码逻辑不变,仅添加日志。
+            result.addAll(visibleEntIds);
+            
+            log.debug("数据权限过滤完成。基础ID: {}, 可见ID数量: {}, 过滤后结果集大小: {}, 结果集内容: {}", 
+                    entId, visibleEntIds.size(), result.size(), result);
+        }
+
+        return result;
+    }
+
 
 
+    private DataPermissionDTO fetchDataPermissionForCurrentUser() {
+        try {
+            DataPermissionFilterReqDto reqDto = new DataPermissionFilterReqDto();
+            reqDto.setUserId(LoginUserHolder.getUserId());
+            reqDto.setRoleId(LoginUserHolder.getCurrentRoleId());
+            reqDto.setManager(LoginUserHolder.isManager());
+            return dataPermissionFeignService.getDataPermissionFilter(reqDto);
+        } catch (Exception e) {
+            log.warn("获取数据权限失败,跳过本接口数据权限过滤: {}", e.getMessage());
+            return null;
+        }
+    }
     /**
     /**
      *
      *
      * @param records
      * @param records

+ 15 - 10
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/handler/ComeIntoHandler.java

@@ -309,7 +309,12 @@ public class ComeIntoHandler extends AbstractWaybillOrderHandler<WaybillOrderCme
             return;
             return;
         }
         }
         // 非空载情况,必须校验是否完成装载
         // 非空载情况,必须校验是否完成装载
-        checkStatus(waybillOrder);
+        if (!Objects.equals(CarWaybillV1Enum.EXIT_COMPLETED.getCode(), waybillOrder.getStatus())
+                && !Objects.equals(CarWaybillV1Enum.REPLENISH_FINISH.getCode(), waybillOrder.getStatus())
+                && !Objects.equals(CarWaybillV1Enum.WAIT_LEAVE.getCode(), waybillOrder.getStatus())
+                && !Objects.equals(CarWaybillV1Enum.UNLOADING.getCode(), waybillOrder.getStatus())) {
+            return;
+        }
 
 
         // 场景二:正常流程,0.5<净重<=任务量
         // 场景二:正常流程,0.5<净重<=任务量
         if (loadAmount.compareTo(entrustAmount) <= 0) {
         if (loadAmount.compareTo(entrustAmount) <= 0) {
@@ -320,15 +325,15 @@ public class ComeIntoHandler extends AbstractWaybillOrderHandler<WaybillOrderCme
         waybillOrder.setTargetStatus(3);
         waybillOrder.setTargetStatus(3);
     }
     }
 
 
-    /**
-     * 正常流程和超载流程,需校验是否已完成装载
-     */
-    private void checkStatus(KwtWaybillOrder waybillOrder) {
-        if (!Objects.equals(CarWaybillV1Enum.EXIT_COMPLETED.getCode(), waybillOrder.getStatus())
-                && !Objects.equals(CarWaybillV1Enum.REPLENISH_FINISH.getCode(), waybillOrder.getStatus())) {
-            throw new BusinessPlatfromException(ErrorCodeEnum.WAYBILL_ORDER_STATUS_ERROR, "当前物流运单状态不是“已装货/补货完成”状态,无法推进待离场/卸货中状态!");
-        }
-    }
+//    /**
+//     * 正常流程和超载流程,需校验是否已完成装载
+//     */
+//    private void checkStatus(KwtWaybillOrder waybillOrder) {
+//        if (!Objects.equals(CarWaybillV1Enum.EXIT_COMPLETED.getCode(), waybillOrder.getStatus())
+//                && !Objects.equals(CarWaybillV1Enum.REPLENISH_FINISH.getCode(), waybillOrder.getStatus())) {
+//            return;
+//        }
+//    }
 
 
     @Override
     @Override
     protected String getProcessName() {
     protected String getProcessName() {

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/handler/TakingOrderHandler.java

@@ -160,7 +160,6 @@ public class TakingOrderHandler extends AbstractWaybillOrderHandler<OrderCircula
                 gatekeeper.setWaybillAcceptTime(waybillOrder.getCreateTime());
                 gatekeeper.setWaybillAcceptTime(waybillOrder.getCreateTime());
                 gatekeeper.setType(GatekeeperTypeEnum.LOADING.getCode());
                 gatekeeper.setType(GatekeeperTypeEnum.LOADING.getCode());
                 gatekeeper.setStatus(GatekeeperStatusEnum.PENDING_ENTRY.getCode());
                 gatekeeper.setStatus(GatekeeperStatusEnum.PENDING_ENTRY.getCode());
-                gatekeeper.setWaybillAcceptTime(waybillOrder.getCreateTime());
                 gatekeeper.setTruckType(truck.getTruckType());
                 gatekeeper.setTruckType(truck.getTruckType());
                 gatekeeper.setEntrustAmount(truckLoadVolume);
                 gatekeeper.setEntrustAmount(truckLoadVolume);
                 gatekeeper.setCarAxis(truck.getCarAxis());
                 gatekeeper.setCarAxis(truck.getCarAxis());
@@ -404,6 +403,7 @@ public class TakingOrderHandler extends AbstractWaybillOrderHandler<OrderCircula
         waybillOrder.setDriverIdcard(driver.getIdcard());
         waybillOrder.setDriverIdcard(driver.getIdcard());
         waybillOrder.setStatus(CarWaybillV1Enum.PENDING_VEHICLE.getCode());
         waybillOrder.setStatus(CarWaybillV1Enum.PENDING_VEHICLE.getCode());
         waybillOrder.setTaskStartTime(new Date());
         waybillOrder.setTaskStartTime(new Date());
+        waybillOrder.setCreateTime(new Date());
         waybillOrder.setCreateBy(param.getDriverId());
         waybillOrder.setCreateBy(param.getDriverId());
         waybillOrder.setUpdateBy(param.getDriverId());
         waybillOrder.setUpdateBy(param.getDriverId());
         waybillOrder.setDispatchWay(logOrder.getDispatchWay());
         waybillOrder.setDispatchWay(logOrder.getDispatchWay());

+ 79 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/enuma/WaybillTimelinePhaseEnum.java

@@ -0,0 +1,79 @@
+package com.sckw.transport.model.enuma;
+
+import com.sckw.core.model.enums.CarWaybillV1Enum;
+import lombok.Getter;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 前端运单节点时间轴展示阶段;每一阶段内嵌关联若干 {@link CarWaybillV1Enum}(支持多对一)。
+ * <p>
+ * 展示顺序:已接单 → 到达装货点 → 已装货 → 已离场 → 已卸货
+ */
+@Getter
+public enum WaybillTimelinePhaseEnum {
+
+    ORDER_ACCEPTED(1, "已接单",
+            EnumSet.of(CarWaybillV1Enum.PENDING_VEHICLE)),
+
+    ARRIVED_LOADING_POINT(5, "到达装货点",
+            EnumSet.of(CarWaybillV1Enum.REFUSE_TRAFFIC)),
+
+    LOADED(15, "已装货",
+            EnumSet.of(
+                    CarWaybillV1Enum.EXIT_COMPLETED,
+                    CarWaybillV1Enum.EMPTY_WAIT_LEAVE,
+                    CarWaybillV1Enum.WAIT_LEAVE,
+                    CarWaybillV1Enum.UNLOADING,
+                    CarWaybillV1Enum.WAIT_RELEASE,
+                    CarWaybillV1Enum.REPLENISHING,
+                    CarWaybillV1Enum.REPLENISH_FINISH,
+                    CarWaybillV1Enum.RELEASED_NOT_EXITED)),
+
+    DEPARTED(20, "已离场",
+            EnumSet.of(
+                    CarWaybillV1Enum.WAIT_LOADING)),
+
+    UNLOADED(25, "已卸货",
+            EnumSet.of(
+                    CarWaybillV1Enum.COMPLETION_LOADING,
+                    CarWaybillV1Enum.REVIEW_REJECTION,
+                    CarWaybillV1Enum.CANCELLED));
+
+    private final int phaseOrder;
+    private final String phaseLabel;
+    private final Set<CarWaybillV1Enum> mappedWaybillStatuses;
+
+    WaybillTimelinePhaseEnum(int phaseOrder, String phaseLabel, Set<CarWaybillV1Enum> mappedWaybillStatuses) {
+        this.phaseOrder = phaseOrder;
+        this.phaseLabel = phaseLabel;
+        this.mappedWaybillStatuses = Collections.unmodifiableSet(mappedWaybillStatuses);
+    }
+
+    private static final Map<Integer, WaybillTimelinePhaseEnum> STATUS_CODE_TO_PHASE;
+
+    static {
+        Map<Integer, WaybillTimelinePhaseEnum> map = new HashMap<>(32);
+        for (WaybillTimelinePhaseEnum phase : values()) {
+            for (CarWaybillV1Enum st : phase.mappedWaybillStatuses) {
+                map.put(st.getCode(), phase);
+            }
+        }
+        STATUS_CODE_TO_PHASE = Collections.unmodifiableMap(map);
+    }
+
+    /**
+     * @param waybillStatusCode {@link CarWaybillV1Enum#getCode()}
+     */
+    public static Optional<WaybillTimelinePhaseEnum> resolve(Integer waybillStatusCode) {
+        if (waybillStatusCode == null) {
+            return Optional.empty();
+        }
+        return Optional.ofNullable(STATUS_CODE_TO_PHASE.get(waybillStatusCode));
+    }
+
+    public List<Integer> mappedWaybillStatusCodes() {
+        return mappedWaybillStatuses.stream().map(CarWaybillV1Enum::getCode).collect(Collectors.toList());
+    }
+}

+ 53 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/SalesWaybillOrderResp.java

@@ -0,0 +1,53 @@
+package com.sckw.transport.model.param;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author :chenXiaoFei
+ * @version :1.0
+ * @description : 分页查询运单信息响应参数
+ * @create :2025-11-11 20:16:00
+ */
+@Data
+public class SalesWaybillOrderResp implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -6153312023002477484L;
+
+    /**
+     * 执行中的订单
+     */
+    @Schema(description = "执行中的订单")
+    private Integer ongoingLogOrder;
+
+    /**
+     * 今日车次
+     */
+    @Schema(description = "今日车次")
+    private Integer todayTruckCount;
+
+    /**
+     * 场内车辆
+     */
+    @Schema(description = "场内车辆")
+    private Integer insideVehicleCount;
+
+    /**
+     * 今日出货量
+     */
+    @Schema(description = "今日出货量")
+    private Integer todayShipmentWeight;
+
+    /**
+     * 本月出货量
+     */
+    @Schema(description = "本月出货量")
+    private Integer monthShipmentWeight;
+
+
+}

+ 5 - 4
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillOrderNodeVo.java

@@ -1,5 +1,6 @@
 package com.sckw.transport.model.vo;
 package com.sckw.transport.model.vo;
 
 
+import com.sckw.transport.model.enuma.WaybillTimelinePhaseEnum;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Data;
 
 
@@ -133,14 +134,14 @@ public class WaybillOrderNodeVo implements Serializable {
         private String createTime;
         private String createTime;
 
 
         /**
         /**
-         * 运单状态
+         * 状态序号:接口返回前会按 {@link WaybillTimelinePhaseEnum} 映射为前端五步序号 1~5;无法映射时仍为原始运单状态
          */
          */
-        @Schema(description = "运单状态码")
+        @Schema(description = "状态序号:1已接单 2到达装货点 3已装货 4已离场 5已卸货(无法映射时为原始运单状态码")
         private Integer orderStatus;
         private Integer orderStatus;
         /**
         /**
-         * 状态描述
+         * 状态名称:映射后为前端五步文案;无法映射时仍为运单状态原始描述
          */
          */
-        @Schema(description = "状态码描述")
+        @Schema(description = "状态名称(映射后与 orderStatus 对应五步文案)")
         private String orderStatusName;
         private String orderStatusName;
     }
     }
 }
 }

+ 11 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwfTaskService.java

@@ -104,8 +104,17 @@ public class KwfTaskService {
         }else {
         }else {
             totalCount = kwtWaybillOrderStream.size();
             totalCount = kwtWaybillOrderStream.size();
         }
         }
-        List<Integer> tasking = Arrays.asList(CarWaybillV1Enum.PENDING_VEHICLE.getCode(),CarWaybillV1Enum.WEIGHT_TRAFFIC.getCode(), CarWaybillV1Enum.REFUSE_TRAFFIC.getCode(),
-                CarWaybillV1Enum.EXIT_COMPLETED.getCode(), CarWaybillV1Enum.WAIT_LOADING.getCode());
+        List<Integer> tasking = Arrays.asList(CarWaybillV1Enum.PENDING_VEHICLE.getCode(),
+                CarWaybillV1Enum.REFUSE_TRAFFIC.getCode(),
+                CarWaybillV1Enum.EXIT_COMPLETED.getCode(),
+                CarWaybillV1Enum.EMPTY_WAIT_LEAVE.getCode(),
+                CarWaybillV1Enum.WAIT_LEAVE.getCode(),
+                CarWaybillV1Enum.UNLOADING.getCode(),
+                CarWaybillV1Enum.WAIT_RELEASE.getCode(),
+                CarWaybillV1Enum.REPLENISHING.getCode(),
+                CarWaybillV1Enum.REPLENISH_FINISH.getCode(),
+                CarWaybillV1Enum.RELEASED_NOT_EXITED.getCode(),
+                CarWaybillV1Enum.WAIT_LOADING.getCode());
         //处理中的任务数
         //处理中的任务数
         long taskingCount = waybillOrder.stream()
         long taskingCount = waybillOrder.stream()
                 .filter(w -> tasking.contains(w.getStatus()) && StringUtils.isNotBlank(w.getTruckNo()))
                 .filter(w -> tasking.contains(w.getStatus()) && StringUtils.isNotBlank(w.getTruckNo()))

+ 57 - 7
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderV1Service.java

@@ -62,10 +62,7 @@ import com.sckw.transport.common.config.UrlConfigProperties;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.*;
 import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.*;
 import com.sckw.transport.model.dto.*;
-import com.sckw.transport.model.enuma.ApproveStatusEnum;
-import com.sckw.transport.model.enuma.CarWaybillDetailEnum;
-import com.sckw.transport.model.enuma.CarWaybillNdexTopEnum;
-import com.sckw.transport.model.enuma.CarWaybillTableTopEnum;
+import com.sckw.transport.model.enuma.*;
 import com.sckw.transport.model.param.WaybillOrderNodeReq;
 import com.sckw.transport.model.param.WaybillOrderNodeReq;
 import com.sckw.transport.model.param.WaybillOrderReq;
 import com.sckw.transport.model.param.WaybillOrderReq;
 import com.sckw.transport.model.param.WaybillOrderResp;
 import com.sckw.transport.model.param.WaybillOrderResp;
@@ -5473,7 +5470,7 @@ public class KwtWaybillOrderV1Service {
     }
     }
 
 
     private List<Integer>  getWaybillOrderStatus() {
     private List<Integer>  getWaybillOrderStatus() {
-       return Arrays.asList(CarWaybillV1Enum.WEIGHT_TRAFFIC.getCode(), CarWaybillV1Enum.EMPTY_WAIT_LEAVE.getCode(),
+       return Arrays.asList( CarWaybillV1Enum.EMPTY_WAIT_LEAVE.getCode(),
                 CarWaybillV1Enum.WAIT_LEAVE.getCode(), CarWaybillV1Enum.UNLOADING.getCode(),
                 CarWaybillV1Enum.WAIT_LEAVE.getCode(), CarWaybillV1Enum.UNLOADING.getCode(),
                 CarWaybillV1Enum.WAIT_RELEASE.getCode(), CarWaybillV1Enum.REPLENISHING.getCode(),
                 CarWaybillV1Enum.WAIT_RELEASE.getCode(), CarWaybillV1Enum.REPLENISHING.getCode(),
                 CarWaybillV1Enum.REPLENISH_FINISH.getCode(), CarWaybillV1Enum.RELEASED_NOT_EXITED.getCode());
                 CarWaybillV1Enum.REPLENISH_FINISH.getCode(), CarWaybillV1Enum.RELEASED_NOT_EXITED.getCode());
@@ -5511,8 +5508,13 @@ public class KwtWaybillOrderV1Service {
         //获取时间线
         //获取时间线
         List<WaybillOrderNodeVo.Timeline> voList = getTimelines(nodes);
         List<WaybillOrderNodeVo.Timeline> voList = getTimelines(nodes);
         waybillOrderNodeVo.setTimelines(voList);
         waybillOrderNodeVo.setTimelines(voList);
-        // 获取时间节点
+        // 获取时间节点,并按前端五步序号排序(映射写入 orderStatus / orderStatusName)
         List<WaybillOrderNodeVo.WaybillOrderNode> nodeList = getWaybillOrderNodes(voList);
         List<WaybillOrderNodeVo.WaybillOrderNode> nodeList = getWaybillOrderNodes(voList);
+        log.info("查询运单节点轨迹,时间节点:{}", JSON.toJSONString(nodeList));
+        // 将原始运单状态映射为前端五步时间轴阶段(1-5),并更新节点的状态码和名称
+        applyTimelinePhaseFromWaybillStatus(nodeList);
+        // 对映射后的节点列表按阶段去重,保留每个阶段最早的一条记录
+        nodeList = dedupeWaybillOrderNodesByStatus(nodeList);
         nodeList = nodeList.stream()
         nodeList = nodeList.stream()
                 .sorted(Comparator.comparing(WaybillOrderNodeVo.WaybillOrderNode::getOrderStatus))
                 .sorted(Comparator.comparing(WaybillOrderNodeVo.WaybillOrderNode::getOrderStatus))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
@@ -5559,7 +5561,7 @@ public class KwtWaybillOrderV1Service {
     @NotNull
     @NotNull
     private static List<WaybillOrderNodeVo.WaybillOrderNode> getWaybillOrderNodes(List<WaybillOrderNodeVo.Timeline> voList) {
     private static List<WaybillOrderNodeVo.WaybillOrderNode> getWaybillOrderNodes(List<WaybillOrderNodeVo.Timeline> voList) {
         Map<Integer, List<WaybillOrderNodeVo.Timeline>> statusAndTimelineMap = voList.stream()
         Map<Integer, List<WaybillOrderNodeVo.Timeline>> statusAndTimelineMap = voList.stream()
-                .filter(t ->!Arrays.asList(CarWaybillV1Enum.WEIGHT_TRAFFIC.getCode(),CarWaybillV1Enum.COMPLETED.getCode(),CarWaybillV1Enum.CANCELLED.getCode(), CarWaybillV1Enum.REVIEW_REJECTION.getCode()).contains(t.getOrderStatus()))
+                .filter(t ->!Arrays.asList(CarWaybillV1Enum.COMPLETED.getCode(),CarWaybillV1Enum.CANCELLED.getCode(), CarWaybillV1Enum.REVIEW_REJECTION.getCode()).contains(t.getOrderStatus()))
                 .sorted(Comparator.comparing(WaybillOrderNodeVo.Timeline::getCreateTime))
                 .sorted(Comparator.comparing(WaybillOrderNodeVo.Timeline::getCreateTime))
                 .collect(Collectors.groupingBy(WaybillOrderNodeVo.Timeline::getOrderStatus));
                 .collect(Collectors.groupingBy(WaybillOrderNodeVo.Timeline::getOrderStatus));
         List<WaybillOrderNodeVo.WaybillOrderNode> nodeList = Lists.newArrayList();
         List<WaybillOrderNodeVo.WaybillOrderNode> nodeList = Lists.newArrayList();
@@ -5577,6 +5579,54 @@ public class KwtWaybillOrderV1Service {
         return nodeList;
         return nodeList;
     }
     }
 
 
+    /**
+     * 将原始运单状态映射到前端五步时间轴,写入既有字段 {@code orderStatus}(1~5 阶段序号)、{@code orderStatusName}(阶段文案);
+     * 无法映射的节点保留 {@link #getWaybillOrderNodes} 中已赋值的原始码与描述。
+     */
+    private static void applyTimelinePhaseFromWaybillStatus(List<WaybillOrderNodeVo.WaybillOrderNode> nodeList) {
+        if (CollectionUtils.isEmpty(nodeList)) {
+            return;
+        }
+        for (WaybillOrderNodeVo.WaybillOrderNode node : nodeList) {
+            WaybillTimelinePhaseEnum.resolve(node.getOrderStatus()).ifPresent(phase -> {
+                node.setOrderStatus(phase.getPhaseOrder());
+                node.setOrderStatusName(phase.getPhaseLabel());
+            });
+        }
+    }
+
+    /**
+     * 映射后多个原始状态可能合并为同一阶段序号(1~5),会出现重复 {@code orderStatus};
+     * 按状态码去重,同一时间保留该阶段下 {@code createTime} 最早(第一次出现)的一条节点。
+     */
+    private static List<WaybillOrderNodeVo.WaybillOrderNode> dedupeWaybillOrderNodesByStatus(
+            List<WaybillOrderNodeVo.WaybillOrderNode> nodeList) {
+        if (CollectionUtils.isEmpty(nodeList)) {
+            return nodeList;
+        }
+        return nodeList.stream()
+                .filter(node -> node.getOrderStatus() != null)
+                .collect(Collectors.toMap(
+                        WaybillOrderNodeVo.WaybillOrderNode::getOrderStatus,
+                        Function.identity(),
+                        (a, b) -> {
+                            Date ta = parseWaybillNodeCreateTime(a.getCreateTime());
+                            Date tb = parseWaybillNodeCreateTime(b.getCreateTime());
+                            return !ta.after(tb) ? a : b;
+                        }))
+                .values()
+                .stream()
+                .collect(Collectors.toList());
+    }
+
+    private static Date parseWaybillNodeCreateTime(String createTime) {
+        if (org.apache.commons.lang3.StringUtils.isBlank(createTime)) {
+            return new Date(0L);
+        }
+        Date d = DateUtils.formatDate(createTime);
+        return d != null ? d : new Date(0L);
+    }
+
     /**
     /**
      * 构建状态描述文本
      * 构建状态描述文本
      * 格式:车辆【川A5478C】司机【张三】装载货物【铁矿石】【参运】【28.70吨】
      * 格式:车辆【川A5478C】司机【张三】装载货物【铁矿石】【参运】【28.70吨】

+ 7 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/kwfTruckTraceService.java

@@ -1172,9 +1172,15 @@ private Map<String, Integer> getTruckLocationStatusMap(Map<Long, String> truckId
         // 默认返回任务进行中的各种状态
         // 默认返回任务进行中的各种状态
         return Arrays.asList(
         return Arrays.asList(
                 CarWaybillV1Enum.PENDING_VEHICLE.getCode(),  // 待提货
                 CarWaybillV1Enum.PENDING_VEHICLE.getCode(),  // 待提货
-                CarWaybillV1Enum.WEIGHT_TRAFFIC.getCode(),   // 运输中(称重)
                 CarWaybillV1Enum.REFUSE_TRAFFIC.getCode(),   // 拒绝运输
                 CarWaybillV1Enum.REFUSE_TRAFFIC.getCode(),   // 拒绝运输
                 CarWaybillV1Enum.EXIT_COMPLETED.getCode(),   // 出口完成
                 CarWaybillV1Enum.EXIT_COMPLETED.getCode(),   // 出口完成
+                CarWaybillV1Enum.EMPTY_WAIT_LEAVE.getCode(),
+                CarWaybillV1Enum.WAIT_LEAVE.getCode(),
+                CarWaybillV1Enum.UNLOADING.getCode(),
+                CarWaybillV1Enum.WAIT_RELEASE.getCode(),
+                CarWaybillV1Enum.REPLENISHING.getCode(),
+                CarWaybillV1Enum.REPLENISH_FINISH.getCode(),
+                CarWaybillV1Enum.RELEASED_NOT_EXITED.getCode(),
                 CarWaybillV1Enum.WAIT_LOADING.getCode()      // 等待装货
                 CarWaybillV1Enum.WAIT_LOADING.getCode()      // 等待装货
         );
         );
     }
     }