Pu Zhibing
昨天 d0d6f8f40e5d9762d940b47c566da1876361020e
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java
@@ -1,5 +1,8 @@
package com.stylefeng.guns.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.stylefeng.guns.modular.system.warpper.PushOrderInfoWarpper;
@@ -25,8 +28,7 @@
    Logger logger = LoggerFactory.getLogger("ServiceLog");
    @Autowired
    private RestTemplate internalRestTemplate;
    private final String socket_uri = "http://192.168.110.85:6000";
@@ -43,20 +45,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -74,20 +79,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -112,20 +120,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -145,20 +156,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -185,20 +199,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -224,20 +241,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -259,20 +279,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -297,20 +320,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
            }
        }
    }
@@ -333,20 +359,23 @@
        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://127.0.0.1:3002/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        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"));
        }
    }
}
}