|
|
@ -59,6 +59,27 @@ public class CsdjService { |
|
|
log.info("[CSDJ] 开始处理 CSDJ 数据,terminalId:{}, data:{}", |
|
|
log.info("[CSDJ] 开始处理 CSDJ 数据,terminalId:{}, data:{}", |
|
|
csdjEntity.getTerminalId(), csdjEntity.getData()); |
|
|
csdjEntity.getTerminalId(), csdjEntity.getData()); |
|
|
|
|
|
|
|
|
|
|
|
String terminalId = csdjEntity.getTerminalId(); |
|
|
|
|
|
|
|
|
|
|
|
String topCompanyId= commonOpt.getTopCompanyId(terminalId); |
|
|
|
|
|
if (topCompanyId==null || topCompanyId.equals("0")){ |
|
|
|
|
|
log.error("no companyId is found========================>>>> {}",terminalId); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
DataSourceContextHolder.clearCurrentDataSourceKey(); |
|
|
|
|
|
DataSourceContextHolder.setCurrentDataSourceKey("dataSourceForCompany_"+topCompanyId); |
|
|
|
|
|
|
|
|
|
|
|
log.info("Use datasource for company:"+topCompanyId); |
|
|
|
|
|
|
|
|
|
|
|
long currentTs = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
//存入 csdj_log 表
|
|
|
|
|
|
csdjDao.insertCsdjLog( |
|
|
|
|
|
csdjEntity.getTerminalId(), |
|
|
|
|
|
csdjEntity.getData(), |
|
|
|
|
|
csdjEntity.getTs() |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
// 1. 解析通報数据
|
|
|
// 1. 解析通報数据
|
|
|
CsdjNotificationData notificationData = csdjNotificationParser.parse(csdjEntity.getData()); |
|
|
CsdjNotificationData notificationData = csdjNotificationParser.parse(csdjEntity.getData()); |
|
|
if (notificationData == null) { |
|
|
if (notificationData == null) { |
|
|
@ -88,6 +109,20 @@ public class CsdjService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 处理デジタル入力端子的告警/恢复 |
|
|
* 处理デジタル入力端子的告警/恢复 |
|
|
|
|
|
* |
|
|
|
|
|
* 告警: |
|
|
|
|
|
* { |
|
|
|
|
|
* "terminalId": "TEST002", |
|
|
|
|
|
* "data": "00 0E 07 00 25 06 20 0E 00 00 00 C0 01 08 01 00 00 00 00", |
|
|
|
|
|
* "ts": "1782272698000" |
|
|
|
|
|
* } |
|
|
|
|
|
* |
|
|
|
|
|
* 恢复: |
|
|
|
|
|
* { |
|
|
|
|
|
* "terminalId": "TEST002", |
|
|
|
|
|
* "data": "00 0E 07 00 25 06 20 0E 00 00 00 C0 01 00 01 00 00 00 00", |
|
|
|
|
|
* "ts": "1782272698000" |
|
|
|
|
|
* } |
|
|
*/ |
|
|
*/ |
|
|
private void processDigitalTerminal(CsdjEntity csdjEntity, CsdjNotificationData notificationData, CsdjDigitalInputTerminal terminal) { |
|
|
private void processDigitalTerminal(CsdjEntity csdjEntity, CsdjNotificationData notificationData, CsdjDigitalInputTerminal terminal) { |
|
|
String terminalId = csdjEntity.getTerminalId(); |
|
|
String terminalId = csdjEntity.getTerminalId(); |
|
|
@ -116,23 +151,12 @@ public class CsdjService { |
|
|
// terminalId, terminalNo, stateText);
|
|
|
// terminalId, terminalNo, stateText);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
String topCompanyId= commonOpt.getTopCompanyId(terminalId); |
|
|
|
|
|
if (topCompanyId==null || topCompanyId.equals("0")){ |
|
|
|
|
|
log.error("no companyId is found========================>>>> {}",terminalId); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
DataSourceContextHolder.clearCurrentDataSourceKey(); |
|
|
|
|
|
DataSourceContextHolder.setCurrentDataSourceKey("dataSourceForCompany_"+topCompanyId); |
|
|
|
|
|
|
|
|
|
|
|
log.info("Use datasource for company:"+topCompanyId); |
|
|
|
|
|
List<DeviceEntity> deviceEntity=this.deviceDao.getDeviceInfoByDeviceId(terminalId); |
|
|
List<DeviceEntity> deviceEntity=this.deviceDao.getDeviceInfoByDeviceId(terminalId); |
|
|
this.guavaRedisCache.incrementDailyDeviceIdCount(terminalId); |
|
|
this.guavaRedisCache.incrementDailyDeviceIdCount(terminalId); |
|
|
if (CollectionUtil.isEmpty(deviceEntity)){ |
|
|
if (CollectionUtil.isEmpty(deviceEntity)){ |
|
|
log.error("no deviceEntity is found========================>>>> {}",terminalId); |
|
|
log.error("no deviceEntity is found========================>>>> {}",terminalId); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
long currentTs = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
Long companyId = deviceEntity.get(0).getCompanyId(); |
|
|
Long companyId = deviceEntity.get(0).getCompanyId(); |
|
|
|
|
|
|
|
|
@ -162,7 +186,7 @@ public class CsdjService { |
|
|
dataProcessService.setAlertBlock(deviceInfoVO); |
|
|
dataProcessService.setAlertBlock(deviceInfoVO); |
|
|
entity.setAlertBlock(deviceInfoVO.getAlertBlock()); |
|
|
entity.setAlertBlock(deviceInfoVO.getAlertBlock()); |
|
|
|
|
|
|
|
|
entity.setReceive_ts(currentTs); |
|
|
entity.setReceive_ts(csdjEntity.getTs()); |
|
|
Long dbId = dashboardAlertDao.insertAlertHistory(entity, 3); |
|
|
Long dbId = dashboardAlertDao.insertAlertHistory(entity, 3); |
|
|
csdjAlarmHistory.setAlertHistoryId(dbId); |
|
|
csdjAlarmHistory.setAlertHistoryId(dbId); |
|
|
|
|
|
|
|
|
|