Updated findSeverity method
This commit is contained in:
parent
37bc889f11
commit
f9e1077bca
@ -374,13 +374,9 @@ public class AlarmController extends BaseController {
|
|||||||
throw new ThingsboardException("Invalid alarms search query: Both parameters 'searchStatus' " +
|
throw new ThingsboardException("Invalid alarms search query: Both parameters 'searchStatus' " +
|
||||||
"and 'status' can't be specified at the same time!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
"and 'status' can't be specified at the same time!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||||
}
|
}
|
||||||
UserId assigneeUserId = null;
|
|
||||||
if (assigneeId != null) {
|
|
||||||
assigneeUserId = new UserId(UUID.fromString(assigneeId));
|
|
||||||
}
|
|
||||||
checkEntityId(entityId, Operation.READ);
|
checkEntityId(entityId, Operation.READ);
|
||||||
try {
|
try {
|
||||||
return alarmService.findHighestAlarmSeverity(getCurrentUser().getTenantId(), entityId, alarmSearchStatus, alarmStatus, assigneeUserId);
|
return alarmService.findHighestAlarmSeverity(getCurrentUser().getTenantId(), entityId, alarmSearchStatus, alarmStatus, assigneeId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,8 +165,8 @@ public class DefaultAlarmSubscriptionService extends AbstractSubscriptionService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus, UserId assigneeUserId) {
|
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus, String assigneeId) {
|
||||||
return alarmService.findHighestAlarmSeverity(tenantId, entityId, alarmSearchStatus, alarmStatus, assigneeUserId);
|
return alarmService.findHighestAlarmSeverity(tenantId, entityId, alarmSearchStatus, alarmStatus, assigneeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public interface AlarmService extends EntityDaoService {
|
|||||||
ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query);
|
ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query);
|
||||||
|
|
||||||
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
||||||
AlarmStatus alarmStatus, UserId assigneeUserId);
|
AlarmStatus alarmStatus, String assigneeId);
|
||||||
|
|
||||||
ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type);
|
ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type);
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public interface AlarmDao extends Dao<Alarm> {
|
|||||||
|
|
||||||
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
||||||
|
|
||||||
Set<AlarmSeverity> findAlarmSeverities(TenantId tenantId, EntityId entityId, Set<AlarmStatus> status, UserId assigneeUserId);
|
Set<AlarmSeverity> findAlarmSeverities(TenantId tenantId, EntityId entityId, Set<AlarmStatus> status, String assigneeId);
|
||||||
|
|
||||||
PageData<AlarmId> findAlarmsIdsByEndTsBeforeAndTenantId(Long time, TenantId tenantId, PageLink pageLink);
|
PageData<AlarmId> findAlarmsIdsByEndTsBeforeAndTenantId(Long time, TenantId tenantId, PageLink pageLink);
|
||||||
|
|
||||||
|
|||||||
@ -371,7 +371,7 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
||||||
AlarmStatus alarmStatus, UserId assigneeUserId) {
|
AlarmStatus alarmStatus, String assigneeId) {
|
||||||
Set<AlarmStatus> statusList = null;
|
Set<AlarmStatus> statusList = null;
|
||||||
if (alarmSearchStatus != null) {
|
if (alarmSearchStatus != null) {
|
||||||
statusList = alarmSearchStatus.getStatuses();
|
statusList = alarmSearchStatus.getStatuses();
|
||||||
@ -379,7 +379,7 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
|
|||||||
statusList = Collections.singleton(alarmStatus);
|
statusList = Collections.singleton(alarmStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<AlarmSeverity> alarmSeverities = alarmDao.findAlarmSeverities(tenantId, entityId, statusList, assigneeUserId);
|
Set<AlarmSeverity> alarmSeverities = alarmDao.findAlarmSeverities(tenantId, entityId, statusList, assigneeId);
|
||||||
|
|
||||||
return alarmSeverities.stream().min(AlarmSeverity::compareTo).orElse(null);
|
return alarmSeverities.stream().min(AlarmSeverity::compareTo).orElse(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,7 +154,7 @@ public interface AlarmRepository extends JpaRepository<AlarmEntity, UUID> {
|
|||||||
@Param("affectedEntityId") UUID affectedEntityId,
|
@Param("affectedEntityId") UUID affectedEntityId,
|
||||||
@Param("affectedEntityType") String affectedEntityType,
|
@Param("affectedEntityType") String affectedEntityType,
|
||||||
@Param("alarmStatuses") Set<AlarmStatus> alarmStatuses,
|
@Param("alarmStatuses") Set<AlarmStatus> alarmStatuses,
|
||||||
@Param("assigneeId") UUID assigneeId);
|
@Param("assigneeId") String assigneeId);
|
||||||
|
|
||||||
@Query("SELECT a.id FROM AlarmEntity a WHERE a.tenantId = :tenantId AND a.createdTime < :time AND a.endTs < :time")
|
@Query("SELECT a.id FROM AlarmEntity a WHERE a.tenantId = :tenantId AND a.createdTime < :time AND a.endTs < :time")
|
||||||
Page<UUID> findAlarmsIdsByEndTsBeforeAndTenantId(@Param("time") Long time, @Param("tenantId") UUID tenantId, Pageable pageable);
|
Page<UUID> findAlarmsIdsByEndTsBeforeAndTenantId(@Param("time") Long time, @Param("tenantId") UUID tenantId, Pageable pageable);
|
||||||
|
|||||||
@ -181,11 +181,7 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<AlarmSeverity> findAlarmSeverities(TenantId tenantId, EntityId entityId, Set<AlarmStatus> statuses, UserId assigneeUserId) {
|
public Set<AlarmSeverity> findAlarmSeverities(TenantId tenantId, EntityId entityId, Set<AlarmStatus> statuses, String assigneeId) {
|
||||||
UUID assigneeId = null;
|
|
||||||
if (assigneeUserId != null) {
|
|
||||||
assigneeId = assigneeUserId.getId();
|
|
||||||
}
|
|
||||||
return alarmRepository.findAlarmSeverities(tenantId.getId(), entityId.getId(), entityId.getEntityType().name(), statuses, assigneeId);
|
return alarmRepository.findAlarmSeverities(tenantId.getId(), entityId.getId(), entityId.getEntityType().name(), statuses, assigneeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public interface RuleEngineAlarmService {
|
|||||||
|
|
||||||
ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query);
|
ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query);
|
||||||
|
|
||||||
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus, UserId assigneeId);
|
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus, String assigneeId);
|
||||||
|
|
||||||
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user