Compare commits

..

1 Commits

Author SHA1 Message Date
cxc
cc46a48feb websocket 2023-02-27 10:28:04 +08:00
3 changed files with 126 additions and 150 deletions

View File

@ -162,7 +162,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
{{ {{
scope.row.deviceType scope.row.deviceType
? deviceTypeList.find(v => v.value == scope.row.deviceType) ? deviceTypeList.find((v) => v.value == scope.row.deviceType)
.label .label
: '' : ''
}} }}
@ -177,25 +177,8 @@
<el-table-column align="center" prop="version" label="可升级软件版本"> <el-table-column align="center" prop="version" label="可升级软件版本">
</el-table-column> </el-table-column>
<el-table-column align="center" label="升级状态"> <el-table-column align="center" label="升级状态">
<!-- <template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.isUpdate == 0 ? '已' : '可' }}升级 {{ scope.row.isUpdate == 0 ? '已' : '可' }}升级
</template> -->
<template #default="{row}">
<el-progress
v-if="row.updateStatus == '1'"
type="circle"
:width="40"
:stroke-width="2"
status="success"
:percentage="100"
></el-progress>
<el-progress
v-else
type="circle"
:width="40"
:stroke-width="2"
:percentage="0"
></el-progress>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="上次升级时间"> <el-table-column align="center" label="上次升级时间">
@ -286,7 +269,7 @@ import {
OTAUpdate, OTAUpdate,
OTAUpdates, OTAUpdates,
getNodeOTAHistory, getNodeOTAHistory,
nodeOTAHistoryExport nodeOTAHistoryExport,
} from '@/api/firmware/firmwareupdate'; } from '@/api/firmware/firmwareupdate';
import { select as projectSelect } from '@/api/hardware/project'; import { select as projectSelect } from '@/api/hardware/project';
import { select as productSelect } from '@/api/hardware/product'; import { select as productSelect } from '@/api/hardware/product';
@ -296,7 +279,7 @@ import { userSelect } from '@/api/system/user';
export default { export default {
name: 'FirmwareUpdate', name: 'FirmwareUpdate',
components: { components: {
Region Region,
}, },
data() { data() {
return { return {
@ -307,7 +290,7 @@ export default {
queryProjectSelectList: [], queryProjectSelectList: [],
isUpdateList: [ isUpdateList: [
{ label: '已升级', value: 0 }, { label: '已升级', value: 0 },
{ label: '可升级', value: 1 } { label: '可升级', value: 1 },
], ],
value: '', value: '',
options: '', options: '',
@ -320,14 +303,14 @@ export default {
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10,
}, },
deviceTypeList: [ deviceTypeList: [
{ label: '锐能设备', value: 'rn' }, { label: '锐能设备', value: 'rn' },
{ label: '铁塔设备', value: 'tt' } { label: '铁塔设备', value: 'tt' },
], ],
nodeOTAHistoryDialog: false, nodeOTAHistoryDialog: false,
nodeOTAHistoryData: [] nodeOTAHistoryData: [],
}; };
}, },
created() { created() {
@ -352,12 +335,12 @@ export default {
this.$confirm('是否确认导出所有节点升级记录?', '警告', { this.$confirm('是否确认导出所有节点升级记录?', '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
}) })
.then(function () { .then(function () {
return nodeOTAHistoryExport(); return nodeOTAHistoryExport();
}) })
.then(response => { .then((response) => {
this.download(response.msg); this.download(response.msg);
}); });
}, },
@ -404,12 +387,12 @@ export default {
this.$confirm(`是否确认升级${deviceId}?`, '警告', { this.$confirm(`是否确认升级${deviceId}?`, '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
}) })
.then(() => { .then(() => {
this.OTAUpdate([{ productId, nodeId, deviceId }]); this.OTAUpdate([{ productId, nodeId, deviceId }]);
}) })
.catch(res => {}); .catch((res) => {});
}, },
handleOTAUpdate() { handleOTAUpdate() {
if (this.ids.length) { if (this.ids.length) {
@ -418,18 +401,18 @@ export default {
}); });
const h = this.$createElement; const h = this.$createElement;
this.$confirm( this.$confirm(
`是否确认批量升级\r\n${snap.map(v => v.deviceId).join(',\r\n')}?`, `是否确认批量升级\r\n${snap.map((v) => v.deviceId).join(',\r\n')}?`,
'警告', '警告',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
} }
) )
.then(() => { .then(() => {
this.OTAUpdate(snap); this.OTAUpdate(snap);
}) })
.catch(res => {}); .catch((res) => {});
} else { } else {
let snap = Object.assign({}, this.queryParams); let snap = Object.assign({}, this.queryParams);
delete snap.pageNum; delete snap.pageNum;
@ -437,12 +420,12 @@ export default {
this.$confirm(`是否确认批量升级?`, '警告', { this.$confirm(`是否确认批量升级?`, '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
}) })
.then(() => { .then(() => {
this.OTAUpdates(snap); this.OTAUpdates(snap);
}) })
.catch(res => {}); .catch((res) => {});
} }
}, },
@ -475,18 +458,14 @@ export default {
this.ids = selection; this.ids = selection;
}, },
getList() { getList() {
list(this.queryParams).then(response => { list(this.queryParams).then((response) => {
this.tableData = response.rows; this.tableData = response.rows;
this.total = response.total; this.total = response.total;
}); });
}, },
handleUpdate() {} handleUpdate() {},
} },
}; };
</script> </script>
<style scoped> <style></style>
::v-deep .el-progress__text {
font-size: 16px !important;
}
</style>

View File

@ -204,10 +204,10 @@
</template> </template>
<script> <script>
import { getKeyHistory, info, updateValue } from '@/api/hardware/device' import { getKeyHistory, info, updateValue } from '@/api/hardware/device';
import { getProvinceByCode } from '@/api/hardware/province' import { getProvinceByCode } from '@/api/hardware/province';
import { handleOffsetAndRange } from '../../../utils/offsetMap' import { handleOffsetAndRange } from '../../../utils/offsetMap';
import ReconnectingWebSocket from 'reconnecting-websocket' import ReconnectingWebSocket from 'reconnecting-websocket';
export default { export default {
name: 'DeviceDetail', name: 'DeviceDetail',
@ -248,49 +248,49 @@ export default {
{ label: '锐能设备', value: 'rn' }, { label: '锐能设备', value: 'rn' },
{ label: '铁塔设备', value: 'tt' } { label: '铁塔设备', value: 'tt' }
] ]
} };
}, },
watch: { watch: {
selectDate() { selectDate() {
if (!this.selectDate) { if (!this.selectDate) {
this.selectDate = '' this.selectDate = '';
} }
} }
}, },
computed: { computed: {
// 过充 单体过充阈值 // 过充 单体过充阈值
overcharge() { overcharge() {
let a = this.signal.find(item => item.keyCN == '单体过充阈值') let a = this.signal.find(item => item.keyCN == '单体过充阈值');
return a ? a.valueCN - 0 : null return a ? a.valueCN - 0 : null;
}, },
// 过放 单体过放阈值 // 过放 单体过放阈值
overdischarge() { overdischarge() {
let a = this.signal.find(item => item.keyCN == '单体过放阈值') let a = this.signal.find(item => item.keyCN == '单体过放阈值');
return a ? a.valueCN - 0 : null return a ? a.valueCN - 0 : null;
}, },
// 过压 单体过压阈值 // 过压 单体过压阈值
overVoltage() { overVoltage() {
let a = this.signal.find(item => item.keyCN == '单体过压阈值') let a = this.signal.find(item => item.keyCN == '单体过压阈值');
return a ? a.valueCN - 0 : null return a ? a.valueCN - 0 : null;
}, },
// 欠压 单体欠压阈值 // 欠压 单体欠压阈值
underVoltage() { underVoltage() {
let a = this.signal.find(item => item.keyCN == '单体欠压阈值') let a = this.signal.find(item => item.keyCN == '单体欠压阈值');
return a ? a.valueCN - 0 : null return a ? a.valueCN - 0 : null;
} }
}, },
created() { created() {
let { id } = this.$route.query let { id } = this.$route.query;
if (!id) { if (!id) {
this.msgError('无设备ID') this.msgError('无设备ID');
this.$router.go(-1) this.$router.go(-1);
return return;
} }
this.id = id this.id = id;
this.getDetail() this.getDetail();
}, },
mounted() { mounted() {
this.initWebsocket() this.initWebsocket();
}, },
methods: { methods: {
handleOffsetAndRange, handleOffsetAndRange,
@ -301,30 +301,29 @@ export default {
type: 'warning' type: 'warning'
}) })
.then(() => { .then(() => {
item.value = command item.value = command;
let query = this.info let query = this.info;
query['signal'] = item query['signal'] = item;
updateValue(query).then(({ code, data, message }) => { updateValue(query).then(({ code, data, message }) => {
if (200 == code) { if (200 == code) {
this.msgSuccess(message) this.msgSuccess(message);
this.getDetail() this.getDetail();
} else { } else {
this.msgError(message) this.msgError(message);
} }
});
}) })
}) .catch(() => {});
.catch(() => {
})
// this.$message('click on item ' + command); // this.$message('click on item ' + command);
}, },
open(item) { open(item) {
let keyVla = '' let keyVla = '';
if (item.key == '01305001') { if (item.key == '01305001') {
keyVla = '数值20-3600' keyVla = '数值20-3600';
} else if (item.key == '01306001') { } else if (item.key == '01306001') {
keyVla = '字符串' keyVla = '字符串';
} else { } else {
keyVla = '数值20-600' keyVla = '数值20-600';
} }
this.$prompt(`请输入${keyVla}`, '提示', { this.$prompt(`请输入${keyVla}`, '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -333,68 +332,67 @@ export default {
inputErrorMessage: '校验失败' inputErrorMessage: '校验失败'
}) })
.then(({ value }) => { .then(({ value }) => {
item.value = value item.value = value;
let query = this.info let query = this.info;
query['signal'] = item query['signal'] = item;
updateValue(query).then(({ code, data, message }) => { updateValue(query).then(({ code, data, message }) => {
if (200 == code) { if (200 == code) {
this.msgSuccess(message) this.msgSuccess(message);
this.getDetail() this.getDetail();
} else { } else {
this.msgError(message) this.msgError(message);
} }
}) });
}) })
.catch(() => { .catch(() => {
// this.msgInfo('取消输入'); // this.msgInfo('取消输入');
}) });
}, },
getDetail() { getDetail() {
info(this.id).then(async ({ code, msg, info }) => { info(this.id).then(async ({ code, msg, info }) => {
if (200 == code) { if (200 == code) {
info.proName = await this.getProvinceByCode(info.proCode) info.proName = await this.getProvinceByCode(info.proCode);
info.cityName = await this.getProvinceByCode(info.cityCode) info.cityName = await this.getProvinceByCode(info.cityCode);
info.disName = await this.getProvinceByCode(info.disCode) info.disName = await this.getProvinceByCode(info.disCode);
this.info = info;
this.info = info
if (info.deviceSignal) { if (info.deviceSignal) {
let deviceSignal = JSON.parse(info.deviceSignal.signalJsonTurn) let deviceSignal = JSON.parse(info.deviceSignal.signalJsonTurn);
this.signal = deviceSignal?.signal this.signal = deviceSignal.signal;
this.defaultSignal = info.defaultSignal this.defaultSignal = info.defaultSignal;
// console.log(info.deviceSignal.signalJsonTurn); // console.log(info.deviceSignal.signalJsonTurn);
// console.log(this.signal); // console.log(this.signal);
// let a = deviceSignal.signal.find( // let a = deviceSignal.signal.find(
// item => item.keyCN == '单体过充阈值' // item => item.keyCN == '单体过充阈值'
// ); // );
// console.log(a.valueCN); // console.log(a.valueCN);
this.signalUpdateTime = info.deviceSignal.updateTime this.signalUpdateTime = info.deviceSignal.updateTime;
} }
} else { } else {
this.msgError(msg) this.msgError(msg);
} }
}) });
}, },
getProvinceByCode(code) { getProvinceByCode(code) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getProvinceByCode(code) getProvinceByCode(code)
.then(({ code, msg, data }) => { .then(({ code, msg, data }) => {
if (code == 200) { if (code == 200) {
resolve(data?.cityName) resolve(data.cityName);
} else { } else {
this.$message.error(msg) this.$message.error(msg);
reject({ msg, code }) reject({ msg, code });
} }
}) })
.catch(error => { .catch(error => {
reject(error) reject(error);
}) });
}) });
}, },
openDialog(deviceId, key) { openDialog(deviceId, key) {
this.dialogVisible = true this.dialogVisible = true;
this.queryParams.deviceId = deviceId this.queryParams.deviceId = deviceId;
this.queryParams.key = key this.queryParams.key = key;
this.getChartData() this.getChartData();
}, },
// getDay(mss) { // getDay(mss) {
@ -406,33 +404,33 @@ export default {
// }, // },
getNewData() { getNewData() {
if (this.selectDate == '') return this.$message.info('请选择日期') if (this.selectDate == '') return this.$message.info('请选择日期');
// let a = new Date(this.selectDate[0]).getTime(); // let a = new Date(this.selectDate[0]).getTime();
// let b = new Date(this.selectDate[1]).getTime(); // let b = new Date(this.selectDate[1]).getTime();
// const minTime = b - a; // const minTime = b - a;
// const flag = this.getDay(minTime); // const flag = this.getDay(minTime);
this.queryParams.startTime = this.selectDate[0] this.queryParams.startTime = this.selectDate[0];
this.queryParams.endTime = this.selectDate[1] this.queryParams.endTime = this.selectDate[1];
this.getChartData() this.getChartData();
}, },
getChartData() { getChartData() {
getKeyHistory(this.queryParams).then(data => { getKeyHistory(this.queryParams).then(data => {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart(data) this.initChart(data);
}) });
}) });
}, },
initChart(data) { initChart(data) {
var echarts = require('echarts') var echarts = require('echarts');
this.centerChart = echarts.init(this.$refs.echa) this.centerChart = echarts.init(this.$refs.echa);
let months = [] let months = [];
let nums = [] let nums = [];
data.map(item => { data.map(item => {
for (const k in item) { for (const k in item) {
months.push(k) months.push(k);
nums.push(item[k]) nums.push(item[k]);
} }
}) });
let option = { let option = {
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis'
@ -443,27 +441,27 @@ export default {
dataView: { dataView: {
readOnly: true, readOnly: true,
optionToContent: function(opt) { optionToContent: function(opt) {
let axisData = opt.xAxis[0].data //坐标数据 let axisData = opt.xAxis[0].data; //坐标数据
let series = opt.series //折线图数据 let series = opt.series; //折线图数据
let tdHeads = '<td>序号</td><td>时间</td>' //表头 let tdHeads = '<td>序号</td><td>时间</td>'; //表头
let tdBodys = '' //数据 let tdBodys = ''; //数据
series.forEach(function(item) { series.forEach(function(item) {
//组装表头 //组装表头
tdHeads += `<td style="text-align:center">${item.name}</td>` tdHeads += `<td style="text-align:center">${item.name}</td>`;
}) });
let table = `<table style="width:100%;text-align: center"><tbody><tr>${tdHeads} </tr>` let table = `<table style="width:100%;text-align: center"><tbody><tr>${tdHeads} </tr>`;
for (let i = 0, l = axisData.length; i < l; i++) { for (let i = 0, l = axisData.length; i < l; i++) {
for (let j = 0; j < series.length; j++) { for (let j = 0; j < series.length; j++) {
//组装表数据 //组装表数据
tdBodys += `<td>${series[j].data[i]}</td>` tdBodys += `<td>${series[j].data[i]}</td>`;
} }
table += `<tr><td>${i + 1}</td><td >${ table += `<tr><td>${i + 1}</td><td >${
axisData[i] axisData[i]
}</td>${tdBodys}</tr>` }</td>${tdBodys}</tr>`;
tdBodys = '' tdBodys = '';
} }
table += '</tbody></table>' table += '</tbody></table>';
return table return table;
} }
}, },
// restore: {}, // restore: {},
@ -475,7 +473,7 @@ export default {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: months.map(function(str) { data: months.map(function(str) {
return str.replace(' ', '\n') return str.replace(' ', '\n');
}) })
}, },
yAxis: { yAxis: {
@ -492,21 +490,21 @@ export default {
} }
} }
] ]
} };
this.centerChart.setOption(option) this.centerChart.setOption(option);
}, },
initWebsocket() { initWebsocket() {
const wsBaseUrl = const wsBaseUrl =
process.env.NODE_ENV === 'development' process.env.NODE_ENV === 'development'
? '192.168.110.10:8080' ? '192.168.110.10:8080'
: `${window.location.host}:8080` : `${window.location.host}/${process.env.VUE_APP_BASE_API}`;
this.websocket = new ReconnectingWebSocket(`ws://${wsBaseUrl}/ws`) this.websocket = new ReconnectingWebSocket(`ws://${wsBaseUrl}/ws`);
this.websocket.addEventListener('message', e => { this.websocket.addEventListener('message', e => {
this.$message.success(e.data) this.$message.success(e.data);
}) });
}
} }
} }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -39,9 +39,8 @@ module.exports = {
// target: `http://47.115.73.110:8080`, // target: `http://47.115.73.110:8080`,
// target: `http://121.37.250.170:8080`, // target: `http://121.37.250.170:8080`,
// target: `http://192.168.0.129:8080`, // target: `http://192.168.0.129:8080`,
target: `http://120.79.217.22:81/api`,
// target: `http://192.168.0.131:8080`, // target: `http://192.168.0.131:8080`,
// target: `http://192.168.110.10:8080`, target: `http://192.168.110.10:8080`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''