| | |
| | | package com.xiaopeng.map.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.xiaopeng.api.dto.map.HistoryPointDto; |
| | | import com.xiaopeng.api.dto.map.OrderRouteAndFareDto; |
| | | import com.xiaopeng.api.dto.map.RouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.feignClient.order.XpOrderClient; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.dto.WeatherDTO; |
| | | import com.xiaopeng.api.vo.map.PointByIpVo; |
| | | import com.xiaopeng.api.vo.map.XpDistanceAndDurationVo; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.common.core.constant.CacheConstants; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.map.mangodb.model.GeoPoint; |
| | | import com.xiaopeng.map.mangodb.service.XpGeoFencingPolygonService; |
| | | import com.xiaopeng.map.utils.AmapWalkingRouteUtil; |
| | | import com.xiaopeng.map.utils.GDMapGeocodingUtil; |
| | | import com.xiaopeng.map.utils.mangoUtils.MongoGeoFenceUtil; |
| | | import com.xiaopeng.unifiedverification.interceptor.XpClientCheck; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.bson.Document; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | |
| | | return R.ok(pointByIpVo); |
| | | } |
| | | |
| | | |
| | | @Value("${map.urls.weather:https://restapi.amap.com/v3/weather/weatherInfo?key=%s&city=%s}") |
| | | String WEATHER_URL; |
| | | |
| | | @Autowired |
| | | ObjectMapper om; |
| | | |
| | | @Value("${map.apikey:66ae577f63898dae3016d599fda57221}") |
| | | String key; |
| | | |
| | | @ApiOperation(value = "获取天气信息", tags = {"内部-调价"}) |
| | | @GetMapping("/logan/inner/weatherInfo") |
| | | public R<WeatherDTO> weather(@RequestParam String city) throws IOException { |
| | | |
| | | try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
| | | HttpGet httpGet = new HttpGet(String.format(WEATHER_URL, key, city)); |
| | | try (CloseableHttpResponse response = httpClient.execute(httpGet)) { |
| | | HttpEntity entity = response.getEntity(); |
| | | if (entity != null) { |
| | | String resp = EntityUtils.toString(entity, StandardCharsets.UTF_8); |
| | | System.out.println(resp); |
| | | return R.ok(om.readValue(resp, WeatherDTO.class)); |
| | | } |
| | | return R.fail("获取天气信息失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |