|
@@ -1,5 +1,6 @@
|
|
|
package org.jetlinks.community.bridge.web;
|
|
package org.jetlinks.community.bridge.web;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
@@ -17,6 +18,7 @@ import org.jetlinks.community.bridge.enums.BridgeStatus;
|
|
|
import org.jetlinks.community.bridge.server.aliyun.AliBridgeGateway;
|
|
import org.jetlinks.community.bridge.server.aliyun.AliBridgeGateway;
|
|
|
import org.jetlinks.community.bridge.service.AliBridgeDeviceService;
|
|
import org.jetlinks.community.bridge.service.AliBridgeDeviceService;
|
|
|
import org.jetlinks.community.bridge.service.AliBridgeService;
|
|
import org.jetlinks.community.bridge.service.AliBridgeService;
|
|
|
|
|
+import org.jetlinks.core.utils.IdUtils;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Mono;
|
|
@@ -147,7 +149,11 @@ public class AliBridgeServerController implements
|
|
|
@Operation(summary = "更新网桥信息")
|
|
@Operation(summary = "更新网桥信息")
|
|
|
@CreateAction
|
|
@CreateAction
|
|
|
public Mono<Void> updateBridge(@RequestBody AliIotBridgeEntity bridge,@PathVariable("serverId") String id){
|
|
public Mono<Void> updateBridge(@RequestBody AliIotBridgeEntity bridge,@PathVariable("serverId") String id){
|
|
|
|
|
+ if(StrUtil.isEmpty(bridge.getId())){
|
|
|
|
|
+ bridge.setId(IdUtils.newUUID());
|
|
|
|
|
+ }
|
|
|
return bridgeService.findById(id)
|
|
return bridgeService.findById(id)
|
|
|
|
|
+ .defaultIfEmpty(bridge)
|
|
|
.flatMap(oldBridge-> bridgeGateway.replaceBridgeServer(oldBridge.getNodeId(),oldBridge.getId(),bridge))
|
|
.flatMap(oldBridge-> bridgeGateway.replaceBridgeServer(oldBridge.getNodeId(),oldBridge.getId(),bridge))
|
|
|
.flatMap(nowBridge->
|
|
.flatMap(nowBridge->
|
|
|
bridgeService.save(bridge)
|
|
bridgeService.save(bridge)
|
|
@@ -158,20 +164,6 @@ public class AliBridgeServerController implements
|
|
|
bridgeGateway.registerDevice(bridge.getNodeId(),bridge.getId(),deviceConfig).then(Mono.empty())
|
|
bridgeGateway.registerDevice(bridge.getNodeId(),bridge.getId(),deviceConfig).then(Mono.empty())
|
|
|
)).then()
|
|
)).then()
|
|
|
);
|
|
);
|
|
|
- //删除设备后重新注册设备
|
|
|
|
|
-// return bridgeService.findById(id)
|
|
|
|
|
-// .flatMap(oldBridge->
|
|
|
|
|
-// Mono.zip(
|
|
|
|
|
-// bridgeGateway.replaceBridgeServer(oldBridge.getNodeId(),oldBridge.getId(),bridge)
|
|
|
|
|
-// , bridgeService.save(bridge))
|
|
|
|
|
-// .flatMap(tp2->bridgeDeviceService.createQuery()
|
|
|
|
|
-// .where(AliIotBridgeDeviceConfig::getBridgeId,bridge.getId())
|
|
|
|
|
-// .fetch()
|
|
|
|
|
-// .flatMap(deviceConfig->
|
|
|
|
|
-// bridgeGateway.registerDevice(bridge.getNodeId(),bridge.getId(),deviceConfig)
|
|
|
|
|
-// ).then()
|
|
|
|
|
-// )
|
|
|
|
|
-// );
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|