| 
					
				 | 
			
			
				@@ -0,0 +1,286 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.steerinfo.route.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.framework.controller.RESTfulResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.service.RouteService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.threeRequest.ZhongJiaoXingLu; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.util.DataConversionTool; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.util.HTTPRequestUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.util.LngLonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.vo.FullPathVisualizationTo.ViewVisualization; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.vo.Map.Point; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.vo.Map.RouteVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.vo.Map.StartAndEndRoute; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.steerinfo.route.vo.resultJson.SearchPoint; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.data.redis.core.RedisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.util.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.net.URLEncoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.CompletableFuture; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.TimeUnit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Service(value = "xmsService") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class RouteServiceImpl implements RouteService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedisTemplate redisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ZhongJiaoXingLu zhongJiaoXingLu; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${str.tengxun.key}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String key; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${redis.prefix.order}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String prefixOrder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${redis.prefix.line}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String prefixLine; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${redis.prefix.suffix}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String suffix; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 必须参数 运输订单号:orderNumber、车牌号:capacityNumber、出厂时间:resultOutGateTime、预警开关:turnOf、发货地址:shipperName、收货地址:receiveAddress 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param mapValue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public CompletableFuture<String> saveRoute(Map mapValue) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获得起点的经纬度和code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           SimpleDateFormat dateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           Date gateTime = dateFormat.parse(mapValue.get("resultOutGateTime").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(mapValue.get("shipperName").toString()==null?"四川省达州钢铁集团有限责任公司":mapValue.get("shipperName").toString(),"utf-8")+"&key="+key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           //创建收货地址    addressProvince 省份、addressDistrict 市区、addressTown 县镇 、addressDeliveryAddress 收货地址、 addressLongitude 收货地址经度、addressLatitude 收货地址纬度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           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="+key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           //入网验证 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           String netValidationResult = zhongJiaoXingLu.netValidation(mapValue.get("capacityNumber").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           Map netValidationMap = (Map) JSONObject.parse(netValidationResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //运单生成之后保存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               HashMap<String, String> redisMap=new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisMap.put("startLonlat", searchPoint.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint.getResult().getLocation().getLat().toString().substring(0,8)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisMap.put("endLonlat", searchPoint2.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint2.getResult().getLocation().getLat().toString().substring(0,8)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisMap.put("vclN", mapValue.get("capacityNumber").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisMap.put("vco","2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               String qryBtm=mapValue.get("resultOutGateTime").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //获得两天、23小时、45分钟之后的时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               Date parse = simpleDateFormat.parse(qryBtm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //时间添加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               Calendar calendar = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               calendar.setTime(parse); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               calendar.add(Calendar.DAY_OF_MONTH, 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               calendar.add(Calendar.HOUR_OF_DAY, 23); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               calendar.add(Calendar.SECOND, 45); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //计算时间差 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               long agetime = parse.getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               long lateTime = calendar.getTimeInMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //两天、23小时、45分钟之后的时间差毫秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               long reductionTime1=lateTime-agetime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               long currentTime = new Date().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //减去已经过的时间(毫秒) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               long reductionTime2=currentTime-agetime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //redis 存储的时间(秒) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               long saveTime=(reductionTime1-reductionTime2)/1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisMap.put("qryBtm", simpleDateFormat.format(simpleDateFormat.parse(qryBtm))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               String qryEtm= simpleDateFormat.format(calendar.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisMap.put("qryEtm",qryEtm ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               String orderUrl=prefixOrder+":"+mapValue.get("orderNumber").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               String redisJson= JSON.toJSONString(redisMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //保存请求中交的参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisTemplate.opsForValue().set(orderUrl, redisJson, saveTime, TimeUnit.SECONDS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               redisTemplate.opsForValue().set(orderUrl+suffix, redisJson); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               //预警开关判断0开启1关闭 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               if(mapValue.get("turnOf").toString().equals("0")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   redisMap.put("startCode",searchPoint.getResult().getAd_info().getAdcode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   redisMap.put("destCode",searchPoint2.getResult().getAd_info().getAdcode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   redisMap.put("qryBtm",parse.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   redisMap.put("qryEtm",calendar.getTime().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   String subAbnormalLineWarnV2Json = zhongJiaoXingLu.subAbnormalLineWarnV2(redisMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   JSONObject jsonObject = JSONObject.parseObject(subAbnormalLineWarnV2Json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   if (jsonObject!=null&&jsonObject.get("status").toString().equals(1001+"")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       HashMap<String, Object> tripMap = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       tripMap.put("orderNumber", mapValue.get("orderNumber").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       tripMap.put("rid", jsonObject.get("result").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       //omsFeign.insertOrderTripId(tripMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           return  CompletableFuture.completedFuture("successful"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return CompletableFuture.completedFuture("fail"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 必须参数 orderNumber 运输订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 获得运输全路径 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param mapValue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public CompletableFuture<RouteVo> fullPathVisualization(HashMap mapValue) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获得saveRoute()保存在redis请求中交的查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String redisJson = (String) redisTemplate.opsForValue().get(prefixOrder + ":" + mapValue.get("orderNumber")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HashMap routeMap = JSON.parseObject(redisJson, HashMap.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String json=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //判断请求参数是否为空 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (routeMap!=null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //获得路径 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            json =zhongJiaoXingLu.visualRoute(routeMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //可能中交请求参数已经过期、已经成了路线、可以直接获取路径 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            json  = (String) redisTemplate.opsForValue().get(prefixLine + ":" + mapValue.get("orderNumber")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //当redis获取不到参数的备选方案从数据库获取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (json==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HashMap<String, Object> hashMap=new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                hashMap.put("orderNumber",mapValue.get("orderNumber")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //从数据库获取参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                RESTfulResult startAndEndCapacityNumber =null; //tmsFeign.getStartAndEndCapacityNumber(hashMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HashMap<String, Object> resultMap= (HashMap<String, Object>) startAndEndCapacityNumber.getData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //入网验证 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String netValidationResult = zhongJiaoXingLu.netValidation(resultMap.get("capacityNumber").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map netValidationMap = (Map) JSONObject.parse(netValidationResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (Integer.parseInt(netValidationMap.get("status").toString())==1001&&netValidationMap.get("result").toString().equals("yes")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String searchPointJson = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(resultMap.get("shipperName").toString(),"utf-8")+"&key="+key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    SearchPoint searchPoint= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson, SearchPoint.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String searchPointJson2 = HTTPRequestUtils.sendGet("https://apis.map.qq.com/ws/geocoder/v1/", "address="+ URLEncoder.encode(resultMap.get("addressDeliveryAddress").toString(),"utf-8")+"&key="+key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    SearchPoint searchPoint2= (SearchPoint) DataConversionTool.jsonToBean(searchPointJson2, SearchPoint.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //运单生成之后保存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    HashMap<String, String> redisMap=new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    redisMap.put("startLonlat", searchPoint.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint.getResult().getLocation().getLat().toString().substring(0,8)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    redisMap.put("endLonlat", searchPoint2.getResult().getLocation().getLng().toString().substring(0,9)+","+searchPoint2.getResult().getLocation().getLat().toString().substring(0,8)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    redisMap.put("vclN", resultMap.get("capacityNumber").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    redisMap.put("vco","2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String qryBtm=resultMap.get("resultOutGateTime").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //获得两天、23小时、45分钟之后的时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Date parse = simpleDateFormat.parse(qryBtm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //时间添加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Calendar calendar = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    calendar.setTime(parse); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    calendar.add(Calendar.DAY_OF_MONTH, 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    calendar.add(Calendar.HOUR_OF_DAY, 23); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    calendar.add(Calendar.SECOND, 45); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //计算时间差 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long agetime = parse.getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long lateTime = calendar.getTimeInMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //两天、23小时、45分钟之后的时间差毫秒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long reductionTime1=lateTime-agetime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long currentTime = new Date().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //减去已经过的时间(毫秒) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long reductionTime2=currentTime-agetime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //redis 存储的时间(秒) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    long saveTime=(reductionTime1-reductionTime2)/1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    redisMap.put("qryBtm", simpleDateFormat.format(simpleDateFormat.parse(qryBtm))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String qryEtm= simpleDateFormat.format(calendar.getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    redisMap.put("qryEtm",qryEtm ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (saveTime>1800){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String orderUrl=prefixOrder+":"+mapValue.get("orderNumber").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String redisStr= JSON.toJSONString(redisMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        redisTemplate.opsForValue().set(orderUrl, redisStr, saveTime, TimeUnit.SECONDS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //设置60天后过期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Calendar calendar2= Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        long agoTime= calendar2.getTime().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        calendar2.add(Calendar.MONTH,2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        long late= calendar2.getTime().getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        long save=(lateTime-agoTime)/1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        json = zhongJiaoXingLu.visualRoute(redisMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        redisTemplate.opsForValue().set(prefixLine+":"+mapValue.get("orderNumber").toString(), json, save, TimeUnit.SECONDS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获得路线之后封装成路线对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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<Point> routes = to.getResult().getRunRoute().stream().map(item->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Point er=new Point(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    er.setLat(points[0]+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    er.setLon(points[1]+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return  er; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //初始化起始点,已经经过路段的第一个点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                startAndEndRoute.setStartPoint(routes.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //已经完成路线点集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                startAndEndRoute.setRunRoute(routes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //预估轨迹 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (to.getResult().getEstimateRoute()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<Point> estimateRoute= to.getResult().getEstimateRoute().stream().map(item->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Point er=new Point(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    double[] points = LngLonUtil.gps84_To_Gcj02((Double.valueOf(item.getLat()) / 600000), (Double.valueOf(item.getLon()) / 600000)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    er.setLat(points[0]+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    er.setLon(points[1]+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return  er; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //结束点 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                startAndEndRoute.setEndPoint(estimateRoute.get(estimateRoute.size()-1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //预估轨迹赋值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                startAndEndRoute.setEstimateRoute(estimateRoute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //当前所行驶历程数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |