From ee839f3fadece627daec9c4113ba5f5974133b7e Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期二, 05 七月 2022 18:03:03 +0800
Subject: [PATCH] up
---
src/samples/sockteStomp.ts | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/samples/sockteStomp.ts b/src/samples/sockteStomp.ts
index 44dbde3..38460f8 100644
--- a/src/samples/sockteStomp.ts
+++ b/src/samples/sockteStomp.ts
@@ -21,13 +21,16 @@
*/
const writeResult=(resultInfo:any)=>{
if(devices.length>0){
- const deviceInfo=devices.find(de=>{de.deviceName===resultInfo.deviceName})
+ const deviceInfo=devices.find(de=>{
+ return de.deviceName===resultInfo.deviceNumber
+ })
+ console.log('---1-',deviceInfo)
if(deviceInfo!==undefined){
switch(deviceInfo.deviceType){
case '读卡器':
sockteStore().setdkqSockte(
{
- deviceName:resultInfo.deviceName,
+ deviceName:resultInfo.deviceNumber,
type:"读卡器",
result:resultInfo.result,
resultTime:resultInfo.resultTime,
@@ -36,9 +39,10 @@
)
break
case "体重秤":
+ console.log(resultInfo,'体重秤')
sockteStore().setweightSockte(
{
- deviceName:resultInfo.deviceName,
+ deviceName:resultInfo.deviceNumber,
type:"体重秤",
result:resultInfo.result,
resultTime:resultInfo.resultTime,
@@ -49,7 +53,7 @@
case "血压计":
sockteStore().setxyjSockte(
{
- deviceName:resultInfo.deviceName,
+ deviceName:resultInfo.deviceNumber,
type:"血压计",
result:resultInfo.result,
resultTime:resultInfo.resultTime,
@@ -107,12 +111,13 @@
// 订阅结果事件返回函数
const callback = function(message:any) {
- if (message.body) {
+ console.log('接收到数据-----',message.body)
+ if (message.body!==undefined) {
const data=JSON.parse(message.body)
- if(data.deviceName)
- console.log(data,'接收到的数据')
+ console.log(data,"体重数据")
writeResult(data)
- } else {
+ }
+ else {
alert("接收数据异常");
}
};
@@ -148,7 +153,7 @@
if(stompClient!==null){
stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/result`,callback)
// /queue/{clientCode}/{deviceName}/keepalive
- stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/keepalive`,callbackState)
+ // stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/keepalive`,callbackState)
stompClient.send(`/app/device/request/${clientCode}/${de.deviceName}`, {}, JSON.stringify({"deviceNumber":de.deviceName}));
}
--
Gitblit v1.8.0