up
chenyc
2022-07-05 ee839f3fadece627daec9c4113ba5f5974133b7e
up
2个文件已修改
41 ■■■■ 已修改文件
src/samples/sockteStomp.ts 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/index.vue 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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}));
            } 
src/views/home/index.vue
@@ -39,7 +39,7 @@
                },10000)
                setInterval(function(){
                    state.Newdate=formatDate(new Date(),"YYYY-mm-dd HH:MM:SS")
                    console.log(state.Newdate,'----ss')
                    // console.log(state.Newdate,'----ss')
                },1000)
            })
            return{ ...toRefs(state),isLink,netLink,weightInfo,inputRef,inputChabge
@@ -67,10 +67,16 @@
                    <img class="imgss" alt="Vue logo" src="@/assets/logo.png" />
                </div>
            </el-col>
            <el-col :span="12">
            <el-col :span="6">
                <!-- <div> sockte连接状态{{isLink}}</div>
                <div> 网络连接状态{{netLink}}</div> -->
                <el-input id="inputCode" @change="inputChabge" v-model="inputCode" ref="inputRef" placeholder="" />
            </el-col>
            <el-col :span="6">
                <div class="datess">
                    60
                </div>
            </el-col>
        </el-row>
        <div class="grid-container">
@@ -175,4 +181,12 @@
    background: #c1c2c6;
    color: black;
}
.datess{
    text-align: right;
    padding-right: 20px;
    height: 30px;
    line-height: 30px;
    color: red;
    font-weight: 1000;
}
</style>