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