解决长连接 连接不上bug
This commit is contained in:
parent
ebbf4120bf
commit
a121765433
@ -20,7 +20,7 @@ func (this RealDataService) FailDataList(minutes int,appid int) (failDataResList
|
||||
toStartOfInterval(a.part_date, INTERVAL `+strconv.Itoa(minutes)+` minute) as interval_date,
|
||||
formatDateTime(interval_date,'%Y-%m-%d') as year ,formatDateTime(interval_date,'%H:%M') as start_minute, formatDateTime(addMinutes(interval_date, ?),'%H:%M') as end_minute,
|
||||
count(report_data) as count,a.error_reason,a.error_handling,report_type
|
||||
from (select * from xwl_acceptance_status where table_id = ? and status = ? limit 1000 ) a
|
||||
from (select * from xwl_acceptance_status where table_id = ? and status = ? order by part_date desc limit 1000 ) a
|
||||
group by interval_date,a.error_reason,a.error_handling,report_type
|
||||
order by interval_date desc;
|
||||
`,minutes,appid,consumer_data.FailStatus)
|
||||
|
@ -35,7 +35,7 @@ func Init() *App {
|
||||
)
|
||||
|
||||
app.Post("/api/gm_user/login", ManagerUserController{}.Login)
|
||||
|
||||
routerWebsocket(app)
|
||||
app.Use(
|
||||
Timer,
|
||||
JwtMiddleware,
|
||||
@ -44,7 +44,6 @@ func Init() *App {
|
||||
|
||||
runRouterGroupFn(
|
||||
app,
|
||||
routerWebsocket,
|
||||
runOperaterLog,
|
||||
runGmUser,
|
||||
runRealData,
|
||||
|
@ -12,8 +12,7 @@
|
||||
|
||||
</div>
|
||||
<div
|
||||
style="height: 60px;line-height: 50px;display: flex;align-items: center;justify-content: space-between;border-bottom: 1px solid #f0f2f5"
|
||||
>
|
||||
style="height: 60px;line-height: 50px;display: flex;align-items: center;justify-content: space-between;border-bottom: 1px solid #f0f2f5">
|
||||
<div>
|
||||
<a-button @click="openDeviceDialog">查看distinctId列表</a-button>
|
||||
<template v-if="linkedID!=''">
|
||||
@ -23,19 +22,12 @@
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<a-input-search
|
||||
v-model="input"
|
||||
allow-clear
|
||||
placeholder="请输入搜索(如distinctId,事件名...)"
|
||||
style="width: 200px"
|
||||
@change="search"
|
||||
/>
|
||||
<a-input-search v-model="input" allow-clear placeholder="请输入搜索(如distinctId,事件名...)" style="width: 200px"
|
||||
@change="search"/>
|
||||
</div>
|
||||
</div>
|
||||
<el-table
|
||||
v-if="showList"
|
||||
<el-table border v-if="showList"
|
||||
v-loading="connectLoading"
|
||||
border
|
||||
:data="filterList"
|
||||
stripe
|
||||
style="width: 100%"
|
||||
@ -110,13 +102,8 @@
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
<el-dialog
|
||||
v-if="dialogVisible"
|
||||
width="80%"
|
||||
:visible.sync="dialogVisible"
|
||||
title="测试distinctId管理"
|
||||
@close="dialogVisible = false"
|
||||
>
|
||||
<el-dialog v-if="dialogVisible" width="80%" :visible.sync="dialogVisible" title="测试distinctId管理"
|
||||
@close="dialogVisible = false">
|
||||
<el-card class="app-container">
|
||||
<div class="filter-container">
|
||||
<el-tag class="filter-item">distinctId:</el-tag>
|
||||
@ -125,9 +112,7 @@
|
||||
<el-input v-model="remark" style="width: 200px" placeholder="请输入备注" class="filter-item"/>
|
||||
<el-button class="filter-item" type="primary" @click="addDeviceId">添加</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
v-if="showDebugDeviceList"
|
||||
border
|
||||
<el-table border v-if="showDebugDeviceList"
|
||||
:data="debugDeviceList"
|
||||
stripe
|
||||
style="width: 100%"
|
||||
@ -165,15 +150,10 @@
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
v-if="scope.row.device_id!=linkedID"
|
||||
size="mini"
|
||||
type="success"
|
||||
icon="el-icon-link"
|
||||
@click="initWs(scope.row.device_id)"
|
||||
>连接设备
|
||||
<el-button size="mini" type="success" icon="el-icon-link" v-if="scope.row.device_id!=linkedID"
|
||||
@click="initWs(scope.row.device_id)">连接设备
|
||||
</el-button>
|
||||
<el-button v-else size="mini" type="warning" icon="el-icon-link" @click="closeWs()">断开连接</el-button>
|
||||
<el-button size="mini" type="warning" icon="el-icon-link" v-else @click="closeWs()">断开连接</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-close" @click="delteDeviceId(scope.row.device_id)">
|
||||
删除
|
||||
</el-button>
|
||||
@ -217,7 +197,7 @@ export default {
|
||||
deviceId: '',
|
||||
remark: '',
|
||||
linkedID: '',
|
||||
socket: null
|
||||
socket: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -227,8 +207,15 @@ export default {
|
||||
return table
|
||||
},
|
||||
path() {
|
||||
const api = process.env.VUE_APP_BASE_API
|
||||
return api.replace('http', 'ws') + '/ws'
|
||||
let api = process.env.VUE_APP_BASE_API
|
||||
|
||||
if(api == ""){
|
||||
|
||||
return "ws://"+ window.location.host+"/ws"
|
||||
|
||||
}
|
||||
|
||||
return api.replace("http", "ws") + "/ws"
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -312,7 +299,7 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
const list = res.data.list
|
||||
let list = res.data.list
|
||||
this.debugDeviceList = []
|
||||
if (list != null) {
|
||||
this.debugDeviceList = list
|
||||
@ -350,16 +337,16 @@ export default {
|
||||
},
|
||||
initWs(uuid) {
|
||||
this.closeWs()
|
||||
if (this.linkedID != '' && uuid != this.linkedID) {
|
||||
if (this.linkedID != "" && uuid != this.linkedID) {
|
||||
this.list = []
|
||||
}
|
||||
|
||||
if (typeof (WebSocket) === 'undefined') {
|
||||
if (typeof (WebSocket) === "undefined") {
|
||||
this.$message({
|
||||
showClose: true,
|
||||
offset: 60,
|
||||
type: 'error',
|
||||
message: '您的浏览器不支持socket'
|
||||
message: "您的浏览器不支持socket"
|
||||
})
|
||||
} else {
|
||||
// 实例化socket
|
||||
@ -371,24 +358,24 @@ export default {
|
||||
showClose: true,
|
||||
offset: 60,
|
||||
type: 'success',
|
||||
message: 'socket连接成功'
|
||||
message: "socket连接成功"
|
||||
})
|
||||
}
|
||||
// 监听socket错误信息
|
||||
this.socket.onerror = (err) => {
|
||||
console.log('onerror', err)
|
||||
console.log("onerror", err)
|
||||
this.$message({
|
||||
showClose: true,
|
||||
offset: 60,
|
||||
type: 'error',
|
||||
message: 'socket连接失败'
|
||||
message: "socket连接失败",
|
||||
})
|
||||
}
|
||||
// 监听socket消息
|
||||
this.socket.onmessage = (msg) => {
|
||||
const res = JSON.parse(msg.data)
|
||||
let res = JSON.parse(msg.data)
|
||||
if (res.code == 1) {
|
||||
const data = JSON.parse(res.data)
|
||||
let data = JSON.parse(res.data)
|
||||
data['isFormatData'] = false
|
||||
data['index'] = this.list.length
|
||||
data['dataFormat'] = JSON.stringify(JSON.parse(data['report_data']), null, '\t')
|
||||
@ -399,11 +386,11 @@ export default {
|
||||
this.socket.onclose = (res) => {
|
||||
if (res.code == 1006) {
|
||||
setTimeout(() => {
|
||||
console.log('进行重连')
|
||||
console.log("进行重连")
|
||||
this.initWs(uuid)
|
||||
}, 2000)
|
||||
}
|
||||
console.log('socket已经关闭')
|
||||
console.log("socket已经关闭")
|
||||
}
|
||||
this.linkedID = uuid
|
||||
}
|
||||
@ -412,7 +399,7 @@ export default {
|
||||
this.socket.send(data)
|
||||
},
|
||||
async search() {
|
||||
const list = filterData(this.list, this.input.trim())
|
||||
let list = filterData(this.list, this.input.trim())
|
||||
this.list = list
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user