1、修改推送的bug

This commit is contained in:
weidong 2024-01-15 10:20:09 +08:00
parent 79eb27c7af
commit 9f4f5ad5c9
4 changed files with 21 additions and 18 deletions

View File

@ -121,15 +121,16 @@ public class Forwarder {
calcDataQueryWrapper.orderByAsc("createtime"); calcDataQueryWrapper.orderByAsc("createtime");
List<GnssCalcData> calcDataList = gnssDataMapper.selectList(calcDataQueryWrapper); List<GnssCalcData> calcDataList = gnssDataMapper.selectList(calcDataQueryWrapper);
// 推送记录 // 推送记录
sendBatch(fwdRecord.getProject_id(),calcDataList); if(sendBatch(fwdRecord.getProject_id(),calcDataList)>0) {
// 记录推送结果 // 记录推送结果
fwdRecord.setState(FwdRecord.STATE_FWD_DONE); fwdRecord.setState(FwdRecord.STATE_FWD_DONE);
fwdRecordsMapper.updateById(fwdRecord); fwdRecordsMapper.updateById(fwdRecord);
} }
} }
}
void sendBatch(String projectId, List<GnssCalcData> records){ int sendBatch(String projectId, List<GnssCalcData> records){
if(records.size() == 0) return; if(records.size() == 0) return 0;
LocalDateTime lastTime = records.get(0).getCreatetime(); LocalDateTime lastTime = records.get(0).getCreatetime();
@ -144,8 +145,7 @@ public class Forwarder {
} }
} }
send(projectId, records); return send(projectId, records);
} }
int send(String projectId, List<GnssCalcData> records) { int send(String projectId, List<GnssCalcData> records) {

View File

@ -43,13 +43,6 @@ public class GXXfzForwarder extends Forwarder{
xfzTcpClient.start(); xfzTcpClient.start();
} }
@Scheduled(cron = "0 29,39,59 * * * ?") // 每29分/59分执行一次
private void checkTCP() {
if(!xfzTcpClient.isActive()) {
xfzTcpClient.connect();
}
}
/** /**
* 每半小时转发GNSS解算结果 * 每半小时转发GNSS解算结果
*/ */
@ -69,6 +62,16 @@ public class GXXfzForwarder extends Forwarder{
int sendNum = 0; int sendNum = 0;
if(records.size() == 0) return 0; if(records.size() == 0) return 0;
if(!xfzTcpClient.isActive()) {
xfzTcpClient.connect();
try {
Thread.sleep(5000);
}
catch (Exception e){
}
}
XFZData xfzTcpMessage = new XFZData(); XFZData xfzTcpMessage = new XFZData();
xfzTcpMessage.setProjectID(projectId); xfzTcpMessage.setProjectID(projectId);
xfzTcpMessage.setWorkPointID(projectId); xfzTcpMessage.setWorkPointID(projectId);
@ -77,7 +80,7 @@ public class GXXfzForwarder extends Forwarder{
xfzTcpMessage.setData(dataList); xfzTcpMessage.setData(dataList);
for(GnssCalcData locationRecord: records) { for(GnssCalcData locationRecord: records) {
if(!locationRecord.getEnabled()) continue; if(!locationRecord.getEnabled() || locationRecord.getRb562e()==null) continue;
XFZData.Data data = new XFZData.Data(); XFZData.Data data = new XFZData.Data();
dataList.add(data); dataList.add(data);
data.setDataTime(locationRecord.getCreatetime().format(dateFormatter)); data.setDataTime(locationRecord.getCreatetime().format(dateFormatter));

View File

@ -61,7 +61,7 @@ public class GZYForwarder extends Forwarder{
for(GnssCalcData locationRecord: records) { for(GnssCalcData locationRecord: records) {
if(!locationRecord.getEnabled()) continue; if(!locationRecord.getEnabled() || locationRecord.getRb562e()==null) continue;
GZYData.Data tranData = new GZYData.Data(); GZYData.Data tranData = new GZYData.Data();
tranData.setCollectTime(locationRecord.getCreatetime().format(formatter)); tranData.setCollectTime(locationRecord.getCreatetime().format(formatter));
double n = NumberUtils.scale(locationRecord.getRb562n(), 2); double n = NumberUtils.scale(locationRecord.getRb562n(), 2);

View File

@ -101,7 +101,7 @@ public class KingMaForwarder extends Forwarder{
List<KingMaData> dataList = new ArrayList<>(records.size()); List<KingMaData> dataList = new ArrayList<>(records.size());
for(GnssCalcData locationRecord: records) { for(GnssCalcData locationRecord: records) {
if(!locationRecord.getEnabled()) continue; if(!locationRecord.getEnabled() || locationRecord.getRb562e()==null) continue;
KingMaData data = new KingMaData(); KingMaData data = new KingMaData();
data.setDataTime(locationRecord.getCreatetime().toString()); data.setDataTime(locationRecord.getCreatetime().toString());
data.setProjectId(projectId); data.setProjectId(projectId);