|
|
|
@ -63,7 +63,7 @@ public class F10Service { |
|
|
|
} else if (208 == src.length) { |
|
|
|
handle208(rawEntity); |
|
|
|
} else { |
|
|
|
log.warn("原始报文长度不是328或者208字节"); |
|
|
|
log.warn("[F10] 原始报文长度不是328或者208字节"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -89,7 +89,7 @@ public class F10Service { |
|
|
|
try { |
|
|
|
latestTs = Long.parseLong(latestTsStr); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("Redis数据异常,无法转换为Long: key={}, value={}", redisKey, latestTsStr); |
|
|
|
log.error("[F10] Redis数据异常,无法转换为Long: key={}, value={}", redisKey, latestTsStr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -104,31 +104,33 @@ public class F10Service { |
|
|
|
redisUtils.add(redisKey, String.valueOf(receivedCurrentTs)); |
|
|
|
} else if (receivedCurrentTs == latestTs) { |
|
|
|
// 重复数据 → 直接丢弃
|
|
|
|
log.warn("重复处理,丢弃 deviceId={}", f10ProcessingData.getGatewayId()); |
|
|
|
log.warn("重复处理,丢弃 gatewayId={}", f10ProcessingData.getGatewayId()); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
// 旧数据 → 标记过期
|
|
|
|
isExpired = true; |
|
|
|
log.warn("[F10] 过期数据, gatewayId={}", f10ProcessingData.getGatewayId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TopCompanyInfo topCompanyInfo= commonOpt.getCompanyIdByDevicePrefix(f10ProcessingData.getGatewayId() + "_"); |
|
|
|
if (topCompanyInfo==null || "0".equals(topCompanyInfo.getTopCompanyId())){ |
|
|
|
log.error("no companyId is found========================>>>> {}",f10ProcessingData.getGatewayId()); |
|
|
|
log.error("[F10] no companyId is found========================>>>> {}",f10ProcessingData.getGatewayId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
DataSourceContextHolder.clearCurrentDataSourceKey(); |
|
|
|
DataSourceContextHolder.setCurrentDataSourceKey("dataSourceForCompany_"+topCompanyInfo.getTopCompanyId()); |
|
|
|
|
|
|
|
log.info("Use datasource for company:"+topCompanyInfo.getTopCompanyId()); |
|
|
|
log.info("[F10] Use datasource for company:"+topCompanyInfo.getTopCompanyId()); |
|
|
|
|
|
|
|
Long companyId = Long.valueOf(topCompanyInfo.getSelfCompanyId()); |
|
|
|
f10ProcessingData.setCompanyId(companyId); |
|
|
|
|
|
|
|
f10Dao.insertF10ProcessingData(f10ProcessingData); |
|
|
|
log.info("[F10] 解析入库成功, gatewayId: {}", f10ProcessingData.getGatewayId()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("F10解析入库失败", e); |
|
|
|
log.error("[F10] F10解析208入库失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -158,7 +160,7 @@ public class F10Service { |
|
|
|
try { |
|
|
|
latestTs = Long.parseLong(latestTsStr); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("Redis数据异常,无法转换为Long: key={}, value={}", redisKey, latestTsStr); |
|
|
|
log.error("[F10] Redis数据异常,无法转换为Long: key={}, value={}", redisKey, latestTsStr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -173,28 +175,29 @@ public class F10Service { |
|
|
|
redisUtils.add(redisKey, String.valueOf(receivedCurrentTs)); |
|
|
|
} else if (receivedCurrentTs == latestTs) { |
|
|
|
// 重复数据 → 直接丢弃
|
|
|
|
log.warn("重复告警,丢弃 deviceId={}", f10JournalLog.getDeviceId()); |
|
|
|
log.warn("[F10] 重复告警, 丢弃 deviceId={}", f10JournalLog.getDeviceId()); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
// 旧数据 → 标记过期
|
|
|
|
isExpired = true; |
|
|
|
log.warn("[F10] 过期数据, deviceId={}", f10JournalLog.getDeviceId()); |
|
|
|
} |
|
|
|
} |
|
|
|
f10JournalLog.setExpiredFlag(isExpired ? 1 : 0); |
|
|
|
|
|
|
|
String topCompanyId= commonOpt.getTopCompanyId(f10JournalLog.getDeviceId()); |
|
|
|
if (topCompanyId==null || topCompanyId.equals("0")){ |
|
|
|
log.error("no companyId is found========================>>>> {}",f10JournalLog.getDeviceId()); |
|
|
|
log.error("[F10] no companyId is found========================>>>> {}",f10JournalLog.getDeviceId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
DataSourceContextHolder.clearCurrentDataSourceKey(); |
|
|
|
DataSourceContextHolder.setCurrentDataSourceKey("dataSourceForCompany_"+topCompanyId); |
|
|
|
|
|
|
|
log.info("Use datasource for company:"+topCompanyId); |
|
|
|
log.info("[F10] Use datasource for company:"+topCompanyId); |
|
|
|
List<DeviceEntity> deviceEntity=this.deviceDao.getDeviceInfoByDeviceId(f10JournalLog.getDeviceId()); |
|
|
|
this.guavaRedisCache.incrementDailyDeviceIdCount(f10JournalLog.getDeviceId()); |
|
|
|
if (CollectionUtil.isEmpty(deviceEntity)){ |
|
|
|
log.error("no deviceEntity is found========================>>>> {}",f10JournalLog.getDeviceId()); |
|
|
|
log.error("[F10] no deviceEntity is found========================>>>> {}",f10JournalLog.getDeviceId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -228,9 +231,10 @@ public class F10Service { |
|
|
|
|
|
|
|
|
|
|
|
f10Dao.insertF10Log(f10JournalLog); |
|
|
|
log.info("[F10] 解析入库成功, deviceId: {}", f10JournalLog.getDeviceId()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("F10解析入库失败", e); |
|
|
|
log.error("[F10] F10解析308入库失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|