|
|
|
@ -22,18 +22,25 @@ public class AssetItem {
|
|
|
|
|
|
|
|
|
|
public static AssetItem fromData(Map<String, Object> map, String timeField,
|
|
|
|
|
I2relation relation, List<SyncFieldsInfo> fieldList) {
|
|
|
|
|
AssetItem root = new AssetItem();
|
|
|
|
|
root.setAssetCode(relation.getSensorid());
|
|
|
|
|
|
|
|
|
|
List<AttributeItem> list = new ArrayList<>();
|
|
|
|
|
for (SyncFieldsInfo field : fieldList) {
|
|
|
|
|
if (relation.getSensorindex().equals(field.getSensorindex())) {
|
|
|
|
|
AttributeItem item = AttributeItem.fromData(map, field);
|
|
|
|
|
list.add(item);
|
|
|
|
|
if (item != null) {
|
|
|
|
|
list.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
root.setAttributeList(list);
|
|
|
|
|
LocalDateTime time = (LocalDateTime) map.get(timeField);
|
|
|
|
|
root.setTimestamp(time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
|
|
|
|
return root;
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
AssetItem root = new AssetItem();
|
|
|
|
|
root.setAssetCode(relation.getSensorid());
|
|
|
|
|
root.setAttributeList(list);
|
|
|
|
|
LocalDateTime time = (LocalDateTime) map.get(timeField);
|
|
|
|
|
root.setTimestamp(time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
|
|
|
|
return root;
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|