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> <artifactId>spring-boot-starter-websocket</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies> </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); JSONObject map = JSONObject.parseObject(clientHandler.topicMsg);
map.put("customDevId",clientHandler.devId); map.put("customDevId",clientHandler.devId);
double vA = Double.valueOf(map.get("PhV_phsA").toString()); double vA = Double.valueOf(map.get("PhV_phsA").toString());
@@ -160,6 +160,7 @@ public class TestController {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
//Thread.sleep(180000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

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

View File

@@ -24,6 +24,8 @@
</select> </select>
<button style="margin-left: 100px" id="export">导出历史数据</button>
<span style="float: right" id="stationId">xxxxxxxxxxxxxx</span> <span style="float: right" id="stationId">xxxxxxxxxxxxxx</span>
<span style="float: right;margin-right: 15px" id="timeId">yyyy-MM-dd HH:mm:ss</span> <span style="float: right;margin-right: 15px" id="timeId">yyyy-MM-dd HH:mm:ss</span>
@@ -70,6 +72,41 @@
initVEchart() 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() { function initVEchart() {
// 基于准备好的dom初始化echarts实例 // 基于准备好的dom初始化echarts实例
@@ -370,6 +407,7 @@
} }
var historyMessage = []
/** /**
@@ -389,6 +427,7 @@
* 当服务端打开连接 * 当服务端打开连接
*/ */
webSocket.onopen = function (event) { webSocket.onopen = function (event) {
historyMessage = []
console.log('WebSocket打开连接'); console.log('WebSocket打开连接');
}; };
@@ -399,6 +438,7 @@
console.log('WebSocket收到消息%c' + event.data, 'color:green'); console.log('WebSocket收到消息%c' + event.data, 'color:green');
//获取服务端消息 //获取服务端消息
var message = JSON.parse(event.data) || {}; var message = JSON.parse(event.data) || {};
historyMessage.push(message)
devId = $('#selectId').find('option:selected').val() devId = $('#selectId').find('option:selected').val()
@@ -482,6 +522,7 @@
}) })
if (pinPuEcharts) {
serviseV = [] serviseV = []
for (let i = 2; i < 26; i++) { for (let i = 2; i < 26; i++) {
@@ -496,6 +537,7 @@
}, },
] ]
}) })
}
}; };
@@ -518,7 +560,6 @@
} }
var serviseV = [] var serviseV = []
var pinPuEcharts var pinPuEcharts
$('#buttonPinPu').click(function () { $('#buttonPinPu').click(function () {