Ver Fonte

新增自动派车司机接单分数限制

donglang há 4 meses atrás
pai
commit
a5e5f1c12b

+ 8 - 0
sckw-modules-api/sckw-fleet-api/src/main/java/com/sckw/fleet/api/RemoteFleetService.java

@@ -133,4 +133,12 @@ public interface RemoteFleetService {
 
 
     void unbindTruck(Long entId, Long driverId);
+
+    /**
+     * @param driverId 司机分数
+     * @desc 查询司机分数
+     * @author zk
+     * @date 2023/8/3
+     **/
+    RDriverScoreVo findDriverScore(Long supEntId, Long logEntId, Long driverId);
 }

+ 15 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dubbo/RemoteFleetServiceImpl.java

@@ -676,4 +676,19 @@ public class RemoteFleetServiceImpl implements RemoteFleetService {
         truckReportRepository.updateById(truckReport);
 
     }
+
+    @Override
+    public RDriverScoreVo findDriverScore(Long supEntId, Long logEntId, Long driverId) {
+        //1. 查询司机的评分
+        KwfDriverScore driverScore = driverScoreRepository.findDriverScoreByEntIds(supEntId, logEntId, driverId);
+        if (driverScore == null) {
+            return null;
+        }
+        RDriverScoreVo driverScoreVo = new RDriverScoreVo();
+        driverScoreVo.setProviderEntId(driverScore.getProviderEntId());
+        driverScoreVo.setLogisticsEntId(driverScore.getLogisticsEntId());
+        driverScoreVo.setDriverId(driverScore.getDriverId());
+        driverScoreVo.setScore(driverScore.getScore());
+        return driverScoreVo;
+    }
 }

+ 2 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/handler/AbstractWaybillOrderHandler.java

@@ -214,8 +214,8 @@ public abstract class AbstractWaybillOrderHandler<T extends WaybillOrderProcessP
     /**
      * 查询物流订单
      */
-    protected KwtLogisticsOrder getLogisticsOrder(Long waybillOrderId) {
-        KwtLogisticsOrder logisticsOrder = logisticsOrderRepository.queryByLogisticsOrderId(waybillOrderId);
+    protected KwtLogisticsOrder getLogisticsOrder(Long logOrderId) {
+        KwtLogisticsOrder logisticsOrder = logisticsOrderRepository.queryByLogisticsOrderId(logOrderId);
         if (logisticsOrder == null) {
             throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_FOUND, "物流订单数据不存在!");
         }

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

@@ -8,10 +8,10 @@ import com.sckw.core.exception.BusinessPlatfromException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.AddressTypeEnum;
 import com.sckw.core.model.enums.CarWaybillV1Enum;
+import com.sckw.core.model.enums.DispatchWayEnums;
 import com.sckw.core.model.enums.LogisticsOrderV1Enum;
 import com.sckw.core.utils.CollectionUtils;
-import com.sckw.fleet.api.model.vo.RDriverVo;
-import com.sckw.fleet.api.model.vo.RTruckVo;
+import com.sckw.fleet.api.model.vo.*;
 import com.sckw.order.api.model.OrderDetailVo;
 import com.sckw.order.api.model.UpdateActualAmountParam;
 import com.sckw.transport.model.*;
@@ -171,11 +171,30 @@ public class TakingOrderHandler extends AbstractWaybillOrderHandler<OrderCircula
      * @return
      */
     private RDriverVo checkDriver(OrderCirculateTakingQueryParam param) {
-        RDriverVo driver = remoteFleetService.findDriver(param.getDriverId());
-        if (driver == null || driver.getStatus() == Global.NUMERICAL_ONE) {
+        RDriverVo driverVo = remoteFleetService.findDriver(param.getDriverId());
+        if (driverVo == null || driverVo.getStatus() == Global.NUMERICAL_ONE) {
             throw new BusinessPlatfromException(ErrorCodeEnum.DRIVER_STATUS_ERROR, "当前司机已锁定");
         }
-        return driver;
+        //校验是否是自动派单
+        KwtLogisticsOrder logisticsOrder = getLogisticsOrder(param.getLogOrderId());
+        if (!DispatchWayEnums.AUTO_DISPATCH.getCode().equals(logisticsOrder.getDispatchWay())) {
+            return driverVo;
+        }
+        //查询订单托运单位
+        KwtLogisticsOrderUnit logisticsOrderUnit = logisticsOrderUnitRepository.queryByLOrderIdAndUnitType(param.getLogOrderId(), 1);
+        if (logisticsOrderUnit == null || logisticsOrderUnit.getEntId() == null) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_ENT, "未找到关联的物流订单托运企业(供应商)!");
+        }
+
+        //查询司机派车系数
+        TruckDispatchCoefficientVO dispatchCoefficient = getAutoTruckDispatchByEntId(logisticsOrderUnit.getEntId());
+        Integer driverOrderLimit = dispatchCoefficient.getDriverOrderLimit();
+        //查询司机分数
+        RDriverScoreVo driverScore = remoteFleetService.findDriverScore(logisticsOrderUnit.getEntId(), param.getEntId(), param.getDriverId());
+        if (driverScore == null || driverScore.getScore() == null || driverOrderLimit == 0 || driverScore.getScore().compareTo(BigDecimal.valueOf(driverOrderLimit)) < 0) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DRIVER_STATUS_ERROR, "当前司机分数过低,不能继续接单");
+        }
+        return driverVo;
     }
 
     /**