Commit 9414269b authored by zhushanglei's avatar zhushanglei

gps数据采集修改redis

parent fa375150
...@@ -19,12 +19,15 @@ import java.util.concurrent.TimeUnit; ...@@ -19,12 +19,15 @@ import java.util.concurrent.TimeUnit;
**/ **/
public class TcpClientHandler extends SimpleChannelInboundHandler<Object> { public class TcpClientHandler extends SimpleChannelInboundHandler<Object> {
private static final String NAMESPACE = "gps:";
public static String serverUrl; public static String serverUrl;
private static Logger logger = LoggerFactory.getLogger(TcpClientHandler.class); private static Logger logger = LoggerFactory.getLogger(TcpClientHandler.class);
public static boolean complex = false; //是否差分定位模式 public static boolean complex = false; //是否差分定位模式
public static int expireTime = 120;
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) { protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
try { try {
...@@ -114,6 +117,7 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<Object> { ...@@ -114,6 +117,7 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<Object> {
} }
String jsonObject = JSON.toJSONString(gpsDto); String jsonObject = JSON.toJSONString(gpsDto);
String result = post(serverUrl,jsonObject); String result = post(serverUrl,jsonObject);
RedisUtils.set( NAMESPACE + TcpClient.deviceId ,jsonObject, expireTime); //放入redis
logger.info(result); logger.info(result);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment