up
chenyc
2022-07-05 ee839f3fadece627daec9c4113ba5f5974133b7e
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("接收数据异常");
    }
};
@@ -135,7 +140,9 @@
const connectCallback=function(){
    const pcName= os.hostname()
    // 订阅患者信息服务
    stompClient.subscribe(`/queue/patient/info/${pcName}`,PatientCallback)
    if(stompClient!==null){
        stompClient.subscribe(`/queue/patient/info/${pcName}`,PatientCallback)
    }
    console.log("链接成功",stompClient,pcName)
    // 更新sockte链接状态
    sockteStore().setsockteIsLink(true)
@@ -146,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}));
            }