|
|
|
@ -5,7 +5,7 @@ |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* You may obtain a copy of the License at |
|
|
|
* |
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* |
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
|
|
@ -16,8 +16,6 @@ |
|
|
|
package org.thingsboard.server.dao.sql.device; |
|
|
|
|
|
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
|
import com.google.common.util.concurrent.ListeningExecutorService; |
|
|
|
import com.google.common.util.concurrent.MoreExecutors; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
|
|
|
import org.springframework.data.repository.CrudRepository; |
|
|
|
@ -33,7 +31,6 @@ import org.thingsboard.server.dao.sql.JpaAbstractSearchTextDao; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
|
|
|
|
|
|
|
@ -45,7 +42,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
|
|
|
public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
DeviceRepository deviceRepository; |
|
|
|
private DeviceRepository deviceRepository; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected Class<DeviceEntity> getEntityClass() { |
|
|
|
@ -70,8 +67,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> |
|
|
|
|
|
|
|
@Override |
|
|
|
public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) { |
|
|
|
System.out.println(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds).size()); |
|
|
|
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); |
|
|
|
return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds))); |
|
|
|
} |
|
|
|
|
|
|
|
@ -89,7 +84,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> |
|
|
|
|
|
|
|
@Override |
|
|
|
public ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds) { |
|
|
|
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); |
|
|
|
return service.submit(() -> DaoUtil.convertDataList( |
|
|
|
deviceRepository.findDevicesByTenantIdAndCustomerIdAndIdIn(tenantId, customerId, deviceIds))); |
|
|
|
} |
|
|
|
@ -127,7 +121,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> |
|
|
|
|
|
|
|
@Override |
|
|
|
public ListenableFuture<List<TenantDeviceType>> findTenantDeviceTypesAsync() { |
|
|
|
//TODO
|
|
|
|
return null; |
|
|
|
return service.submit(() -> deviceRepository.findTenantDeviceTypes()); |
|
|
|
} |
|
|
|
} |
|
|
|
|