From 10a7d157e32b7257f850c09617a40a5ff4efa081 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期二, 19 八月 2025 11:35:33 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/QYTDriving
---
user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java | 296 +++++++++++++++++++++++++++++++++-------------------------
1 files changed, 167 insertions(+), 129 deletions(-)
diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java
index 3fe73b0..e3dac6c 100644
--- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java
+++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/util/PushUtil.java
@@ -1,5 +1,8 @@
package com.supersavedriving.user.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.user.modular.system.warpper.PushCheckOrderInfoWarpper;
@@ -25,9 +28,8 @@
public class PushUtil {
Logger logger = LoggerFactory.getLogger("ServiceLog");
-
- @Autowired
- private RestTemplate internalRestTemplate;
+
+ private final String socket_uri = "http://192.168.110.85:6000";
@@ -42,22 +44,26 @@
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);
- 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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -73,22 +79,26 @@
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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -111,22 +121,26 @@
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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -142,22 +156,26 @@
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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -176,22 +194,26 @@
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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -201,22 +223,26 @@
msg.put("msg", "SUCCESS");
msg.put("method", "CHECK_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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -241,22 +267,26 @@
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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -276,22 +306,26 @@
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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
@@ -312,22 +346,26 @@
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());
+ params.put("bussinessType", "daijia");
+ 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"));
+ }
}
}
}
--
Gitblit v1.7.1