| | |
| | | */ |
| | | 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, |
| | |
| | | ) |
| | | break |
| | | case "体重秤": |
| | | console.log(resultInfo,'体重秤') |
| | | sockteStore().setweightSockte( |
| | | { |
| | | deviceName:resultInfo.deviceName, |
| | | deviceName:resultInfo.deviceNumber, |
| | | type:"体重秤", |
| | | result:resultInfo.result, |
| | | resultTime:resultInfo.resultTime, |
| | |
| | | case "血压计": |
| | | sockteStore().setxyjSockte( |
| | | { |
| | | deviceName:resultInfo.deviceName, |
| | | deviceName:resultInfo.deviceNumber, |
| | | type:"血压计", |
| | | result:resultInfo.result, |
| | | resultTime:resultInfo.resultTime, |
| | |
| | | |
| | | // 订阅结果事件返回函数 |
| | | 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("接收数据异常"); |
| | | } |
| | | }; |
| | |
| | | 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})); |
| | | |
| | | } |