diff --git a/online-taxi-public/servcie-price/pom.xml b/online-taxi-public/servcie-price/pom.xml
index 15495ca..1d547dd 100644
--- a/online-taxi-public/servcie-price/pom.xml
+++ b/online-taxi-public/servcie-price/pom.xml
@@ -20,5 +20,20 @@
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+ io.github.openfeign
+ feign-httpclient
+
\ No newline at end of file
diff --git a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/ServicePriceApplication.java b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/ServicePriceApplication.java
index 14cb87f..57f15d2 100644
--- a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/ServicePriceApplication.java
+++ b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/ServicePriceApplication.java
@@ -3,9 +3,11 @@ package com.taxi.serviceprice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient//服务发现
+@EnableFeignClients
public class ServicePriceApplication {
public static void main(String[] args) {
diff --git a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/remote/ServiceMapClient.java b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/remote/ServiceMapClient.java
new file mode 100644
index 0000000..b46dde0
--- /dev/null
+++ b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/remote/ServiceMapClient.java
@@ -0,0 +1,17 @@
+package com.taxi.serviceprice.remote;
+
+import com.internal.dto.ResponseResult;
+import com.internal.request.ForecastPriceDTO;
+import com.internal.response.DirectionResponse;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@FeignClient("service-map")
+public interface ServiceMapClient {
+
+ @RequestMapping(method = RequestMethod.GET,value = "/direction/driving")
+ ResponseResult direction(@RequestBody ForecastPriceDTO forecastPriceDTO);
+
+}
diff --git a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/service/ForecastPriceService.java b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/service/ForecastPriceService.java
index df66ba3..f2eec3f 100644
--- a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/service/ForecastPriceService.java
+++ b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/service/ForecastPriceService.java
@@ -1,14 +1,20 @@
package com.taxi.serviceprice.service;
import com.internal.dto.ResponseResult;
-import com.internal.response.ForecastPriceResponse;
+import com.internal.request.ForecastPriceDTO;
+import com.internal.response.DirectionResponse;
+import com.taxi.serviceprice.remote.ServiceMapClient;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class ForecastPriceService {
+ @Autowired
+ private ServiceMapClient serviceMapClient;
+
/**
* 根据 出发地和目的的经纬度,计算预估价格
* @param depLongitude
@@ -25,11 +31,18 @@ public class ForecastPriceService {
log.info("目的地纬度," + destLatitude);
log.info("调用地图服务,查询地图和时长");
+
+
+ ForecastPriceDTO forecastPriceDTO = new ForecastPriceDTO();
+ forecastPriceDTO.setDepLongitude(depLongitude);
+ forecastPriceDTO.setDepLatitude(depLatitude);
+ forecastPriceDTO.setDestLongitude(destLongitude);
+ forecastPriceDTO.setDestLatitude(destLatitude);
+ ResponseResult directionResponse = serviceMapClient.direction(forecastPriceDTO);
+ log.info("距离"+directionResponse.getData().getDistance());
+ log.info("时间"+directionResponse.getData().getDuration());
log.info("读取计价规则");
log.info("根据距离、时长,计价规则;计算价格");
-
- ForecastPriceResponse forecastPriceResponse = new ForecastPriceResponse();
- forecastPriceResponse.setPrice(12.121);
- return ResponseResult.success(forecastPriceResponse);
+ return ResponseResult.success();
}
}
diff --git a/online-taxi-public/servcie-price/src/main/resources/application.yaml b/online-taxi-public/servcie-price/src/main/resources/application.yaml
index 44cf7de..4211a0f 100644
--- a/online-taxi-public/servcie-price/src/main/resources/application.yaml
+++ b/online-taxi-public/servcie-price/src/main/resources/application.yaml
@@ -7,4 +7,4 @@ spring:
discovery:
server-addr: 127.0.0.1:8848
application:
- name: servcie-price
\ No newline at end of file
+ name: service-price
\ No newline at end of file
diff --git a/online-taxi-public/servcie-price/target/classes/application.yaml b/online-taxi-public/servcie-price/target/classes/application.yaml
index 44cf7de..4211a0f 100644
--- a/online-taxi-public/servcie-price/target/classes/application.yaml
+++ b/online-taxi-public/servcie-price/target/classes/application.yaml
@@ -7,4 +7,4 @@ spring:
discovery:
server-addr: 127.0.0.1:8848
application:
- name: servcie-price
\ No newline at end of file
+ name: service-price
\ No newline at end of file
diff --git a/online-taxi-public/service-map/pom.xml b/online-taxi-public/service-map/pom.xml
index a3f469b..359141a 100644
--- a/online-taxi-public/service-map/pom.xml
+++ b/online-taxi-public/service-map/pom.xml
@@ -21,6 +21,7 @@
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
+
\ No newline at end of file