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
70511567
Commit
70511567
authored
Sep 24, 2020
by
shulidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
e030ae71
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
16 deletions
+36
-16
PowerPlantApplication.java
...sc/energy/power/plant/business/PowerPlantApplication.java
+1
-1
BtreeInspectionController.java
.../plant/business/controller/BtreeInspectionController.java
+9
-12
C2TreeAnalysis.java
...se/sc/energy/power/plant/business/jna/C2TreeAnalysis.java
+1
-0
JWTFilter.java
...se/sc/energy/power/plant/business/security/JWTFilter.java
+3
-3
Utils.java
...a/cn/wise/sc/energy/power/plant/business/utils/Utils.java
+22
-0
No files found.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/PowerPlantApplication.java
View file @
70511567
...
@@ -14,7 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
...
@@ -14,7 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@ImportAutoConfiguration
(
SecurityConfig
.
class
)
@ImportAutoConfiguration
(
SecurityConfig
.
class
)
public
class
PowerPlantApplication
{
public
class
PowerPlantApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"jna.protected"
,
"true"
);
//
System.setProperty("jna.protected","true");
SpringApplication
.
run
(
PowerPlantApplication
.
class
,
args
);
SpringApplication
.
run
(
PowerPlantApplication
.
class
,
args
);
}
}
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/BtreeInspectionController.java
View file @
70511567
...
@@ -7,15 +7,12 @@ import cn.wise.sc.energy.power.plant.business.domain.redisTrans.BtreeInerAction;
...
@@ -7,15 +7,12 @@ import cn.wise.sc.energy.power.plant.business.domain.redisTrans.BtreeInerAction;
import
cn.wise.sc.energy.power.plant.business.domain.redisTrans.BtreeProcess
;
import
cn.wise.sc.energy.power.plant.business.domain.redisTrans.BtreeProcess
;
import
cn.wise.sc.energy.power.plant.business.jna.C2TreeAnalysis
;
import
cn.wise.sc.energy.power.plant.business.jna.C2TreeAnalysis
;
import
cn.wise.sc.energy.power.plant.business.repository.BtreeInfoConfigRepository
;
import
cn.wise.sc.energy.power.plant.business.repository.BtreeInfoConfigRepository
;
import
cn.wise.sc.energy.power.plant.business.task.schedule.ScheduleUtil
;
import
cn.wise.sc.energy.power.plant.business.utils.BeanUtilsExt
;
import
cn.wise.sc.energy.power.plant.business.utils.BeanUtilsExt
;
import
cn.wise.sc.energy.power.plant.business.utils.Utils
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.hibernate.loader.plan.build.internal.LoadGraphLoadPlanBuildingStrategy
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RDeque
;
import
org.redisson.api.RList
;
import
org.redisson.api.RList
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.client.codec.StringCodec
;
import
org.redisson.client.codec.StringCodec
;
...
@@ -82,7 +79,7 @@ public class BtreeInspectionController {
...
@@ -82,7 +79,7 @@ public class BtreeInspectionController {
public
BaseResponse
getProcess
()
{
public
BaseResponse
getProcess
()
{
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
RBucket
<
String
>
currentIndex
=
redissonClient
.
getBucket
(
"btreetask:
C0A001-1"
);
RBucket
<
String
>
currentIndex
=
redissonClient
.
getBucket
(
"btreetask:
"
+
Utils
.
getTaskPrefix
()
);
if
(
currentIndex
.
get
()
==
null
)
{
if
(
currentIndex
.
get
()
==
null
)
{
result
.
put
(
"status"
,
-
3
);
result
.
put
(
"status"
,
-
3
);
return
BaseResponse
.
okData
(
result
);
return
BaseResponse
.
okData
(
result
);
...
@@ -126,7 +123,7 @@ public class BtreeInspectionController {
...
@@ -126,7 +123,7 @@ public class BtreeInspectionController {
@PostMapping
(
"/interaction"
)
@PostMapping
(
"/interaction"
)
public
BaseResponse
interaction
(
@RequestBody
BtreeInerAct
btreeInerAct
)
{
public
BaseResponse
interaction
(
@RequestBody
BtreeInerAct
btreeInerAct
)
{
//存储redis
//存储redis
RBucket
<
String
>
currentIndex
=
redissonClient
.
getBucket
(
"btreetask:
C0A001-1"
);
RBucket
<
String
>
currentIndex
=
redissonClient
.
getBucket
(
"btreetask:
"
+
Utils
.
getTaskPrefix
()
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
if
(
currentIndex
.
get
()
==
null
)
{
if
(
currentIndex
.
get
()
==
null
)
{
result
.
put
(
"status"
,
-
3
);
result
.
put
(
"status"
,
-
3
);
...
@@ -134,7 +131,7 @@ public class BtreeInspectionController {
...
@@ -134,7 +131,7 @@ public class BtreeInspectionController {
}
}
RList
<
String
>
a
=
redissonClient
.
getList
(
"result_"
+
currentIndex
.
get
(),
new
StringCodec
());
//currentIndex.get()
RList
<
String
>
a
=
redissonClient
.
getList
(
"result_"
+
currentIndex
.
get
(),
new
StringCodec
());
//currentIndex.get()
a
.
add
(
0
,
JSON
.
toJSONString
(
btreeInerAct
));
a
.
add
(
0
,
JSON
.
toJSONString
(
btreeInerAct
));
//
todo
更新状态-2为-1
//更新状态-2为-1
RList
<
String
>
redisList
=
redissonClient
.
getList
(
"process_"
+
currentIndex
.
get
(),
new
StringCodec
());
//currentIndex.get()
RList
<
String
>
redisList
=
redissonClient
.
getList
(
"process_"
+
currentIndex
.
get
(),
new
StringCodec
());
//currentIndex.get()
BtreeProcess
btreeProcess
=
JSON
.
parseObject
(
redisList
.
get
(
0
),
BtreeProcess
.
class
);
BtreeProcess
btreeProcess
=
JSON
.
parseObject
(
redisList
.
get
(
0
),
BtreeProcess
.
class
);
btreeProcess
.
setGrade
(-
1.0
);
btreeProcess
.
setGrade
(-
1.0
);
...
@@ -147,15 +144,15 @@ public class BtreeInspectionController {
...
@@ -147,15 +144,15 @@ public class BtreeInspectionController {
@PostMapping
(
"/createBtree"
)
@PostMapping
(
"/createBtree"
)
public
BaseResponse
<
String
>
del
()
{
public
BaseResponse
<
String
>
del
()
{
//todo 获取全场机组的最后时间点
//todo 获取全场机组的最后时间点
//
todo
根据规则创建二叉树巡检任务,并存入redis
//根据规则创建二叉树巡检任务,并存入redis
String
taskId
=
"C0A001-1-"
+
System
.
currentTimeMillis
();
String
taskId
=
Utils
.
getTaskPrefix
()+
"-"
+
System
.
currentTimeMillis
();
//每次新建任务都保存一下
//每次新建任务都保存一下
redissonClient
.
getBucket
(
"btreetask:
C0A001-1"
).
set
(
taskId
,
5
L
,
TimeUnit
.
MINUTES
);
redissonClient
.
getBucket
(
"btreetask:
"
+
Utils
.
getTaskPrefix
()).
set
(
taskId
,
10
L
,
TimeUnit
.
MINUTES
);
//
todo
jna发起任务。
//jna发起任务。
String
taskjson
=
"{\"taskId\":\""
+
taskId
+
"\",\"taskTyped\":0,\"Data\":[1599717386000,1599717386000]}"
;
String
taskjson
=
"{\"taskId\":\""
+
taskId
+
"\",\"taskTyped\":0,\"Data\":[1599717386000,1599717386000]}"
;
try
{
try
{
new
Thread
(()->{
new
Thread
(()->{
C2TreeAnalysis
.
INSTANCE
.
MachineryUnit
Diagnose
(
taskjson
);
C2TreeAnalysis
.
INSTANCE
.
C2Tree
Diagnose
(
taskjson
);
}).
start
();
}).
start
();
}
catch
(
RuntimeException
e
)
{
}
catch
(
RuntimeException
e
)
{
throw
e
;
throw
e
;
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/jna/C2TreeAnalysis.java
View file @
70511567
...
@@ -19,5 +19,6 @@ public interface C2TreeAnalysis extends Library {
...
@@ -19,5 +19,6 @@ public interface C2TreeAnalysis extends Library {
* "{\"taskId\":任务id,\"taskTyped\":0(固定值),\"Data\":[1599717386000,1599717386000]每个机组的最后的时间戳}"
* "{\"taskId\":任务id,\"taskTyped\":0(固定值),\"Data\":[1599717386000,1599717386000]每个机组的最后的时间戳}"
*/
*/
String
MachineryUnitDiagnose
(
String
jstr
);
String
MachineryUnitDiagnose
(
String
jstr
);
String
C2TreeDiagnose
(
String
jstr
);
}
}
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/security/JWTFilter.java
View file @
70511567
...
@@ -48,10 +48,10 @@ public class JWTFilter extends BasicAuthenticationFilter {
...
@@ -48,10 +48,10 @@ public class JWTFilter extends BasicAuthenticationFilter {
final
String
token
=
this
.
getToken
(
request
);
final
String
token
=
this
.
getToken
(
request
);
//设置websocket 子协议头
//设置websocket 子协议头
response
.
setHeader
(
"Sec-WebSocket-Protocol"
,
request
.
getHeader
(
"Sec-WebSocket-Protocol"
));
response
.
setHeader
(
"Sec-WebSocket-Protocol"
,
request
.
getHeader
(
"Sec-WebSocket-Protocol"
));
if
(
true
){
/*
if(true){
filterChain.doFilter(request, response);
filterChain.doFilter(request, response);
return;
return;
}
}
*/
if
(
request
.
getServletPath
().
contains
(
"/login"
)||
request
.
getServletPath
().
contains
(
"/plantInfo/allPlantInfo"
)){
if
(
request
.
getServletPath
().
contains
(
"/login"
)||
request
.
getServletPath
().
contains
(
"/plantInfo/allPlantInfo"
)){
filterChain
.
doFilter
(
request
,
response
);
filterChain
.
doFilter
(
request
,
response
);
return
;
return
;
...
@@ -88,7 +88,7 @@ public class JWTFilter extends BasicAuthenticationFilter {
...
@@ -88,7 +88,7 @@ public class JWTFilter extends BasicAuthenticationFilter {
}
}
SecurityContextHolder
.
getContext
()
SecurityContextHolder
.
getContext
()
.
setAuthentication
(
new
UsernamePasswordAuthenticationToken
(
.
setAuthentication
(
new
UsernamePasswordAuthenticationToken
(
userDetails
.
getUsername
()
,
null
,
userDetails
.
getAuthorities
()
userDetails
,
null
,
userDetails
.
getAuthorities
()
));
));
filterChain
.
doFilter
(
request
,
response
);
filterChain
.
doFilter
(
request
,
response
);
}
}
...
...
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/utils/Utils.java
View file @
70511567
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
utils
;
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
utils
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfo
;
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.KafkaConsumeBean
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.KafkaConsumeBean
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.KafkaDataBean
;
import
cn.wise.sc.energy.power.plant.business.opentsdb.bean.KafkaDataBean
;
...
@@ -15,6 +16,9 @@ import net.opentsdb.client.api.query.response.QueryLastResponse;
...
@@ -15,6 +16,9 @@ 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.LastDataPointQuery
;
import
org.apache.curator.retry.RetryUntilElapsed
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
...
@@ -52,6 +56,24 @@ public class Utils {
...
@@ -52,6 +56,24 @@ public class Utils {
return
putRequestExt
;
return
putRequestExt
;
}
}
public
static
UserInfo
getUser
()
{
UserInfo
userDetails
=
(
UserInfo
)
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
if
(
userDetails
!=
null
)
{
return
userDetails
;
}
return
null
;
}
public
static
String
getTaskPrefix
()
{
UserInfo
userDetails
=
(
UserInfo
)
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
if
(
userDetails
!=
null
)
{
UserInfo
userInfo
=
Utils
.
getUser
();
String
prefix
=
userInfo
.
getPlantid
()
+
"-"
+
userInfo
.
getId
();
return
prefix
;
}
return
null
;
}
// public static void main(String[] args) throws IOException, URISyntaxException {
// public static void main(String[] args) throws IOException, URISyntaxException {
//// ResponseEnum.LICENCE_NOT_FOUND.assertNotNull(null);
//// ResponseEnum.LICENCE_NOT_FOUND.assertNotNull(null);
// Object object = "11111";
// Object object = "11111";
...
...
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