Refactoring
This commit is contained in:
parent
5338d8e094
commit
c24db73a37
@ -42,9 +42,9 @@ public class SessionInfoCreator {
|
|||||||
if (!"null".equals(msg.getDeviceInfo().getAdditionalInfo())) {
|
if (!"null".equals(msg.getDeviceInfo().getAdditionalInfo())) {
|
||||||
try {
|
try {
|
||||||
JsonNode infoNode = context.getMapper().readTree(msg.getDeviceInfo().getAdditionalInfo());
|
JsonNode infoNode = context.getMapper().readTree(msg.getDeviceInfo().getAdditionalInfo());
|
||||||
if (infoNode.get("gateway").asBoolean(false)) {
|
if (infoNode.get("gateway").asBoolean()) {
|
||||||
boolean activityTimeFromGatewayDevice = false;
|
boolean activityTimeFromGatewayDevice = false;
|
||||||
if (infoNode.get("activityTimeFromGatewayDevice") != null) {
|
if (infoNode.has("activityTimeFromGatewayDevice")) {
|
||||||
activityTimeFromGatewayDevice = infoNode.get("activityTimeFromGatewayDevice").asBoolean();
|
activityTimeFromGatewayDevice = infoNode.get("activityTimeFromGatewayDevice").asBoolean();
|
||||||
}
|
}
|
||||||
builder.setActivityTimeFromGatewayDevice(activityTimeFromGatewayDevice);
|
builder.setActivityTimeFromGatewayDevice(activityTimeFromGatewayDevice);
|
||||||
|
|||||||
@ -649,10 +649,10 @@ public class DefaultTransportService implements TransportService {
|
|||||||
Optional<Device> deviceOpt = dataDecodingEncodingService.decode(msg.getData().toByteArray());
|
Optional<Device> deviceOpt = dataDecodingEncodingService.decode(msg.getData().toByteArray());
|
||||||
if (deviceOpt.isPresent()) {
|
if (deviceOpt.isPresent()) {
|
||||||
Device device = deviceOpt.get();
|
Device device = deviceOpt.get();
|
||||||
if (device.getAdditionalInfo().get("gateway") != null && device.getAdditionalInfo().get("gateway").asBoolean()) {
|
if (device.getAdditionalInfo().has("gateway") && device.getAdditionalInfo().get("gateway").asBoolean()) {
|
||||||
sessions.forEach((uuid, currentMD) -> {
|
sessions.forEach((uuid, currentMD) -> {
|
||||||
if (device.getId().equals(new DeviceId(new UUID(currentMD.getSessionInfo().getDeviceIdMSB(), currentMD.getSessionInfo().getDeviceIdLSB())))) {
|
if (device.getId().equals(new DeviceId(new UUID(currentMD.getSessionInfo().getDeviceIdMSB(), currentMD.getSessionInfo().getDeviceIdLSB())))) {
|
||||||
boolean newActivityTimeFromGatewayDevice = device.getAdditionalInfo().get("activityTimeFromGatewayDevice").asBoolean(false);
|
boolean newActivityTimeFromGatewayDevice = device.getAdditionalInfo().get("activityTimeFromGatewayDevice").asBoolean();
|
||||||
if (currentMD.getSessionInfo().getActivityTimeFromGatewayDevice() != newActivityTimeFromGatewayDevice) {
|
if (currentMD.getSessionInfo().getActivityTimeFromGatewayDevice() != newActivityTimeFromGatewayDevice) {
|
||||||
SessionInfoProto currentSessionInfo = currentMD.getSessionInfo();
|
SessionInfoProto currentSessionInfo = currentMD.getSessionInfo();
|
||||||
SessionInfoProto newSessionInfo = SessionInfoProto.newBuilder()
|
SessionInfoProto newSessionInfo = SessionInfoProto.newBuilder()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user