mirror of
https://github.com/traccar/traccar.git
synced 2025-01-09 04:07:38 +08:00
Add computed attributes priority
This commit is contained in:
parent
248a3927dd
commit
4ebc4c6ee6
@ -11,6 +11,12 @@
|
|||||||
<dropColumn tableName="tc_servers" columnName="twelvehourformat" />
|
<dropColumn tableName="tc_servers" columnName="twelvehourformat" />
|
||||||
<dropColumn tableName="tc_users" columnName="twelvehourformat" />
|
<dropColumn tableName="tc_users" columnName="twelvehourformat" />
|
||||||
|
|
||||||
|
<addColumn tableName="tc_attributes">
|
||||||
|
<column name="priority" type="INT" defaultValueNumeric="0">
|
||||||
|
<constraints nullable="false" />
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
@ -35,13 +35,14 @@ import org.traccar.session.cache.CacheManager;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ComputedAttributesHandler extends BasePositionHandler {
|
public class ComputedAttributesHandler extends BasePositionHandler {
|
||||||
|
|
||||||
@ -140,7 +141,9 @@ public class ComputedAttributesHandler extends BasePositionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePosition(Position position, Callback callback) {
|
public void handlePosition(Position position, Callback callback) {
|
||||||
Collection<Attribute> attributes = cacheManager.getDeviceObjects(position.getDeviceId(), Attribute.class);
|
var attributes = cacheManager.getDeviceObjects(position.getDeviceId(), Attribute.class).stream()
|
||||||
|
.sorted(Comparator.comparing(Attribute::getPriority).reversed())
|
||||||
|
.collect(Collectors.toUnmodifiableList());
|
||||||
for (Attribute attribute : attributes) {
|
for (Attribute attribute : attributes) {
|
||||||
if (attribute.getAttribute() != null) {
|
if (attribute.getAttribute() != null) {
|
||||||
Object result = null;
|
Object result = null;
|
||||||
|
@ -61,4 +61,14 @@ public class Attribute extends BaseModel {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int priority;
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriority(int priority) {
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user