增加单次解算浏览UI;增加imei和deviceid的绑定

This commit is contained in:
weidong 2023-10-29 22:00:17 +08:00
parent 62a44aa32d
commit c669070cbd
11 changed files with 72 additions and 275 deletions

View File

@ -14,6 +14,7 @@ import java.net.InetSocketAddress;
@Data
public class DeviceChannel {
private String deviceId;
private String imei;
private Channel channel;

View File

@ -5,6 +5,7 @@ import io.netty.channel.Channel;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import java.net.InetSocketAddress;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@ -12,6 +13,8 @@ import java.util.stream.Collectors;
/**
* @author Layton
* @date 2023/2/2 21:00
* 提供两种获取channel的方法通过deviceId通过imeiimei是DTU连接服务器最先上报的消息
* 利用imei-ipaddr-deviceId可以发现imei和deviceId的绑定关系
*/
public class OnlineChannels {
@ -19,7 +22,7 @@ public class OnlineChannels {
// DTU已连接有imei上报但deviceId还没上报
// 记录DTU连接的好处当DTU重连接而设备还没上报deviceId时可以通过IMEI或广播消息来找到设备
private final Map<String, Channel> dtuChannels = new ConcurrentHashMap<>();
private final Map<InetSocketAddress, String> dtuChannels = new ConcurrentHashMap<>();
// 设备已连接deviceId已上报
private final Map<String, DeviceChannel> channels = new ConcurrentHashMap<>();
@ -36,16 +39,25 @@ public class OnlineChannels {
return (attr.get()==null);
}
public void putDtuChannel(Channel channel, String imei){
dtuChannels.put(imei, channel);
Attribute<String> attr = channel.attr(AttributeKey.valueOf("imei"));
attr.set(imei);
public void putDtuChannel(String imei, InetSocketAddress address){
dtuChannels.put(address, imei);
}
public void putDeviceChannel(DeviceChannel channel) {
Attribute<String> attr = channel.getChannel().attr(AttributeKey.valueOf("device_id"));
attr.set(channel.getDeviceId());
channels.put(channel.getDeviceId(), channel);
public DeviceChannel updateDeviceChannel(String deviceId, Channel channel, InetSocketAddress address) {
DeviceChannel deviceChannel = channels.get(deviceId);
if(deviceChannel == null){
deviceChannel = new DeviceChannel(deviceId, channel, address);
channels.put(deviceId, deviceChannel);
}
else {
deviceChannel.setChannel(channel);
deviceChannel.setAddress(address);
}
String imei = dtuChannels.get(address);
if(imei != null) deviceChannel.setImei(imei);
return deviceChannel;
}
public Optional<DeviceChannel> get(String deviceId) {
@ -59,4 +71,5 @@ public class OnlineChannels {
public DeviceChannel getDeviceChannel(String deviceId){
return channels.get(deviceId);
}
}

View File

@ -49,16 +49,16 @@ public class RtcmUdpHandler extends ChannelInboundHandlerAdapter {
}
// 消息解析
BaseMessage message = MessageParser.instance.parse(packet.content());
// 更新通道
DeviceChannel deviceChannel;
if(onlineChannels.isNewDeviceChannel(ctx.channel())){
deviceChannel = new DeviceChannel(message.getId(), ctx.channel(), packet.sender());
onlineChannels.putDeviceChannel(deviceChannel);
}
else{
deviceChannel = onlineChannels.getDeviceChannel(message.getId());
// 为加快处理速度只有收到D3F0/D3F2时才更新通道包括对端地址和绑定imei
DeviceChannel deviceChannel = null;
if(message.getHeader() == (short)0xD3F0 || message.getHeader() == (short)0xD3F2){
onlineChannels.updateDeviceChannel(message.getId(), ctx.channel(), packet.sender());
}
else deviceChannel = onlineChannels.getDeviceChannel(message.getId());
if(deviceChannel!= null) {
deviceChannel.updateRxBytes(message.getLen(), message.getHeader());
}
// 业务处理
bizExecutors.execute(message);
} catch (UnSupportedMessageException e) {
@ -67,7 +67,7 @@ public class RtcmUdpHandler extends ChannelInboundHandlerAdapter {
byte[] data = new byte[packet.content().readableBytes()];
packet.content().getBytes(0, data);
if(data.length == 15 && data[0]=='8' && data[1]=='6') {
OnlineChannels.INSTANCE.putDtuChannel(ctx.channel(), new String(data));
OnlineChannels.INSTANCE.putDtuChannel(new String(data), packet.sender());
}
else logger.warn("receive un supported message: {}", e.getMessage());
}
@ -82,7 +82,6 @@ public class RtcmUdpHandler extends ChannelInboundHandlerAdapter {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
ctx.close();
logger.error("Exception caught: {}", cause.toString());
}
}

View File

@ -0,0 +1,37 @@
package com.imdroid.beidou.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imdroid.secapi.dto.GnssMsg;
import com.imdroid.secapi.dto.GnssSingleCalcData;
import com.imdroid.secapi.dto.GnssSingleCalcDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class GnssSingleCalcDataController extends BasicController{
@Autowired
GnssSingleCalcDataMapper dataMapper;
@RequestMapping("/page/gnss_data_raw")
public String gnssDataRaw()throws Exception {
return "/page/gnss_data_raw";
}
/**** 推送数据 *****/
@RequestMapping("/gnss/data/list_raw")
@ResponseBody
public JSONObject listMsg(int page, int limit) {
Page<GnssSingleCalcData> pageable = new Page<>(page, limit);
IPage<GnssSingleCalcData> cs = dataMapper.selectPage(pageable, null);
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonObject.put("msg", "");
jsonObject.put("count", cs.getTotal());
jsonObject.put("data", cs.getRecords());
return jsonObject;
}
}

View File

@ -30,11 +30,6 @@ public class LayuiController extends BasicController{
return "/page/gnss_data_calc";
}
@RequestMapping("/page/gnss_data_raw")
public String gnssDataRaw()throws Exception {
return "/page/gnss_data_raw";
}
@RequestMapping("/page/gnss_data_tools")
public String gnssDataTools()throws Exception {
return "/page/gnss_data_tools";

View File

@ -1,46 +0,0 @@
{
"code": 0,
"msg": "",
"count": 1000,
"data": [
{
"deviceid": "2307001",
"report_time": "2023-01-01 12:23:56",
"b562e": "22.12",
"b562n": "10.24",
"b562d": "5.1",
"roll": "0.1",
"pitch": "0.2",
"yaw": "90.1",
"pps": "512",
"sat_count": "24",
"sat_used": "10"
},
{
"deviceid": "2307001",
"report_time": "2023-01-01 12:23:56",
"b562e": "22.12",
"b562n": "10.24",
"b562d": "5.1",
"roll": "0.1",
"pitch": "0.2",
"yaw": "90.1",
"pps": "512",
"sat_count": "24",
"sat_used": "10"
},
{
"deviceid": "2307001",
"report_time": "2023-01-01 12:23:56",
"b562e": "22.12",
"b562n": "10.24",
"b562d": "5.1",
"roll": "0.1",
"pitch": "0.2",
"yaw": "90.1",
"pps": "512",
"sat_count": "24",
"sat_used": "10"
}
]
}

View File

@ -1,55 +0,0 @@
{
"code": 0,
"msg": "",
"count": 100,
"data": [
{
"id": "2307001",
"name": "1号机",
"parent_id": "",
"device_type": "基站",
"location": "广州",
"project_id": "0",
"group_id": "1",
"calc_id": "1",
"op_mode": "正常",
"syn": "是"
},
{
"id": "2307002",
"name": "2号机",
"parent_id": "2307001",
"device_type": "测站",
"location": "广州",
"project_id": "0",
"group_id": "1",
"calc_id": "1",
"op_mode": "正常",
"syn": "是"
},
{
"id": "2307003",
"name": "3号机",
"parent_id": "2307001",
"device_type": "测站",
"location": "广州",
"project_id": "0",
"group_id": "1",
"calc_id": "1",
"op_mode": "正常",
"syn": "是"
},
{
"id": "2307004",
"name": "1号机",
"parent_id": "2307001",
"device_type": "测站",
"location": "广州",
"project_id": "0",
"group_id": "1",
"calc_id": "1",
"op_mode": "维护",
"syn": "否"
}
]
}

View File

@ -1,31 +0,0 @@
{
"code": 0,
"msg": "",
"count": 1000,
"data": [
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"type": "配置",
"content": "D3 11 00 09 00 23 33 DD 1E 06 00 00 01"
},
{
"device_id": "2307011",
"report_time": "2023-01-01 12:23:56",
"type": "配置应答",
"content": "D3 11 00 0A 00 23 33 DD 1E 06 00 00 01 01"
},
{
"device_id": "2307021",
"report_time": "2023-01-01 12:23:56",
"type": "通知",
"content": "D3 F0 00 09 00 23 33 DD"
},
{
"device_id": "2307031",
"report_time": "2023-01-01 12:23:56",
"type": "通知",
"content": "D3 F2 00 09 00 23 33 DD"
}
]
}

View File

@ -1,55 +0,0 @@
{
"code": 0,
"msg": "",
"count": 1000,
"data": [
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "2023-01-01 12:23:56",
"roll": "0.1",
"pitch": "0.2",
"yaw": "90.1",
"rssi": "31",
"voltage": "9900",
"temperature": "45",
"humidity": "30"
},
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "2023-01-01 12:23:56",
"roll": "0.1",
"pitch": "0.2",
"yaw": "90.1",
"rssi": "31",
"voltage": "9900",
"temperature": "45",
"humidity": "30"
},
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "2023-01-01 12:23:56",
"roll": "0.1",
"pitch": "0.2",
"yaw": "90.1",
"rssi": "31",
"voltage": "9900",
"temperature": "45",
"humidity": "30"
},
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "2023-01-01 12:23:56",
"roll": "0.1",
"pitch": "0.2",
"yaw": "90.1",
"rssi": "31",
"voltage": "9900",
"temperature": "45",
"humidity": "30"
}
]
}

View File

@ -1,59 +0,0 @@
{
"code": 0,
"msg": "",
"count": 1000,
"data": [
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "12:23:56",
"server_rx": "300123",
"server_tx": "212200",
"uart1_rx": "212200",
"uart1_tx": "300123",
"uart1_unknown": "9900",
"uart2_rx": "300123",
"uart2_tx": "212200",
"uart2_unknown": "30"
},
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "12:23:56",
"server_rx": "300123",
"server_tx": "212200",
"uart1_rx": "212200",
"uart1_tx": "300123",
"uart1_unknown": "9900",
"uart2_rx": "300123",
"uart2_tx": "212200",
"uart2_unknown": "30"
},
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "12:23:56",
"server_rx": "300123",
"server_tx": "212200",
"uart1_rx": "212200",
"uart1_tx": "300123",
"uart1_unknown": "9900",
"uart2_rx": "300123",
"uart2_tx": "212200",
"uart2_unknown": "30"
},
{
"device_id": "2307001",
"report_time": "2023-01-01 12:23:56",
"local_time": "12:23:56",
"server_rx": "300123",
"server_tx": "212200",
"uart1_rx": "212200",
"uart1_tx": "300123",
"uart1_unknown": "9900",
"uart2_rx": "300123",
"uart2_tx": "212200",
"uart2_unknown": "30"
}
]
}

View File

@ -53,7 +53,7 @@
table.render({
elem: '#currentTableId',
url: 'api/gnss_data_raw.json',//假数据
url: '/gnss/data/list_raw',//假数据
defaultToolbar: ['filter', 'exports', 'print', {
title: '提示',
layEvent: 'LAYTABLE_TIPS',
@ -61,16 +61,14 @@
}],
cols: [[
{field: 'deviceid', title: '设备号'},
{field: 'report_time', title: '时间'},
{field: 'createtime', title: '上报时间', templet: "<div>{{layui.util.toDateString(d.createtime, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
{field: 'b562e', title: '原始东'},
{field: 'b562n', title: '原始北'},
{field: 'b562d', title: '原始天'},
{field: 'roll', title: 'roll'},
{field: 'pitch', title: 'pitch'},
{field: 'yaw', title: 'yaw'},
{field: 'pps', title: '平均延迟'},
{field: 'sat_count', title: '卫星数'},
{field: 'sat_used', title: '使用卫星数'},
{field: 'shock', title: 'shock'}
]],
limits: [10, 15, 20, 25, 50, 100],
limit: 15,