Procházet zdrojové kódy

提交解绑车辆bug

chenxiaofei před 2 týdny
rodič
revize
34c2cb5a4e

+ 5 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtLogisticsOrder.java

@@ -237,6 +237,11 @@ public class KwtLogisticsOrder implements Serializable {
      * 派单方式(1-手动派单、2-自动派单)
      */
     private Integer dispatchWay;
+    /**
+     * 装卸货之间的距离
+     */
+    @TableField("distance")
+    private String distance;
 
     private static final long serialVersionUID = 1L;
 

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/LogisticsOrderResp.java

@@ -182,7 +182,7 @@ public class LogisticsOrderResp implements Serializable {
      * 装卸货之间距离
      */
     @Schema(description = "装卸货之间距离")
-    private double distanceKm;
+    private String distanceKm;
 
     /**
      * 订单余量

+ 20 - 3
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtAcceptCarriageOrderService.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.google.common.collect.Lists;
+import com.mysql.cj.x.protobuf.MysqlxDatatypes;
 import com.sckw.contract.api.RemoteContractService;
 import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
 import com.sckw.core.common.enums.StringConstant;
@@ -3222,6 +3223,21 @@ public class KwtAcceptCarriageOrderService {
         //实际派车数 20
         Integer actualDisPatch = orderDTO.getActualDisPatch() == null ? 0 : orderDTO.getActualDisPatch();
         //已派车辆数(累计已分配的车辆数)
+        //装卸地之间距离
+        double distanceKm = LocUtils.calculateDistanceByAmap(
+                Optional.ofNullable(orderDTO.getLoadLng()).map(String::valueOf).orElse(null),
+                Optional.ofNullable(orderDTO.getLoadLat()).map(String::valueOf).orElse(null),
+                Optional.ofNullable(orderDTO.getUnloadLng()).map(String::valueOf).orElse(null),
+                Optional.ofNullable(orderDTO.getUnloadLat()).map(String::valueOf).orElse(null));
+        // 如果高德API调用失败,使用原始方法作为备选
+        if (distanceKm == -1) {
+            distanceKm = DistanceUtils.calculateDistance(
+                    Optional.ofNullable(orderDTO.getLoadLng()).map(Double::valueOf).orElse(null),
+                    Optional.ofNullable(orderDTO.getLoadLat()).map(Double::valueOf).orElse(null),
+                    Optional.ofNullable(orderDTO.getUnloadLng()).map(Double::valueOf).orElse(null),
+                    Optional.ofNullable(orderDTO.getUnloadLat()).map(Double::valueOf).orElse(null));
+        }
+        String distance = String.valueOf(distanceKm);
         Integer dispatched = 0;
         for (LogisticData x : logisticInfo) {
             Long lOrderId = new IdWorker(NumberConstant.ONE).nextId();
@@ -3253,7 +3269,7 @@ public class KwtAcceptCarriageOrderService {
                 dispatched = Math.min(dispatched, actualDisPatch);
 
                 //物流订单信息
-                setLogisticOrderInfo(orderDTO, x, lOrderId, lOrderNo, saveLogisticsOrderList);
+                setLogisticOrderInfo(orderDTO, x, lOrderId, lOrderNo, saveLogisticsOrderList,distance);
                 //地址信息
                 setLogisticAddress(orderDTO, x, lOrderId, saveAddressList);
                 //商品信息
@@ -3268,7 +3284,7 @@ public class KwtAcceptCarriageOrderService {
 
             } else {
                 //物流订单信息
-                setLogisticOrderInfo(orderDTO, x, lOrderId, lOrderNo, saveLogisticsOrderList);
+                setLogisticOrderInfo(orderDTO, x, lOrderId, lOrderNo, saveLogisticsOrderList,distance);
 
                 //地址信息
                 setLogisticAddress(orderDTO, x, lOrderId, saveAddressList);
@@ -3588,7 +3604,7 @@ public class KwtAcceptCarriageOrderService {
         saveAddressList.add(unloadAddress);
     }
 
-    private static void setLogisticOrderInfo(AddLogisticOrderDTO orderDTO, LogisticData x, Long lOrderId, String lOrderNo, List<KwtLogisticsOrder> saveLogisticsOrderList) {
+    private static void setLogisticOrderInfo(AddLogisticOrderDTO orderDTO, LogisticData x, Long lOrderId, String lOrderNo, List<KwtLogisticsOrder> saveLogisticsOrderList,String distance) {
         KwtLogisticsOrder kwtLogisticsOrder = new KwtLogisticsOrder();
         kwtLogisticsOrder.setId(lOrderId);
         kwtLogisticsOrder.setEntId(orderDTO.getEntId());
@@ -3631,6 +3647,7 @@ public class KwtAcceptCarriageOrderService {
         kwtLogisticsOrder.setUpdateTime(date);
         kwtLogisticsOrder.setBindStatus(String.valueOf(NumberConstant.ZERO));
         kwtLogisticsOrder.setDispatchWay(orderDTO.getDispatchWay());
+        kwtLogisticsOrder.setDistance(distance);
         saveLogisticsOrderList.add(kwtLogisticsOrder);
     }
 }

+ 2 - 29
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsConsignmentService.java

@@ -2518,21 +2518,7 @@ public class KwtLogisticsConsignmentService {
         logisticsOrderResp.setUnloadPhone(unloadAdd.getPhone());
         logisticsOrderResp.setStartTime(DateUtils.format(kwtLogisticsOrder.getStartTime(), DateUtils.DATE_PATTERN));
         logisticsOrderResp.setEndTime(DateUtils.format(kwtLogisticsOrder.getEndTime(), DateUtils.DATE_PATTERN));
-        //装卸地之间距离
-        double distanceKm = LocUtils.calculateDistanceByAmap(
-                Optional.ofNullable(loadAdd.getLng()).map(String::valueOf).orElse(null),
-                Optional.ofNullable(loadAdd.getLat()).map(String::valueOf).orElse(null),
-                Optional.ofNullable(unloadAdd.getLng()).map(String::valueOf).orElse(null),
-                Optional.ofNullable(unloadAdd.getLat()).map(String::valueOf).orElse(null));
-        // 如果高德API调用失败,使用原始方法作为备选
-        if (distanceKm == -1) {
-            distanceKm = DistanceUtils.calculateDistance(
-                Optional.ofNullable(loadAdd.getLng()).map(Double::valueOf).orElse(null),
-                Optional.ofNullable(loadAdd.getLat()).map(Double::valueOf).orElse(null),
-                Optional.ofNullable(unloadAdd.getLng()).map(Double::valueOf).orElse(null),
-                Optional.ofNullable(unloadAdd.getLat()).map(Double::valueOf).orElse(null));
-        }
-        logisticsOrderResp.setDistanceKm(distanceKm);
+        logisticsOrderResp.setDistanceKm(kwtLogisticsOrder.getDistance());
         KwtLogisticsOrderContract orderContract = finalLogOrderIdAndContractMap.getOrDefault(kwtLogisticsOrder.getId(),
                 new KwtLogisticsOrderContract());
         logisticsOrderResp.setContractNo(orderContract.getContractNo());
@@ -2796,20 +2782,7 @@ public class KwtLogisticsConsignmentService {
         loadingInfoVO.setUnloadAddress(unloadAdd.getCityName() + unloadAdd.getDetailAddress());
         loadingInfoVO.setUnloadContacts(unloadAdd.getContacts());
         loadingInfoVO.setUnloadPhone(unloadAdd.getPhone());
-        //装卸地之间距离
-        double distanceKm = LocUtils.calculateDistanceByAmap(
-                Optional.ofNullable(loadAdd.getLng()).map(String::valueOf).orElse(null),
-                Optional.ofNullable(loadAdd.getLat()).map(String::valueOf).orElse(null),
-                Optional.ofNullable(unloadAdd.getLng()).map(String::valueOf).orElse(null),
-                Optional.ofNullable(unloadAdd.getLat()).map(String::valueOf).orElse(null));
-        if (distanceKm ==-1){
-               distanceKm = DistanceUtils.calculateDistance(
-                    Optional.ofNullable(loadAdd.getLng()).map(Double::valueOf).orElse(null),
-                    Optional.ofNullable(loadAdd.getLat()).map(Double::valueOf).orElse(null),
-                    Optional.ofNullable(unloadAdd.getLng()).map(Double::valueOf).orElse(null),
-                    Optional.ofNullable(unloadAdd.getLat()).map(Double::valueOf).orElse(null));
-        }
-        loadingInfoVO.setReferenceDistance(String.valueOf(distanceKm));
+        loadingInfoVO.setReferenceDistance(logisticsOrder.getDistance());
         logisticsOrderDetailResp.setLoadingInfoVO(loadingInfoVO);
     }
 

+ 1 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/app/WaybillOrderService.java

@@ -373,12 +373,7 @@ public class WaybillOrderService {
         KwtLogisticsOrderAddress takeAddress = logOrderIdAndAddressMap.getOrDefault(order.getId() + "-" + AddressTypeEnum.TAKE.getCode(), new KwtLogisticsOrderAddress());
         orderResp.setUnloadAddress(takeAddress.getCityName()+takeAddress.getDetailAddress());
         //装卸地之间距离
-        double distanceKm = DistanceUtils.calculateDistance(
-                Optional.ofNullable(shipmentAddress.getLng()).map(Double::valueOf).orElse(null),
-                Optional.ofNullable(shipmentAddress.getLat()).map(Double::valueOf).orElse(null),
-                Optional.ofNullable(takeAddress.getLng()).map(Double::valueOf).orElse(null),
-                Optional.ofNullable(takeAddress.getLat()).map(Double::valueOf).orElse(null));
-        orderResp.setDistanceKm(distanceKm);
+        orderResp.setDistanceKm(order.getDistance());
 
         //时间
         orderResp.setStartTime(DateUtils.format(order.getStartTime(), DateUtils.DATE_PATTERN));