...
|
...
|
@@ -19,6 +19,7 @@ import com.google.common.util.concurrent.ListenableFuture; |
19
|
19
|
import lombok.extern.slf4j.Slf4j;
|
20
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
21
|
21
|
import org.springframework.data.domain.Page;
|
|
22
|
+import org.springframework.data.domain.PageImpl;
|
22
|
23
|
import org.springframework.data.domain.Pageable;
|
23
|
24
|
import org.springframework.data.jpa.repository.JpaRepository;
|
24
|
25
|
import org.springframework.stereotype.Component;
|
...
|
...
|
@@ -40,12 +41,14 @@ import org.thingsboard.server.common.data.page.PageLink; |
40
|
41
|
import org.thingsboard.server.dao.DaoUtil;
|
41
|
42
|
import org.thingsboard.server.dao.device.DeviceDao;
|
42
|
43
|
import org.thingsboard.server.dao.model.sql.DeviceEntity;
|
|
44
|
+import org.thingsboard.server.dao.model.sql.DeviceInfoEntity;
|
43
|
45
|
import org.thingsboard.server.dao.sql.JpaAbstractDao;
|
44
|
46
|
import org.thingsboard.server.dao.util.SqlDao;
|
|
47
|
+import org.thingsboard.server.dao.yunteng.service.TkDeviceService;
|
45
|
48
|
|
46
|
|
-import java.util.List;
|
47
|
|
-import java.util.Optional;
|
48
|
|
-import java.util.UUID;
|
|
49
|
+import java.lang.reflect.InvocationTargetException;
|
|
50
|
+import java.util.*;
|
|
51
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
49
|
52
|
|
50
|
53
|
import static org.thingsboard.server.dao.DaoUtil.convertTenantEntityInfosToDto;
|
51
|
54
|
|
...
|
...
|
@@ -65,6 +68,8 @@ public class JpaDeviceDao extends JpaAbstractDao<DeviceEntity, Device> implement |
65
|
68
|
|
66
|
69
|
@Autowired
|
67
|
70
|
private DeviceProfileRepository deviceProfileRepository;
|
|
71
|
+ @Autowired
|
|
72
|
+ TkDeviceService tkDeviceService;
|
68
|
73
|
|
69
|
74
|
@Override
|
70
|
75
|
protected Class<DeviceEntity> getEntityClass() {
|
...
|
...
|
@@ -107,17 +112,25 @@ public class JpaDeviceDao extends JpaAbstractDao<DeviceEntity, Device> implement |
107
|
112
|
|
108
|
113
|
@Override
|
109
|
114
|
public PageData<DeviceInfo> findDeviceInfosByFilter(DeviceInfoFilter filter, PageLink pageLink) {
|
110
|
|
- return DaoUtil.toPageData(
|
111
|
|
- deviceRepository.findDeviceInfosByFilter(
|
112
|
|
- filter.getTenantId().getId(),
|
113
|
|
- DaoUtil.getStringId(filter.getCustomerId()),
|
114
|
|
- DaoUtil.getStringId(filter.getEdgeId()),
|
115
|
|
- filter.getType(),
|
116
|
|
- DaoUtil.getStringId(filter.getDeviceProfileId()),
|
117
|
|
- filter.getActive() != null,
|
118
|
|
- Boolean.TRUE.equals(filter.getActive()),
|
119
|
|
- pageLink.getTextSearch(),
|
120
|
|
- DaoUtil.toPageable(pageLink)));
|
|
115
|
+ Page<DeviceInfoEntity> list = deviceRepository.findDeviceInfosByFilter(
|
|
116
|
+ filter.getTenantId().getId(),
|
|
117
|
+ DaoUtil.getStringId(filter.getCustomerId()),
|
|
118
|
+ DaoUtil.getStringId(filter.getEdgeId()),
|
|
119
|
+ filter.getType(),
|
|
120
|
+ DaoUtil.getStringId(filter.getDeviceProfileId()),
|
|
121
|
+ filter.getActive() != null,
|
|
122
|
+ Boolean.TRUE.equals(filter.getActive()),
|
|
123
|
+ pageLink.getTextSearch(),
|
|
124
|
+ DaoUtil.toPageable(pageLink));
|
|
125
|
+ List<DeviceInfoEntity> listContent = new CopyOnWriteArrayList<>(list.getContent());
|
|
126
|
+ for (DeviceInfoEntity entity:listContent) {
|
|
127
|
+ String result = tkDeviceService.usedBySceneLinkage(entity.getTenantId().toString(), entity.getId().toString());
|
|
128
|
+ if(!result.isEmpty()){
|
|
129
|
+ listContent.remove(entity);
|
|
130
|
+ }
|
|
131
|
+ }
|
|
132
|
+ Page<DeviceInfoEntity> newPage = new PageImpl<>(listContent, DaoUtil.toPageable(pageLink), listContent.size());
|
|
133
|
+ return DaoUtil.toPageData(newPage);
|
121
|
134
|
}
|
122
|
135
|
|
123
|
136
|
@Override
|
...
|
...
|
|