Showing
5 changed files
with
24 additions
and
13 deletions
@@ -115,7 +115,7 @@ public class RpcCommandTask { | @@ -115,7 +115,7 @@ public class RpcCommandTask { | ||
115 | } | 115 | } |
116 | } else { | 116 | } else { |
117 | sendRpcCommandByProducts( | 117 | sendRpcCommandByProducts( |
118 | - targetContent, cmdJsonNode, tenantId, securityUser, taskCenterId); | 118 | + targetContent, cmdJsonNode, tenantId, securityUser, taskCenterId,targetContent.getOrganizationId()); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
@@ -132,10 +132,11 @@ public class RpcCommandTask { | @@ -132,10 +132,11 @@ public class RpcCommandTask { | ||
132 | JsonNode cmdJsonNode, | 132 | JsonNode cmdJsonNode, |
133 | String tenantId, | 133 | String tenantId, |
134 | SecurityUser securityUser, | 134 | SecurityUser securityUser, |
135 | - String taskCenterId) { | 135 | + String taskCenterId, |
136 | + String organizationId) { | ||
136 | for (String deviceProfileId : targetContent.getData()) { | 137 | for (String deviceProfileId : targetContent.getData()) { |
137 | Futures.addCallback( | 138 | Futures.addCallback( |
138 | - tkDeviceService.findDeviceListByDeviceProfileId(deviceProfileId, tenantId), | 139 | + tkDeviceService.findDeviceListByDeviceProfileId(deviceProfileId, tenantId,organizationId), |
139 | new FutureCallback<>() { | 140 | new FutureCallback<>() { |
140 | @Override | 141 | @Override |
141 | public void onSuccess(@Nullable List<DeviceDTO> deviceDTOS) { | 142 | public void onSuccess(@Nullable List<DeviceDTO> deviceDTOS) { |
@@ -777,16 +777,19 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | @@ -777,16 +777,19 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | ||
777 | 777 | ||
778 | @Override | 778 | @Override |
779 | public ListenableFuture<List<DeviceDTO>> findDeviceListByDeviceProfileId( | 779 | public ListenableFuture<List<DeviceDTO>> findDeviceListByDeviceProfileId( |
780 | - String deviceProfileId, String tenantId) { | 780 | + String deviceProfileId, String tenantId,String organizationId) { |
781 | if (StringUtils.isEmpty(deviceProfileId) || StringUtils.isEmpty(tenantId)) { | 781 | if (StringUtils.isEmpty(deviceProfileId) || StringUtils.isEmpty(tenantId)) { |
782 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | 782 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
783 | } | 783 | } |
784 | + | ||
785 | + List<String> orgIds = organizationService.organizationAllIds(tenantId, organizationId); | ||
784 | List<DeviceDTO> devices = new ArrayList<>(); | 786 | List<DeviceDTO> devices = new ArrayList<>(); |
785 | List<TkDeviceEntity> entityList = | 787 | List<TkDeviceEntity> entityList = |
786 | baseMapper.selectList( | 788 | baseMapper.selectList( |
787 | new LambdaQueryWrapper<TkDeviceEntity>() | 789 | new LambdaQueryWrapper<TkDeviceEntity>() |
788 | .eq(TkDeviceEntity::getTenantId, tenantId) | 790 | .eq(TkDeviceEntity::getTenantId, tenantId) |
789 | - .eq(TkDeviceEntity::getDeviceProfileId, deviceProfileId)); | 791 | + .eq(TkDeviceEntity::getDeviceProfileId, deviceProfileId) |
792 | + .in(!orgIds.isEmpty(),TkDeviceEntity::getOrganizationId, orgIds)); | ||
790 | return Optional.ofNullable(entityList) | 793 | return Optional.ofNullable(entityList) |
791 | .map( | 794 | .map( |
792 | list -> | 795 | list -> |
@@ -798,15 +801,20 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | @@ -798,15 +801,20 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | ||
798 | } | 801 | } |
799 | 802 | ||
800 | @Override | 803 | @Override |
801 | - public List<String> findTbDeviceIdsByDeviceProfileId(String deviceProfileId, String tenantId) { | 804 | + public List<String>findTbDeviceIdsByDeviceProfileId(String deviceProfileId, String tenantId,String organizationId) { |
802 | if (StringUtils.isEmpty(deviceProfileId) || StringUtils.isEmpty(tenantId)) { | 805 | if (StringUtils.isEmpty(deviceProfileId) || StringUtils.isEmpty(tenantId)) { |
803 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | 806 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
804 | } | 807 | } |
808 | + List<String> orgIds = null; | ||
809 | + if(!StringUtils.isEmpty(organizationId)){ | ||
810 | + orgIds = organizationService.organizationAllIds(tenantId, organizationId); | ||
811 | + } | ||
805 | return Optional.ofNullable( | 812 | return Optional.ofNullable( |
806 | baseMapper.selectList( | 813 | baseMapper.selectList( |
807 | new LambdaQueryWrapper<TkDeviceEntity>() | 814 | new LambdaQueryWrapper<TkDeviceEntity>() |
808 | .eq(TkDeviceEntity::getTenantId, tenantId) | 815 | .eq(TkDeviceEntity::getTenantId, tenantId) |
809 | .eq(TkDeviceEntity::getDeviceProfileId, deviceProfileId) | 816 | .eq(TkDeviceEntity::getDeviceProfileId, deviceProfileId) |
817 | + .in(!orgIds.isEmpty(),TkDeviceEntity::getOrganizationId, orgIds) | ||
810 | .select(TkDeviceEntity::getTbDeviceId))) | 818 | .select(TkDeviceEntity::getTbDeviceId))) |
811 | .map(list -> list.stream().map(TkDeviceEntity::getTbDeviceId).collect(Collectors.toList())) | 819 | .map(list -> list.stream().map(TkDeviceEntity::getTbDeviceId).collect(Collectors.toList())) |
812 | .orElse(null); | 820 | .orElse(null); |
@@ -127,7 +127,9 @@ public class TkTaskCenterServiceImpl | @@ -127,7 +127,9 @@ public class TkTaskCenterServiceImpl | ||
127 | baseMapper.updateById(entity); | 127 | baseMapper.updateById(entity); |
128 | updateTaskCenterCache(entity); | 128 | updateTaskCenterCache(entity); |
129 | } | 129 | } |
130 | - saveOrUpdateDeviceTaskCenter(entity, isUpdate); | 130 | + String organizationId = tkTaskCenterDTO.getExecuteTarget() !=null? |
131 | + tkTaskCenterDTO.getExecuteTarget().getOrganizationId():null; | ||
132 | + saveOrUpdateDeviceTaskCenter(entity, isUpdate,organizationId); | ||
131 | return tkTaskCenterDTO; | 133 | return tkTaskCenterDTO; |
132 | } | 134 | } |
133 | 135 | ||
@@ -345,7 +347,7 @@ public class TkTaskCenterServiceImpl | @@ -345,7 +347,7 @@ public class TkTaskCenterServiceImpl | ||
345 | } | 347 | } |
346 | } | 348 | } |
347 | 349 | ||
348 | - private void saveOrUpdateDeviceTaskCenter(TkTaskCenterEntity entity, boolean isUpdate) { | 350 | + private void saveOrUpdateDeviceTaskCenter(TkTaskCenterEntity entity, boolean isUpdate,String organizationId) { |
349 | String taskCenterId = entity.getId(); | 351 | String taskCenterId = entity.getId(); |
350 | String tenantId = entity.getTenantId(); | 352 | String tenantId = entity.getTenantId(); |
351 | // 判断是按产品执行还是按设备执行 | 353 | // 判断是按产品执行还是按设备执行 |
@@ -357,7 +359,7 @@ public class TkTaskCenterServiceImpl | @@ -357,7 +359,7 @@ public class TkTaskCenterServiceImpl | ||
357 | processDeviceTaskCenterMapping(isUpdate, tenantId, taskCenterId, data); | 359 | processDeviceTaskCenterMapping(isUpdate, tenantId, taskCenterId, data); |
358 | } else { | 360 | } else { |
359 | for (String key : data) { | 361 | for (String key : data) { |
360 | - List<String> tbDeviceIds = tkDeviceService.findTbDeviceIdsByDeviceProfileId(key, tenantId); | 362 | + List<String> tbDeviceIds = tkDeviceService.findTbDeviceIdsByDeviceProfileId(key, tenantId,organizationId); |
361 | processDeviceTaskCenterMapping(isUpdate, tenantId, taskCenterId, tbDeviceIds); | 363 | processDeviceTaskCenterMapping(isUpdate, tenantId, taskCenterId, tbDeviceIds); |
362 | } | 364 | } |
363 | } | 365 | } |
@@ -224,7 +224,7 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | @@ -224,7 +224,7 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | ||
224 | */ | 224 | */ |
225 | Map<String, List<String>> getDeviceIdsByDeviceProfileId(String tenantId, String tbDeviceProfileId); | 225 | Map<String, List<String>> getDeviceIdsByDeviceProfileId(String tenantId, String tbDeviceProfileId); |
226 | 226 | ||
227 | - ListenableFuture<List<DeviceDTO>> findDeviceListByDeviceProfileId(String deviceProfileId,String tenantId); | 227 | + ListenableFuture<List<DeviceDTO>> findDeviceListByDeviceProfileId(String deviceProfileId,String tenantId,String organizationId); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | * 通过设备配置ID查询所有的tbDeviceId | 230 | * 通过设备配置ID查询所有的tbDeviceId |
@@ -232,7 +232,7 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | @@ -232,7 +232,7 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | ||
232 | * @param tenantId 租户ID | 232 | * @param tenantId 租户ID |
233 | * @return id集合 | 233 | * @return id集合 |
234 | */ | 234 | */ |
235 | - List<String> findTbDeviceIdsByDeviceProfileId(String deviceProfileId,String tenantId); | 235 | + List<String> findTbDeviceIdsByDeviceProfileId(String deviceProfileId,String tenantId,String organizationId); |
236 | 236 | ||
237 | /** | 237 | /** |
238 | * 根据TB设备ID列表获取设备信息 | 238 | * 根据TB设备ID列表获取设备信息 |
@@ -187,7 +187,7 @@ class ReactState { | @@ -187,7 +187,7 @@ class ReactState { | ||
187 | if (ScopeEnum.ALL.equals(entityType)) { | 187 | if (ScopeEnum.ALL.equals(entityType)) { |
188 | trifggerDevices = | 188 | trifggerDevices = |
189 | tkDeviceService.findTbDeviceIdsByDeviceProfileId( | 189 | tkDeviceService.findTbDeviceIdsByDeviceProfileId( |
190 | - tkProjectId, trigger.getTenantId()); | 190 | + tkProjectId, trigger.getTenantId(),null); |
191 | } | 191 | } |
192 | AtomicReference<String> matchKey = new AtomicReference<>(""); | 192 | AtomicReference<String> matchKey = new AtomicReference<>(""); |
193 | AtomicBoolean matched = new AtomicBoolean(false); | 193 | AtomicBoolean matched = new AtomicBoolean(false); |
@@ -288,7 +288,7 @@ class ReactState { | @@ -288,7 +288,7 @@ class ReactState { | ||
288 | if (ScopeEnum.ALL.equals(entityType)) { | 288 | if (ScopeEnum.ALL.equals(entityType)) { |
289 | conditionDevices = | 289 | conditionDevices = |
290 | tkDeviceService.findTbDeviceIdsByDeviceProfileId( | 290 | tkDeviceService.findTbDeviceIdsByDeviceProfileId( |
291 | - tkProjectId, condition.getTenantId()); | 291 | + tkProjectId, condition.getTenantId(),null); |
292 | } | 292 | } |
293 | AtomicBoolean oneConditionResult = new AtomicBoolean(true); | 293 | AtomicBoolean oneConditionResult = new AtomicBoolean(true); |
294 | conditionDevices.stream() | 294 | conditionDevices.stream() |