Commit 59e99111b977a3a643907282e00e4298dbb1c518
1 parent
81587b8d
fix: 场景联动给网关子设备下发的命令记录显示到网关设备的问题修复
Showing
1 changed file
with
29 additions
and
24 deletions
1 | 1 | package org.thingsboard.server.dao.yunteng.impl; |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | +import java.util.ArrayList; | |
5 | +import java.util.List; | |
6 | +import java.util.Set; | |
7 | +import java.util.stream.Collectors; | |
4 | 8 | import lombok.RequiredArgsConstructor; |
5 | 9 | import org.springframework.stereotype.Service; |
6 | 10 | import org.thingsboard.server.common.data.yunteng.dto.DoActionDTO; |
7 | -import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; | |
8 | 11 | import org.thingsboard.server.common.data.yunteng.enums.ScopeEnum; |
9 | 12 | import org.thingsboard.server.dao.yunteng.entities.TenantBaseEntity; |
10 | 13 | import org.thingsboard.server.dao.yunteng.entities.TkDeviceEntity; |
... | ... | @@ -14,44 +17,46 @@ import org.thingsboard.server.dao.yunteng.mapper.DoActionMapper; |
14 | 17 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
15 | 18 | import org.thingsboard.server.dao.yunteng.service.DoActionService; |
16 | 19 | |
17 | -import java.util.ArrayList; | |
18 | -import java.util.List; | |
19 | -import java.util.Set; | |
20 | -import java.util.stream.Collectors; | |
21 | - | |
22 | -/** @Description @Author cxy @Date 2021/12/6 20:23 */ | |
20 | +/** | |
21 | + * @Description @Author cxy @Date 2021/12/6 20:23 | |
22 | + */ | |
23 | 23 | @Service |
24 | 24 | @RequiredArgsConstructor |
25 | 25 | public class TkDoActionServiceImpl extends AbstractBaseService<DoActionMapper, TkDoActionEntity> |
26 | 26 | implements DoActionService { |
27 | 27 | private final DeviceMapper deviceMapper; |
28 | + | |
28 | 29 | @Override |
29 | 30 | public List<TkDoActionEntity> getActionsByAll(String sceneId) { |
30 | 31 | LambdaQueryWrapper filter = |
31 | - new LambdaQueryWrapper<TkDoActionEntity>().eq(TkDoActionEntity::getSceneLinkageId, sceneId).eq(TkDoActionEntity::getEntityType, ScopeEnum.ALL); | |
32 | + new LambdaQueryWrapper<TkDoActionEntity>() | |
33 | + .eq(TkDoActionEntity::getSceneLinkageId, sceneId) | |
34 | + .eq(TkDoActionEntity::getEntityType, ScopeEnum.ALL); | |
32 | 35 | return baseMapper.selectList(filter); |
33 | 36 | } |
34 | 37 | |
35 | - | |
36 | 38 | @Override |
37 | 39 | public List<TkDoActionEntity> getActionsByPart(String sceneId) { |
38 | 40 | LambdaQueryWrapper filter = |
39 | - new LambdaQueryWrapper<TkDoActionEntity>().eq(TkDoActionEntity::getSceneLinkageId, sceneId).eq(TkDoActionEntity::getEntityType, ScopeEnum.PART); | |
41 | + new LambdaQueryWrapper<TkDoActionEntity>() | |
42 | + .eq(TkDoActionEntity::getSceneLinkageId, sceneId) | |
43 | + .eq(TkDoActionEntity::getEntityType, ScopeEnum.PART); | |
40 | 44 | List<TkDoActionEntity> source = baseMapper.selectList(filter); |
41 | - return source.stream().map(t ->{ | |
42 | - List<TkDeviceEntity> partDevices = deviceMapper.selectList(new LambdaQueryWrapper<TkDeviceEntity>().in(TkDeviceEntity::getTbDeviceId,t.getDeviceId())); | |
43 | - List<String> deviceId = new ArrayList<>(); | |
44 | - for(TkDeviceEntity item : partDevices){ | |
45 | - if(DeviceTypeEnum.SENSOR.equals(item.getDeviceType())){ | |
46 | - deviceId.add(item.getGatewayId()); | |
47 | - }else{ | |
48 | - deviceId.add(item.getTbDeviceId()); | |
49 | - } | |
50 | - } | |
51 | - t.setDeviceId(deviceId); | |
52 | - return t; | |
53 | - }).collect(Collectors.toList()); | |
54 | - | |
45 | + return source.stream() | |
46 | + .map( | |
47 | + t -> { | |
48 | + List<TkDeviceEntity> partDevices = | |
49 | + deviceMapper.selectList( | |
50 | + new LambdaQueryWrapper<TkDeviceEntity>() | |
51 | + .in(TkDeviceEntity::getTbDeviceId, t.getDeviceId())); | |
52 | + List<String> deviceId = new ArrayList<>(); | |
53 | + for (TkDeviceEntity item : partDevices) { | |
54 | + deviceId.add(item.getTbDeviceId()); | |
55 | + } | |
56 | + t.setDeviceId(deviceId); | |
57 | + return t; | |
58 | + }) | |
59 | + .collect(Collectors.toList()); | |
55 | 60 | } |
56 | 61 | |
57 | 62 | @Override | ... | ... |