|
|
@@ -3559,20 +3559,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
waybillOrderDetailResp.setUnloadAddress(unLoadAdd.getCityName()+unLoadAdd.getDetailAddress());
|
|
|
|
|
|
//预计里程
|
|
|
- double distanceKm = com.sckw.core.utils.LocUtils.calculateDistanceByAmap(
|
|
|
- Optional.ofNullable(loadAdd.getLat()).map(String::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(loadAdd.getLng()).map(String::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(unLoadAdd.getLat()).map(String::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(unLoadAdd.getLng()).map(String::valueOf).orElse(null));
|
|
|
- // 如果高德API调用失败,使用原始方法作为备选
|
|
|
- if (distanceKm == -1) {
|
|
|
- distanceKm = DistanceUtils.calculateDistance(
|
|
|
- Optional.ofNullable(loadAdd.getLat()).map(Double::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(loadAdd.getLng()).map(Double::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(unLoadAdd.getLat()).map(Double::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(unLoadAdd.getLng()).map(Double::valueOf).orElse(null));
|
|
|
- }
|
|
|
- waybillOrderDetailResp.setDistanceKm(distanceKm);
|
|
|
+ waybillOrderDetailResp.setDistanceKm(logOrder.getDistance());
|
|
|
waybillOrderDetailResp.setLoadLatitude(loadAdd.getLat());
|
|
|
waybillOrderDetailResp.setLoadLongitude(loadAdd.getLng());
|
|
|
waybillOrderDetailResp.setUnloadLatitude(unLoadAdd.getLat());
|
|
|
@@ -3787,6 +3774,9 @@ public class KwtWaybillOrderV1Service {
|
|
|
//先不执行自动派单逻辑
|
|
|
return;
|
|
|
}
|
|
|
+ //查询物流订单
|
|
|
+ KwtLogisticsOrder logisticsOrder = kwtLogisticsOrderRepository.queryByLogisticsOrderId(billOrder.getLOrderId());
|
|
|
+
|
|
|
//查询运单装卸货地址
|
|
|
List<KwtWaybillOrderAddress> addressList = waybillOrderAddressRepository.queryByWOrderId(billOrder.getId());
|
|
|
if (CollectionUtils.isEmpty(addressList)) {
|
|
|
@@ -3814,10 +3804,10 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
|
|
|
//2. 校验司机运单完成是否超时
|
|
|
- checkCompletionTimeout(billOrder, addressMap, driverRulesVO);
|
|
|
+ checkCompletionTimeout(billOrder, logisticsOrder, driverRulesVO);
|
|
|
|
|
|
//3. 校验司机连续准时卸货(审核通过)
|
|
|
- checkContinuousUnload(billOrder, addressMap);
|
|
|
+ checkContinuousUnload(billOrder, logisticsOrder);
|
|
|
|
|
|
//4. 校验司机连续准确填写卸货信息(审核通过)
|
|
|
checkContinuousPass(billOrder, addressMap);
|
|
|
@@ -3854,7 +3844,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
* 校验司机运单完成是否超时
|
|
|
* @param waybillOrder
|
|
|
*/
|
|
|
- private void checkCompletionTimeout(KwtWaybillOrder waybillOrder, Map<Integer, KwtWaybillOrderAddress> addressMap,
|
|
|
+ private void checkCompletionTimeout(KwtWaybillOrder waybillOrder, KwtLogisticsOrder logisticsOrder,
|
|
|
DriverConductRulesVO driverRulesVO) {
|
|
|
//单趟严重超时倍数
|
|
|
BigDecimal timeoutMultiple = driverRulesVO.getUnloadSeriousTimeoutMultiple();
|
|
|
@@ -3866,7 +3856,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
|
|
|
//校验司机运单完成是否超时
|
|
|
- Boolean isTimeOut = isTimeOut(waybillOrder, addressMap, timeoutMultiple);
|
|
|
+ Boolean isTimeOut = isTimeOut(waybillOrder, logisticsOrder, timeoutMultiple);
|
|
|
if (isTimeOut) {
|
|
|
//1、更新司机分数(减分)
|
|
|
timeoutScore = -Math.abs(timeoutScore);
|
|
|
@@ -3881,14 +3871,14 @@ public class KwtWaybillOrderV1Service {
|
|
|
/**
|
|
|
* 校验司机运单完成是否超时
|
|
|
* @param waybillOrder 运单
|
|
|
- * @param addressMap 运单地址
|
|
|
+ * @param logisticsOrder 运单地址
|
|
|
*/
|
|
|
- protected Boolean isTimeOut(KwtWaybillOrder waybillOrder, Map<Integer, KwtWaybillOrderAddress> addressMap, BigDecimal timeoutMultiple) {
|
|
|
+ protected Boolean isTimeOut(KwtWaybillOrder waybillOrder, KwtLogisticsOrder logisticsOrder, BigDecimal timeoutMultiple) {
|
|
|
log.info("校验司机运单完成是否超时:运单ID:{}", waybillOrder.getId());
|
|
|
//运单总耗时
|
|
|
Long orderTotalTimes = calOrderTotalTimes(waybillOrder);
|
|
|
//平台配置的单趟总耗时
|
|
|
- Integer singleTripTotalTimes = calSingleTripTotalTimes(waybillOrder, addressMap);
|
|
|
+ Integer singleTripTotalTimes = calSingleTripTotalTimes(waybillOrder, logisticsOrder);
|
|
|
//计算超时阈值
|
|
|
BigDecimal threshold = timeoutMultiple.compareTo(BigDecimal.ZERO) == 0 ?
|
|
|
new BigDecimal(singleTripTotalTimes) : timeoutMultiple.multiply(new BigDecimal(singleTripTotalTimes));
|
|
|
@@ -3927,10 +3917,10 @@ public class KwtWaybillOrderV1Service {
|
|
|
/**
|
|
|
* 计算平台配置的运单单趟总耗时
|
|
|
* @param waybillOrder
|
|
|
- * @param addressMap
|
|
|
+ * @param logisticsOrder
|
|
|
* @return
|
|
|
*/
|
|
|
- private Integer calSingleTripTotalTimes(KwtWaybillOrder waybillOrder, Map<Integer, KwtWaybillOrderAddress> addressMap) {
|
|
|
+ private Integer calSingleTripTotalTimes(KwtWaybillOrder waybillOrder, KwtLogisticsOrder logisticsOrder) {
|
|
|
// 获取自动派单系数配置(单趟耗时 = 装货时间 + 卸货时间 + 运输时间 + 返回时间)
|
|
|
TruckDispatchCoefficientVO truckDispatchVO = remoteFleetService.findAutoTruckDispatchByEntId(waybillOrder.getEntId());
|
|
|
if (truckDispatchVO == null) {
|
|
|
@@ -3947,29 +3937,13 @@ public class KwtWaybillOrderV1Service {
|
|
|
waybillOrder.getEntId(), vehicleLoadingHours, vehicleUnloadingHours, vehicleAvgSpeed, waybillOrder.getId());
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "司机配置的装货时长/卸货时长/平均行驶速度需要≥0!");
|
|
|
}
|
|
|
- //查询运单装卸货地址
|
|
|
- KwtWaybillOrderAddress shipmentAddress = addressMap.getOrDefault(AddressTypeEnum.SHIPMENT.getCode(), new KwtWaybillOrderAddress());
|
|
|
- KwtWaybillOrderAddress takeAddress = addressMap.getOrDefault(AddressTypeEnum.TAKE.getCode(), new KwtWaybillOrderAddress());
|
|
|
-
|
|
|
//应卸货地与实际卸货地之间距离
|
|
|
- double twoPlaceDistanceKm = com.sckw.core.utils.LocUtils.calculateDistanceByAmap(
|
|
|
- Optional.ofNullable(takeAddress.getLng()).map(String::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(takeAddress.getLat()).map(String::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(shipmentAddress.getLng()).map(String::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(shipmentAddress.getLat()).map(String::valueOf).orElse(null));
|
|
|
- // 如果高德API调用失败,使用原始方法作为备选
|
|
|
- if (twoPlaceDistanceKm == -1) {
|
|
|
- twoPlaceDistanceKm = DistanceUtils.calculateDistance(
|
|
|
- Optional.ofNullable(takeAddress.getLng()).map(Double::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(takeAddress.getLat()).map(Double::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(shipmentAddress.getLng()).map(Double::valueOf).orElse(null),
|
|
|
- Optional.ofNullable(shipmentAddress.getLat()).map(Double::valueOf).orElse(null));
|
|
|
- }
|
|
|
- //运输时间/返回时间(小时) = 两地距离除以平均行驶速度
|
|
|
- if (twoPlaceDistanceKm == 0.0 || Double.isNaN(twoPlaceDistanceKm)) {
|
|
|
+ String distance = logisticsOrder.getDistance();
|
|
|
+ if (StringUtils.isBlank(distance)) {
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR, "物流运单装货地址有误!");
|
|
|
}
|
|
|
- BigDecimal bdDividend = BigDecimal.valueOf(twoPlaceDistanceKm);
|
|
|
+ //运输时间/返回时间(小时) = 两地距离除以平均行驶速度
|
|
|
+ BigDecimal bdDividend = new BigDecimal(distance);
|
|
|
BigDecimal bdDivisor = BigDecimal.valueOf(vehicleAvgSpeed);
|
|
|
//运输时间小时
|
|
|
BigDecimal transportTimeHours = bdDividend.divide(bdDivisor, 4, RoundingMode.HALF_UP);
|
|
|
@@ -3988,7 +3962,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
* 校验司机连续准时卸货
|
|
|
* @param waybillOrder
|
|
|
*/
|
|
|
- private void checkContinuousUnload(KwtWaybillOrder waybillOrder, Map<Integer, KwtWaybillOrderAddress> addressMap) {
|
|
|
+ private void checkContinuousUnload(KwtWaybillOrder waybillOrder, KwtLogisticsOrder logisticsOrder) {
|
|
|
// 获取司机行为规则配置(连续准时卸货次数)
|
|
|
DriverConductRulesVO driverRulesVO = remoteFleetService.findDriverConductRulesByEntId(waybillOrder.getEntId());
|
|
|
if (driverRulesVO == null) {
|
|
|
@@ -4014,7 +3988,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
List<Long> nodeIds = new ArrayList<>();
|
|
|
for (KwtWaybillOrderNode orderNode : waybillOrderNodeList) {
|
|
|
KwtWaybillOrder wOrder = kwtWaybillOrderRepository.queryByBillOrderId(orderNode.getWOrderId());
|
|
|
- Boolean timeOut = isTimeOut(wOrder, addressMap, BigDecimal.ZERO);
|
|
|
+ Boolean timeOut = isTimeOut(wOrder, logisticsOrder, BigDecimal.ZERO);
|
|
|
if (timeOut) {
|
|
|
log.info("司机{}存在超时情况,运单id:{}", orderNode.getDriverId(), orderNode.getWOrderId());
|
|
|
return;
|