Browse Source

add 通道更新

18339543638 3 years ago
parent
commit
060c0fdb26

+ 3 - 3
jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/netpump/DataUtils.java

@@ -48,11 +48,11 @@ public class DataUtils {
     }
 
     // 设置 长包 接收数据
-    public static String getLongContent(String content,Map<String, Object> propertiesMap ,Map<String, Object> eventsMap){
+    public static String getLongContent(String content,Map<String, Object> propertiesMap ,Map<String, Object> eventsMap,String deviceId){
         // 泵号   [2-9]字节
         String dataNum = getContent(content,0,4);
-        propertiesMap.put("dataNum",dataNum);
-
+//        propertiesMap.put("dataNum",dataNum);
+        propertiesMap.put("dataNum",deviceId);
         String pumpCode = getContent(content,4,20);
         propertiesMap.put("pumpCode",pumpCode);
         // 住院号

+ 4 - 4
jetlinks-components/network-component/network-core/src/main/java/org/jetlinks/community/netpump/NetPumpDeviceMetadataCodec.java

@@ -34,13 +34,13 @@ public class NetPumpDeviceMetadataCodec implements DeviceMessageCodec {
     public Publisher<DeviceMessage> decode(@Nonnull MessageDecodeContext context) {
         byte[] bytes = context.getMessage().getPayload().array();
         String value = DataUtils.byteArrToHexString(bytes);
-//        String value =new String(bytes);
         MqttMessage message = (MqttMessage) context.getMessage();
+
         String topic = message.getTopic();
         if (!topic.endsWith("/properties/report")) {
             throw new UnsupportedOperationException();
         }
-        return decodeLong(value);
+        return decodeLong(value, context.getDevice().getDeviceId());
     }
 
     @Nonnull
@@ -50,10 +50,10 @@ public class NetPumpDeviceMetadataCodec implements DeviceMessageCodec {
     }
 
 
-    private Flux<DeviceMessage> decodeLong(String  value){
+    private Flux<DeviceMessage> decodeLong(String  value,String deviceId){
         Map<String, Object> propertiesMap=new HashMap<>();
         Map<String, Object> eventsMap=new HashMap<>();
-        String pumpCode = DataUtils.getLongContent(value, propertiesMap, eventsMap);
+        String pumpCode = DataUtils.getLongContent(value, propertiesMap, eventsMap,deviceId);
 
         List<DeviceMessage> result = new ArrayList<>();
         ReportPropertyMessage reportPropertyMessage = new ReportPropertyMessage();

+ 8 - 0
jetlinks-manager/media-manager/src/main/java/org/jetlinks/community/media/controller/MediaDeviceController.java

@@ -26,6 +26,7 @@ import org.jetlinks.community.media.transmit.callback.DeferredResultHolder;
 import org.jetlinks.community.media.transmit.callback.RequestMessage;
 import org.jetlinks.community.media.transmit.cmd.SipCommander;
 import org.jetlinks.core.device.DeviceOperationBroker;
+import org.jetlinks.core.device.DeviceRegistry;
 import org.jetlinks.core.device.StandaloneDeviceMessageBroker;
 import org.jetlinks.core.server.MessageHandler;
 import org.springframework.http.ResponseEntity;
@@ -60,11 +61,18 @@ public class MediaDeviceController implements ReactiveServiceCrudController<Medi
     private final LocalPlayService playService;
     private final LocalMediaDeviceChannelService deviceChannelService;
     private final LocalMediaServerItemService mediaServerItemService;
+    private final DeviceRegistry registry;
     @Override
     public ReactiveCrudService<MediaDevice, String> getService() {
         return mediaDeviceService;
     }
 
+    @Operation(summary = "设备查询")
+    @GetMapping("/deviceId/{deviceId}")
+    public Mono<?> get(@PathVariable("deviceId") String deviceId){
+        return registry.getDevice(deviceId)
+            .switchIfEmpty(Mono.error(new BusinessException("查无设备")));
+    }
     @QueryAction
     @Operation(summary = "设备点播")
     @PostMapping("/{deviceId}/{channelId}/_start")