|
|
@@ -23,6 +23,7 @@ import org.hswebframework.web.exception.NotFoundException;
|
|
|
import org.hswebframework.web.exception.ValidationException;
|
|
|
import org.hswebframework.web.id.IDGenerator;
|
|
|
import org.jetlinks.community.device.entity.*;
|
|
|
+import org.jetlinks.community.device.entity.geo.GeoProperty;
|
|
|
import org.jetlinks.community.device.enums.DeviceState;
|
|
|
import org.jetlinks.community.device.response.DeviceDeployResult;
|
|
|
import org.jetlinks.community.device.response.DeviceDetail;
|
|
|
@@ -96,6 +97,8 @@ public class DeviceInstanceController implements
|
|
|
private final DeviceConfigMetadataManager metadataManager;
|
|
|
|
|
|
private final DeviceTagsService tagsService;
|
|
|
+
|
|
|
+ private final ReactiveRepository<GeoProperty, String> propertyRepository;
|
|
|
@SuppressWarnings("all")
|
|
|
public DeviceInstanceController(LocalDeviceInstanceService service,
|
|
|
DeviceRegistry registry,
|
|
|
@@ -104,7 +107,8 @@ public class DeviceInstanceController implements
|
|
|
ReactiveRepository<DeviceTagEntity, String> tagRepository,
|
|
|
DeviceDataService deviceDataService,
|
|
|
DeviceConfigMetadataManager metadataManager,
|
|
|
- DeviceTagsService tagsService) {
|
|
|
+ DeviceTagsService tagsService,
|
|
|
+ ReactiveRepository<GeoProperty, String> propertyRepository) {
|
|
|
this.service = service;
|
|
|
this.registry = registry;
|
|
|
this.productService = productService;
|
|
|
@@ -113,6 +117,7 @@ public class DeviceInstanceController implements
|
|
|
this.deviceDataService = deviceDataService;
|
|
|
this.metadataManager = metadataManager;
|
|
|
this.tagsService=tagsService;
|
|
|
+ this.propertyRepository=propertyRepository;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -327,11 +332,20 @@ public class DeviceInstanceController implements
|
|
|
@Operation(summary = "删除设备标签")
|
|
|
public Mono<Void> deleteDeviceTag(@PathVariable @Parameter(description = "设备ID") String deviceId,
|
|
|
@PathVariable @Parameter(description = "标签ID") String tagId) {
|
|
|
- return tagRepository.createDelete()
|
|
|
- .where(DeviceTagEntity::getDeviceId, deviceId)
|
|
|
- .and(DeviceTagEntity::getId, tagId)
|
|
|
- .execute()
|
|
|
- .then();
|
|
|
+ return tagRepository.findById(tagId)
|
|
|
+ .doOnNext(ignore->
|
|
|
+ tagRepository.createDelete()
|
|
|
+ .where(DeviceTagEntity::getDeviceId, deviceId)
|
|
|
+ .and(DeviceTagEntity::getId, tagId)
|
|
|
+ .execute()
|
|
|
+ .subscribe()
|
|
|
+ ).filter(tagsService::judgementGeo)
|
|
|
+ .map(tag->
|
|
|
+ propertyRepository
|
|
|
+ .createDelete()
|
|
|
+ .where(GeoProperty::getFromId,tagId)
|
|
|
+ .execute()
|
|
|
+ ).then();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -420,6 +434,7 @@ public class DeviceInstanceController implements
|
|
|
tag.tryValidate();
|
|
|
})
|
|
|
.as(tagsService::save)
|
|
|
+ .onErrorMap(DuplicateKeyException.class, err -> new BusinessException("标签不可重复添加", err))
|
|
|
.thenMany(getDeviceTags(deviceId));
|
|
|
}
|
|
|
|