1.添加安全登录功能
2.调整部分接口
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -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>
|
||||
|
||||
|
||||
19
src/main/java/com/njcn/roma/config/Security.java
Normal file
19
src/main/java/com/njcn/roma/config/Security.java
Normal 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
</select>
|
||||
|
||||
|
||||
<button style="margin-left: 100px" id="export">导出历史数据</button>
|
||||
|
||||
<span style="float: right" id="stationId">xxxxxxxxxxxxxx</span>
|
||||
|
||||
<span style="float: right;margin-right: 15px" id="timeId">yyyy-MM-dd HH:mm:ss</span>
|
||||
@@ -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实例
|
||||
@@ -370,6 +407,7 @@
|
||||
}
|
||||
|
||||
|
||||
var historyMessage = []
|
||||
|
||||
|
||||
/**
|
||||
@@ -389,6 +427,7 @@
|
||||
* 当服务端打开连接
|
||||
*/
|
||||
webSocket.onopen = function (event) {
|
||||
historyMessage = []
|
||||
console.log('WebSocket打开连接');
|
||||
};
|
||||
|
||||
@@ -399,6 +438,7 @@
|
||||
console.log('WebSocket收到消息:%c' + event.data, 'color:green');
|
||||
//获取服务端消息
|
||||
var message = JSON.parse(event.data) || {};
|
||||
historyMessage.push(message)
|
||||
|
||||
|
||||
devId = $('#selectId').find('option:selected').val()
|
||||
@@ -482,6 +522,7 @@
|
||||
})
|
||||
|
||||
|
||||
if (pinPuEcharts) {
|
||||
serviseV = []
|
||||
for (let i = 2; i < 26; i++) {
|
||||
|
||||
@@ -496,6 +537,7 @@
|
||||
},
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -518,7 +560,6 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
var serviseV = []
|
||||
var pinPuEcharts
|
||||
$('#buttonPinPu').click(function () {
|
||||
|
||||
Reference in New Issue
Block a user