1、不同第三方错开时间发送,避免数据库集中查询
This commit is contained in:
parent
76d1ef3b2c
commit
1bb6946bf8
@ -1,6 +1,7 @@
|
||||
package com.imdroid.beidou_fwd.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.imdroid.common.util.ThreadManager;
|
||||
import com.imdroid.secapi.dto.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@ -16,7 +17,8 @@ public class Forwarder {
|
||||
String description;
|
||||
Integer tenantId;
|
||||
boolean useFwdId;
|
||||
|
||||
int totalSendNum = 0;
|
||||
boolean fwdFailed = false;
|
||||
static boolean isFwdTableInit = false;
|
||||
|
||||
@Autowired
|
||||
@ -111,8 +113,9 @@ public class Forwarder {
|
||||
}
|
||||
|
||||
// 按项目打包推送
|
||||
int totalSendNum = 0;
|
||||
boolean fwdFailed = false;
|
||||
totalSendNum = 0;
|
||||
fwdFailed = false;
|
||||
List<FwdRecord> fwdRecordList = new ArrayList<>();
|
||||
for (Map.Entry<String, List<GnssCalcData>> entry: projects.entrySet()){
|
||||
String projectId = entry.getKey();
|
||||
List<GnssCalcData> records = entry.getValue();
|
||||
@ -137,12 +140,18 @@ public class Forwarder {
|
||||
fwdRecord.setState(FwdRecord.STATE_FWD_FAILED);
|
||||
fwdFailed = true;
|
||||
}
|
||||
fwdRecordsMapper.insert(fwdRecord);
|
||||
fwdRecordList.add(fwdRecord);
|
||||
}
|
||||
|
||||
// 更新推送信息
|
||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||
for(FwdRecord record:fwdRecordList){
|
||||
fwdRecordsMapper.insert(record);
|
||||
}
|
||||
if(totalSendNum>0) updateFwd(totalSendNum, true);
|
||||
else if(fwdFailed) updateFwd(totalSendNum, false);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -153,8 +162,9 @@ public class Forwarder {
|
||||
queryWrapper.eq("state",FwdRecord.STATE_UPLOAD_DONE);
|
||||
List<FwdRecord> fwdRecordsList = fwdRecordsMapper.selectList(queryWrapper);
|
||||
// 2.检索这个这个时间段的解算结果,如果有数据则单个终端转发,标志记录为已补传
|
||||
int totalSendNum = 0;
|
||||
boolean fwdFailed = false;
|
||||
totalSendNum = 0;
|
||||
fwdFailed = false;
|
||||
List<FwdRecord> fwdRecordList = new ArrayList<>();
|
||||
for(FwdRecord fwdRecord:fwdRecordsList){
|
||||
// 查找device
|
||||
QueryWrapper<GnssDevice> deviceQueryWrapper = new QueryWrapper<>();
|
||||
@ -183,12 +193,17 @@ public class Forwarder {
|
||||
fwdRecord.setState(FwdRecord.STATE_FWD_FAILED);
|
||||
fwdFailed = true;
|
||||
}
|
||||
fwdRecordsMapper.updateById(fwdRecord);
|
||||
fwdRecordList.add(fwdRecord);
|
||||
}
|
||||
|
||||
// 更新推送信息
|
||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||
for(FwdRecord record:fwdRecordList){
|
||||
fwdRecordsMapper.updateById(record);
|
||||
}
|
||||
if(totalSendNum>0) updateFwd(totalSendNum, true);
|
||||
else if(fwdFailed) updateFwd(totalSendNum, false);
|
||||
});
|
||||
}
|
||||
|
||||
int sendBatch(GnssDevice device, String projectId, List<GnssCalcData> records){
|
||||
|
||||
@ -67,7 +67,6 @@ public class GXXfzForwarder extends Forwarder{
|
||||
*/
|
||||
@Scheduled(cron = "0 0,30 * * * ?") // 每30分钟执行一次
|
||||
private void forwardGnss() {
|
||||
logger.info("forwardGnss");
|
||||
forwardCurrentGnss(FORWARDER_NAME);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user