1、微服务间调用加异常捕获
This commit is contained in:
parent
eb0e0e9453
commit
5501f0bb05
@ -271,7 +271,7 @@ public class Forwarder {
|
||||
}
|
||||
|
||||
void insertData(GnssStatus offDevice,GnssStatus refDevice){
|
||||
logger.info("insertData");
|
||||
logger.info("insertData based on {}",refDevice.getDeviceid());
|
||||
QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("deviceid",refDevice.getDeviceid());
|
||||
queryWrapper.eq("enabled",true);
|
||||
|
||||
@ -26,6 +26,8 @@ public class GNSSCalcFilterService {
|
||||
private GnssGroupCalcMapper groupCalcMapper;
|
||||
@Autowired
|
||||
private GnssCalcDataMapper repository;
|
||||
@Autowired
|
||||
private GnssMsgMapper msgMapper;
|
||||
|
||||
public static final int FILTER_MIN_CYCLE_HOUR = 2;
|
||||
public static final int FILTER_DEFAULT_CYCLE_HOUR = 8;
|
||||
@ -107,10 +109,10 @@ public class GNSSCalcFilterService {
|
||||
query.orderByDesc("createtime");
|
||||
|
||||
List<GnssCalcData> gnssDeviceLocationRecords = repository.selectList(query);
|
||||
logger.info(deviceId + " select records from "+filterAfterTime.format(dateFormatter)+
|
||||
/* logger.debug(deviceId + " select records from "+filterAfterTime.format(dateFormatter)+
|
||||
" to "+newRecordTime.format(dateFormatter)+
|
||||
", record num:"+gnssDeviceLocationRecords.size());
|
||||
|
||||
*/
|
||||
if(gnssDeviceLocationRecords.size() == 0){
|
||||
//第一个点无参考,当作坏点处理
|
||||
newRecord.setEnabled(false);
|
||||
@ -162,7 +164,7 @@ public class GNSSCalcFilterService {
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info(deviceId + " filter records num: " + count+", min cycle num: "+minCount);
|
||||
logger.debug("{} filter records num: {}",deviceId,count);
|
||||
if (count >= FILTER_MIN_RECORD_NUM) {
|
||||
newRecord.setRpose(NumberUtils.scaleTwo(sumE / count));
|
||||
newRecord.setRposn(NumberUtils.scaleTwo(sumN / count));
|
||||
@ -198,7 +200,8 @@ public class GNSSCalcFilterService {
|
||||
varyCycle.startTime = now;
|
||||
varyCycle.filterCycleHour = groupCalc.getFilter_min_hour();
|
||||
autoCycleDevices.put(deviceId, varyCycle);
|
||||
logger.info(deviceId + ": filter cycle change to " + varyCycle.filterCycleHour);
|
||||
saveMsg(deviceId, curCalcData.getTenantid(),
|
||||
"filter cycle changed to"+varyCycle.filterCycleHour,now);
|
||||
}
|
||||
else {
|
||||
VaryFilterCycle varyCycle = autoCycleDevices.get(deviceId);
|
||||
@ -211,7 +214,8 @@ public class GNSSCalcFilterService {
|
||||
if (now.isAfter(varyCycle.startTime.plusHours(1))) {
|
||||
varyCycle.filterCycleHour++;
|
||||
varyCycle.startTime = now;
|
||||
logger.info(deviceId + ": refresh filter cycle "+varyCycle.filterCycleHour);
|
||||
saveMsg(deviceId, curCalcData.getTenantid(),
|
||||
"filter cycle changed to"+varyCycle.filterCycleHour,now);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -242,8 +246,25 @@ public class GNSSCalcFilterService {
|
||||
groupCalc.getXy_threshold(), groupCalc.getZ_threshold(), groupCalc.getAdv_filter());
|
||||
repository.updateById(calcData);
|
||||
lastTime = calcData.getCreatetime();
|
||||
logger.info(deviceId + " update rpos");
|
||||
//logger.info(deviceId + " update rpos");
|
||||
}
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
void saveMsg(String deviceId, Integer tenantId, String content, LocalDateTime time){
|
||||
GnssMsg gnssMsg = new GnssMsg();
|
||||
gnssMsg.setTenantid(tenantId);
|
||||
gnssMsg.setCreatetime(time);
|
||||
gnssMsg.setDeviceid(deviceId);
|
||||
gnssMsg.setMsgtype(0);
|
||||
gnssMsg.setMsglen(content.length());
|
||||
gnssMsg.setTx(false);
|
||||
if(content.length()<=128) {
|
||||
gnssMsg.setContent(content);
|
||||
}
|
||||
else{
|
||||
gnssMsg.setContent(content.substring(0,120)+"...");
|
||||
}
|
||||
msgMapper.insert(gnssMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,12 @@ public class MultiLineGNSSCalcService {
|
||||
lastD342Time = new D342Time();
|
||||
deviceMap.put(deviceId, lastD342Time);
|
||||
// 产生断点补传通知
|
||||
beidouClient.onGnssUpload(deviceId, d342Message.getTenantId(), msgTime, "session begin");
|
||||
try {
|
||||
beidouClient.onGnssUpload(deviceId, d342Message.getTenantId(), msgTime, "session begin");
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
GnssStatus gnssStatus = dataPersistService.getDeviceState(deviceId);
|
||||
if (gnssStatus != null) {
|
||||
gnssStatus.setUpdatetime(LocalDateTime.now());
|
||||
@ -93,7 +98,12 @@ public class MultiLineGNSSCalcService {
|
||||
void d342SessionDone(String deviceId, Integer tenantId, LocalDateTime lastDate){
|
||||
//补传结束指示
|
||||
logger.info(deviceId + " d342 session done! "+lastDate);
|
||||
beidouClient.onGnssUploadComplete(deviceId,tenantId, lastDate);
|
||||
try {
|
||||
beidouClient.onGnssUploadComplete(deviceId, tenantId, lastDate);
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
// 计算上轮结果
|
||||
calcService.calSingleDone(deviceId, tenantId, lastDate);
|
||||
// 重算最近的
|
||||
|
||||
@ -28,7 +28,13 @@ public class D31xConfigAckMessageExecutor implements Executor<D31xConfigAckMessa
|
||||
if(device == null) return null;
|
||||
message.setTenantId(device.getTenantId());
|
||||
// 转发应答
|
||||
beidouClient.onConfigAck(message.getId(), device.getTenantId(), ByteUtil.bytesToHexString(message.getSrcData()));
|
||||
try {
|
||||
beidouClient.onConfigAck(message.getId(), device.getTenantId(),
|
||||
ByteUtil.bytesToHexString(message.getSrcData()));
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -43,12 +43,17 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
||||
|
||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||
GnssStatus lastGnssStatus = dataPersistService.getDeviceState(message.getId());
|
||||
if(lastGnssStatus!=null && lastGnssStatus.getState() == GnssStatus.STATE_OFFLINE){
|
||||
beidouClient.onLine(lastGnssStatus.getDeviceid(), lastGnssStatus.getTenantid(), lastGnssStatus.getUpdatetime());
|
||||
try {
|
||||
if (lastGnssStatus != null && lastGnssStatus.getState() == GnssStatus.STATE_OFFLINE) {
|
||||
beidouClient.onLine(lastGnssStatus.getDeviceid(),
|
||||
lastGnssStatus.getTenantid(), lastGnssStatus.getUpdatetime());
|
||||
} else {
|
||||
// 通知beidou服务设备上线
|
||||
beidouClient.onDeviceActive(message.getId(), device.getTenantId());
|
||||
}
|
||||
}
|
||||
else{
|
||||
// 通知beidou服务设备上线
|
||||
beidouClient.onDeviceActive(message.getId(), device.getTenantId());
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
dataPersistService.saveDeviceState(message);
|
||||
});
|
||||
|
||||
@ -60,12 +60,17 @@ public class D3F2StopIndicationMessageExecutor implements Executor<D3F2StopIndic
|
||||
device.getDeviceId(), device.getTenantId());
|
||||
dataPersistService.saveDeviceTrxStat(message, (uploadTime!=null), device);
|
||||
// 通知beidou服务设备休眠
|
||||
beidouClient.onDeviceStop(deviceId,device.getTenantId());
|
||||
if(uploadTime!=null){
|
||||
String info = "d342 num:"+device.getD342Count()+
|
||||
", bytes:"+device.getD342Bytes()+
|
||||
", d341 included:"+device.getD341In42Count();
|
||||
beidouClient.onGnssUpload(deviceId,device.getTenantId(),uploadTime,info);
|
||||
try {
|
||||
beidouClient.onDeviceStop(deviceId, device.getTenantId());
|
||||
if (uploadTime != null) {
|
||||
String info = "d342 num:" + device.getD342Count() +
|
||||
", bytes:" + device.getD342Bytes() +
|
||||
", d341 included:" + device.getD341In42Count();
|
||||
beidouClient.onGnssUpload(deviceId, device.getTenantId(), uploadTime, info);
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
// 检查告警
|
||||
if(device.getDeviceType() == Device.DEVICE_BASE_STATION) {
|
||||
|
||||
@ -129,8 +129,12 @@ public class DataPersistServiceImpl implements DataPersistService {
|
||||
gnssMsg.setMsgtype(message.getHeader());
|
||||
gnssMsg.setMsglen(message.getLen());
|
||||
gnssMsg.setTx(false);
|
||||
if(content!=null && content.length()<=128) {
|
||||
gnssMsg.setContent(content);
|
||||
if(content!=null) {
|
||||
if (content.length() <= 128) {
|
||||
gnssMsg.setContent(content);
|
||||
} else {
|
||||
gnssMsg.setContent(content.substring(0, 120) + "...");
|
||||
}
|
||||
}
|
||||
msgMapper.insert(gnssMsg);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user