minor refactoring code to get OTA package id
This commit is contained in:
parent
cc3372d963
commit
7914f3d1d0
@ -181,22 +181,11 @@ public class DefaultOtaPackageStateService implements OtaPackageStateService {
|
|||||||
|
|
||||||
private void update(TenantId tenantId, DeviceProfile deviceProfile, OtaPackageType otaPackageType) {
|
private void update(TenantId tenantId, DeviceProfile deviceProfile, OtaPackageType otaPackageType) {
|
||||||
Consumer<Device> updateConsumer;
|
Consumer<Device> updateConsumer;
|
||||||
OtaPackageId packageId = null;
|
OtaPackageId packageId = otaPackageType.equals(FIRMWARE)? deviceProfile.getFirmwareId() : deviceProfile.getSoftwareId();
|
||||||
if (otaPackageType.equals(FIRMWARE)) {
|
|
||||||
if (deviceProfile.getFirmwareId() != null) {
|
|
||||||
packageId = deviceProfile.getFirmwareId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (otaPackageType.equals(SOFTWARE)) {
|
|
||||||
if (deviceProfile.getSoftwareId() != null) {
|
|
||||||
packageId = deviceProfile.getSoftwareId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packageId != null) {
|
if (packageId != null) {
|
||||||
long ts = System.currentTimeMillis();
|
long ts = System.currentTimeMillis();
|
||||||
OtaPackageId finalPackageId = packageId;
|
updateConsumer = d -> send(d.getTenantId(), d.getId(), packageId, ts, otaPackageType);
|
||||||
updateConsumer = d -> send(d.getTenantId(), d.getId(), finalPackageId, ts, otaPackageType);
|
|
||||||
} else {
|
} else {
|
||||||
updateConsumer = d -> remove(d, otaPackageType);
|
updateConsumer = d -> remove(d, otaPackageType);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user