Commit 816d5215b8640fbe0acc2079ebdadb57019efabb
Merge branch 'fix/teambition/2024-10-28' into 'master_dev'
Fix/teambition/2024 10 28 See merge request yunteng/thingskit!457
Showing
11 changed files
with
64 additions
and
35 deletions
... | ... | @@ -393,25 +393,30 @@ public class TkDeviceController extends BaseController { |
393 | 393 | @ApiParam(value = "是否场景联动调用,是true") @RequestParam(value = "isSceneLinkage", required = false) Boolean isSceneLinkage, |
394 | 394 | @ApiParam(value = "是否边缘分配设备调用,是true") @RequestParam(value = "isEdgeDistribution", required = false) Boolean isEdgeDistribution, |
395 | 395 | @ApiParam(value = "edgeId") @RequestParam(value = "edgeId", required = false) String edgeId, |
396 | - @ApiParam(value = "排除边端设备是true") @RequestParam(value = "isExcludeEdge", required = false) Boolean isExcludeEdge | |
396 | + @ApiParam(value = "排除边端设备是true") @RequestParam(value = "isExcludeEdge", required = false) Boolean isExcludeEdge, | |
397 | + @ApiParam(value = "排除云端设备是true") @RequestParam(value = "isExcludeCloud", required = false) Boolean isExcludeCloud | |
397 | 398 | ) |
398 | 399 | throws ThingsboardException { |
399 | - if(isExcludeEdge==null){ | |
400 | - isExcludeEdge=false; | |
400 | + if (isExcludeEdge == null) { | |
401 | + isExcludeEdge = false; | |
402 | + } | |
403 | + if (isExcludeCloud == null) { | |
404 | + isExcludeCloud = false; | |
401 | 405 | } |
402 | 406 | return tkdeviceService.findDevicesByDeviceTypeAndOrganizationId( |
403 | - deviceType, | |
404 | - getCurrentUser().getTenantId().getId(), | |
405 | - organizationId, | |
406 | - deviceLabel, | |
407 | - StringUtils.isEmpty(deviceProfileId)?null:UUID.fromString(deviceProfileId), | |
408 | - transportType, | |
409 | - isSceneLinkage, | |
410 | - isEdgeDistribution, | |
411 | - StringUtils.isEmpty(edgeId)?null:UUID.fromString(edgeId), | |
412 | - isExcludeEdge | |
407 | + deviceType, | |
408 | + getCurrentUser().getTenantId().getId(), | |
409 | + organizationId, | |
410 | + deviceLabel, | |
411 | + StringUtils.isEmpty(deviceProfileId) ? null : UUID.fromString(deviceProfileId), | |
412 | + transportType, | |
413 | + isSceneLinkage, | |
414 | + isEdgeDistribution, | |
415 | + StringUtils.isEmpty(edgeId) ? null : UUID.fromString(edgeId), | |
416 | + isExcludeEdge, | |
417 | + isExcludeCloud | |
413 | 418 | ); |
414 | - } | |
419 | + } | |
415 | 420 | |
416 | 421 | |
417 | 422 | @PostMapping("/getListByDeviceProfileIds") | ... | ... |
... | ... | @@ -83,6 +83,21 @@ public class TkOpenApiRecordController extends BaseController { |
83 | 83 | return ResponseEntity.ok(openApiRecordService.getClassify(getCurrentUser().getTenantId().toString(), type)); |
84 | 84 | } |
85 | 85 | |
86 | + @GetMapping("/getCustomClassify") | |
87 | + @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{})") | |
88 | + @ApiImplicitParams(value = { | |
89 | + @ApiImplicitParam(name = "startTime", value = "开始时间" ,required = true), | |
90 | + @ApiImplicitParam(name = "endTime", value = "结束时间" ,required = true), | |
91 | + @ApiImplicitParam(name = "type", value = "统计类型 day以两小时为分组,month以一天为分组" ,required = true) | |
92 | + }) | |
93 | + public ResponseEntity<List<OpenApiRecordClassifyAllDTO>> getCustomClassify( | |
94 | + @RequestParam(value = "startTime", required = true) Long startTime, | |
95 | + @RequestParam(value = "endTime", required = true) Long endTime, | |
96 | + @RequestParam(value = "type" ) String type | |
97 | + ) throws ThingsboardException { | |
98 | + return ResponseEntity.ok(openApiRecordService.getClassify(getCurrentUser().getTenantId().toString(), type,new java.util.Date(startTime),new java.util.Date(endTime))); | |
99 | + } | |
100 | + | |
86 | 101 | |
87 | 102 | @GetMapping("/getPage") |
88 | 103 | public TkPageData<OpenApiRecordTopDTO> getPage( | ... | ... |
... | ... | @@ -19,6 +19,7 @@ import org.thingsboard.server.dao.yunteng.service.OpenApiRecordService; |
19 | 19 | |
20 | 20 | import java.sql.Time; |
21 | 21 | import java.util.ArrayList; |
22 | +import java.util.Date; | |
22 | 23 | import java.util.List; |
23 | 24 | import java.util.Map; |
24 | 25 | import java.util.concurrent.atomic.AtomicInteger; |
... | ... | @@ -126,7 +127,11 @@ public class OpenApiRecordImpl extends AbstractBaseService<OpenApiRecordMapper, |
126 | 127 | case "week":startTime=new java.util.Date(endTime.getTime()- HOUR_TIMESTAMP*24L*7L);break; |
127 | 128 | case "month":startTime=new java.util.Date(endTime.getTime()- HOUR_TIMESTAMP*24L*30L);break; |
128 | 129 | } |
130 | + return getClassify(tenantId,type,startTime,endTime); | |
131 | + } | |
129 | 132 | |
133 | + @Override | |
134 | + public List<OpenApiRecordClassifyAllDTO> getClassify(String tenantId, String type, Date startTime, Date endTime) { | |
130 | 135 | List<OpenApiRecordClassifyDTO> tops = baseMapper.getClassify(tenantId,type,startTime,endTime); |
131 | 136 | List<OpenApiRecordClassifyAllDTO> allList =new ArrayList<>(); |
132 | 137 | if(!tops.isEmpty()){ | ... | ... |
... | ... | @@ -328,7 +328,8 @@ public class TkDeviceServiceImpl extends AbstractTbBaseService<DeviceMapper, TkD |
328 | 328 | Boolean isSceneLinkage, |
329 | 329 | Boolean isEdgeDistribution, |
330 | 330 | UUID edgeId, |
331 | - Boolean isExcludeEdge) { | |
331 | + Boolean isExcludeEdge, | |
332 | + Boolean isExcludeCloud) { | |
332 | 333 | List<String> orgIds = organizationService.organizationAllIds(tenantId.toString(), organizationId); |
333 | 334 | if (orgIds.isEmpty()) { |
334 | 335 | throw new TkDataValidationException(MessageUtils.message(ErrorMessage.ORGANIZATION_NOT_EXTIED.getI18nCode())); |
... | ... | @@ -336,7 +337,7 @@ public class TkDeviceServiceImpl extends AbstractTbBaseService<DeviceMapper, TkD |
336 | 337 | |
337 | 338 | List<TkDeviceEntity> listEntity = baseMapper.findDevicesByDeviceTypeAndOrganizationId(orgIds, |
338 | 339 | deviceType == null ? null : deviceType.name(), |
339 | - deviceLabel, deviceProfileId, transportTypeEnum,isSceneLinkage,isEdgeDistribution,edgeId,isExcludeEdge); | |
340 | + deviceLabel, deviceProfileId, transportTypeEnum,isSceneLinkage,isEdgeDistribution,edgeId,isExcludeEdge,isExcludeCloud); | |
340 | 341 | return listEntity.stream().map(entity -> { |
341 | 342 | return CopyUtils.copyAndReturn(entity, new DeviceDTO()); |
342 | 343 | } | ... | ... |
... | ... | @@ -62,7 +62,7 @@ public class TkDeviceStateLogServiceImpl |
62 | 62 | } |
63 | 63 | if(isPtCommonTenant){ |
64 | 64 | List<TkDeviceEntity> devices = deviceMapper.findDevicesByDeviceTypeAndOrganizationId((List<String>) queryMap.get("orgIds"), |
65 | - null,null,null,null,false,false,null,false); | |
65 | + null,null,null,null,false,false,null,false,false); | |
66 | 66 | List<String> finalTbDevices = new ArrayList<>(); |
67 | 67 | devices.forEach(item -> finalTbDevices.add(item.getTbDeviceId().toString())); |
68 | 68 | deviceIds = finalTbDevices; | ... | ... |
... | ... | @@ -250,7 +250,7 @@ public class TkHomePageServiceImpl implements HomePageService { |
250 | 250 | totalFilter.put("organizationIds",organizationIds); |
251 | 251 | //查询所有设备 |
252 | 252 | List<TkDeviceEntity> devices = deviceMapper.findDevicesByDeviceTypeAndOrganizationId(organizationIds,null, |
253 | - null,null,null,false,false,null,false); | |
253 | + null,null,null,false,false,null,false,false); | |
254 | 254 | List<String> finalTbDevices = new ArrayList<>(); |
255 | 255 | devices.forEach(item -> finalTbDevices.add(item.getTbDeviceId().toString())); |
256 | 256 | todayFilter.put("deviceIds",finalTbDevices); | ... | ... |
... | ... | @@ -113,7 +113,7 @@ public class TkVideoServiceImpl extends AbstractBaseService<TkVideoMapper, TkVid |
113 | 113 | List<TkVideoGbtDeviceDTO> deviceList = new ArrayList<>(); |
114 | 114 | List<DeviceDTO> deviceDTOS = tkdeviceService.findDevicesByDeviceTypeAndOrganizationId( |
115 | 115 | null, UUID.fromString(dto.getTenantId()),organizationId,null, |
116 | - null, TransportTypeEnum.GBT28181,false,false,null,true); | |
116 | + null, TransportTypeEnum.GBT28181,false,false,null,true,false); | |
117 | 117 | if(deviceDTOS.isEmpty()){ |
118 | 118 | return dto; |
119 | 119 | } | ... | ... |
... | ... | @@ -165,7 +165,8 @@ public interface DeviceMapper extends BaseMapper<TkDeviceEntity> { |
165 | 165 | @Param("isSceneLinkage")Boolean isSceneLinkage, |
166 | 166 | @Param("isEdgeDistribution")Boolean isEdgeDistribution, |
167 | 167 | @Param("edgeId")UUID edgeId, |
168 | - @Param("isExcludeEdge")Boolean isExcludeEdge) ; | |
168 | + @Param("isExcludeEdge")Boolean isExcludeEdge, | |
169 | + @Param("isExcludeCloud")Boolean isExcludeCloud) ; | |
169 | 170 | |
170 | 171 | |
171 | 172 | List<DeviceDTO> findDevicesByProfileIdAndOrganizationId( | ... | ... |
... | ... | @@ -21,4 +21,5 @@ public interface OpenApiRecordService extends BaseService<TkOpenApiRecordEntity> |
21 | 21 | TkPageData<OpenApiRecordTopDTO> getPage(String tenantId,Integer page,Integer pageSize); |
22 | 22 | |
23 | 23 | List<OpenApiRecordClassifyAllDTO> getClassify(String tenantId,String type); |
24 | + public List<OpenApiRecordClassifyAllDTO> getClassify(String tenantId,String type,java.util.Date startTime,java.util.Date endTime); | |
24 | 25 | } | ... | ... |
... | ... | @@ -81,7 +81,7 @@ public interface TkDeviceService extends TbBaseService<TkDeviceEntity> { |
81 | 81 | TransportTypeEnum transportTypeEnum, |
82 | 82 | Boolean isSceneLinkage, |
83 | 83 | Boolean isEdgeDistribution, |
84 | - UUID edgeId,Boolean excludeEdge); | |
84 | + UUID edgeId,Boolean excludeEdge,Boolean isExcludeCloud); | |
85 | 85 | |
86 | 86 | |
87 | 87 | List<DeviceDTO> findDevicesByOrganizationIds( | ... | ... |
... | ... | @@ -567,18 +567,16 @@ |
567 | 567 | <include refid="basicColumns"/>,dev.transport_type |
568 | 568 | FROM device ifd |
569 | 569 | left join device_profile dev on ifd.device_profile_id = dev.id |
570 | - <if test="isSceneLinkage == true"> | |
571 | - <!--此设备是边端创建或者已经分配给边端--> | |
570 | + <if test="isSceneLinkage == true or isExcludeEdge == true or isExcludeCloud == true"> | |
572 | 571 | LEFT JOIN relation re on re.to_id = ifd.id and re.from_type = 'EDGE' and( re.relation_type = 'ManagedByEdge' or re.relation_type = 'Contains') |
573 | 572 | </if> |
574 | - | |
575 | - <if test="edgeId != null"> | |
576 | - LEFT JOIN relation re on re.to_id = ifd.id | |
577 | - and re.from_id =#{edgeId} | |
578 | - and re.from_type = 'EDGE' | |
579 | - and re.relation_type_group = 'EDGE' | |
580 | - and re.relation_type = 'Contains' | |
581 | - </if> | |
573 | +<!-- <if test="edgeId != null">--> | |
574 | +<!-- LEFT JOIN relation re on re.to_id = ifd.id--> | |
575 | +<!-- and re.from_id =#{edgeId}--> | |
576 | +<!-- and re.from_type = 'EDGE'--> | |
577 | +<!-- and re.relation_type_group = 'EDGE'--> | |
578 | +<!-- and re.relation_type = 'Contains'--> | |
579 | +<!-- </if>--> | |
582 | 580 | <if test="isEdgeDistribution == true"> |
583 | 581 | <!--此设备是否已被场景联动使用--> |
584 | 582 | LEFT JOIN tk_do_action action on action.device_id LIKE CONCAT('%',ifd.id ,'%') |
... | ... | @@ -588,14 +586,17 @@ |
588 | 586 | where |
589 | 587 | 1=1 |
590 | 588 | <if test="isExcludeEdge == true"> |
591 | - and ifd.id not in (SELECT dev.id from device dev inner join relation re_edge on dev.id=re_edge.to_id and re_edge.from_type = 'EDGE' and re_edge.relation_type = 'ManagedByEdge') | |
589 | + and (dev.transport_type!='GBT28181' or re.to_id is null) | |
590 | + </if> | |
591 | + <if test="isExcludeCloud == true"> | |
592 | + and (dev.transport_type!='GBT28181' or re.to_id is not null) | |
592 | 593 | </if> |
593 | 594 | <if test="isSceneLinkage == true"> |
594 | 595 | and re.to_id is null |
595 | 596 | </if> |
596 | - <if test="edgeId != null"> | |
597 | - and re.from_id is null | |
598 | - </if> | |
597 | +<!-- <if test="edgeId != null">--> | |
598 | +<!-- and re.from_id is null--> | |
599 | +<!-- </if>--> | |
599 | 600 | <if test="isEdgeDistribution == true"> |
600 | 601 | and action.device_id is null |
601 | 602 | and cond.entity_id is null | ... | ... |