From d6a14beb93cb572247db0edff3f25f99e217fcf1 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 22 八月 2025 15:34:17 +0800
Subject: [PATCH] 修改bug

---
 DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java |   66 ++++++++++++++++++++++++++++++---
 1 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java
index e893605..8393e30 100644
--- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java
+++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java
@@ -15,10 +15,10 @@
 import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
 import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
 
 import java.math.BigDecimal;
 import java.math.MathContext;
@@ -33,9 +33,6 @@
  */
 @Component
 public class PushUtil {
-
-    @Autowired
-    private RestTemplate internalRestTemplate;
 
     @Autowired
     private IOrderTaxiService orderTaxiService;
@@ -57,7 +54,11 @@
     
     private Map<String, Timer> taskMap = new HashMap<>();//存储定时推送的定时器
     
-    private final String socket_uri = "http://127.0.0.1:6000";
+    @Value("${qyt.socket_uri}")
+    private String socket_uri;
+    
+    
+
 
 
     // qyt 改派重新推单
@@ -86,6 +87,7 @@
         params.put("msg", jsonObject.toJSONString());
         params.put("id", uid);
         params.put("type", type);
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {
@@ -125,6 +127,7 @@
         params.put("msg", jsonObject.toJSONString());
         params.put("id", uid);
         params.put("type", type);
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {
@@ -136,6 +139,51 @@
             }
         }
     }
+
+
+    /**
+     * 改派推单结束
+      * @param type
+     * @param uid
+     * @param orderId
+     * @param orderType
+     * @param state
+     */
+    public void pushReassignEndCancel(Integer type, Integer uid, Integer orderId, Integer orderType, Integer state) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("code", 200);
+        jsonObject.put("msg", "SUCCESS");
+        jsonObject.put("method", "REASSIGN_END_CANCEL");
+        Map<String, Object> map = new HashMap<>();
+        map.put("orderId", orderId);
+        map.put("orderType", orderType);
+        map.put("state", state);
+        jsonObject.put("data", map);
+
+        //调用推送
+        HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient");
+        post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
+        //将请求头部和参数合成一个请求
+        Map<String, Object> params = new HashMap<>();
+        params.put("msg", jsonObject.toJSONString());
+        params.put("id", uid);
+        params.put("type", type);
+        params.put("bussinessType", "dache");
+        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) {
+                System.err.println(jsonObject1.getString("msg"));
+            }
+        }
+
+    }
+
+
+
     /**
      * 推送订单状态
      *
@@ -164,6 +212,7 @@
         params.put("msg", jsonObject.toJSONString());
         params.put("id", uid);
         params.put("type", type);
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {
@@ -203,6 +252,7 @@
         params.put("msg", jsonObject.toJSONString());
         params.put("id", uid);
         params.put("type", type);
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {
@@ -363,7 +413,7 @@
             return;
         }
         //计算预计距离和剩余时间
-        String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(driverId));
+        String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + String.valueOf(driverId));
         if(null == value || "".equals(value)){
             return;
         }
@@ -439,6 +489,7 @@
         params.put("msg", msg.toJSONString());
         params.put("id", jsonObject.getIntValue("id"));
         params.put("type", jsonObject.getIntValue("type"));
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {
@@ -473,6 +524,7 @@
         params.put("msg", msg.toJSONString());
         params.put("id", id);
         params.put("type", type);
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {
@@ -515,6 +567,7 @@
         params.put("msg", jsonObject.toJSONString());
         params.put("id", uid);
         params.put("type", type);
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {
@@ -555,6 +608,7 @@
         params.put("msg", jsonObject.toJSONString());
         params.put("id", uid);
         params.put("type", type);
+        params.put("bussinessType", "dache");
         post.form(params);
         HttpResponse execute = post.execute();
         if (200 != execute.getStatus()) {

--
Gitblit v1.7.1