Pu Zhibing
4 天以前 8522e469e00e1cf6c0410165b0f76c806c13ca83
MessagePushTravel/src/main/java/com/sinata/push/util/echo/NettyServerController.java
@@ -5,6 +5,7 @@
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
//import com.sinata.push.config.QYTConfig;
import com.sinata.push.util.*;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -33,19 +34,26 @@
   public static Hashtable<String, Hashtable<ChannelHandlerContext, String>> map = new Hashtable<String, Hashtable<ChannelHandlerContext,String>>();
   public static Hashtable<String,String> table;
//   public static QYTConfig qytConfig;
   private RedisUtil redisUtil = SpringUtil.getObject(RedisUtil.class);
   
   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
   static{
      if(table == null){
         table = new Hashtable<>();
      }
   }
//   public static void setQytConfig(QYTConfig qytConfig) {
//      NettyServerController.qytConfig = qytConfig;
//   }
   
   public static boolean isdebug = false;
   public static int i = 0;
@@ -74,9 +82,7 @@
         if(msgStr.indexOf("{") == -1 || msgStr.indexOf("}") == -1 || msgStr.indexOf("code") == -1 || msgStr.indexOf("msg") == -1 || msgStr.indexOf("data") == -1 || msgStr.indexOf("method") == -1) {
            return;
         }
         if(isdebug) {
//            System.out.println("<<<--receive-->>>" + msg);
         }
         System.out.println("<<<--receive-->>>" + msg);
         
         // 获取socket信息,保存相应的socket
         JSONObject jsonMsg = JSONObject.parseObject(msg.toString());
@@ -201,7 +207,7 @@
                        params.put("lat", String.valueOf(lat));
                        params.put("directionAngle", String.valueOf(computeAzimuth));
                        params.put("altitude", String.valueOf(altitude));
                        HttpRequest post = HttpUtil.createPost(URLUtil.zuul + "/driver-server/base/savePosition");
                        HttpRequest post = HttpUtil.createPost("http://10.31.182.11:8010/chuxing/driver-server/base/savePosition");
                        post.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
                        post.form(params);
                        HttpResponse execute = post.execute();
@@ -228,7 +234,7 @@
                     params.put("lat", String.valueOf(lat));
                     params.put("directionAngle", String.valueOf(computeAzimuth));
                     params.put("altitude", String.valueOf(altitude));
                     HttpRequest post = HttpUtil.createPost(URLUtil.aj_zuul + "/driver-server/base/driver/addDriverPosition");
                     HttpRequest post = HttpUtil.createPost("http://10.31.182.11:8010/daijia/driver-server/base/driver/addDriverPosition");
                     post.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
                     post.form(params);
                     HttpResponse execute = post.execute();
@@ -241,7 +247,7 @@
                     }
                  }
                  
                  redisUtil.setStrValue(business + ":DRIVER" + driverId, lon + "," + lat, 30);//实时位置存入redis中
                  redisUtil.setStrValue(business + "_DRIVER" + driverId, lon + "," + lat, 30);//实时位置存入redis中
               }else{
                  this.sendMsgToClient(ctx, "__error__" + msg.toString());
               }