Browse Source
Merge pull request #13305 from irynamatveieva/improvements/calculated-field
Msg ts in calculated field: added check for timestamp
pull/13272/head
Viacheslav Klimov
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
3 additions and
5 deletions
-
application/src/main/java/org/thingsboard/server/controller/CalculatedFieldController.java
-
application/src/main/java/org/thingsboard/server/service/cf/ctx/state/BaseCalculatedFieldState.java
|
|
|
@ -277,7 +277,7 @@ public class CalculatedFieldController extends BaseController { |
|
|
|
lastUpdateTimestamp = Math.max(lastUpdateTimestamp, maxTs); |
|
|
|
} |
|
|
|
} |
|
|
|
return lastUpdateTimestamp; |
|
|
|
return lastUpdateTimestamp == -1 ? System.currentTimeMillis() : lastUpdateTimestamp; |
|
|
|
} |
|
|
|
|
|
|
|
private <E extends HasId<I> & HasTenantId, I extends EntityId> void checkReferencedEntities(CalculatedFieldConfiguration calculatedFieldConfig, SecurityUser user) throws ThingsboardException { |
|
|
|
|
|
|
|
@ -113,10 +113,8 @@ public abstract class BaseCalculatedFieldState implements CalculatedFieldState { |
|
|
|
if (entry instanceof SingleValueArgumentEntry singleValueArgumentEntry) { |
|
|
|
this.lastUpdateTimestamp = singleValueArgumentEntry.getTs(); |
|
|
|
} else if (entry instanceof TsRollingArgumentEntry tsRollingArgumentEntry) { |
|
|
|
Map.Entry<Long, Double> lastEntry = tsRollingArgumentEntry.getTsRecords().pollLastEntry(); |
|
|
|
if (lastEntry != null) { |
|
|
|
this.lastUpdateTimestamp = lastEntry.getKey(); |
|
|
|
} |
|
|
|
Map.Entry<Long, Double> lastEntry = tsRollingArgumentEntry.getTsRecords().lastEntry(); |
|
|
|
this.lastUpdateTimestamp = (lastEntry != null) ? lastEntry.getKey() : System.currentTimeMillis(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|