From d959a545c69237d376f3bdef7f11d10013353c7a Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 19 三月 2025 15:55:05 +0800 Subject: [PATCH] bug修改 订单数据查询优化 数据上传行政区划代码更换为订单所属行政区划代码 --- DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushMinistryOfTransportUtil.java | 102 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 91 insertions(+), 11 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 cf0aef7..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 @@ -58,6 +58,8 @@ @Autowired private ITransactionDetailsService transactionDetailsService; + @Autowired + private GDMapGeocodingUtil gdMapGeocodingUtil; private String path = "http://127.0.0.1:8868/"; @@ -74,7 +76,7 @@ mileage += (orderPrivateCar.getMileage() == null ? 0 : orderPrivateCar.getMileage()); } JSONObject jsonObject = new JSONObject(); - jsonObject.put("Address", 520302);//注册地行政区划代码 + jsonObject.put("Address", 530602);//注册地行政区划代码 jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌 jsonObject.put("TotalMile", Integer.valueOf(mileage / 1000));//行驶总里程(km) jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除) @@ -101,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", 520302);//发起第行政区划代码 + 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 @@ -141,13 +158,28 @@ * 订单成功接口 * @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", 520302);//发起地行政区划代码 + 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]));//车辆纬度 @@ -353,7 +385,7 @@ * 经营支付接口 * @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()); @@ -362,7 +394,23 @@ 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", 520302);//上车位置行政区划代码 + 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());//机动车驾驶员 if (driver.getIdCard() == null){ return; @@ -448,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()); @@ -490,7 +538,23 @@ return; } jsonObject.put("LicenseId", driver.getIdCard());//机动车驾驶证号 - jsonObject.put("DriverRegionCode", 520302);//行政区划代码 + 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);//经度 @@ -523,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; @@ -558,7 +622,23 @@ } JSONObject jsonObject = new JSONObject(); jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌 - jsonObject.put("VehicleRegionCode", 520302);//行政区划代码 + 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