|
@@ -94,7 +94,7 @@ public class RouteServiceImpl implements RouteService {
|
|
|
String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+URLEncoder.encode(mapValue.get("receiveAddress").toString()==null?"长沙市":mapValue.get("receiveAddress").toString(),"utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
|
|
|
SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
|
|
|
if (searchPoint2.getStatus()==0&&searchPoint2.getResult()!=null){
|
|
|
- System.out.println(searchPoint2);
|
|
|
+
|
|
|
if (searchPoint2.getResult().getAddress_components()!=null){
|
|
|
materieldesMap.put("addressProvince",searchPoint2.getResult().getAddress_components().getProvince()==null?"湖南省":searchPoint2.getResult().getAddress_components().getProvince());
|
|
|
materieldesMap.put("addressDistrict",searchPoint2.getResult().getAddress_components().getDistrict()==null?"开福区":searchPoint2.getResult().getAddress_components().getDistrict());
|
|
@@ -500,10 +500,8 @@ public class RouteServiceImpl implements RouteService {
|
|
|
calendar2.add(Calendar.MONTH,2);
|
|
|
long late= calendar2.getTime().getTime();
|
|
|
long save=(lateTime-agoTime)/1000;
|
|
|
- System.out.println(redisMap);
|
|
|
- System.out.println("置60天后过期");
|
|
|
+
|
|
|
json = zhongJiaoXingLu.visualRoute(redisMap);
|
|
|
- System.out.println(json.length()>100?json.substring(0,100):json);
|
|
|
if (json!=null){
|
|
|
redisTemplate.opsForValue().set(prefixLine+":"+mapValue.get("orderNumber").toString(), json, save>0?save:3184000, TimeUnit.SECONDS);
|
|
|
}
|
|
@@ -765,6 +763,87 @@ public class RouteServiceImpl implements RouteService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public CompletableFuture<RouteVo> fullPathVisualizationByCarNumber(HashMap mapValue) throws Exception {
|
|
|
+
|
|
|
+ String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+URLEncoder.encode("四川省达州钢铁集团有限责任公司","utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
|
|
|
+ SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class);
|
|
|
+ String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+URLEncoder.encode("四川省达川区","utf-8")+"&key=WDTBZ-A5VKJ-UDLFI-KYJY6-WTP2S-A6B4Y");
|
|
|
+ SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class);
|
|
|
+ //运单生成之后保存
|
|
|
+ HashMap<String,String> redisMap=new HashMap<>();
|
|
|
+ String startLon=searchPoint.getResult().getLocation().getLng().toString().length()>9?searchPoint.getResult().getLocation().getLng().toString().substring(0,9):searchPoint.getResult().getLocation().getLng().toString();
|
|
|
+ String startLat=searchPoint.getResult().getLocation().getLat().toString().length()>9?searchPoint.getResult().getLocation().getLat().toString().substring(0,8):searchPoint.getResult().getLocation().getLat().toString();
|
|
|
+ redisMap.put("startLonlat", startLon+","+startLat);
|
|
|
+ String endLon= searchPoint2.getResult().getLocation().getLng().toString().length()>9?searchPoint2.getResult().getLocation().getLng().toString().substring(0,9):searchPoint2.getResult().getLocation().getLng().toString();
|
|
|
+ String endLat= searchPoint2.getResult().getLocation().getLat().toString().length()>9?searchPoint2.getResult().getLocation().getLat().toString().substring(0,8):searchPoint2.getResult().getLocation().getLat().toString();
|
|
|
+ redisMap.put("endLonlat",endLon+","+endLat);
|
|
|
+ redisMap.put("vclN", mapValue.get("capacityNumber").toString());
|
|
|
+ redisMap.put("vco","2");
|
|
|
+ redisMap.put("qryBtm", mapValue.get("startTime").toString());
|
|
|
+ redisMap.put("qryEtm",mapValue.get("endTime").toString());
|
|
|
+ String json = zhongJiaoXingLu.visualRoute2(redisMap);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
+ if (json!=null&&jsonObject.get("status").toString().equals(1001+"")){
|
|
|
+ //初始开始链路和结束线路、开始点、结束点、当前点的集合
|
|
|
+ List<StartAndEndRoute> startAndEndRouteList=new ArrayList<>();
|
|
|
+ //一条路线,开始链路和结束线路、开始点、结束点、当前点
|
|
|
+ StartAndEndRoute startAndEndRoute=new StartAndEndRoute();
|
|
|
+
|
|
|
+ ViewVisualization to= (ViewVisualization) DataConversionTool.jsonToBean(json,ViewVisualization.class);
|
|
|
+ //初始化vo对象
|
|
|
+ RouteVo vo=new RouteVo();
|
|
|
+ //当前所在的点
|
|
|
+ //当前所在的点
|
|
|
+ if ((!StringUtils.isEmpty(to.getResult().getLat()))&& (!StringUtils.isEmpty(to.getResult().getLon()))){
|
|
|
+ Double[] centerpoint = LngLonUtil.gps84_To_Gcj02((Double.valueOf(to.getResult().getLat()) / 600000), (Double.valueOf(to.getResult().getLon()) / 600000));
|
|
|
+ //当前所在的点
|
|
|
+ Point currentPoint=new Point();
|
|
|
+ currentPoint.setLat(centerpoint[0]+"");
|
|
|
+ currentPoint.setLon(centerpoint[1]+"");
|
|
|
+ startAndEndRoute.setCurrentPoint(currentPoint);
|
|
|
+ }
|
|
|
+ //当前所在地名称
|
|
|
+ startAndEndRoute.setCurrentPointName(to.getResult().getAdr());
|
|
|
+ //初始已行驶轨迹集合
|
|
|
+ if (to.getResult().getRunRoute()!=null){
|
|
|
+ List<RunRoutePoint> routes =new ArrayList();
|
|
|
+ List<Double[]> routesPath =new ArrayList();
|
|
|
+ for(RunRoutePoint item : to.getResult().getRunRoute()){
|
|
|
+ RunRoutePoint runRoutePoint=item;
|
|
|
+ //将已行驶轨迹转义数据格式
|
|
|
+ Double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000));
|
|
|
+ routesPath.add(new Double[]{points[1],points[0]});
|
|
|
+ //经纬度
|
|
|
+ runRoutePoint.setLat(points[0]+"");
|
|
|
+ runRoutePoint.setLon(points[1]+"");
|
|
|
+ //坐标点
|
|
|
+ routes.add(runRoutePoint);
|
|
|
+ }
|
|
|
+ //初始化起始点,已经经过路段的第一个点
|
|
|
+ Point startPoint=new Point();
|
|
|
+ startPoint.setLat(routes.get(0).getLat());
|
|
|
+ startPoint.setLon(routes.get(0).getLon());
|
|
|
+ startAndEndRoute.setStartPoint(startPoint);
|
|
|
+ //点集合
|
|
|
+ startAndEndRoute.setRunPath(routesPath);
|
|
|
+ //已经完成路线点集合
|
|
|
+ startAndEndRoute.setRunRoute(routes);
|
|
|
+ }
|
|
|
+ //当前所行驶历程数
|
|
|
+ String mil=to.getResult().getRunDistance()+"km";
|
|
|
+ startAndEndRoute.setMiled(mil);
|
|
|
+ startAndEndRouteList.add(startAndEndRoute);
|
|
|
+ vo.setStartAndEndRoutes(startAndEndRouteList);
|
|
|
+ //
|
|
|
+ //设置返回值对象
|
|
|
+ return CompletableFuture.completedFuture(vo) ;
|
|
|
+ }else {
|
|
|
+ return CompletableFuture.completedFuture(new RouteVo());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|