...
|
...
|
@@ -136,6 +136,14 @@ public class TkDeviceProfileServiceImpl |
136
|
136
|
Optional.ofNullable(deviceProfileDTO.getCategoryId()).ifPresent(tbDeviceProfile::setCategoryId);
|
137
|
137
|
|
138
|
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
|
148
|
if (StringUtils.isNotBlank(chainIdStr)) {
|
141
|
149
|
RuleChainId chainId = new RuleChainId(UUID.fromString(chainIdStr));
|
...
|
...
|
@@ -222,16 +230,16 @@ public class TkDeviceProfileServiceImpl |
222
|
230
|
JsonNode datasource = convertEntity.getDatasourceContent();
|
223
|
231
|
if(null != datasource){
|
224
|
232
|
JsonNode usedDeviceProfileIds = datasource.get("convertProducts");
|
225
|
|
- List<String> ids = null;
|
|
233
|
+ List<String> ids = new ArrayList<>();;
|
226
|
234
|
if(usedDeviceProfileIds.isArray()){
|
227
|
235
|
Iterator<JsonNode> iteratorNodes = usedDeviceProfileIds.iterator();
|
228
|
236
|
while (iteratorNodes.hasNext()){
|
229
|
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
|
243
|
if(ids.contains(entity.getId().toString())){
|
236
|
244
|
throw new TkDataValidationException(String.format(ErrorMessage.
|
237
|
245
|
CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_CONVERT.getMessage(),entity.getName(),convertEntity.getName()));
|
...
|
...
|
|