|
|
@ -11,6 +11,7 @@ import com.techsor.datacenter.sender.dao.DeviceDao; |
|
|
import com.techsor.datacenter.sender.dto.DeviceInfoVO; |
|
|
import com.techsor.datacenter.sender.dto.DeviceInfoVO; |
|
|
import com.techsor.datacenter.sender.entitiy.DeviceEntity; |
|
|
import com.techsor.datacenter.sender.entitiy.DeviceEntity; |
|
|
import com.techsor.datacenter.sender.entitiy.DynamodbEntity; |
|
|
import com.techsor.datacenter.sender.entitiy.DynamodbEntity; |
|
|
|
|
|
import com.techsor.datacenter.sender.entitiy.company.TopCompanyInfo; |
|
|
import com.techsor.datacenter.sender.entitiy.csdj.*; |
|
|
import com.techsor.datacenter.sender.entitiy.csdj.*; |
|
|
import com.techsor.datacenter.sender.utils.csdj.CsdjNotificationParser; |
|
|
import com.techsor.datacenter.sender.utils.csdj.CsdjNotificationParser; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
@ -49,8 +50,15 @@ public class CsdjService { |
|
|
|
|
|
|
|
|
String terminalId = csdjEntity.getTerminalId(); |
|
|
String terminalId = csdjEntity.getTerminalId(); |
|
|
|
|
|
|
|
|
String topCompanyId = commonOpt.getTopCompanyId(terminalId); |
|
|
String deviceCompanyMappingRedisKey = "csdj:deviceCompanyMapping"; |
|
|
if (topCompanyId == null || topCompanyId.equals("0")) { |
|
|
TopCompanyInfo topCompanyInfo= commonOpt.getCompanyIdByDevicePrefix(deviceCompanyMappingRedisKey, terminalId + "-", 1012L); |
|
|
|
|
|
if (topCompanyInfo==null || "0".equals(topCompanyInfo.getTopCompanyId())){ |
|
|
|
|
|
log.error("[F10] no companyId is found========================>>>> {}",terminalId); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String topCompanyId = topCompanyInfo.getTopCompanyId(); |
|
|
|
|
|
if (topCompanyId == null) { |
|
|
log.error("no companyId is found========================>>>> {}", terminalId); |
|
|
log.error("no companyId is found========================>>>> {}", terminalId); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -59,13 +67,13 @@ public class CsdjService { |
|
|
|
|
|
|
|
|
log.info("Use datasource for company:" + topCompanyId); |
|
|
log.info("Use datasource for company:" + topCompanyId); |
|
|
|
|
|
|
|
|
List<DeviceEntity> deviceEntitys = this.deviceDao.getDeviceInfoByDeviceId(terminalId); |
|
|
// List<DeviceEntity> deviceEntitys = this.deviceDao.getDeviceInfoByDeviceId(terminalId);
|
|
|
this.guavaRedisCache.incrementDailyDeviceIdCount(terminalId); |
|
|
// this.guavaRedisCache.incrementDailyDeviceIdCount(terminalId);
|
|
|
if (CollectionUtil.isEmpty(deviceEntitys)) { |
|
|
// if (CollectionUtil.isEmpty(deviceEntitys)) {
|
|
|
log.error("no deviceEntity is found========================>>>> {}", terminalId); |
|
|
// log.error("no deviceEntity is found========================>>>> {}", terminalId);
|
|
|
return; |
|
|
// return;
|
|
|
} |
|
|
// }
|
|
|
DeviceEntity deviceEntity = deviceEntitys.get(0); |
|
|
// DeviceEntity deviceEntity = deviceEntitys.get(0);
|
|
|
|
|
|
|
|
|
// 1. 解析通報数据
|
|
|
// 1. 解析通報数据
|
|
|
CsdjNotificationData notificationData = csdjNotificationParser.parse(csdjEntity.getData()); |
|
|
CsdjNotificationData notificationData = csdjNotificationParser.parse(csdjEntity.getData()); |
|
|
@ -102,15 +110,15 @@ public class CsdjService { |
|
|
Map<String, Long> deviceAlertHistoryMap = new HashMap<>(); |
|
|
Map<String, Long> deviceAlertHistoryMap = new HashMap<>(); |
|
|
if (digitalTerminals != null && !digitalTerminals.isEmpty()) { |
|
|
if (digitalTerminals != null && !digitalTerminals.isEmpty()) { |
|
|
for (CsdjDigitalInputTerminal terminal : digitalTerminals) { |
|
|
for (CsdjDigitalInputTerminal terminal : digitalTerminals) { |
|
|
Map.Entry<String, Long> entry = processDigitalTerminal(csdjEntity, notificationData, terminal, deviceEntity); |
|
|
Map.Entry<String, Long> entry = processDigitalTerminal(csdjEntity, notificationData, terminal); |
|
|
if (entry.getValue() != null) { |
|
|
if (null != entry && entry.getValue() != null) { |
|
|
deviceAlertHistoryMap.put(entry.getKey(), entry.getValue()); |
|
|
deviceAlertHistoryMap.put(entry.getKey(), entry.getValue()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 5. 更新 csdj_device_realtime 表
|
|
|
// 5. 更新 csdj_device_realtime 表
|
|
|
Long companyId = deviceEntity.getCompanyId(); |
|
|
Long companyId = Long.valueOf(topCompanyInfo.getSelfCompanyId()); |
|
|
saveDeviceRealtime(terminalId, companyId, csdjEntity.getData(), notificationData, deviceAlertHistoryMap); |
|
|
saveDeviceRealtime(terminalId, companyId, csdjEntity.getData(), notificationData, deviceAlertHistoryMap); |
|
|
|
|
|
|
|
|
log.info("[CSDJ] 处理 CSDJ 数据完成,terminalId:{}", csdjEntity.getTerminalId()); |
|
|
log.info("[CSDJ] 处理 CSDJ 数据完成,terminalId:{}", csdjEntity.getTerminalId()); |
|
|
@ -120,7 +128,7 @@ public class CsdjService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private Map.Entry<String, Long> processDigitalTerminal(CsdjEntity csdjEntity, CsdjNotificationData notificationData, |
|
|
private Map.Entry<String, Long> processDigitalTerminal(CsdjEntity csdjEntity, CsdjNotificationData notificationData, |
|
|
CsdjDigitalInputTerminal terminal, DeviceEntity deviceEntity) { |
|
|
CsdjDigitalInputTerminal terminal) { |
|
|
String terminalId = csdjEntity.getTerminalId(); |
|
|
String terminalId = csdjEntity.getTerminalId(); |
|
|
String deviceId = terminal.getDeviceId(); |
|
|
String deviceId = terminal.getDeviceId(); |
|
|
Integer terminalNo = terminal.getTerminalNo(); |
|
|
Integer terminalNo = terminal.getTerminalNo(); |
|
|
@ -130,6 +138,15 @@ public class CsdjService { |
|
|
log.info("[CSDJ] デジタル入力端子,terminalId:{}, deviceId:{}, No:{}, state:{}, isAlarm:{}", |
|
|
log.info("[CSDJ] デジタル入力端子,terminalId:{}, deviceId:{}, No:{}, state:{}, isAlarm:{}", |
|
|
terminalId, deviceId, terminalNo, stateText, isAlarm); |
|
|
terminalId, deviceId, terminalNo, stateText, isAlarm); |
|
|
|
|
|
|
|
|
|
|
|
List<DeviceEntity> deviceEntitys = this.deviceDao.getDeviceInfoByDeviceId(deviceId); |
|
|
|
|
|
this.guavaRedisCache.incrementDailyDeviceIdCount(terminalId); |
|
|
|
|
|
if (CollectionUtil.isEmpty(deviceEntitys)) { |
|
|
|
|
|
log.error("no deviceEntity is found========================>>>> {}", terminalId); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
DeviceEntity deviceEntity = deviceEntitys.get(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long companyId = deviceEntity.getCompanyId(); |
|
|
Long companyId = deviceEntity.getCompanyId(); |
|
|
|
|
|
|
|
|
CsdjAlarmHistory csdjAlarmHistory = new CsdjAlarmHistory(); |
|
|
CsdjAlarmHistory csdjAlarmHistory = new CsdjAlarmHistory(); |
|
|
|