| | |
| | | for(Driver driver : list){//开始进行推送 |
| | | // 判断该司机是否有30分钟内预约单 |
| | | long count = orderPrivateCars.stream().filter(orderPrivateCar1 -> driver.getId().equals(orderPrivateCar1.getDriverId()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).minusMinutes(30).isBefore(LocalDateTime.now()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).minusMinutes(31).isBefore(LocalDateTime.now()) |
| | | && DateUtil.dateToLocalDateTime(orderPrivateCar1.getTravelTime()).isAfter(LocalDateTime.now())).count(); |
| | | if(orderPrivateCar.getOrderType() == 2 && orderPrivateCarDriverIds.contains(driver.getId())){ |
| | | continue; |
| | |
| | | if(null != value){ |
| | | /*Map<String, String> distance1 = gdMapElectricFenceUtil.getDistance(lon + "," + lat, value, 0);//计算距离 |
| | | double d = Double.valueOf(distance1.get("distance")).doubleValue();*/ |
| | | double d = GDMapGeocodingUtil.getDistance(lat,lon,Double.parseDouble(value.split(",")[1]),Double.parseDouble(value.split(",")[0])); |
| | | // double d = GDMapGeocodingUtil.getDistance(lat,lon,Double.parseDouble(value.split(",")[1]),Double.parseDouble(value.split(",")[0])); |
| | | double d = gdMapElectricFenceUtil.getDrivingRoute(lat,lon,Double.parseDouble(value.split(",")[1]),Double.parseDouble(value.split(",")[0])); |
| | | if(d < (distance * 1000)){ |
| | | list.add(driver); |
| | | } |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | } |
| | | return resoult; |
| | | } |
| | | |
| | | public Double getDrivingRoute(double startLat, double startLon, double endLat, double endLon) { |
| | | String url = "https://restapi.amap.com/v3/direction/driving?" + |
| | | "origin=" + startLon + "," + startLat + |
| | | "&destination=" + endLon + "," + endLat + |
| | | "&key=" + key; |
| | | String forObject = restTemplate.getForObject(url, String.class); |
| | | // 转化为json对象 |
| | | JSONObject jsonObject = JSONObject.parseObject(forObject); |
| | | JSONObject route = jsonObject.getJSONObject("route"); |
| | | JSONArray paths = route.getJSONArray("paths"); |
| | | JSONObject o = (JSONObject)paths.get(0); |
| | | Double distance = o.getDouble("distance"); |
| | | return distance; |
| | | } |
| | | |
| | | |
| | | |