1、修改贵州院UDP推送
This commit is contained in:
parent
5732629274
commit
c922252b88
@ -3,9 +3,6 @@ package com.imdroid.beidou_fwd.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* udp数据推送 api
|
||||
*
|
||||
@ -16,14 +13,7 @@ public class GZYData {
|
||||
private String identityName;
|
||||
private String type = "dbwy";
|
||||
|
||||
private List<Data> TranData;
|
||||
public GZYData(){
|
||||
TranData = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addData(Data data){
|
||||
TranData.add(data);
|
||||
}
|
||||
private Data TranData;
|
||||
|
||||
@lombok.Data
|
||||
public static class Data {
|
||||
|
||||
@ -17,6 +17,8 @@ public class Forwarder {
|
||||
Integer tenantId;
|
||||
boolean useFwdId;
|
||||
|
||||
static boolean isFwdTableInit = false;
|
||||
|
||||
@Autowired
|
||||
private GnssDeviceMapper deviceMapper;
|
||||
|
||||
@ -36,6 +38,11 @@ public class Forwarder {
|
||||
this.description = desc;
|
||||
this.tenantId = tenantId;
|
||||
this.useFwdId = useFwdId;
|
||||
|
||||
if(!isFwdTableInit){
|
||||
isFwdTableInit = true;
|
||||
fwdMapper.delete(null);
|
||||
}
|
||||
QueryWrapper<GnssGroupFwd> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("name",name);
|
||||
GnssGroupFwd gnssGroupFwd = fwdMapper.selectOne(queryWrapper);
|
||||
@ -65,6 +72,15 @@ public class Forwarder {
|
||||
.eq("fwd_group_id2", fwdGroupId);
|
||||
List<GnssDevice> gnssDeviceList = deviceMapper.selectList(queryWrapper);
|
||||
List<GnssCalcData> recordsToSend;
|
||||
|
||||
// 查询最近半小时的记录
|
||||
QueryWrapper<GnssCalcData> gnssQueryWrapper = new QueryWrapper<>();
|
||||
gnssQueryWrapper.ge("createtime",sendAfterTime);
|
||||
gnssQueryWrapper.orderByDesc("createtime");
|
||||
gnssQueryWrapper.eq("enabled",true);
|
||||
gnssQueryWrapper.isNotNull("rpose");
|
||||
List<GnssCalcData> locationRecords = gnssDataMapper.selectList(gnssQueryWrapper);
|
||||
|
||||
for(GnssDevice device:gnssDeviceList){
|
||||
if(device.getOpmode() != GnssDevice.OP_MODE_USE) continue;
|
||||
String projectId = device.getProject_id();
|
||||
@ -75,27 +91,21 @@ public class Forwarder {
|
||||
recordsToSend = new ArrayList<>();
|
||||
projects.put(projectId,recordsToSend);
|
||||
}
|
||||
QueryWrapper<GnssCalcData> gnssQueryWrapper = new QueryWrapper<>();
|
||||
gnssQueryWrapper.eq("deviceid",device.getDeviceid());
|
||||
gnssQueryWrapper.ge("createtime",sendAfterTime);
|
||||
gnssQueryWrapper.orderByDesc("createtime");
|
||||
gnssQueryWrapper.eq("enabled",true);
|
||||
gnssQueryWrapper.isNotNull("rpose");
|
||||
gnssQueryWrapper.last("limit 1");
|
||||
GnssCalcData record = gnssDataMapper.selectOne(gnssQueryWrapper);
|
||||
if(record!=null) {
|
||||
// 替换成推送用的名字和数值
|
||||
if(device.getIpose()!=null &&
|
||||
device.getIposn()!=null &&
|
||||
device.getIposd()!=null){
|
||||
record.setRpose(record.getRpose()-device.getIpose());
|
||||
record.setRposn(record.getRposn()-device.getIposn());
|
||||
record.setRposd(record.getRposd()-device.getIposd());
|
||||
for(GnssCalcData record:locationRecords){
|
||||
if(record.getDeviceid().equals(device.getDeviceid())) {
|
||||
// 替换成推送用的名字和数值
|
||||
if (device.getIpose() != null &&
|
||||
device.getIposn() != null &&
|
||||
device.getIposd() != null) {
|
||||
record.setRpose(record.getRpose() - device.getIpose());
|
||||
record.setRposn(record.getRposn() - device.getIposn());
|
||||
record.setRposd(record.getRposd() - device.getIposd());
|
||||
}
|
||||
if (useFwdId && device.getFwddeviceid() != null && device.getFwddeviceid().trim().length() > 0) {
|
||||
record.setDeviceid(device.getFwddeviceid());
|
||||
}
|
||||
recordsToSend.add(record);
|
||||
}
|
||||
if(useFwdId && device.getFwddeviceid()!=null && device.getFwddeviceid().trim().length()>0) {
|
||||
record.setDeviceid(device.getFwddeviceid());
|
||||
}
|
||||
recordsToSend.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ public class GZYForwarder extends Forwarder{
|
||||
/**
|
||||
* 每半小时转发GNSS解算结果
|
||||
*/
|
||||
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||
@Scheduled(cron = "0 0/5 * * * ?") // 每30分钟执行一次
|
||||
private void forwardGnss() {
|
||||
forwardCurrentGnss(FORWARDER_NAME);
|
||||
}
|
||||
@ -67,9 +67,8 @@ public class GZYForwarder extends Forwarder{
|
||||
tranData.setX(n);
|
||||
tranData.setY(e);
|
||||
tranData.setZ(d);
|
||||
gzyData.addData(tranData);
|
||||
String json = GsonUtil.toJson(gzyData);
|
||||
String msg = "JGKJ" + json + "#!";
|
||||
gzyData.setTranData(tranData);
|
||||
String msg = "JGKJ" + GsonUtil.toJson(gzyData) + "#!";
|
||||
logger.info("forward to GZY");
|
||||
logger.info(msg);
|
||||
udpClient.sendMessage(msg);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user