Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
plant
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhu
plant
Commits
604464f5
Commit
604464f5
authored
Aug 28, 2020
by
qinhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jna 和 波形图 过滤
parent
02de534a
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
258 additions
and
130 deletions
+258
-130
pom.xml
pom.xml
+2
-0
pom.xml
power-bussiness/pom.xml
+26
-1
PowerPlantApplication.java
...sc/energy/power/plant/business/PowerPlantApplication.java
+7
-1
CharacterParamController.java
...r/plant/business/controller/CharacterParamController.java
+3
-68
UserInfoController.java
...y/power/plant/business/controller/UserInfoController.java
+5
-0
FrequencyQuery.java
...sc/energy/power/plant/business/domain/FrequencyQuery.java
+28
-14
Oscillogram.java
...se/sc/energy/power/plant/business/domain/Oscillogram.java
+1
-1
WaveAnalysis.java
...wise/sc/energy/power/plant/business/jni/WaveAnalysis.java
+8
-2
JWTFilter.java
...se/sc/energy/power/plant/business/security/JWTFilter.java
+46
-34
ICharacterParamService.java
.../power/plant/business/service/ICharacterParamService.java
+7
-0
CharacterParamServiceImpl.java
...lant/business/service/impl/CharacterParamServiceImpl.java
+123
-7
application.yml
power-bussiness/src/main/resources/application.yml
+2
-2
jna-5.6.0.jar
power-bussiness/src/main/resources/jna-5.6.0.jar
+0
-0
jna-platform-5.6.0.jar
power-bussiness/src/main/resources/jna-platform-5.6.0.jar
+0
-0
libGMWaveAnalysisModel.so
power-bussiness/src/main/resources/libGMWaveAnalysisModel.so
+0
-0
No files found.
pom.xml
View file @
604464f5
...
@@ -90,6 +90,7 @@
...
@@ -90,6 +90,7 @@
</dependencyManagement>
</dependencyManagement>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<artifactId>
maven-compiler-plugin
</artifactId>
...
@@ -108,5 +109,6 @@
...
@@ -108,5 +109,6 @@
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project>
</project>
power-bussiness/pom.xml
View file @
604464f5
...
@@ -13,7 +13,21 @@
...
@@ -13,7 +13,21 @@
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
</properties>
</properties>
<dependencies>
<dependencies>
<!--名字生成第三方包-->
<dependency>
<groupId>
com.simplename
</groupId>
<artifactId>
jna
</artifactId>
<version>
5.6.0
</version>
<scope>
system
</scope>
<systemPath>
${project.basedir}/src/main/resources/jna-5.6.0.jar
</systemPath>
</dependency>
<dependency>
<groupId>
com.simplename
</groupId>
<artifactId>
jna-platform
</artifactId>
<version>
5.6.0
</version>
<scope>
system
</scope>
<systemPath>
${project.basedir}/src/main/resources/jna-platform-5.6.0.jar
</systemPath>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
...
@@ -146,6 +160,17 @@
...
@@ -146,6 +160,17 @@
<plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<includeSystemScope>
true
</includeSystemScope>
</configuration>
<!-- 指定该Main Class为全局的唯一入口 -->
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
<!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/PowerPlantApplication.java
View file @
604464f5
...
@@ -13,6 +13,12 @@ import org.springframework.scheduling.annotation.EnableScheduling;
...
@@ -13,6 +13,12 @@ import org.springframework.scheduling.annotation.EnableScheduling;
public
class
PowerPlantApplication
{
public
class
PowerPlantApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
PowerPlantApplication
.
class
,
args
);
SpringApplication
.
run
(
PowerPlantApplication
.
class
,
args
);
WaveAnalysis
.
waveAnalysisModel
(
"{}"
);
String
str
=
"{\"Record\":{\"Data\":{\"Data\":[{\"Data\":[14.5446,19.6776,33.1913,35.8237,30.389],\"KKSCode\":\"c0a00101mka12cy616r\",\"KeyPhaseOffset\":[],\"Period\":1}],\"Direction\":0,\"GenerationFreq\":50,\"KeyPhaseTyped\":1,\"PoleNum\":2,\"RecordFlag\":1}},\"StartTime\":1597126940000,\"TimeSpan\":1280}"
;
System
.
out
.
println
(
"===========调用开始================"
);
System
.
out
.
println
(
"参数从信息:==="
);
System
.
out
.
println
(
str
);
String
s
=
WaveAnalysis
.
INSTANCE
.
WaveAnalysisModel
(
str
);
System
.
out
.
println
(
"==========================="
);
System
.
out
.
println
(
"结果:"
+
s
);
}
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/CharacterParamController.java
View file @
604464f5
...
@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotEmpty
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
...
@@ -78,74 +79,7 @@ public class CharacterParamController {
...
@@ -78,74 +79,7 @@ public class CharacterParamController {
@PostMapping
(
"/oscillogram"
)
@PostMapping
(
"/oscillogram"
)
public
BaseResponse
<
List
<
Oscillogram
>>
oscillogram
(
@RequestBody
List
<
String
>
kksCodes
)
{
public
BaseResponse
<
List
<
Oscillogram
>>
oscillogram
(
@RequestBody
List
<
String
>
kksCodes
)
{
List
<
Filter
>
filters
=
new
ArrayList
<>(
kksCodes
.
size
());
return
BaseResponse
.
okData
(
iCharacterParamService
.
getOscillogram
(
kksCodes
));
for
(
String
kkscode
:
kksCodes
)
{
RowFilter
filter
=
new
RowFilter
(
CompareFilter
.
CompareOp
.
EQUAL
,
new
SubstringComparator
(
StrUtil
.
swapCase
(
kkscode
)));
filters
.
add
(
filter
);
}
FilterList
filterList
=
new
FilterList
(
filters
);
Scan
scan1
=
new
Scan
();
scan1
.
setCaching
(
10000
);
scan1
.
setFilter
(
filterList
);
scan1
.
addFamily
(
Bytes
.
toBytes
(
"records"
));
OscillogramRowMapper
oscillogramRowMapper
=
new
OscillogramRowMapper
();
List
<
Oscillogram
>
oscillograms
=
hbaseTemplate
.
find
(
"thermalpower-plant-wave-data"
,
scan1
,
oscillogramRowMapper
);
Scan
scan2
=
new
Scan
();
scan2
.
setCaching
(
10000
);
scan2
.
setFilter
(
filterList
);
scan2
.
addFamily
(
Bytes
.
toBytes
(
"tags"
));
OscillogramTagsMapper
oscillogramRowMapper2
=
new
OscillogramTagsMapper
();
List
<
Oscillogram
>
oscillogramsTags
=
hbaseTemplate
.
find
(
"thermalpower-plant-wave-data"
,
scan2
,
oscillogramRowMapper2
);
System
.
out
.
println
(
"=================波形图数据===================="
);
System
.
out
.
println
(
oscillograms
.
size
());
System
.
out
.
println
(
oscillogramsTags
.
size
());
//关联tags
oscillograms
.
forEach
(
arg
->
oscillogramsTags
.
forEach
(
opt
->
{
if
(
opt
.
getRowKey
().
equals
(
arg
.
getRowKey
()))
{
arg
.
setTimeSpan
(
opt
.
getTimeSpan
());
arg
.
getMapData
();
arg
.
setRecordFlag
(
opt
.
getRecordFlag
());
}
}));
List
<
CharacterParamInfo
>
characterParamInfos
=
iCharacterParamService
.
getByKksCodes
(
kksCodes
);
List
<
Oscillogram
>
rts
=
new
ArrayList
<>(
oscillograms
.
size
());
for
(
Oscillogram
oscillogram
:
oscillograms
)
{
characterParamInfos
.
forEach
(
arg
->
{
if
(
oscillogram
.
getKKsCode
().
equals
(
arg
.
getKksCode
()))
{
rts
.
add
(
oscillogram
);
}
});
}
// FrequencyQuery frequencyQuery = new FrequencyQuery();
// FrequencyQuery.Record record = new FrequencyQuery.Record();
// FrequencyQuery.DataOut dataOut = new FrequencyQuery.DataOut();
// frequencyQuery.setRecord(record);
// frequencyQuery.getRecord().setData(dataOut);
// frequencyQuery.getRecord().getData().setData(new ArrayList<>());
// for (Oscillogram oscillogram : rts) {
// FrequencyQuery.DataIn dataIn = new FrequencyQuery.DataIn();
// dataIn.setKKSCode(oscillogram.getKKsCode());
// dataIn.setData(oscillogram.getMapData());
// dataIn.setKeyPhaseOffset(oscillogram.getNoVersionKeyPhaseOffset());
// dataIn.setPeriod(oscillogram.getPeriod());
// dataOut.setDirection(0);
// dataOut.setGenerationFreq(oscillogram.getGenerationFreq());
// dataOut.setRecordFlag(oscillogram.getRecordFlag());
// dataOut.setPoleNum(oscillogram.getPoleNum());
// frequencyQuery.getRecord().getData().getData().add(dataIn);
// }
//
// iCharacterParamService.getFrequency(JSON.toJSONString(rts));
return
BaseResponse
.
okData
(
rts
);
}
}
@PostMapping
(
"/upload"
)
@PostMapping
(
"/upload"
)
...
@@ -169,4 +103,5 @@ public class CharacterParamController {
...
@@ -169,4 +103,5 @@ public class CharacterParamController {
return
BaseResponse
.
okDataMsg
(
false
,
"上传失败!"
);
return
BaseResponse
.
okDataMsg
(
false
,
"上传失败!"
);
}
}
}
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/UserInfoController.java
View file @
604464f5
...
@@ -55,4 +55,9 @@ public class UserInfoController {
...
@@ -55,4 +55,9 @@ public class UserInfoController {
return
iUserInfoService
.
edit
(
userInfo
);
return
iUserInfoService
.
edit
(
userInfo
);
}
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
"{\"Record\":{\"Data\":{\"Data\":[{\"Data\":[14.5446,19.6776,33.1913,35.8237,30.389],\"KKSCode\":\"c0a00101mka12cy616r\",\"KeyPhaseOffset\":[],\"Period\":1}],\"Direction\":0,\"GenerationFreq\":50,\"KeyPhaseTyped\":1,\"PoleNum\":2,\"RecordFlag\":1}},\"StartTime\":1597126940000,\"TimeSpan\":1280}"
;
System
.
out
.
println
(
str
);
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/FrequencyQuery.java
View file @
604464f5
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
domain
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
domain
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.List
;
...
@@ -15,18 +16,22 @@ public class FrequencyQuery {
...
@@ -15,18 +16,22 @@ public class FrequencyQuery {
/**
/**
* 开始时间
* 开始时间
*/
*/
private
Long
StartTime
;
@JSONField
(
name
=
"StartTime"
)
private
Long
startTime
;
/**
/**
* 时间间隔
* 时间间隔
*/
*/
private
Long
TimeSpan
;
@JSONField
(
name
=
"TimeSpan"
)
private
Long
timeSpan
;
@JSONField
(
name
=
"Record"
)
private
Record
record
;
private
Record
record
;
@lombok
.
Data
@lombok
.
Data
public
static
class
Record
{
public
static
class
Record
{
private
DataOut
Data
;
@JSONField
(
name
=
"Record"
)
private
DataOut
data
;
}
}
@lombok
.
Data
@lombok
.
Data
...
@@ -34,28 +39,33 @@ public class FrequencyQuery {
...
@@ -34,28 +39,33 @@ public class FrequencyQuery {
/**
/**
* 键相类型为波形数据数组下标
* 键相类型为波形数据数组下标
*/
*/
private
Integer
KeyPhaseTyped
=
1
;
@JSONField
(
name
=
"KeyPhaseTyped"
)
private
Integer
keyPhaseTyped
=
1
;
/**
/**
* 磁极数目
* 磁极数目
*/
*/
private
Integer
PoleNum
;
@JSONField
(
name
=
"PoleNum"
)
private
Integer
poleNum
;
/**
/**
* 发电机频率单位(Hz)
* 发电机频率单位(Hz)
*/
*/
private
String
GenerationFreq
;
@JSONField
(
name
=
"GenerationFreq"
)
private
String
generationFreq
;
/**
/**
* 旋转方向(0:顺时针,1:逆时针)
* 旋转方向(0:顺时针,1:逆时针)
*/
*/
private
Integer
Direction
;
@JSONField
(
name
=
"Direction"
)
private
Integer
direction
;
/**
/**
* 记录类型(0:连续采样,1定时采样:)
* 记录类型(0:连续采样,1定时采样:)
*/
*/
private
Integer
RecordFlag
;
@JSONField
(
name
=
"RecordFlag"
)
private
Integer
recordFlag
;
private
List
<
DataIn
>
Data
;
@JSONField
(
name
=
"Data"
)
private
List
<
DataIn
>
data
;
}
}
@Data
@Data
...
@@ -64,21 +74,25 @@ public class FrequencyQuery {
...
@@ -64,21 +74,25 @@ public class FrequencyQuery {
/**
/**
* 测点对应KKS编码
* 测点对应KKS编码
*/
*/
private
String
KKSCode
;
@JSONField
(
name
=
"KKSCode"
)
private
String
kKSCode
;
/**
/**
* 样包采样周期数
* 样包采样周期数
*/
*/
private
Integer
Period
;
@JSONField
(
name
=
"Period"
)
private
Integer
period
;
/**
/**
* 各键相点相对起始时间偏移
* 各键相点相对起始时间偏移
*/
*/
private
String
KeyPhaseOffset
;
@JSONField
(
name
=
"KeyPhaseOffset"
)
private
String
keyPhaseOffset
;
/**
/**
* 数据区域
* 数据区域
*/
*/
private
String
Data
;
@JSONField
(
name
=
"Data"
)
private
String
data
;
}
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/Oscillogram.java
View file @
604464f5
...
@@ -49,7 +49,7 @@ public class Oscillogram {
...
@@ -49,7 +49,7 @@ public class Oscillogram {
private
Integer
recordFlag
;
private
Integer
recordFlag
;
private
Stri
ng
startTime
;
private
Lo
ng
startTime
;
private
String
rowKey
;
private
String
rowKey
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/jni/WaveAnalysis.java
View file @
604464f5
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
jni
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
jni
;
import
com.sun.jna.Library
;
import
com.sun.jna.Native
;
/**
/**
* @description:
* @description:
* @author: qh
* @author: qh
* @create: 2020-08-24 19:40
* @create: 2020-08-24 19:40
**/
**/
public
class
WaveAnalysis
{
public
interface
WaveAnalysis
extends
Library
{
String
dllPath
=
"libGMWaveAnalysisModel.so"
;
WaveAnalysis
INSTANCE
=
Native
.
load
(
dllPath
,
WaveAnalysis
.
class
);
public
static
native
String
w
aveAnalysisModel
(
String
jstr
);
String
W
aveAnalysisModel
(
String
jstr
);
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/security/JWTFilter.java
View file @
604464f5
...
@@ -4,11 +4,14 @@ import io.jsonwebtoken.Claims;
...
@@ -4,11 +4,14 @@ import io.jsonwebtoken.Claims;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.Jwts
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.web.authentication.www.BasicAuthenticationFilter
;
import
org.springframework.security.web.authentication.www.BasicAuthenticationFilter
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
javax.servlet.FilterChain
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.Cookie
;
...
@@ -16,44 +19,53 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -16,44 +19,53 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Objects
;
import
java.util.Objects
;
import
static
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
security
.
SecurityConstants
.
AUTHORIZATION_HEADER
;
import
static
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
security
.
SecurityConstants
.
AUTHORIZATION_HEADER
;
import
static
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
security
.
SecurityConstants
.
TOKEN_PREFIX
;
import
static
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
security
.
SecurityConstants
.
TOKEN_PREFIX
;
public
class
JWTFilter
extends
BasicAuthenticationFilter
{
public
class
JWTFilter
extends
BasicAuthenticationFilter
{
private
final
UserDetailsService
userDetailsService
;
private
final
UserDetailsService
userDetailsService
;
public
JWTFilter
(
final
AuthenticationManager
authenticationManager
,
final
UserDetailsService
userDetailsService
)
{
super
(
authenticationManager
);
this
.
userDetailsService
=
userDetailsService
;
}
@Override
public
JWTFilter
(
final
AuthenticationManager
authenticationManager
,
protected
void
doFilterInternal
(
final
HttpServletRequest
request
,
final
UserDetailsService
userDetailsService
)
{
final
HttpServletResponse
response
,
final
FilterChain
filterChain
)
super
(
authenticationManager
);
throws
ServletException
,
IOException
{
this
.
userDetailsService
=
userDetailsService
;
final
String
token
=
this
.
getToken
(
request
);
if
(!
StringUtils
.
hasText
(
token
))
{
filterChain
.
doFilter
(
request
,
response
);
return
;
}
}
final
Claims
claims
=
Jwts
.
parserBuilder
()
@Override
.
setSigningKey
(
JWTKeyHolder
.
KEY
)
protected
void
doFilterInternal
(
final
HttpServletRequest
request
,
.
build
()
final
HttpServletResponse
response
,
final
FilterChain
filterChain
)
.
parseClaimsJws
(
token
)
throws
ServletException
,
IOException
{
.
getBody
();
final
String
token
=
this
.
getToken
(
request
);
final
UserDetails
userDetails
=
this
.
userDetailsService
if
(!
StringUtils
.
hasText
(
token
))
{
.
loadUserByUsername
(
claims
.
getSubject
());
filterChain
.
doFilter
(
request
,
response
);
SecurityContextHolder
.
getContext
()
return
;
.
setAuthentication
(
new
UsernamePasswordAuthenticationToken
(
}
userDetails
.
getUsername
(),
null
,
userDetails
.
getAuthorities
()
Claims
claims
;
));
try
{
filterChain
.
doFilter
(
request
,
response
);
claims
=
Jwts
.
parserBuilder
()
}
.
setSigningKey
(
JWTKeyHolder
.
KEY
)
.
build
()
.
parseClaimsJws
(
token
)
.
getBody
();
}
catch
(
Exception
e
)
{
response
.
setStatus
(
401
);
filterChain
.
doFilter
(
request
,
response
);
return
;
}
final
UserDetails
userDetails
=
this
.
userDetailsService
.
loadUserByUsername
(
claims
.
getSubject
());
SecurityContextHolder
.
getContext
()
.
setAuthentication
(
new
UsernamePasswordAuthenticationToken
(
userDetails
.
getUsername
(),
null
,
userDetails
.
getAuthorities
()
));
filterChain
.
doFilter
(
request
,
response
);
}
private
String
getToken
(
final
HttpServletRequest
request
)
{
private
String
getToken
(
final
HttpServletRequest
request
)
{
// if (request.getCookies() != null) {
// if (request.getCookies() != null) {
// for (final Cookie cookie : request.getCookies()) {
// for (final Cookie cookie : request.getCookies()) {
// if (Objects.equals(cookie.getName(), SecurityConstants.AUTH_COOKIE)) {
// if (Objects.equals(cookie.getName(), SecurityConstants.AUTH_COOKIE)) {
...
@@ -63,10 +75,10 @@ public class JWTFilter extends BasicAuthenticationFilter {
...
@@ -63,10 +75,10 @@ public class JWTFilter extends BasicAuthenticationFilter {
// }
// }
// }
// }
// }
// }
final
String
header
=
request
.
getHeader
(
AUTHORIZATION_HEADER
);
final
String
header
=
request
.
getHeader
(
AUTHORIZATION_HEADER
);
if
(
header
!=
null
&&
header
.
startsWith
(
TOKEN_PREFIX
))
{
if
(
header
!=
null
&&
header
.
startsWith
(
TOKEN_PREFIX
))
{
return
header
.
substring
(
TOKEN_PREFIX
.
length
());
return
header
.
substring
(
TOKEN_PREFIX
.
length
());
}
return
null
;
}
}
return
null
;
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/ICharacterParamService.java
View file @
604464f5
...
@@ -4,6 +4,7 @@ import cn.wise.sc.energy.power.plant.business.bean.DataPower;
...
@@ -4,6 +4,7 @@ import cn.wise.sc.energy.power.plant.business.bean.DataPower;
import
cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery
;
import
cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.Frequency
;
import
cn.wise.sc.energy.power.plant.business.domain.Frequency
;
import
cn.wise.sc.energy.power.plant.business.domain.Oscillogram
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
...
@@ -106,4 +107,10 @@ public interface ICharacterParamService extends IBaseService<String, CharacterPa
...
@@ -106,4 +107,10 @@ public interface ICharacterParamService extends IBaseService<String, CharacterPa
* @return list
* @return list
*/
*/
List
<
Frequency
>
getFrequency
(
String
toJSONString
);
List
<
Frequency
>
getFrequency
(
String
toJSONString
);
/**
* 获取波形图
* @param kksCodes kkscode
*/
List
<
Oscillogram
>
getOscillogram
(
List
<
String
>
kksCodes
);
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/CharacterParamServiceImpl.java
View file @
604464f5
...
@@ -5,10 +5,15 @@ import cn.wise.sc.energy.power.plant.business.bean.DataPower;
...
@@ -5,10 +5,15 @@ import cn.wise.sc.energy.power.plant.business.bean.DataPower;
import
cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery
;
import
cn.wise.sc.energy.power.plant.business.bean.TimeModelQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.Frequency
;
import
cn.wise.sc.energy.power.plant.business.domain.Frequency
;
import
cn.wise.sc.energy.power.plant.business.domain.FrequencyQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.Oscillogram
;
import
cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper
;
import
cn.wise.sc.energy.power.plant.business.domain.OscillogramTagsMapper
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.eum.TendencyStatus
;
import
cn.wise.sc.energy.power.plant.business.domain.eum.TendencyStatus
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo
;
import
cn.wise.sc.energy.power.plant.business.jni.WaveAnalysis
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.OpentsdbOkHttpClient
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.QueryRequestExt
;
...
@@ -17,14 +22,20 @@ import cn.wise.sc.energy.power.plant.business.repository.UnitInfoRepository;
...
@@ -17,14 +22,20 @@ import cn.wise.sc.energy.power.plant.business.repository.UnitInfoRepository;
import
cn.wise.sc.energy.power.plant.business.service.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.business.service.ICharacterParamService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.opentsdb.client.api.query.request.QueryLastRequest
;
import
net.opentsdb.client.api.query.response.QueryLastResponse
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.api.query.response.QueryResponse
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.Aggregator
;
import
net.opentsdb.client.bean.LastDataPointQuery
;
import
net.opentsdb.client.bean.QueryResult
;
import
net.opentsdb.client.bean.QueryResult
;
import
org.apache.hadoop.hbase.client.Scan
;
import
org.apache.hadoop.hbase.filter.CompareFilter
;
import
org.apache.hadoop.hbase.filter.Filter
;
import
org.apache.hadoop.hbase.filter.FilterList
;
import
org.apache.hadoop.hbase.filter.RowFilter
;
import
org.apache.hadoop.hbase.filter.SubstringComparator
;
import
org.apache.hadoop.hbase.util.Bytes
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
...
@@ -58,13 +69,17 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
...
@@ -58,13 +69,17 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
CharacterParamRepository
characterParamRepository
;
CharacterParamRepository
characterParamRepository
;
final
final
UnitInfoRepository
unitInfoRepository
;
UnitInfoRepository
unitInfoRepository
;
final
HbaseTemplate
hbaseTemplate
;
public
CharacterParamServiceImpl
(
UnitInfoServiceImpl
unitInfoService
,
public
CharacterParamServiceImpl
(
UnitInfoServiceImpl
unitInfoService
,
CharacterParamRepository
characterParamRepository
,
CharacterParamRepository
characterParamRepository
,
UnitInfoRepository
unitInfoRepository
)
{
UnitInfoRepository
unitInfoRepository
,
HbaseTemplate
hbaseTemplate
)
{
this
.
unitInfoService
=
unitInfoService
;
this
.
unitInfoService
=
unitInfoService
;
this
.
characterParamRepository
=
characterParamRepository
;
this
.
characterParamRepository
=
characterParamRepository
;
this
.
unitInfoRepository
=
unitInfoRepository
;
this
.
unitInfoRepository
=
unitInfoRepository
;
this
.
hbaseTemplate
=
hbaseTemplate
;
}
}
@Override
@Override
...
@@ -249,8 +264,8 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
...
@@ -249,8 +264,8 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
});
});
//如果时间传0 默认取最后一条数据向前推1h
//如果时间传0 默认取最后一条数据向前推1h
if
(
timeModelQuery
.
getStart
()
==
0
||
timeModelQuery
.
getEnd
()
==
0
)
{
if
(
timeModelQuery
.
getStart
()
==
0
||
timeModelQuery
.
getEnd
()
==
0
)
{
timeModelQuery
.
setStart
(
1597456800000L
);
timeModelQuery
.
setStart
(
1597456800000L
);
timeModelQuery
.
setEnd
(
1597460400000L
);
timeModelQuery
.
setEnd
(
1597460400000L
);
// QueryLastRequest queryLastRequest = new QueryLastRequest();
// QueryLastRequest queryLastRequest = new QueryLastRequest();
// LastDataPointQuery lastDataPointQuery = new LastDataPointQuery();
// LastDataPointQuery lastDataPointQuery = new LastDataPointQuery();
...
@@ -319,11 +334,112 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
...
@@ -319,11 +334,112 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
@Override
@Override
public
List
<
Frequency
>
getFrequency
(
String
toJSONString
)
{
public
List
<
Frequency
>
getFrequency
(
String
toJSONString
)
{
//todo 调用C函数 获取频谱图
System
.
out
.
println
(
"参数:"
);
System
.
out
.
println
(
toJSONString
);
String
s
=
WaveAnalysis
.
INSTANCE
.
WaveAnalysisModel
(
toJSONString
);
System
.
out
.
println
(
s
);
return
null
;
return
null
;
}
}
@Override
public
List
<
Oscillogram
>
getOscillogram
(
List
<
String
>
kksCodes
)
{
//添加过滤器 过滤名字中包含kkscode
List
<
Filter
>
filters
=
new
ArrayList
<>(
kksCodes
.
size
());
for
(
String
kkscode
:
kksCodes
)
{
RowFilter
filter
=
new
RowFilter
(
CompareFilter
.
CompareOp
.
EQUAL
,
new
SubstringComparator
(
StrUtil
.
swapCase
(
kkscode
)));
filters
.
add
(
filter
);
}
FilterList
filterList
=
new
FilterList
(
filters
);
Scan
scanRow
=
new
Scan
();
scanRow
.
setCaching
(
10000
);
scanRow
.
setFilter
(
filterList
);
scanRow
.
addFamily
(
Bytes
.
toBytes
(
"records"
));
scanRow
.
setReversed
(
true
);
Scan
scanTags
=
new
Scan
();
scanTags
.
setCaching
(
10000
);
scanTags
.
setFilter
(
filterList
);
scanTags
.
addFamily
(
Bytes
.
toBytes
(
"tags"
));
scanTags
.
setReversed
(
true
);
OscillogramRowMapper
oscillogramRowMapper
=
new
OscillogramRowMapper
();
List
<
Oscillogram
>
oscillograms
=
hbaseTemplate
.
find
(
"thermalpower-plant-wave-data"
,
scanRow
,
oscillogramRowMapper
);
OscillogramTagsMapper
oscillogramRowMapper2
=
new
OscillogramTagsMapper
();
List
<
Oscillogram
>
oscillogramsTags
=
hbaseTemplate
.
find
(
"thermalpower-plant-wave-data"
,
scanTags
,
oscillogramRowMapper2
);
System
.
out
.
println
(
"=================波形图数据===================="
);
System
.
out
.
println
(
oscillograms
.
size
());
System
.
out
.
println
(
oscillogramsTags
.
size
());
//关联tags 这会很慢!!!
long
start
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
start
);
oscillogramsTags
.
forEach
(
opt
->
{
oscillograms
.
forEach
(
arg
->
{
if
(
opt
.
getRowKey
().
equals
(
arg
.
getRowKey
()))
{
arg
.
setTimeSpan
(
opt
.
getTimeSpan
());
arg
.
getMapData
();
arg
.
setRecordFlag
(
opt
.
getRecordFlag
());
arg
.
setGenerationFreq
(
opt
.
getGenerationFreq
());
arg
.
setPoleNum
(
opt
.
getPoleNum
());
arg
.
setPeriod
(
opt
.
getPeriod
());
}
});
});
//筛选最新的一条数据
List
<
CharacterParamInfo
>
characterParamInfos
=
this
.
getByKksCodes
(
kksCodes
);
Map
<
String
,
Oscillogram
>
oscillogramLastMap
=
new
HashMap
<>(
characterParamInfos
.
size
());
for
(
Oscillogram
oscillogram
:
oscillograms
)
{
characterParamInfos
.
forEach
(
arg
->
{
String
kKSCode
=
oscillogram
.
getKKsCode
();
if
(
kKSCode
.
equals
(
arg
.
getKksCode
()))
{
if
(
oscillogramLastMap
.
containsKey
(
kKSCode
))
{
//比较已存在的startTime大小
if
(
oscillogramLastMap
.
get
(
kKSCode
).
getStart
()
<
oscillogram
.
getStart
())
{
oscillogramLastMap
.
put
(
kKSCode
,
oscillogram
);
}
}
else
{
oscillogramLastMap
.
put
(
kKSCode
,
oscillogram
);
}
}
});
}
List
<
Oscillogram
>
rts
=
new
ArrayList
<>(
oscillogramLastMap
.
size
());
for
(
String
key
:
oscillogramLastMap
.
keySet
())
{
rts
.
add
(
oscillogramLastMap
.
get
(
key
));
}
FrequencyQuery
frequencyQuery
=
new
FrequencyQuery
();
FrequencyQuery
.
Record
record
=
new
FrequencyQuery
.
Record
();
FrequencyQuery
.
DataOut
dataOut
=
new
FrequencyQuery
.
DataOut
();
frequencyQuery
.
setRecord
(
record
);
frequencyQuery
.
getRecord
().
setData
(
dataOut
);
frequencyQuery
.
getRecord
().
getData
().
setData
(
new
ArrayList
<>());
for
(
Oscillogram
oscillogram
:
rts
)
{
frequencyQuery
.
setStartTime
(
oscillogram
.
getStart
());
frequencyQuery
.
setTimeSpan
(
oscillogram
.
getTimeSpan
());
FrequencyQuery
.
DataIn
dataIn
=
new
FrequencyQuery
.
DataIn
();
dataIn
.
setKKSCode
(
StrUtil
.
swapCase
(
oscillogram
.
getKKsCode
()));
dataIn
.
setData
(
oscillogram
.
getMapData
());
dataIn
.
setKeyPhaseOffset
(
oscillogram
.
getNoVersionKeyPhaseOffset
());
dataIn
.
setPeriod
(
oscillogram
.
getPeriod
());
dataOut
.
setDirection
(
0
);
dataOut
.
setGenerationFreq
(
oscillogram
.
getGenerationFreq
());
dataOut
.
setRecordFlag
(
oscillogram
.
getRecordFlag
());
dataOut
.
setPoleNum
(
oscillogram
.
getPoleNum
());
frequencyQuery
.
getRecord
().
getData
().
getData
().
add
(
dataIn
);
}
getFrequency
(
JSON
.
toJSONString
(
frequencyQuery
));
return
rts
;
}
private
DataPower
buildDataPower
(
List
<
QueryResult
>
results
,
private
DataPower
buildDataPower
(
List
<
QueryResult
>
results
,
List
<
CharacterParamInfo
>
characterParamInfos
)
{
List
<
CharacterParamInfo
>
characterParamInfos
)
{
...
...
power-bussiness/src/main/resources/application.yml
View file @
604464f5
...
@@ -53,8 +53,8 @@ spring:
...
@@ -53,8 +53,8 @@ spring:
nodeParent
:
/hbase-unsecure
nodeParent
:
/hbase-unsecure
redisson
:
redisson
:
master-name
:
mymaster
master-name
:
mymaster
address
:
redis://127.0.0.1:637
9
address
:
redis://127.0.0.1:637
8
#
password: Risen12348765
password
:
Risen12348765
subscriptionConnectionMinimumIdleSize
:
1
subscriptionConnectionMinimumIdleSize
:
1
dnsMonitoring
:
false
dnsMonitoring
:
false
failedAttempts
:
2
failedAttempts
:
2
...
...
power-bussiness/src/main/resources/jna-5.6.0.jar
0 → 100644
View file @
604464f5
File added
power-bussiness/src/main/resources/jna-platform-5.6.0.jar
0 → 100644
View file @
604464f5
File added
power-bussiness/src/main/resources/libGMWaveAnalysisModel.so
0 → 100644
View file @
604464f5
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment