1.添加安全登录功能

2.调整部分接口
This commit is contained in:
2024-08-13 16:14:45 +08:00
parent 7449efc6a3
commit 9617f3d975
5 changed files with 127 additions and 53 deletions

View File

@@ -149,6 +149,11 @@
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>

View File

@@ -0,0 +1,19 @@
package com.njcn.roma.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class Security extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().and().authorizeRequests().anyRequest().authenticated().and().csrf().disable();
}
}

View File

@@ -112,7 +112,7 @@ public class TestController {
for(int i=0;i<300;i++){
for(int i=0;i<1000;i++){
JSONObject map = JSONObject.parseObject(clientHandler.topicMsg);
map.put("customDevId",clientHandler.devId);
double vA = Double.valueOf(map.get("PhV_phsA").toString());
@@ -160,6 +160,7 @@ public class TestController {
try {
Thread.sleep(1000);
//Thread.sleep(180000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}

View File

@@ -1,9 +1,17 @@
server:
port: 8790
servlet:
session:
timeout: 1440m
spring:
security:
user:
name: data_njcn
password: dnzl@#002
application:
name: roma
roma:
acceptIp: 25.36.190.3:19776
sendIp: 25.36.190.7:11443

View File

@@ -13,37 +13,39 @@
<div>
<button id="buttonHistory">历史趋势</button>
<button id="buttonPinPu">谐波频谱</button>
<button id="buttonHistory">历史趋势</button>
<button id="buttonPinPu">谐波频谱</button>
<label>设备标识:</label>
<select id="selectId">
<option value="NJCN230497">NJCN230497</option>
<option value="NJCN230497">NJCN230447</option>
<option value="3206010121">3206010121</option>
</select>
<label>设备标识:</label>
<select id="selectId">
<option value="NJCN230497">NJCN230497</option>
<option value="NJCN230497">NJCN230447</option>
<option value="3206010121">3206010121</option>
</select>
<span style="float: right" id="stationId">xxxxxxxxxxxxxx</span>
<button style="margin-left: 100px" id="export">导出历史数据</button>
<span style="float: right;margin-right: 15px" id="timeId">yyyy-MM-dd HH:mm:ss</span>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="history">
<div id="mainOne" style="width: 100%;height: 800px"></div>
<div id="mainTwo" style="width: 100%;height: 800px"></div>
</div>
<span style="float: right" id="stationId">xxxxxxxxxxxxxx</span>
<div id="pinPu" style="display: none">
<span style="float: right;margin-right: 15px" id="timeId">yyyy-MM-dd HH:mm:ss</span>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="history">
<div id="mainOne" style="width: 100%;height: 800px"></div>
<div id="mainTwo" style="width: 100%;height: 800px"></div>
</div>
<div id="pinPuChar" style="width: 100%;height: 800px"></div>
</div>
<div id="pinPu" style="display: none">
<div id="pinPuChar" style="width: 100%;height: 800px"></div>
</div>
</div>
<script type="text/javascript">
var devId;
$(function () {
$('#mainOne').css('height', window.innerHeight / 2 -20)
$('#mainTwo').css('height', window.innerHeight / 2 -20)
$('#mainOne').css('height', window.innerHeight / 2 - 20)
$('#mainTwo').css('height', window.innerHeight / 2 - 20)
devId = $('#selectId').find('option:selected').val()
@@ -70,6 +72,41 @@
initVEchart()
})
$('#export').click(function () {
let str = ``;
if(historyMessage.length > 0){
for(let i in historyMessage[0]){
str+=i+',';
}
str = str.substring(0,str.lastIndexOf(','))+'\n'
}else {
alert("当前无历史数据")
return false
}
download(str, historyMessage)
})
const download = (str, data) => {
// 增加\t为了不让表格显示科学计数法或者其他格式
for (let i = 0; i < data.length; i++) {
for (const key in data[i]) {
str += `${data[i][key] + '\t'},`;
}
str += '\n';
}
// encodeURIComponent解决中文乱码
const uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str);
// 通过创建a标签实现
const link = document.createElement("a");
link.href = uri;
// 对下载的文件命名
link.download = "下载数据.csv";
link.click();
}
function initVEchart() {
// 基于准备好的dom初始化echarts实例
@@ -109,7 +146,7 @@
},
xAxis: {
name:'时间',
name: '时间',
type: 'category',
value: vTime,
boundaryGap: true,
@@ -128,7 +165,7 @@
}
},
yAxis: {
name:'V',
name: 'V',
type: 'value',
axisLabel: {
interval: 0,
@@ -256,7 +293,7 @@
},
xAxis: {
name:'时间',
name: '时间',
type: 'category',
value: vTime,
boundaryGap: true,
@@ -275,7 +312,7 @@
}
},
yAxis: {
name:'A',
name: 'A',
type: 'value',
axisLabel: {
interval: 0,
@@ -370,6 +407,7 @@
}
var historyMessage = []
/**
@@ -389,6 +427,7 @@
* 当服务端打开连接
*/
webSocket.onopen = function (event) {
historyMessage = []
console.log('WebSocket打开连接');
};
@@ -399,28 +438,29 @@
console.log('WebSocket收到消息%c' + event.data, 'color:green');
//获取服务端消息
var message = JSON.parse(event.data) || {};
historyMessage.push(message)
devId = $('#selectId').find('option:selected').val()
if(devId != message.customDevId){
if (devId != message.customDevId) {
return false;
}
$("#timeId").text(message.time.substring(0,4)+'-'+message.time.substring(4,6)+'-'+message.time.substring(6,8)+' '+message.time.substring(9,11)+':'+message.time.substring(11,13)+':'+message.time.substring(13,15))
$("#timeId").text(message.time.substring(0, 4) + '-' + message.time.substring(4, 6) + '-' + message.time.substring(6, 8) + ' ' + message.time.substring(9, 11) + ':' + message.time.substring(11, 13) + ':' + message.time.substring(13, 15))
if(devId == 'NJCN230447'){
if (devId == 'NJCN230447') {
$("#stationId").text("当前位置:保定-满城区-电能质量监测装置-0447")
}else if(devId == 'NJCN230497'){
} else if (devId == 'NJCN230497') {
$("#stationId").text("当前位置:保定-满城区-电能质量监测装置-0497")
}else if(devId == '3206010121'){
} else if (devId == '3206010121') {
$("#stationId").text("当前位置:xx-xx-电能质量监测装置-0121")
}else {
} else {
$("#stationId").text("暂无数据")
}
if(vTime.length>50){
if (vTime.length > 50) {
vTime.shift();
vA.shift();
@@ -432,7 +472,7 @@
}
let temDate = message.time
let aaaDate = temDate.substring(0,4)+'-'+temDate.substring(4,6)+'-'+temDate.substring(6,8)+' '+temDate.substring(9,11)+':'+temDate.substring(11,13)+':'+temDate.substring(13,15)
let aaaDate = temDate.substring(0, 4) + '-' + temDate.substring(4, 6) + '-' + temDate.substring(6, 8) + ' ' + temDate.substring(9, 11) + ':' + temDate.substring(11, 13) + ':' + temDate.substring(13, 15)
vTime.push(aaaDate)
vA.push(message.PhV_phsA)
vB.push(message.PhV_phsB)
@@ -482,21 +522,23 @@
})
serviseV = []
for(let i=2;i<26;i++){
if (pinPuEcharts) {
serviseV = []
for (let i = 2; i < 26; i++) {
let temValV = (Number(message['HRPhV_H'+i+'_phsA'])+Number(message['HRPhV_H'+i+'_phsB'])+Number(message['HRPhV_H'+i+'_phsC']))/3
serviseV.push(temValV.toFixed(3))
let temValV = (Number(message['HRPhV_H' + i + '_phsA']) + Number(message['HRPhV_H' + i + '_phsB']) + Number(message['HRPhV_H' + i + '_phsC'])) / 3
serviseV.push(temValV.toFixed(3))
}
pinPuEcharts.setOption({
series: [
{
data: serviseV
},
]
})
}
pinPuEcharts.setOption({
series: [
{
data: serviseV
},
]
})
};
@@ -518,7 +560,6 @@
}
var serviseV = []
var pinPuEcharts
$('#buttonPinPu').click(function () {
@@ -526,12 +567,12 @@
$('#history').hide()
var pinPuX = []
for(let i=2;i<26;i++){
pinPuX.push(i+'次')
for (let i = 2; i < 26; i++) {
pinPuX.push(i + '次')
}
// 基于准备好的dom初始化echarts实例
pinPuEcharts= echarts.init(document.getElementById('pinPuChar'));
pinPuEcharts = echarts.init(document.getElementById('pinPuChar'));
pinPuEcharts.clear()
// 指定图表的配置项和数据
@@ -569,7 +610,7 @@
},
xAxis: {
name:'次数',
name: '次数',
data: pinPuX,
boundaryGap: true,
axisLine: {
@@ -587,7 +628,7 @@
}
},
yAxis: {
name:'%',
name: '%',
boundaryGap: true,
axisLine: {
show: true,
@@ -608,10 +649,10 @@
name: '谐波电压含有率',
type: 'bar',
data: serviseV,
color:'#339966'
color: '#339966'
},
{
color:'#FF9900',
color: '#FF9900',
name: '限值',
type: 'bar',
data: [