| | |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | |
| | | private Map<String, Timer> taskMap = new HashMap<>();//存储定时推送的定时器 |
| | | |
| | | private final String host = "http://ZUUL-GATEWAY/"; |
| | | |
| | | |
| | | |
| | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("orderId", orderId); |
| | | map.put("orderType", orderType); |
| | | map.put("state", state); |
| | | map.put("time", time); |
| | | if(orderType==1 && state==100){ |
| | | map.put("carpooling", 1); |
| | | map.put("state", 2); |
| | | }else{ |
| | | map.put("state", state); |
| | | } |
| | | jsonObject.put("data", map); |
| | | |
| | | //调用推送 |
| | |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", jsonObject.toJSONString()); |
| | | params.add("id", String.valueOf(uid)); |
| | | |
| | | if(orderType == 2 && type == 1){ |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); |
| | | if(orderTaxi.getOrderSource() == 7){ |
| | | params.add("id", orderTaxi.getDeviceCode()); |
| | | }else{ |
| | | params.add("id", String.valueOf(uid)); |
| | | } |
| | | }else{ |
| | | params.add("id", String.valueOf(uid)); |
| | | } |
| | | |
| | | params.add("type", String.valueOf(type)); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject(host + "/netty/sendMsgToClient",requestEntity , String.class); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | System.err.println(jsonObject1.getString("msg")); |
| | |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", jsonObject.toJSONString()); |
| | | params.add("id", String.valueOf(uid)); |
| | | |
| | | if(orderType == 2 && type == 1){ |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); |
| | | if(orderTaxi.getOrderSource() == 7){ |
| | | params.add("id", orderTaxi.getDeviceCode()); |
| | | }else{ |
| | | params.add("id", String.valueOf(uid)); |
| | | } |
| | | }else{ |
| | | params.add("id", String.valueOf(uid)); |
| | | } |
| | | params.add("type", String.valueOf(type)); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject(host + "/netty/sendMsgToClient",requestEntity , String.class); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | System.err.println(jsonObject1.getString("msg")); |
| | |
| | | if(null == distance){ |
| | | System.err.println("查询距离出错了"); |
| | | }else{ |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60),2).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + ""; |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + ""; |
| | | } |
| | | JSONObject msg = new JSONObject(); |
| | | msg.put("code", 200); |
| | |
| | | if(null == distance){ |
| | | System.err.println("查询距离出错了"); |
| | | }else{ |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60),2).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + ""; |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + ""; |
| | | } |
| | | map.put("laveMileage", d);//距离终点剩余未服务的里程数 |
| | | map.put("laveTime", t);//距离终端剩余未服务的预计时间 |
| | |
| | | JSONObject jsonObject = pushMap.get(orderId + "_" + orderType); |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", msg.toJSONString()); |
| | | params.add("id", jsonObject.getString("id")); |
| | | |
| | | if(orderType == 2){ |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); |
| | | if(orderTaxi.getOrderSource() == 7){ |
| | | params.add("id", orderTaxi.getDeviceCode()); |
| | | }else{ |
| | | params.add("id", jsonObject.getString("id")); |
| | | } |
| | | }else{ |
| | | params.add("id", jsonObject.getString("id")); |
| | | } |
| | | params.add("type", jsonObject.getString("type")); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject(host + "/netty/sendMsgToClient",requestEntity , String.class); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | System.err.println(jsonObject1.getString("msg")); |
| | |
| | | params.add("id", id.toString()); |
| | | params.add("type", type.toString()); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject(host + "/netty/sendMsgToClient",requestEntity , String.class); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | System.err.println(jsonObject1.getString("msg")); |
| | |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("msg", jsonObject.toJSONString()); |
| | | params.add("id", String.valueOf(uid)); |
| | | |
| | | if(orderType == 2 && type == 1){ |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); |
| | | if(orderTaxi.getOrderSource() == 7){ |
| | | params.add("id", orderTaxi.getDeviceCode()); |
| | | }else{ |
| | | params.add("id", String.valueOf(uid)); |
| | | } |
| | | }else{ |
| | | params.add("id", String.valueOf(uid)); |
| | | } |
| | | params.add("type", String.valueOf(type)); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject(host + "/netty/sendMsgToClient",requestEntity , String.class); |
| | | String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject1.getIntValue("code") != 200){ |
| | | System.err.println(jsonObject1.getString("msg")); |