From efd9ac5b88dfdb3c4d2e4bcc5e7a5258aa55542c Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期一, 21 四月 2025 20:29:15 +0800
Subject: [PATCH] 更换缓存连接方式

---
 DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushMinistryOfTransportUtil.java |  153 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 132 insertions(+), 21 deletions(-)

diff --git a/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushMinistryOfTransportUtil.java b/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushMinistryOfTransportUtil.java
index ccdede4..6c9d2db 100644
--- a/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushMinistryOfTransportUtil.java
+++ b/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushMinistryOfTransportUtil.java
@@ -1,6 +1,8 @@
 package com.stylefeng.guns.modular.system.util;
 
 
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
@@ -56,6 +58,8 @@
 
     @Autowired
     private ITransactionDetailsService transactionDetailsService;
+    @Autowired
+    private  GDMapGeocodingUtil gdMapGeocodingUtil;
 
     private String path = "http://127.0.0.1:8868/";
 
@@ -99,11 +103,26 @@
      * 订单发起接口
      * @param orderId
      */
-    public void orderCreate(Integer orderId){
+    public void orderCreate(Integer orderId)  {
         OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
         Map<String, Object> query = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("Address", 530602);//发起第行政区划代码
+        if (orderPrivateCar.getBoardingLon()!=null && orderPrivateCar.getBoardingLat()!=null){
+            Map<String, String> geocode = null;
+            try {
+                geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getBoardingLon() + "", orderPrivateCar.getBoardingLat() + "");
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            if (geocode!=null){
+                System.err.println("数据上传--经纬度转行政区划代码");
+                jsonObject.put("Address", geocode.get("provinceCode"));//发起第行政区划代码
+            }else{
+                jsonObject.put("Address", 530602);//发起第行政区划代码
+            }
+        }else{
+            jsonObject.put("Address", 530602);//发起第行政区划代码
+        }
         jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单编号
         jsonObject.put("DepartTime", orderPrivateCar.getTravelTime());//预计用车时间YYYYMMDDhhmmss
         jsonObject.put("OrderTime", orderPrivateCar.getInsertTime());//订单发起时间YYYYMMDDhhmmss
@@ -124,13 +143,14 @@
         header.put("Accept", "*/*");
         header.put("Accept-Encoding", "gzip");
         header.put("Accept-Charset", "utf-8");
+        System.err.println("订单发起==============================="+map);
         String result = null;
         try {
             result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/orderCreate", map, header,"form").toString();
         } catch (Exception e) {
             e.printStackTrace();
         }
-        System.err.println("---------------------------订单发起接口----------------------:" + result);
+        System.err.println("--------------------------订单发起接口------------------------:" + result);
     }
 
 
@@ -138,30 +158,50 @@
      * 订单成功接口
      * @param orderId
      */
-    public void orderMatch(Integer orderId){
+    public void orderMatch(Integer orderId)  {
         OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
         Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
         Car car = carService.selectById(orderPrivateCar.getCarId());
         String value = redisUtil.getValue("DRIVER" + orderPrivateCar.getDriverId());
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("Address", 530602);//发起地行政区划代码
+        if (orderPrivateCar.getBoardingLon()!=null && orderPrivateCar.getBoardingLat()!=null){
+            Map<String, String> geocode = null;
+            try {
+                geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getBoardingLon() + "", orderPrivateCar.getBoardingLat() + "");
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            if (geocode!=null){
+                System.err.println("数据上传--经纬度转行政区划代码");
+                jsonObject.put("Address", geocode.get("provinceCode"));//发起第行政区划代码
+            }else{
+                jsonObject.put("Address", 530602);//发起第行政区划代码
+            }
+        }else{
+            jsonObject.put("Address", 530602);//发起第行政区划代码
+        }
         jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单编号
         jsonObject.put("Longitude", Double.valueOf(value.split(",")[0]));//车辆经度
         jsonObject.put("Latitude", Double.valueOf(value.split(",")[1]));//车辆纬度
         jsonObject.put("Encrypt", 1);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
-        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证编号
+        if (driver.getIdCard() == null){
+            return;
+        }else if (driver.getIdCard().isEmpty()){
+            return;
+        }
+        jsonObject.put("LicenseId", driver.getIdCard());//机动车驾驶证编号
         jsonObject.put("DriverPhone", driver.getPhone());//驾驶员手机号
         jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
         jsonObject.put("DistributeTime", new Date());//派单成功时间YYYYMMDDhhmmss
         Map<String, Object> map = new HashMap<>();
         map.put("orderMatch", jsonObject.toJSONString());
-
         Map<String, String> header = new HashMap<>();
         header.put("Connection", "keep-alive");
         header.put("Content-Type", "application/x-www-form-urlencoded");
         header.put("Accept", "*/*");
         header.put("Accept-Encoding", "gzip");
         header.put("Accept-Charset", "utf-8");
+        System.err.println("订单成功==============================="+map);
         String result = null;
         try {
             result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/orderMatch", map, header,"form").toString();
@@ -182,7 +222,12 @@
         String value = redisUtil.getValue("DRIVER" + driverId);
         if(ToolUtil.isNotEmpty(value)){
             JSONObject jsonObject = new JSONObject();
-            jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
+            if (driver.getIdCard() == null){
+                return;
+            }else if (driver.getIdCard().isEmpty()){
+                return;
+            }
+            jsonObject.put("LicenseId", driver.getIdCard());//机动车驾驶证号
             jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
             jsonObject.put("LoginTime", new Date());//车辆经营上线时间YYYYMMDDhhmmss
             jsonObject.put("Longitude", Double.valueOf(value.split(",")[0]));//上线经度
@@ -217,7 +262,12 @@
         String value = redisUtil.getValue("DRIVER" + driverId);
         if(ToolUtil.isNotEmpty(value)){
             JSONObject jsonObject = new JSONObject();
-            jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
+            if (driver.getIdCard() == null){
+                return;
+            }else if (driver.getIdCard().isEmpty()){
+                return;
+            }
+            jsonObject.put("LicenseId", driver.getIdCard());//机动车驾驶证号
             jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
             jsonObject.put("LogoutTime", new Date());//车辆经营下线时间YYYYMMDDhhmmss
             jsonObject.put("Longitude", Double.valueOf(value.split(",")[0]));//下线经度
@@ -253,7 +303,12 @@
         Car car = carService.selectById(orderPrivateCar.getCarId());
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单号
-        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
+        if (driver.getIdCard() == null){
+            return;
+        }else if (driver.getIdCard().isEmpty()){
+            return;
+        }
+        jsonObject.put("LicenseId", driver.getIdCard());//机动车驾驶证号
         jsonObject.put("FareType", query.get("id").toString());//运价类型编码
         jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
         jsonObject.put("DepLongitude", Double.valueOf(orderPrivateCar.getBoardingLon()));//车辆出发经度
@@ -278,7 +333,6 @@
         jsonObject.put("WaitTime", orderPrivateCar.getWait() * 60);//等待时间(秒)
         Map<String, Object> map = new HashMap<>();
         map.put("operateDepart", jsonObject.toJSONString());
-
         Map<String, String> header = new HashMap<>();
         header.put("Connection", "keep-alive");
         header.put("Content-Type", "application/x-www-form-urlencoded");
@@ -331,18 +385,39 @@
      * 经营支付接口
      * @param orderId
      */
-    public void operatePay(Integer orderId){
+    public void operatePay(Integer orderId)  {
         OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
         Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
         Map<String, Object> query = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
         Car car = carService.selectById(orderPrivateCar.getCarId());
         ServerCarModel serverCarModel = serverCarModelMapper.selectById(orderPrivateCar.getServerCarModelId());
-        TransactionDetails transactionDetails = transactionDetailsService.selectById(new EntityWrapper<TransactionDetails>().eq("orderType", 1).eq("orderId", orderId));
+        TransactionDetails transactionDetails = transactionDetailsService.selectOne(new EntityWrapper<TransactionDetails>().eq("orderType", 1).eq("orderId", orderId));
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单号
-        jsonObject.put("OnArea", 530602);//上车位置行政区划代码
+        if (orderPrivateCar.getBoardingLon()!=null && orderPrivateCar.getBoardingLat()!=null){
+            Map<String, String> geocode = null;
+            try {
+                geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getBoardingLon() + "", orderPrivateCar.getBoardingLat() + "");
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            if (geocode!=null){
+                System.err.println("数据上传--经纬度转行政区划代码");
+                jsonObject.put("OnArea", geocode.get("provinceCode"));//发起第行政区划代码
+            }else{
+                jsonObject.put("OnArea", 530602);//发起第行政区划代码
+            }
+        }else{
+            jsonObject.put("OnArea", 530602);//发起第行政区划代码
+        }
+//        jsonObject.put("OnArea", 530602);//上车位置行政区划代码
         jsonObject.put("DriverName", driver.getName());//机动车驾驶员
-        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
+        if (driver.getIdCard() == null){
+            return;
+        }else if (driver.getIdCard().isEmpty()){
+            return;
+        }
+        jsonObject.put("LicenseId", driver.getIdCard());//机动车驾驶证号
         jsonObject.put("FareType", query.get("id").toString());//运价类型编码(由网约车公司定义,与运价信息接口保持一街)
         jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
         jsonObject.put("BookDepTime", orderPrivateCar.getTravelTime());//预计上车时间YYYYMMDDhhmmss
@@ -421,7 +496,7 @@
      * 驾驶员定位信息
      * @param orderId
      */
-    public void positionDriver(Integer orderId){
+    public void positionDriver(Integer orderId) {
         OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
         Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
         Car car = carService.selectById(orderPrivateCar.getCarId());
@@ -457,8 +532,29 @@
         }
 
         JSONObject jsonObject = new JSONObject();
-        jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号
-        jsonObject.put("DriverRegionCode", 530602);//行政区划代码
+        if (driver.getIdCard() == null){
+            return;
+        }else if (driver.getIdCard().isEmpty()){
+            return;
+        }
+        jsonObject.put("LicenseId", driver.getIdCard());//机动车驾驶证号
+        if (orderPrivateCar.getBoardingLon()!=null && orderPrivateCar.getBoardingLat()!=null){
+            Map<String, String> geocode = null;
+            try {
+                geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getBoardingLon() + "", orderPrivateCar.getBoardingLat() + "");
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            if (geocode!=null){
+                System.err.println("数据上传--经纬度转行政区划代码");
+                jsonObject.put("DriverRegionCode", geocode.get("provinceCode"));//发起第行政区划代码
+            }else{
+                jsonObject.put("DriverRegionCode", 530602);//发起第行政区划代码
+            }
+        }else{
+            jsonObject.put("DriverRegionCode", 530602);//发起第行政区划代码
+        }
+//        jsonObject.put("DriverRegionCode", 530602);//行政区划代码
         jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
         jsonObject.put("PositionTime", new Date());//定位时间(时间戳)
         jsonObject.put("Longitude", Longitude);//经度
@@ -471,7 +567,6 @@
         jsonObject.put("OrderId", orderNum);//订单编号
         Map<String, Object> map = new HashMap<>();
         map.put("positionDriver", jsonObject.toJSONString());
-
         Map<String, String> header = new HashMap<>();
         header.put("Connection", "keep-alive");
         header.put("Content-Type", "application/x-www-form-urlencoded");
@@ -492,7 +587,7 @@
      * 车辆定位信息
      * @param orderId
      */
-    public void positionVehicle(Integer orderId){
+    public void positionVehicle(Integer orderId) {
         OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
         Car car = carService.selectById(orderPrivateCar.getCarId());
         List<OrderPosition> orderPositions = null;
@@ -527,7 +622,23 @@
         }
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌
-        jsonObject.put("VehicleRegionCode", 530602);//行政区划代码
+        if (orderPrivateCar.getBoardingLon()!=null && orderPrivateCar.getBoardingLat()!=null){
+            Map<String, String> geocode = null;
+            try {
+                geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getBoardingLon() + "", orderPrivateCar.getBoardingLat() + "");
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            if (geocode!=null){
+                System.err.println("数据上传--经纬度转行政区划代码");
+                jsonObject.put("VehicleRegionCode", geocode.get("provinceCode"));//发起第行政区划代码
+            }else{
+                jsonObject.put("VehicleRegionCode", 530602);//发起第行政区划代码
+            }
+        }else{
+            jsonObject.put("VehicleRegionCode", 530602);//发起第行政区划代码
+        }
+//        jsonObject.put("VehicleRegionCode", 530602);//行政区划代码
         jsonObject.put("PositionTime", new Date());//定位时间(时间戳)
         jsonObject.put("Longitude", Longitude);//经度
         jsonObject.put("Latitude", Latitude);//纬度

--
Gitblit v1.7.1