fixed tests
This commit is contained in:
parent
5563da7c0d
commit
33eac2f778
@ -80,14 +80,15 @@ public class TbAlarmCountSubCtx extends TbAbstractEntityQuerySubCtx<AlarmCountQu
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int countAlarms() {
|
private int countAlarms() {
|
||||||
|
List<EntityId> entityIds = null;
|
||||||
|
if (query.getEntityFilter() != null) {
|
||||||
PageData<EntityData> data = entityService.findEntityDataByQuery(getTenantId(), getCustomerId(), buildEntityDataQuery());
|
PageData<EntityData> data = entityService.findEntityDataByQuery(getTenantId(), getCustomerId(), buildEntityDataQuery());
|
||||||
List<EntityId> entityIds = data.getData().stream().map(EntityData::getEntityId).toList();
|
if (data.getData().isEmpty()) {
|
||||||
if (entityIds.isEmpty()) {
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
return (int) alarmService.countAlarmsByQuery(getTenantId(), getCustomerId(), query, entityIds);
|
|
||||||
}
|
}
|
||||||
|
entityIds = data.getData().stream().map(EntityData::getEntityId).toList();
|
||||||
|
}
|
||||||
|
return (int) alarmService.countAlarmsByQuery(getTenantId(), getCustomerId(), query, entityIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntityDataQuery buildEntityDataQuery() {
|
private EntityDataQuery buildEntityDataQuery() {
|
||||||
|
|||||||
@ -17,9 +17,8 @@ package org.thingsboard.server.common.data.query;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.thingsboard.server.common.data.alarm.AlarmSearchStatus;
|
import org.thingsboard.server.common.data.alarm.AlarmSearchStatus;
|
||||||
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
|
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
|
||||||
@ -30,8 +29,7 @@ import java.util.List;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
@ToString
|
||||||
public class AlarmCountQuery extends EntityCountQuery {
|
public class AlarmCountQuery extends EntityCountQuery {
|
||||||
private long startTs;
|
private long startTs;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import java.util.List;
|
|||||||
public class EntityCountQuery {
|
public class EntityCountQuery {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
protected EntityFilter entityFilter;
|
private EntityFilter entityFilter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
protected List<KeyFilter> keyFilters;
|
protected List<KeyFilter> keyFilters;
|
||||||
|
|||||||
@ -351,8 +351,7 @@ public class BaseAlarmService extends AbstractCachedEntityService<TenantId, Page
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countAlarmsByQuery(TenantId tenantId, CustomerId customerId, AlarmCountQuery query) {
|
public long countAlarmsByQuery(TenantId tenantId, CustomerId customerId, AlarmCountQuery query) {
|
||||||
validateId(tenantId, id -> INCORRECT_TENANT_ID + id);
|
return countAlarmsByQuery(tenantId, customerId, query, null);
|
||||||
return alarmDao.countAlarmsByQuery(tenantId, customerId, query, Collections.emptyList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -327,7 +327,7 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository {
|
|||||||
ctx.append(" and a.customer_id = :customerId and ea.customer_id = :customerId");
|
ctx.append(" and a.customer_id = :customerId and ea.customer_id = :customerId");
|
||||||
ctx.addUuidParameter("customerId", customerId.getId());
|
ctx.addUuidParameter("customerId", customerId.getId());
|
||||||
}
|
}
|
||||||
if (!orderedEntityIds.isEmpty()) {
|
if (orderedEntityIds != null) {
|
||||||
ctx.addUuidListParameter("entity_filter_entity_ids", orderedEntityIds.stream().map(EntityId::getId).collect(Collectors.toList()));
|
ctx.addUuidListParameter("entity_filter_entity_ids", orderedEntityIds.stream().map(EntityId::getId).collect(Collectors.toList()));
|
||||||
ctx.append(" and ea.entity_id in (:entity_filter_entity_ids)");
|
ctx.append(" and ea.entity_id in (:entity_filter_entity_ids)");
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository {
|
|||||||
ctx.append(" and a.customer_id = :customerId");
|
ctx.append(" and a.customer_id = :customerId");
|
||||||
ctx.addUuidParameter("customerId", customerId.getId());
|
ctx.addUuidParameter("customerId", customerId.getId());
|
||||||
}
|
}
|
||||||
if (!orderedEntityIds.isEmpty()) {
|
if (orderedEntityIds != null) {
|
||||||
ctx.addUuidListParameter("entity_filter_entity_ids", orderedEntityIds.stream().map(EntityId::getId).collect(Collectors.toList()));
|
ctx.addUuidListParameter("entity_filter_entity_ids", orderedEntityIds.stream().map(EntityId::getId).collect(Collectors.toList()));
|
||||||
ctx.append(" and a.originator_id in (:entity_filter_entity_ids)");
|
ctx.append(" and a.originator_id in (:entity_filter_entity_ids)");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user