1、修改发送GNSS指令保存时的bug
2、增加消息发送方向 3、增加是否自动补传的配置
This commit is contained in:
parent
789440e221
commit
4c2ec4d0a2
@ -14,4 +14,5 @@ public class GnssGroupCalc {
|
||||
Integer filter_min_hour;
|
||||
Float auto_threshold;
|
||||
Integer device_num;
|
||||
Boolean auto_upload;
|
||||
}
|
||||
|
||||
@ -22,5 +22,6 @@ public class GnssMsg {
|
||||
String deviceid;
|
||||
Integer msgtype;
|
||||
Integer msglen;
|
||||
Boolean tx;
|
||||
String content;//只记录部分
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import com.imdroid.sideslope.executor.MessageParser;
|
||||
import com.imdroid.sideslope.message.BaseMessage;
|
||||
import com.imdroid.sideslope.server.OnlineChannels;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
@ -25,14 +24,20 @@ public class RtcmTcpHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||
src.getBytes(0, data);
|
||||
logger.debug("receive message:" + DataTypeUtil.getHexString(data));
|
||||
}
|
||||
BaseMessage message = MessageParser.instance.parse(src);
|
||||
OnlineChannels.INSTANCE.updateConfigChannel(message.getId(), ctx.channel(), null);
|
||||
BizExecutors.execute(message);
|
||||
try {
|
||||
BaseMessage message = MessageParser.instance.parse(src);
|
||||
OnlineChannels.INSTANCE.updateConfigChannel(message.getId(), ctx.channel(), null);
|
||||
BizExecutors.execute(message);
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx)
|
||||
throws Exception {
|
||||
logger.info("channel inactive");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -115,6 +115,7 @@ public class DataPersistServiceImpl implements DataPersistService {
|
||||
gnssMsg.setDeviceid(message.getId());
|
||||
gnssMsg.setMsgtype(message.getHeader());
|
||||
gnssMsg.setMsglen(message.getLen());
|
||||
gnssMsg.setTx(false);
|
||||
msgMapper.insert(gnssMsg);
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,8 @@ public class ApiController {
|
||||
HttpResp resp = new HttpResp();
|
||||
DeviceChannel deviceChannel = OnlineChannels.INSTANCE.getConfigChannel(deviceId);
|
||||
if(deviceChannel == null) deviceChannel = OnlineChannels.INSTANCE.getDataChannel(deviceId);
|
||||
if(deviceChannel!=null && deviceChannel.isOnline()){
|
||||
//if(deviceChannel!=null && deviceChannel.isOnline()){
|
||||
if(deviceChannel!=null){
|
||||
status.put("status", "Online");
|
||||
// send command
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
|
||||
@ -21,6 +21,8 @@ public class APIController extends BasicController{
|
||||
@Autowired
|
||||
GnssGroupMapper groupMapper;
|
||||
@Autowired
|
||||
GnssGroupCalcMapper groupCalcMapper;
|
||||
@Autowired
|
||||
GnssMsgMapper msgMapper;
|
||||
@Autowired
|
||||
GnssStatusMapper gnssStatusMapper;
|
||||
@ -43,7 +45,7 @@ public class APIController extends BasicController{
|
||||
}
|
||||
|
||||
// 保存
|
||||
saveMsg(deviceId, tenantId,msgType, configAck);
|
||||
saveMsg(deviceId, tenantId,msgType, configAck, false);
|
||||
|
||||
// 命令行显示
|
||||
String rxInfo = "RX "+ dateFormat.format(System.currentTimeMillis())+
|
||||
@ -65,9 +67,14 @@ public class APIController extends BasicController{
|
||||
@PostMapping(value = "/api/device_online")
|
||||
@ResponseBody
|
||||
public String onLine(String deviceId, Integer tenantId, LocalDateTime lastOnlineTime) {
|
||||
|
||||
onDeviceActive(deviceId,tenantId);
|
||||
|
||||
// 检查是否自动补传
|
||||
GnssDevice device = deviceMapper.queryByDeviceId(deviceId);
|
||||
if(device == null) return null;
|
||||
GnssGroupCalc groupCalc = groupCalcMapper.selectById(device.getCalc_group_id());
|
||||
if(groupCalc==null || groupCalc.getAuto_upload()) return null;
|
||||
|
||||
// 检查上次是否离线,如果是则启动补传
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Short len = 15;
|
||||
@ -86,7 +93,7 @@ public class APIController extends BasicController{
|
||||
+ HexUtil.Byte2HexString((byte) (now.getMinute()));
|
||||
rtcmClient.config(deviceId, uploadCmd);
|
||||
// 保存
|
||||
saveMsg(deviceId, tenantId,0xD31A, uploadCmd);
|
||||
saveMsg(deviceId, tenantId,0xD31A, uploadCmd, true);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -105,7 +112,7 @@ public class APIController extends BasicController{
|
||||
if(config != null){
|
||||
rtcmClient.config(deviceId, config);
|
||||
// 保存
|
||||
saveMsg(deviceId, tenantId,0xd311, config);
|
||||
saveMsg(deviceId, tenantId,0xd311, config, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,30 +132,31 @@ public class APIController extends BasicController{
|
||||
@PostMapping(value = "/api/gnss_upload")
|
||||
@ResponseBody
|
||||
public String onGnssUpload(String deviceId, Integer tenantId,LocalDateTime uploadTime) {
|
||||
saveMsg(deviceId, tenantId,0xd342, "gnss data upload from "+uploadTime);
|
||||
saveMsg(deviceId, tenantId,0xd342, "gnss data upload from "+uploadTime,false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/api/gnss_upload_pause")
|
||||
@ResponseBody
|
||||
public String onGnssUploadPause(String deviceId, Integer tenantId) {
|
||||
saveMsg(deviceId, tenantId,0xd342, "gnss data upload pause");
|
||||
saveMsg(deviceId, tenantId,0xd342, "gnss data upload pause",false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/api/gnss_upload_complete")
|
||||
@ResponseBody
|
||||
public String onGnssUploadComplete(String deviceId, Integer tenantId) {
|
||||
saveMsg(deviceId, tenantId,0xd342, "gnss data upload completely");
|
||||
saveMsg(deviceId, tenantId,0xd342, "gnss data upload completely",false);
|
||||
return null;
|
||||
}
|
||||
|
||||
void saveMsg(String deviceId, int tenantId, int msgType, String content){
|
||||
void saveMsg(String deviceId, int tenantId, int msgType, String content,boolean isTx){
|
||||
GnssMsg gnssMsg = new GnssMsg();
|
||||
gnssMsg.setCreatetime(LocalDateTime.now());
|
||||
gnssMsg.setTenantid(tenantId);
|
||||
gnssMsg.setDeviceid(deviceId);
|
||||
gnssMsg.setMsgtype(msgType);
|
||||
gnssMsg.setTx(isTx);
|
||||
if(content==null) content="";
|
||||
gnssMsg.setMsglen(content.length()/2);
|
||||
int saveContentLen = content.length();
|
||||
|
||||
@ -74,6 +74,10 @@ public class CmdLineController extends BasicController{
|
||||
gnssMsg.setDeviceid(deviceId);
|
||||
gnssMsg.setMsgtype(msgType);
|
||||
gnssMsg.setMsglen((int) len);
|
||||
gnssMsg.setTx(true);
|
||||
if(cmd.length() >= 100) {
|
||||
cmd = cmd.substring(0, 100)+"...";
|
||||
}
|
||||
gnssMsg.setContent(cmd);
|
||||
msgMapper.insert(gnssMsg);
|
||||
|
||||
|
||||
@ -75,6 +75,7 @@ CREATE TABLE IF NOT EXISTS `gnssgroupcalc` (
|
||||
`filter_min_hour` int DEFAULT NULL COMMENT '最小平滑窗口',
|
||||
`auto_threshold` float DEFAULT NULL,
|
||||
`device_num` int DEFAULT 0,
|
||||
`auto_upload` bit(1) DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
@ -170,6 +171,7 @@ CREATE TABLE IF NOT EXISTS `gnssmsg` (
|
||||
`deviceid` varchar(20) NOT NULL,
|
||||
`msgtype` int default 0,
|
||||
`msglen` int default 0,
|
||||
`tx` bit(1) DEFAULT 0,
|
||||
`content` varchar(128) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
@ -153,6 +153,7 @@
|
||||
{field: 'auto_filter', title: '自适应滤波', templet: '#autoFilterTrans'},
|
||||
{field: 'filter_min_hour', title: '最小滤波周期'},
|
||||
{field: 'auto_threshold', title: '触发门限(mm)'},
|
||||
{field: 'auto_upload', title: '自动补传', templet: '#autoUploadTrans'},
|
||||
{field: 'device_num', title: '关联设备数'},
|
||||
{title: '操作', toolbar: '#currentTableBar', align: "center"}
|
||||
]],
|
||||
@ -209,6 +210,7 @@
|
||||
layero.find('#auto_filter').val(data.auto_filter);
|
||||
layero.find('#filter_min_hour').val(data.filter_min_hour);
|
||||
layero.find('#auto_threshold').val(data.auto_threshold);
|
||||
layero.find('#auto_upload').val(data.auto_upload);
|
||||
}
|
||||
});
|
||||
$(window).on("resize", function () {
|
||||
@ -358,6 +360,14 @@
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="autoUploadTrans">
|
||||
{{# if(d.auto_upload == 1){ }}
|
||||
<span>启用</span>
|
||||
{{# } else { }}
|
||||
<span>禁用</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="modeTrans">
|
||||
{{# if(d.power_mode == 0){ }}
|
||||
<span>低功耗</span>
|
||||
|
||||
@ -60,6 +60,7 @@
|
||||
{field: 'createtime', title: '上报时间', templet: "<div>{{layui.util.toDateString(d.createtime, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
|
||||
{field: 'msgtype', title: '消息类型', templet: "<div>{{d.msgtype.toString(16)}}</div>"},
|
||||
{field: 'msglen', title: '消息长度'},
|
||||
{field: 'tx', title: '收发', templet: '#trxTrans'},
|
||||
{field: 'content', title: '内容', width: '50%'}
|
||||
]],
|
||||
limits: [10, 15, 20, 25, 50, 100],
|
||||
@ -87,3 +88,11 @@
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="trxTrans">
|
||||
{{# if(d.tx == 1){ }}
|
||||
<span>发</span>
|
||||
{{# } else { }}
|
||||
<span>收</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
@ -66,9 +66,9 @@
|
||||
{field: 'uart1txbytes', title: '串口1发'},
|
||||
{field: 'uart1rxbytes', title: '串口1收'},
|
||||
{field: 'uart1unknown', title: '串口1未知'},
|
||||
{field: 'uart2txbytes', title: '串口1发'},
|
||||
{field: 'uart2rxbytes', title: '串口1收'},
|
||||
{field: 'uart2unknown', title: '串口1未知'}
|
||||
{field: 'uart2txbytes', title: '串口2发'},
|
||||
{field: 'uart2rxbytes', title: '串口2收'},
|
||||
{field: 'uart2unknown', title: '串口2未知'}
|
||||
]],
|
||||
limits: [10, 15, 20, 25, 50, 100],
|
||||
limit: 15,
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
<label class="layui-form-label">自适应滤波</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="auto_filter" id="auto_filter" lay-filter="type1">
|
||||
<option value="false">禁用</option>
|
||||
<option value="true">启用</option>
|
||||
<option value=0>禁用</option>
|
||||
<option value=1>启用</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -46,6 +46,15 @@
|
||||
<input type="number" name="auto_threshold" id="auto_threshold" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">自动补传</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="auto_upload" id="auto_upload" lay-filter="type1">
|
||||
<option value=0>禁用</option>
|
||||
<option value=1>启用</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user