添加备选基站
This commit is contained in:
parent
c6fe8d403a
commit
3f0aa45cd9
@ -17,7 +17,7 @@ public interface RtcmClient {
|
|||||||
@GetMapping(value = "/get_device_info")
|
@GetMapping(value = "/get_device_info")
|
||||||
public HttpResp getDeviceInfo(@RequestParam(name = "deviceId") String deviceId, @RequestParam(name = "cmd") String cmd);
|
public HttpResp getDeviceInfo(@RequestParam(name = "deviceId") String deviceId, @RequestParam(name = "cmd") String cmd);
|
||||||
@PostMapping("/device_param_changed")
|
@PostMapping("/device_param_changed")
|
||||||
HttpResp deviceParamChanged(@RequestParam(name = "deviceId") String deviceId,@RequestParam(name = "oldParentId") String oldParentId);
|
HttpResp deviceParamChanged(@RequestParam(name = "deviceId") String deviceId,@RequestParam(name = "oldParentId") String oldParentId, @RequestParam("oldParentId1") String oldParentId1);
|
||||||
|
|
||||||
@PostMapping("/group_param_changed")
|
@PostMapping("/group_param_changed")
|
||||||
HttpResp groupParamChanged();
|
HttpResp groupParamChanged();
|
||||||
|
|||||||
@ -40,6 +40,7 @@ public class GnssDevice {
|
|||||||
private String fwddeviceid; //推送的设备名
|
private String fwddeviceid; //推送的设备名
|
||||||
private String name;
|
private String name;
|
||||||
private String parentid;
|
private String parentid;
|
||||||
|
private String parentid1;
|
||||||
private Integer devicetype;
|
private Integer devicetype;
|
||||||
private String tenantname;
|
private String tenantname;
|
||||||
private String project_id;
|
private String project_id;
|
||||||
|
|||||||
@ -22,6 +22,7 @@ public class GnssDeviceJoin {
|
|||||||
private String fwddeviceid; //推送的设备名
|
private String fwddeviceid; //推送的设备名
|
||||||
private String name;
|
private String name;
|
||||||
private String parentid;
|
private String parentid;
|
||||||
|
private String parentid1;
|
||||||
private Integer devicetype;
|
private Integer devicetype;
|
||||||
private String tenantname;
|
private String tenantname;
|
||||||
private String project_id;
|
private String project_id;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -59,23 +60,43 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
// 推送基站数据
|
// 推送基站数据
|
||||||
if(deviceBs.getOpMode() == GnssDevice.OP_MODE_USE) {
|
if(deviceBs.getOpMode() == GnssDevice.OP_MODE_USE) {
|
||||||
byte[] forwardBytes = message.getSrcData();
|
byte[] forwardBytes = message.getSrcData();
|
||||||
// 要求快速转发,因此用缓存,不要每次都查数据库
|
// 获取使用该基站(包括作为主基站和备选基站)的所有测站
|
||||||
List<Device> deviceList = deviceService.findByParentId(id);
|
List<Device> primaryDevices = deviceService.findByParentId(id);
|
||||||
//logger.debug("base station {} has {} rovers: ", message.getId(),deviceList.size());
|
List<Device> backupDevices = deviceService.findByParentId1(id);
|
||||||
|
|
||||||
|
// 合并两个列表
|
||||||
|
List<Device> allDevices = new ArrayList<>();
|
||||||
|
allDevices.addAll(primaryDevices);
|
||||||
|
allDevices.addAll(backupDevices);
|
||||||
|
|
||||||
DeviceChannel deviceChannel = null;
|
DeviceChannel deviceChannel = null;
|
||||||
for (Device device : deviceList) {
|
for (Device device : allDevices) {
|
||||||
if (device.getOpMode() != GnssDevice.OP_MODE_USE) continue;
|
if (device.getOpMode() != GnssDevice.OP_MODE_USE) continue;
|
||||||
String deviceId = device.getDeviceId();
|
String deviceId = device.getDeviceId();
|
||||||
|
|
||||||
|
// 检查该设备是否应该接收此基站的数据
|
||||||
|
String primaryBaseId = device.getParentId();
|
||||||
|
String backupBaseId = device.getParentId1();
|
||||||
|
|
||||||
|
// 如果当前基站是该设备的备选基站,需要检查主基站是否离线
|
||||||
|
if (id.equals(backupBaseId)) {
|
||||||
|
Device primaryBase = deviceService.findByDeviceId(primaryBaseId);
|
||||||
|
// 如果主基站仍然在线,则跳过备选基站的数据
|
||||||
|
if (primaryBase != null && isBaseStationOnline(primaryBase)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取设备通道并发送数据
|
||||||
if(device.getDataChannelType() == Device.CHANNEL_TYPE_UDP) {
|
if(device.getDataChannelType() == Device.CHANNEL_TYPE_UDP) {
|
||||||
deviceChannel = OnlineChannels.INSTANCE.getDataChannel(deviceId);
|
deviceChannel = OnlineChannels.INSTANCE.getDataChannel(deviceId);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
deviceChannel = OnlineChannels.INSTANCE.getConfigChannel(deviceId);
|
deviceChannel = OnlineChannels.INSTANCE.getConfigChannel(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(deviceChannel != null && deviceChannel.isOnline()) {
|
if(deviceChannel != null && deviceChannel.isOnline()) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("forward d331 rtcm to device {}", deviceId);
|
logger.debug("forward d331 rtcm from {} to device {}", id, deviceId);
|
||||||
}
|
}
|
||||||
if (deviceId.startsWith("2307")) {
|
if (deviceId.startsWith("2307")) {
|
||||||
forwardBytes[2] = (byte) (forwardBytes[2] & 0x07);//兼容不带序号的测站
|
forwardBytes[2] = (byte) (forwardBytes[2] & 0x07);//兼容不带序号的测站
|
||||||
@ -167,5 +188,19 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
return D331RtcmMessage.class;
|
return D331RtcmMessage.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断住基站是否在线
|
||||||
|
* @param baseStation 基站
|
||||||
|
* @return 是否在线
|
||||||
|
*/
|
||||||
|
|
||||||
|
private boolean isBaseStationOnline(Device baseStation){
|
||||||
|
if(baseStation == null) return false;
|
||||||
|
|
||||||
|
LocalDateTime now =LocalDateTime.now();
|
||||||
|
return baseStation.getLastRxTime() !=null &&
|
||||||
|
baseStation.getLastRxTime().isAfter(now.minusMinutes(30));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -32,6 +32,7 @@ public class DbDeviceServiceImpl implements DeviceService {
|
|||||||
device.setDeviceType(gnssDevice.getDevicetype());
|
device.setDeviceType(gnssDevice.getDevicetype());
|
||||||
device.setModel(gnssDevice.getModel());
|
device.setModel(gnssDevice.getModel());
|
||||||
device.setParentId(gnssDevice.getParentid());
|
device.setParentId(gnssDevice.getParentid());
|
||||||
|
device.setParentId1(gnssDevice.getParentid1());
|
||||||
device.setName(gnssDevice.getName());
|
device.setName(gnssDevice.getName());
|
||||||
device.setProjectId(gnssDevice.getProject_id());
|
device.setProjectId(gnssDevice.getProject_id());
|
||||||
device.setCalcGroupId(gnssDevice.getCalc_group_id());
|
device.setCalcGroupId(gnssDevice.getCalc_group_id());
|
||||||
@ -59,6 +60,36 @@ public class DbDeviceServiceImpl implements DeviceService {
|
|||||||
device.setDeviceId(gnssDevice.getDeviceid());
|
device.setDeviceId(gnssDevice.getDeviceid());
|
||||||
device.setDeviceType(gnssDevice.getDevicetype());
|
device.setDeviceType(gnssDevice.getDevicetype());
|
||||||
device.setParentId(gnssDevice.getParentid());
|
device.setParentId(gnssDevice.getParentid());
|
||||||
|
device.setParentId1(gnssDevice.getParentid1());
|
||||||
|
device.setName(gnssDevice.getName());
|
||||||
|
device.setProjectId(gnssDevice.getProject_id());
|
||||||
|
device.setCalcGroupId(gnssDevice.getCalc_group_id());
|
||||||
|
device.setOpMode(gnssDevice.getOpmode());
|
||||||
|
device.setFwdId(gnssDevice.getFwd_group_id());
|
||||||
|
device.setIPose(gnssDevice.getIpose());
|
||||||
|
device.setIPosn(gnssDevice.getIposn());
|
||||||
|
device.setIPosd(gnssDevice.getIposd());
|
||||||
|
device.setEcefx(gnssDevice.getEcefx());
|
||||||
|
device.setEcefy(gnssDevice.getEcefy());
|
||||||
|
device.setEcefz(gnssDevice.getEcefz());
|
||||||
|
deviceList.add(device);
|
||||||
|
}
|
||||||
|
return deviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> findByParentId1(String parentId1) {
|
||||||
|
QueryWrapper<GnssDevice> query = new QueryWrapper<>();
|
||||||
|
query.eq("parentid1", parentId1);
|
||||||
|
List<GnssDevice> gnssDeviceList = gnssDeviceRepository.selectList(query);
|
||||||
|
List<Device> deviceList = new ArrayList<>(gnssDeviceList.size());
|
||||||
|
|
||||||
|
for (GnssDevice gnssDevice : gnssDeviceList) {
|
||||||
|
Device device = new Device();
|
||||||
|
device.setDeviceId(gnssDevice.getDeviceid());
|
||||||
|
device.setDeviceType(gnssDevice.getDevicetype());
|
||||||
|
device.setParentId(gnssDevice.getParentid());
|
||||||
|
device.setParentId1(gnssDevice.getParentid1()); // 添加备选基站ID
|
||||||
device.setName(gnssDevice.getName());
|
device.setName(gnssDevice.getName());
|
||||||
device.setProjectId(gnssDevice.getProject_id());
|
device.setProjectId(gnssDevice.getProject_id());
|
||||||
device.setCalcGroupId(gnssDevice.getCalc_group_id());
|
device.setCalcGroupId(gnssDevice.getCalc_group_id());
|
||||||
|
|||||||
@ -37,6 +37,7 @@ public class Device {
|
|||||||
private String deviceId;
|
private String deviceId;
|
||||||
|
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
private String parentId1;
|
||||||
private String projectId;
|
private String projectId;
|
||||||
private String fwdId;
|
private String fwdId;
|
||||||
|
|
||||||
|
|||||||
@ -11,4 +11,6 @@ public interface DeviceService {
|
|||||||
Device findByDeviceId(String deviceId);
|
Device findByDeviceId(String deviceId);
|
||||||
|
|
||||||
List<Device> findByParentId(String parentId);
|
List<Device> findByParentId(String parentId);
|
||||||
|
|
||||||
|
List<Device> findByParentId1(String parentId1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -57,6 +58,22 @@ public class LocalDeviceServiceImpl implements DeviceService {
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> findByParentId1(String parentId1) {
|
||||||
|
if (parentId1 == null || parentId1.trim().isEmpty()){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<Device> device = subDeviceCache.getIfPresent("backup_" + parentId1); // 使用前缀区分备选基站的缓存
|
||||||
|
if (device == null) {
|
||||||
|
logger.debug("backup base station {} refresh: " + parentId1);
|
||||||
|
device = delegate.findByParentId1(parentId1);
|
||||||
|
if (device != null) {
|
||||||
|
subDeviceCache.put("backup_" + parentId1, device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
public void refresh(String deviceId, String oldParentId){
|
public void refresh(String deviceId, String oldParentId){
|
||||||
Device device = deviceCache.getIfPresent(deviceId);
|
Device device = deviceCache.getIfPresent(deviceId);
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
@ -66,6 +83,10 @@ public class LocalDeviceServiceImpl implements DeviceService {
|
|||||||
subDeviceCache.invalidate(oldParentId);
|
subDeviceCache.invalidate(oldParentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(device.getParentId1() != null || !device.getParentId1().trim().isEmpty()){
|
||||||
|
subDeviceCache.invalidate("back_"+device.getParentId1());
|
||||||
|
}
|
||||||
deviceCache.invalidate(deviceId);
|
deviceCache.invalidate(deviceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import javax.servlet.http.HttpSession;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class GnssDeviceController extends BasicController{
|
public class GnssDeviceController extends BasicController{
|
||||||
@ -115,6 +116,11 @@ public class GnssDeviceController extends BasicController{
|
|||||||
if (StringUtils.hasText(parentid)) {
|
if (StringUtils.hasText(parentid)) {
|
||||||
queryWrapper.like("parentid", parentid);
|
queryWrapper.like("parentid", parentid);
|
||||||
}
|
}
|
||||||
|
//备选基站
|
||||||
|
String parentid1 = search.getString("parentid1");
|
||||||
|
if (StringUtils.hasText(parentid1)){
|
||||||
|
queryWrapper.like("parentid1", parentid1);
|
||||||
|
}
|
||||||
//项目号
|
//项目号
|
||||||
String project_id = search.getString("project_id");
|
String project_id = search.getString("project_id");
|
||||||
if (StringUtils.hasText(project_id)) {
|
if (StringUtils.hasText(project_id)) {
|
||||||
@ -208,7 +214,9 @@ public class GnssDeviceController extends BasicController{
|
|||||||
OpLogManager.OP_OBJ_DEVICE,
|
OpLogManager.OP_OBJ_DEVICE,
|
||||||
device.getDeviceid() + " update: " + diff);
|
device.getDeviceid() + " update: " + diff);
|
||||||
device.setUpdatetime(LocalDateTime.now());
|
device.setUpdatetime(LocalDateTime.now());
|
||||||
if(!old_device.getGroup_id().equals(device.getGroup_id())){
|
if(!old_device.getGroup_id().equals(device.getGroup_id())||
|
||||||
|
!old_device.getParentid().equals(device.getParentid())||
|
||||||
|
!Objects.equals(old_device.getParentid1(),device.getParentid1())){
|
||||||
device.setSyn(false);
|
device.setSyn(false);
|
||||||
}
|
}
|
||||||
num = gnssDeviceMapper.updateById(device);
|
num = gnssDeviceMapper.updateById(device);
|
||||||
@ -229,7 +237,7 @@ public class GnssDeviceController extends BasicController{
|
|||||||
} else {
|
} else {
|
||||||
// 更新组参数的关联个数
|
// 更新组参数的关联个数
|
||||||
updateBasicGroupAssociatedNum(device,old_device);
|
updateBasicGroupAssociatedNum(device,old_device);
|
||||||
rtcmClient.deviceParamChanged(device.getDeviceid(), device.getParentid());
|
rtcmClient.deviceParamChanged(device.getDeviceid(), device.getParentid(), device.getParentid1());
|
||||||
return HttpResult.ok();
|
return HttpResult.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,7 +359,7 @@ public class GnssDeviceController extends BasicController{
|
|||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else{
|
} else{
|
||||||
rtcmClient.deviceParamChanged(del_id, null);
|
rtcmClient.deviceParamChanged(del_id, null, null);
|
||||||
return HttpResult.ok();
|
return HttpResult.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,12 @@
|
|||||||
<input type="text" name="parentid" autocomplete="off" class="layui-input">
|
<input type="text" name="parentid" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<label class="layui-form-label">备选基站号</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="parentid1" autocomplete="off" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">项目号</label>
|
<label class="layui-form-label">项目号</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
@ -128,6 +134,7 @@
|
|||||||
{field: 'group_id', title: '基本参数组', width: 60, sort: true},
|
{field: 'group_id', title: '基本参数组', width: 60, sort: true},
|
||||||
{field: 'calc_group_id', title: '解算参数组', width: 60, sort: true},
|
{field: 'calc_group_id', title: '解算参数组', width: 60, sort: true},
|
||||||
{field: 'parentid', title: '基站编号', width: 80, sort: true},
|
{field: 'parentid', title: '基站编号', width: 80, sort: true},
|
||||||
|
{field: 'parentid1', title: '备选基站', width: 80, sort: true},
|
||||||
{field: 'tenantname', title: '所属组织', width: 120},
|
{field: 'tenantname', title: '所属组织', width: 120},
|
||||||
{field: 'fwd_group_id', title: '推送组', width: 80},
|
{field: 'fwd_group_id', title: '推送组', width: 80},
|
||||||
{field: 'fwd_group_id2', title: '推送2', width: 80},
|
{field: 'fwd_group_id2', title: '推送2', width: 80},
|
||||||
|
|||||||
@ -81,6 +81,12 @@
|
|||||||
<input type="number" name="parentid" id="parentid" placeholder="请输入关联基准站编号" value="" class="layui-input">
|
<input type="number" name="parentid" id="parentid" placeholder="请输入关联基准站编号" value="" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="layui-inline" >
|
||||||
|
<label class="layui-form-label">备选基站</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="parentid1" id="parentid1" placeholder="请输入备选基准站编号" value="" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item" id="ecef_div">
|
<div class="layui-form-item" id="ecef_div">
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
@ -307,6 +313,7 @@
|
|||||||
$('#name').val(data.name);
|
$('#name').val(data.name);
|
||||||
$('#devicetype').val(data.devicetype);
|
$('#devicetype').val(data.devicetype);
|
||||||
$('#parentid').val(data.parentid);
|
$('#parentid').val(data.parentid);
|
||||||
|
$('#parentid1').val(data.parentid1);
|
||||||
$('#tenantname').val(data.tenantname);
|
$('#tenantname').val(data.tenantname);
|
||||||
$('#project_id').val(data.project_id);
|
$('#project_id').val(data.project_id);
|
||||||
$('#project2_id').val(data.project2_id);
|
$('#project2_id').val(data.project2_id);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user