Commit 69eb348fda8ce73a26d1afde5405a4b22e6ba3f8

Authored by xp.Huang
1 parent 01ed914a

fix: 场景联动是否使用产品校验

@@ -136,6 +136,14 @@ public class TkDeviceProfileServiceImpl @@ -136,6 +136,14 @@ public class TkDeviceProfileServiceImpl
136 Optional.ofNullable(deviceProfileDTO.getCategoryId()).ifPresent(tbDeviceProfile::setCategoryId); 136 Optional.ofNullable(deviceProfileDTO.getCategoryId()).ifPresent(tbDeviceProfile::setCategoryId);
137 137
138 String chainIdStr = deviceProfileDTO.getDefaultRuleChainId(); 138 String chainIdStr = deviceProfileDTO.getDefaultRuleChainId();
  139 + if(StringUtils.isNotEmpty(deviceProfileDTO.getId())){
  140 + //编辑的时候判断,是否更换了规则链
  141 + DeviceProfileDTO queryDeviceProfile = findByTbDeviceProfileId(user.getTenantId().getId(),UUID.fromString(deviceProfileDTO.getId()));
  142 + if(!chainIdStr.equals(queryDeviceProfile.getDefaultRuleChainId())){
  143 + //如果更换了规则链,要进行check
  144 + checkDeviceProfilesCanChangeRuleChain(List.of(deviceProfileDTO.getId()),user.getTenantId());
  145 + }
  146 + }
139 // 获取当前租户的默认规则链 147 // 获取当前租户的默认规则链
140 if (StringUtils.isNotBlank(chainIdStr)) { 148 if (StringUtils.isNotBlank(chainIdStr)) {
141 RuleChainId chainId = new RuleChainId(UUID.fromString(chainIdStr)); 149 RuleChainId chainId = new RuleChainId(UUID.fromString(chainIdStr));
@@ -222,16 +230,16 @@ public class TkDeviceProfileServiceImpl @@ -222,16 +230,16 @@ public class TkDeviceProfileServiceImpl
222 JsonNode datasource = convertEntity.getDatasourceContent(); 230 JsonNode datasource = convertEntity.getDatasourceContent();
223 if(null != datasource){ 231 if(null != datasource){
224 JsonNode usedDeviceProfileIds = datasource.get("convertProducts"); 232 JsonNode usedDeviceProfileIds = datasource.get("convertProducts");
225 - List<String> ids = null; 233 + List<String> ids = new ArrayList<>();;
226 if(usedDeviceProfileIds.isArray()){ 234 if(usedDeviceProfileIds.isArray()){
227 Iterator<JsonNode> iteratorNodes = usedDeviceProfileIds.iterator(); 235 Iterator<JsonNode> iteratorNodes = usedDeviceProfileIds.iterator();
228 while (iteratorNodes.hasNext()){ 236 while (iteratorNodes.hasNext()){
229 ids.add(iteratorNodes.next().asText()); 237 ids.add(iteratorNodes.next().asText());
230 } 238 }
231 } 239 }
232 - if(null != ids){  
233 - classification.entrySet().forEach(key->{  
234 - for (TkDeviceProfileEntity entity : classification.get(key)) { 240 + if(!ids.isEmpty()){
  241 + classification.entrySet().forEach(entry->{
  242 + for (TkDeviceProfileEntity entity : classification.get(entry.getKey())) {
235 if(ids.contains(entity.getId().toString())){ 243 if(ids.contains(entity.getId().toString())){
236 throw new TkDataValidationException(String.format(ErrorMessage. 244 throw new TkDataValidationException(String.format(ErrorMessage.
237 CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_CONVERT.getMessage(),entity.getName(),convertEntity.getName())); 245 CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_CONVERT.getMessage(),entity.getName(),convertEntity.getName()));
@@ -45,11 +45,6 @@ public class TkDoActionServiceImpl extends AbstractBaseService<DoActionMapper, T @@ -45,11 +45,6 @@ public class TkDoActionServiceImpl extends AbstractBaseService<DoActionMapper, T
45 45
46 @Override 46 @Override
47 public List<DoActionDTO> findDoActionsBySceneLinkageIds(String tenantId, List<String> sceneLinkageIds) { 47 public List<DoActionDTO> findDoActionsBySceneLinkageIds(String tenantId, List<String> sceneLinkageIds) {
48 - List<TkDoActionEntity> entities = baseMapper.selectList(new LambdaQueryWrapper<TkDoActionEntity>().eq(TkDoActionEntity::getTenantId,tenantId)  
49 - .in(TkDoActionEntity::getSceneLinkageId,sceneLinkageIds));  
50 - if(null !=entities && !entities.isEmpty()){  
51 - return entities.stream().map(entity->entity.getDTO(DoActionDTO.class)).collect(Collectors.toList());  
52 - }  
53 - return null; 48 + return baseMapper.listBySceneLinkageIds(tenantId,sceneLinkageIds);
54 } 49 }
55 } 50 }