liujie
8 小时以前 74f8b8074a2fb391b5363b4dca5f99bf31993430
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/PushUtil.java
@@ -1,5 +1,8 @@
package com.supersavedriving.driver.modular.system.util;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.supersavedriving.driver.modular.system.warpper.PushCheckOrderInfoWarpper;
@@ -24,9 +27,8 @@
public class PushUtil {
    Logger logger = LoggerFactory.getLogger("ServiceLog");
    @Autowired
    private RestTemplate internalRestTemplate;
    private final String socket_uri = "http://192.168.110.85:6000";
@@ -41,20 +43,27 @@
        msg.put("msg", "SUCCESS");
        msg.put("method", "OFFLINE");
        msg.put("data", new Object());
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        return jsonObject1.getIntValue("code");
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
        return 200;
    }
@@ -69,22 +78,25 @@
        msg.put("msg", "SUCCESS");
        msg.put("method", "OFF_WORK");
        msg.put("data", new Object());
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -107,22 +119,25 @@
        map.put("status", status);
        msg.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -141,22 +156,25 @@
        map.put("orderType", 1);
        msg.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -179,22 +197,25 @@
        map.put("countdown", countdown);
        msg.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -213,22 +234,25 @@
        Map<String, Object> map = new HashMap<>();
        msg.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -248,22 +272,25 @@
        msg.put("msg", "SUCCESS");
        msg.put("method", "ORDER_INFO");
        msg.put("data", pushOrderInfoWarpper);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -279,22 +306,25 @@
        msg.put("msg", "SUCCESS");
        msg.put("method", "ORDER_INFO_CHECK");
        msg.put("data", pushCheckOrderInfoWarpper);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -313,22 +343,25 @@
        map.put("orderId", orderId);
        msg.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -345,22 +378,25 @@
        msg.put("msg", "SUCCESS");
        msg.put("method", "START_SERVER");
        msg.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
@@ -373,22 +409,25 @@
        msg.put("msg", "SUCCESS");
        msg.put("method", "CHANGE_SERVER");
        msg.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", msg.toJSONString());
        params.add("id", id.toString());
        params.add("type", type.toString());
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            logger.debug(jsonObject1.getString("msg"));
            System.err.println(jsonObject1.getString("msg"));
        Map<String, Object> params = new HashMap<>();
        params.put("msg", msg.toJSONString());
        params.put("id", id.toString());
        params.put("type", type.toString());
        post.form(params);
        HttpResponse execute = post.execute();
        if (200 != execute.getStatus()) {
            System.err.println("推送异常");
        }else{
            JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class);
            if(jsonObject1.getIntValue("code") != 200){
                logger.debug(jsonObject1.getString("msg"));
                System.err.println(jsonObject1.getString("msg"));
            }
        }
    }
}