From 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 16 五月 2025 10:27:41 +0800 Subject: [PATCH] 修改文档bug --- ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/util/PushUtil.java | 64 ++++++++++++++++++++++++-------- 1 files changed, 48 insertions(+), 16 deletions(-) diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/util/PushUtil.java b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/util/PushUtil.java index fd365f8..0bb57ae 100644 --- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/util/PushUtil.java +++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/util/PushUtil.java @@ -2,11 +2,9 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; - import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil; +import com.stylefeng.guns.modular.system.util.PushURL; import com.stylefeng.guns.modular.system.util.RedisUtil; - - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -16,10 +14,9 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; -import java.math.BigDecimal; -import java.math.MathContext; -import java.math.RoundingMode; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Timer; /** * socket推单处理类 @@ -67,7 +64,7 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println("后台 冻结订单 向司机端推送消息"+jsonObject1.getString("msg")); @@ -104,7 +101,7 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); @@ -143,7 +140,7 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); @@ -178,7 +175,7 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); @@ -216,7 +213,7 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); @@ -252,7 +249,7 @@ 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); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); @@ -291,7 +288,7 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); @@ -339,7 +336,7 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); @@ -380,7 +377,42 @@ 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("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); + JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); + if(jsonObject1.getIntValue("code") != 200){ + System.err.println(jsonObject1.getString("msg")); + } + } + + + /** + * 改派完成后推送用户端提醒 + * @param uid + * @param orderId + * @param orderType + */ + public void pushOrderReassign(Integer uid, Integer type, Integer orderId, Integer orderType, String audioUrl){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code", 200); + jsonObject.put("msg", "SUCCESS"); + jsonObject.put("method", "REASSIGN"); + Map<String, Object> map = new HashMap<>(); + map.put("orderId", orderId); + map.put("orderType", orderType); + map.put("audioUrl", audioUrl); + jsonObject.put("data", map); + + //调用推送 + HttpHeaders headers = new HttpHeaders(); + // 以表单的方式提交 + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + //将请求头部和参数合成一个请求 + MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); + params.add("msg", jsonObject.toJSONString()); + params.add("id", String.valueOf(uid)); + params.add("type", type.toString()); + HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); + String s = internalRestTemplate.postForObject(PushURL.zull_user_url + "/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); -- Gitblit v1.7.1