1、通过UDP更新基站状态
This commit is contained in:
parent
0437fa2f5e
commit
0a00d65b83
@ -1,5 +1,6 @@
|
|||||||
package com.imdroid.sideslope.executor;
|
package com.imdroid.sideslope.executor;
|
||||||
|
|
||||||
|
import com.imdroid.common.util.ThreadManager;
|
||||||
import com.imdroid.secapi.client.BeidouClient;
|
import com.imdroid.secapi.client.BeidouClient;
|
||||||
import com.imdroid.secapi.dto.GnssDevice;
|
import com.imdroid.secapi.dto.GnssDevice;
|
||||||
import com.imdroid.sideslope.bd.Gga;
|
import com.imdroid.sideslope.bd.Gga;
|
||||||
@ -8,6 +9,7 @@ import com.imdroid.sideslope.sal.Device;
|
|||||||
import com.imdroid.sideslope.sal.DeviceService;
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
import com.imdroid.sideslope.server.DeviceChannel;
|
import com.imdroid.sideslope.server.DeviceChannel;
|
||||||
import com.imdroid.sideslope.server.OnlineChannels;
|
import com.imdroid.sideslope.server.OnlineChannels;
|
||||||
|
import com.imdroid.sideslope.service.DataPersistService;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +34,8 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private BeidouClient beidouClient;
|
private BeidouClient beidouClient;
|
||||||
|
@Autowired
|
||||||
|
private DataPersistService dataPersistService;
|
||||||
@Override
|
@Override
|
||||||
public Void execute(D331RtcmMessage message) {
|
public Void execute(D331RtcmMessage message) {
|
||||||
String id = message.getId();
|
String id = message.getId();
|
||||||
@ -63,8 +67,43 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trx stat
|
||||||
message.setTenantId(device1.getTenantId());
|
message.setTenantId(device1.getTenantId());
|
||||||
|
LocalDateTime lastTime = device1.getLastRxTime();
|
||||||
|
Device lastCycleDevice;
|
||||||
|
if(LocalDateTime.now().isAfter(lastTime.plusMinutes(1))){
|
||||||
|
// new cycle
|
||||||
|
lastCycleDevice = new Device();
|
||||||
|
lastCycleDevice.setDeviceId(device1.getDeviceId());
|
||||||
|
lastCycleDevice.setTenantId(device1.getTenantId());
|
||||||
|
lastCycleDevice.setD3xxbytes(device1.getD3xxbytes());
|
||||||
|
lastCycleDevice.setD341Count(device1.getD341Count());
|
||||||
|
lastCycleDevice.setLastRxTime(device1.getLastRxTime());
|
||||||
|
lastCycleDevice.setSatelitesInUse(device1.getSatelitesInUse());
|
||||||
|
device1.clearStat();
|
||||||
|
} else {
|
||||||
|
lastCycleDevice = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果控制通道没连接,则收到不到d3f0和d3f2,则根据UDP最后一个报文触发状态更新和统计
|
||||||
|
// 测站的更新和统计放在解算之后进行,因为要统计固定解浮点解等信息
|
||||||
|
if(lastCycleDevice != null){
|
||||||
|
DeviceChannel channel = OnlineChannels.INSTANCE.getConfigChannel(device1.getDeviceId());
|
||||||
|
if(channel == null || !channel.isOnline()){
|
||||||
|
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||||
|
// 通知上线
|
||||||
|
try {
|
||||||
|
beidouClient.onDeviceActive(device1.getDeviceId(), device1.getTenantId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
dataPersistService.updateDeviceState(lastCycleDevice);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
device1.updateRx(message.getHeader(),message.getLen(),message.getPacketNum());
|
device1.updateRx(message.getHeader(),message.getLen(),message.getPacketNum());
|
||||||
|
// update gga
|
||||||
Gga gga = message.getGga();
|
Gga gga = message.getGga();
|
||||||
if(gga != null) {
|
if(gga != null) {
|
||||||
device1.updateSatelitesNum(gga.getSatellitesInUsed());
|
device1.updateSatelitesNum(gga.getSatellitesInUsed());
|
||||||
@ -73,31 +112,6 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
device1.setLongitude(gga.getLongitude());
|
device1.setLongitude(gga.getLongitude());
|
||||||
device1.setAltitude(gga.getAltitude());
|
device1.setAltitude(gga.getAltitude());
|
||||||
}
|
}
|
||||||
// 借D341做GGA的统计分析
|
|
||||||
/*D341LocationMessage d341Message = new D341LocationMessage();
|
|
||||||
d341Message.setGga(gga);
|
|
||||||
d341Message.setId(message.getId());
|
|
||||||
d341Message.setTenantId(message.getTenantId());
|
|
||||||
d341Message.setPps(message.getPps());
|
|
||||||
d341Message.setTilt(message.getTilt());
|
|
||||||
d341Message.setB562_loc(null);
|
|
||||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
|
||||||
gnssCalcService.calcSingle(d341Message,true);
|
|
||||||
});*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// 收到第一个数据包,如果控制通道没连接,也通知上线
|
|
||||||
if(device1.getD3xxCount() == 1){
|
|
||||||
DeviceChannel channel = OnlineChannels.INSTANCE.getConfigChannel(device1.getDeviceId());
|
|
||||||
if(channel == null || !channel.isOnline()){
|
|
||||||
// 通知上线
|
|
||||||
try{
|
|
||||||
beidouClient.onDeviceActive(device1.getDeviceId(), device1.getTenantId());
|
|
||||||
}
|
|
||||||
catch (Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -22,4 +22,7 @@ public interface DataPersistService {
|
|||||||
void saveDeviceTrxStat(D3F2StopIndicationMessage d3F2StopIndicationMessage, boolean isUploading, Device device);
|
void saveDeviceTrxStat(D3F2StopIndicationMessage d3F2StopIndicationMessage, boolean isUploading, Device device);
|
||||||
|
|
||||||
void saveD342Stat(D342LocationMessage message, Device device);
|
void saveD342Stat(D342LocationMessage message, Device device);
|
||||||
|
|
||||||
|
// 没有收到d3f2情况下的统计
|
||||||
|
void updateDeviceState(Device device);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,4 +140,32 @@ public class DataPersistServiceImpl implements DataPersistService {
|
|||||||
", bytes:"+device.getD342Bytes()+
|
", bytes:"+device.getD342Bytes()+
|
||||||
", total d341 num:"+device.getD341In42Count()+", session done");
|
", total d341 num:"+device.getD341In42Count()+", session done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDeviceState(Device device) {
|
||||||
|
//新增或更新到status数据表里
|
||||||
|
GnssStatus deviceState = deviceStateRepository.getByDeviceId(device.getDeviceId());
|
||||||
|
boolean new_flag = false;
|
||||||
|
if(null == deviceState) {
|
||||||
|
deviceState = new GnssStatus();
|
||||||
|
new_flag = true;
|
||||||
|
}
|
||||||
|
//deviceState.setId(SequenceUtil.getSequence());
|
||||||
|
deviceState.setTenantid(device.getTenantId());
|
||||||
|
deviceState.setDeviceid(device.getDeviceId());
|
||||||
|
deviceState.setUpdatetime(device.getLastRxTime());
|
||||||
|
deviceState.setD3xxbytes(device.getD3xxbytes());
|
||||||
|
deviceState.setB562bytes(device.getD342Bytes());
|
||||||
|
deviceState.setSatelliteinuse(device.getSatelitesInUse());
|
||||||
|
|
||||||
|
// 检测状态和告警
|
||||||
|
deviceState.setState(GnssStatus.STATE_ACTIVE);
|
||||||
|
warningService.checkDeviceStatus(null, deviceState);
|
||||||
|
if(device.getDeviceType() == Device.DEVICE_BASE_STATION){
|
||||||
|
warningService.checkD3xxNum(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(new_flag) deviceStateRepository.insert(deviceState);
|
||||||
|
else deviceStateRepository.updateById(deviceState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,27 +89,30 @@ public class WarningServiceImpl implements WarningService {
|
|||||||
isUpdated = true;
|
isUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(statusMsg!=null) {
|
||||||
//低电压告警
|
//低电压告警
|
||||||
if(statusMsg.getVoltage()!=null) {
|
if (statusMsg.getVoltage() != null) {
|
||||||
if(check(curStatus, WarningCfg.TYPE_LOW_VOLTAGE,
|
if (check(curStatus, WarningCfg.TYPE_LOW_VOLTAGE,
|
||||||
WarningCfg.TYPE_NAME_LOW_VOLTAGE,true,
|
WarningCfg.TYPE_NAME_LOW_VOLTAGE, true,
|
||||||
statusMsg.getVoltage(), null,null)) isUpdated=true;
|
statusMsg.getVoltage(), null, null)) isUpdated = true;
|
||||||
}
|
}
|
||||||
//低RSSI
|
//低RSSI
|
||||||
if(statusMsg.getRssi()!=null) {
|
if (statusMsg.getRssi() != null) {
|
||||||
if(check(curStatus, WarningCfg.TYPE_LOW_RSSI,
|
if (check(curStatus, WarningCfg.TYPE_LOW_RSSI,
|
||||||
WarningCfg.TYPE_NAME_LOW_RSSI,true,
|
WarningCfg.TYPE_NAME_LOW_RSSI, true,
|
||||||
statusMsg.getRssi().intValue(), null,null)) isUpdated=true;
|
statusMsg.getRssi().intValue(), null, null)) isUpdated = true;
|
||||||
}
|
}
|
||||||
//倾角异常告警
|
//倾角异常告警
|
||||||
if(statusMsg.getPitch()!=null) {
|
if (statusMsg.getPitch() != null) {
|
||||||
if(check(curStatus, WarningCfg.TYPE_INCLINE,
|
if (check(curStatus, WarningCfg.TYPE_INCLINE,
|
||||||
WarningCfg.TYPE_NAME_INCLINE,false,
|
WarningCfg.TYPE_NAME_INCLINE, false,
|
||||||
Math.abs(statusMsg.getPitch().intValue()),
|
Math.abs(statusMsg.getPitch().intValue()),
|
||||||
Math.abs(statusMsg.getRoll().intValue()),
|
Math.abs(statusMsg.getRoll().intValue()),
|
||||||
"pitch:"+ NumberUtils.scaleTwo(statusMsg.getPitch().doubleValue())
|
"pitch:" + NumberUtils.scaleTwo(statusMsg.getPitch().doubleValue())
|
||||||
+",roll:"+NumberUtils.scaleTwo(statusMsg.getRoll().doubleValue()))) isUpdated=true;
|
+ ",roll:" + NumberUtils.scaleTwo(statusMsg.getRoll().doubleValue()))) isUpdated = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//卫星数
|
//卫星数
|
||||||
if(curStatus.getSatelliteinuse()!=null){
|
if(curStatus.getSatelliteinuse()!=null){
|
||||||
if(check(curStatus,WarningCfg.TYPE_LESS_INUSE_SAT,
|
if(check(curStatus,WarningCfg.TYPE_LESS_INUSE_SAT,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user