From 40b7f4a7f493cfa5d8b2531d99d7ef8f5a9d5f0a Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期三, 27 十一月 2024 14:41:05 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushMinistryOfTransportUtil.java | 48 +++++++++++++++++++++++++++--------------------- 1 files changed, 27 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 3efe0f3..8a14f3c 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; @@ -57,7 +59,7 @@ @Autowired private ITransactionDetailsService transactionDetailsService; - private String path = "http://120.77.11.218:8868/"; + private String path = "http://127.0.0.1:8868/"; /** @@ -72,7 +74,7 @@ mileage += (orderPrivateCar.getMileage() == null ? 0 : orderPrivateCar.getMileage()); } JSONObject jsonObject = new JSONObject(); - jsonObject.put("Address", 450204);//注册地行政区划代码 + jsonObject.put("Address", 530602);//注册地行政区划代码 jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌 jsonObject.put("TotalMile", Integer.valueOf(mileage / 1000));//行驶总里程(km) jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除) @@ -103,7 +105,7 @@ OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId); Map<String, Object> query = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId()); JSONObject jsonObject = new JSONObject(); - jsonObject.put("Address", 450204);//发起第行政区划代码 + jsonObject.put("Address", 530602);//发起第行政区划代码 jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单编号 jsonObject.put("DepartTime", orderPrivateCar.getTravelTime());//预计用车时间YYYYMMDDhhmmss jsonObject.put("OrderTime", orderPrivateCar.getInsertTime());//订单发起时间YYYYMMDDhhmmss @@ -144,7 +146,7 @@ Car car = carService.selectById(orderPrivateCar.getCarId()); String value = redisUtil.getValue("DRIVER" + orderPrivateCar.getDriverId()); JSONObject jsonObject = new JSONObject(); - jsonObject.put("Address", 450204);//发起地行政区划代码 + 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]));//车辆纬度 @@ -340,7 +342,7 @@ TransactionDetails transactionDetails = transactionDetailsService.selectById(new EntityWrapper<TransactionDetails>().eq("orderType", 1).eq("orderId", orderId)); JSONObject jsonObject = new JSONObject(); jsonObject.put("OrderId", orderPrivateCar.getOrderNum());//订单号 - jsonObject.put("OnArea", 450204);//上车位置行政区划代码 + jsonObject.put("OnArea", 530602);//上车位置行政区划代码 jsonObject.put("DriverName", driver.getName());//机动车驾驶员 jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号 jsonObject.put("FareType", query.get("id").toString());//运价类型编码(由网约车公司定义,与运价信息接口保持一街) @@ -438,7 +440,7 @@ Double Speed = 0D; if(orderPositions != null && orderPositions.size() > 1){ Map<String, String> distance = gdMapElectricFenceUtil.getDistance(orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(), - orderPositions.get(orderPositions.size() - 0).getLon() + "," + orderPositions.get(orderPositions.size() - 0).getLat(), 0); + orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(), 0); Speed = distance != null ? Double.valueOf(distance.get("distance")) / 1000 : 0D; } Integer state = 4; @@ -458,7 +460,7 @@ JSONObject jsonObject = new JSONObject(); jsonObject.put("LicenseId", driver.getDriveCard());//机动车驾驶证号 - jsonObject.put("DriverRegionCode", 450204);//行政区划代码 + jsonObject.put("DriverRegionCode", 530602);//行政区划代码 jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌 jsonObject.put("PositionTime", new Date());//定位时间(时间戳) jsonObject.put("Longitude", Longitude);//经度 @@ -478,13 +480,18 @@ header.put("Accept", "*/*"); header.put("Accept-Encoding", "gzip"); header.put("Accept-Charset", "utf-8"); - String result = null; try { - result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/positionDriver", map, header,"form").toString(); + HttpRequest post = HttpUtil.createPost(path + "ministryOfTransport/positionDriver"); + post.header("Connection", "keep-alive"); + post.header("Content-Type", "application/x-www-form-urlencoded"); + post.header("Accept", "*/*"); + post.header("Accept-Encoding", "gzip"); + post.header("Accept-Charset", "utf-8"); + post.body(JSON.toJSONString(map)); + post.execute(); } catch (Exception e) { e.printStackTrace(); } - System.err.println("-----------------------------驾驶员定位信息------------------------:" + result); } @@ -508,7 +515,7 @@ Double Speed = 0D; if(orderPositions != null && orderPositions.size() > 1){ Map<String, String> distance = gdMapElectricFenceUtil.getDistance(orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(), - orderPositions.get(orderPositions.size() - 0).getLon() + "," + orderPositions.get(orderPositions.size() - 0).getLat(), 0); + orderPositions.get(orderPositions.size() - 1).getLon() + "," + orderPositions.get(orderPositions.size() - 1).getLat(), 0); Speed = distance != null ? Double.valueOf(distance.get("distance")) / 1000 : 0D; } Integer state = 4; @@ -527,7 +534,7 @@ } JSONObject jsonObject = new JSONObject(); jsonObject.put("VehicleNo", car.getCarLicensePlate());//车辆号牌 - jsonObject.put("VehicleRegionCode", 450204);//行政区划代码 + jsonObject.put("VehicleRegionCode", 530602);//行政区划代码 jsonObject.put("PositionTime", new Date());//定位时间(时间戳) jsonObject.put("Longitude", Longitude);//经度 jsonObject.put("Latitude", Latitude);//纬度 @@ -542,19 +549,18 @@ jsonObject.put("OrderId", orderNum);//订单编号(非营运状态下填"0") Map<String, Object> map = new HashMap<>(); map.put("positionVehicle", 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"); - String result = null; try { - result = httpClientUtil.pushHttpRequset("POST", path + "ministryOfTransport/positionVehicle", map, header,"form").toString(); + HttpRequest post = HttpUtil.createPost(path + "ministryOfTransport/positionVehicle"); + post.header("Connection", "keep-alive"); + post.header("Content-Type", "application/x-www-form-urlencoded"); + post.header("Accept", "*/*"); + post.header("Accept-Encoding", "gzip"); + post.header("Accept-Charset", "utf-8"); + post.body(JSON.toJSONString(map)); + post.execute(); } catch (Exception e) { e.printStackTrace(); } - System.err.println("----------------------------车辆定位信息---------------------------:" + result); } -- Gitblit v1.7.1