Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
7079dee7
Commit
7079dee7
authored
Aug 21, 2023
by
chenzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加光伏预警
parent
3556bf18
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
220 additions
and
4 deletions
+220
-4
IdxBizFanWarningRecord.java
.../boot/module/jxiop/biz/entity/IdxBizFanWarningRecord.java
+2
-2
IdxBizPvWarningRecord.java
...s/boot/module/jxiop/biz/entity/IdxBizPvWarningRecord.java
+7
-2
HealthStatusIndicatorServiceImpl.java
...op/biz/service/impl/HealthStatusIndicatorServiceImpl.java
+211
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/entity/IdxBizFanWarningRecord.java
View file @
7079dee7
...
...
@@ -69,13 +69,13 @@ public class IdxBizFanWarningRecord{
*
*/
@TableField
(
"HEALTH_INDEX_SEQ"
)
private
Integer
healthIndexSeq
;
private
String
healthIndexSeq
;
/**
*
*/
@TableField
(
"ANALYSIS_POINT_ID"
)
private
Integer
analysisPointId
;
private
String
analysisPointId
;
/**
* 预警等级
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/entity/IdxBizPvWarningRecord.java
View file @
7079dee7
...
...
@@ -75,7 +75,7 @@ public class IdxBizPvWarningRecord{
*
*/
@TableField
(
"ANALYSIS_POINT_ID"
)
private
Integer
analysisPointId
;
private
String
analysisPointId
;
/**
* 预警等级
...
...
@@ -117,7 +117,7 @@ public class IdxBizPvWarningRecord{
* 网关ID
*/
@TableField
(
"GATEWAY_ID"
)
private
Integer
gatewayId
;
private
String
gatewayId
;
/**
* 点表地址
...
...
@@ -131,4 +131,9 @@ public class IdxBizPvWarningRecord{
@TableField
(
"EQUIPMENT_NAME"
)
private
String
equipmentName
;
/**
* 预警内容
* */
@TableField
(
"CONTENT"
)
private
String
CONTENT
;
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/HealthStatusIndicatorServiceImpl.java
View file @
7079dee7
...
...
@@ -44,6 +44,217 @@ public class HealthStatusIndicatorServiceImpl {
*
*/
@Autowired
IdxBizPvHealthIndexMapper
idxBizPvHealthIndexMapper
;
@Autowired
IdxBizPvWarningRecordMapper
idxBizPvWarningRecordMapper
;
/***
* 每一小时获取一次最大粒度内的指数异常数据
* 判断一小时内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
*
*/
@Scheduled
(
cron
=
"0 0 */1 * * ?"
)
private
void
healthWarningMinuteGF
()
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)-
1
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
LambdaQueryWrapper
<
IdxBizPvHealthIndex
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IdxBizPvHealthIndex:
:
getAnalysisType
,
"按时刻"
);
wrapper
.
le
(
IdxBizPvHealthIndex:
:
getHealthIndex
,
healthValueNotice
);
wrapper
.
ge
(
IdxBizPvHealthIndex:
:
getRecDate
,
df
.
format
(
calendar
.
getTime
()));
wrapper
.
orderByDesc
(
IdxBizPvHealthIndex:
:
getRecDate
);
List
<
IdxBizPvHealthIndex
>
healthIndices
=
idxBizPvHealthIndexMapper
.
selectList
(
wrapper
);
Map
<
String
,
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getIndexAddress
)));
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizPvHealthIndex
>
idxBizPvHealthIndices
=
healthDataMaps
.
get
(
address
);
List
<
Double
>
healthIndex
=
idxBizPvHealthIndices
.
stream
().
map
(
IdxBizPvHealthIndex:
:
getHealthIndex
).
collect
(
Collectors
.
toList
());
long
riskNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueRisk
).
count
();
long
warnNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueWarn
).
count
();
long
noticeNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueNotice
).
count
();
String
level
=
""
;
String
content
=
""
;
String
num
=
""
;
content
=
healthValueMinCount
+
"分钟"
;
if
(
riskNum
>=
healthValueMinCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_risk_minute"
)){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_risk_minute"
,
"risk"
);
level
=
"危险"
;
num
=
""
+
healthValueRisk
;
}
else
if
(
warnNum
>=
healthValueMinCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_warn_minute"
)
){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_warn_minute"
,
"warn"
);
level
=
"警告"
;
num
=
""
+
healthValueWarn
;
}
else
if
(
noticeNum
>=
healthValueMinCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_notice_minute"
)){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_notice_minute"
,
"notice"
);
level
=
"注意"
;
num
=
""
+
healthValueNotice
;
}
if
(!
level
.
equals
(
""
)){
IdxBizPvWarningRecord
idxBizPvWarningRecord
=
new
IdxBizPvWarningRecord
();
idxBizPvWarningRecord
.
setRecord
(
idxBizPvHealthIndices
.
get
(
0
).
getRecord
());
idxBizPvWarningRecord
.
setArae
(
idxBizPvHealthIndices
.
get
(
0
).
getArae
());
idxBizPvWarningRecord
.
setStation
(
idxBizPvHealthIndices
.
get
(
0
).
getStation
());
idxBizPvWarningRecord
.
setSubarray
(
idxBizPvHealthIndices
.
get
(
0
).
getSubarray
());
idxBizPvWarningRecord
.
setGatewayId
(
gateWayId
);
idxBizPvWarningRecord
.
setIndexAddress
(
address
);
idxBizPvWarningRecord
.
setEquipmentName
(
idxBizPvHealthIndices
.
get
(
0
).
getEquipmentName
());
idxBizPvWarningRecord
.
setAnalysisPointId
(
idxBizPvHealthIndices
.
get
(
0
).
getAnalysisObjSeq
());
idxBizPvWarningRecord
.
setDisposotionState
(
"未处置"
);
idxBizPvWarningRecord
.
setStatus
(
"0"
);
idxBizPvWarningRecord
.
setWarningName
(
level
);
idxBizPvWarningRecord
.
setCONTENT
(
"连续"
+
content
+
"健康指数<"
+
num
);
}
}
}
}
/***
* 每五小时获取一次最大粒度内的指数异常数据
* 判断五小时内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
*
*/
@Scheduled
(
cron
=
"0 0 */5 * * ?"
)
private
void
healthWarningHourGF
()
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)-
5
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
LambdaQueryWrapper
<
IdxBizPvHealthIndex
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IdxBizPvHealthIndex:
:
getAnalysisType
,
"按小时"
);
wrapper
.
le
(
IdxBizPvHealthIndex:
:
getHealthIndex
,
healthValueNotice
);
wrapper
.
ge
(
IdxBizPvHealthIndex:
:
getRecDate
,
df
.
format
(
calendar
.
getTime
()));
wrapper
.
orderByDesc
(
IdxBizPvHealthIndex:
:
getRecDate
);
List
<
IdxBizPvHealthIndex
>
healthIndices
=
idxBizPvHealthIndexMapper
.
selectList
(
wrapper
);
Map
<
String
,
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getIndexAddress
)));
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizPvHealthIndex
>
idxBizPvHealthIndices
=
healthDataMaps
.
get
(
address
);
List
<
Double
>
healthIndex
=
idxBizPvHealthIndices
.
stream
().
map
(
IdxBizPvHealthIndex:
:
getHealthIndex
).
collect
(
Collectors
.
toList
());
long
riskNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueRisk
).
count
();
long
warnNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueWarn
).
count
();
long
noticeNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueNotice
).
count
();
String
level
=
""
;
String
content
=
""
;
String
num
=
""
;
content
=
healthValueHourCount
+
"小时"
;
if
(
riskNum
>=
healthValueHourCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_risk_hour"
)){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_risk_hour"
,
"risk"
);
level
=
"危险"
;
num
=
""
+
healthValueRisk
;
}
else
if
(
warnNum
>=
healthValueHourCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_risk_hour"
)
){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_warn_hour"
,
"warn"
);
level
=
"警告"
;
num
=
""
+
healthValueWarn
;
}
else
if
(
noticeNum
>=
healthValueHourCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_notice_hour"
)){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_notice_hour"
,
"notice"
);
level
=
"注意"
;
num
=
""
+
healthValueNotice
;
}
if
(!
level
.
equals
(
""
)){
IdxBizPvWarningRecord
idxBizPvWarningRecord
=
new
IdxBizPvWarningRecord
();
idxBizPvWarningRecord
.
setRecord
(
idxBizPvHealthIndices
.
get
(
0
).
getRecord
());
idxBizPvWarningRecord
.
setArae
(
idxBizPvHealthIndices
.
get
(
0
).
getArae
());
idxBizPvWarningRecord
.
setStation
(
idxBizPvHealthIndices
.
get
(
0
).
getStation
());
idxBizPvWarningRecord
.
setSubarray
(
idxBizPvHealthIndices
.
get
(
0
).
getSubarray
());
idxBizPvWarningRecord
.
setGatewayId
(
gateWayId
);
idxBizPvWarningRecord
.
setIndexAddress
(
address
);
idxBizPvWarningRecord
.
setEquipmentName
(
idxBizPvHealthIndices
.
get
(
0
).
getEquipmentName
());
idxBizPvWarningRecord
.
setAnalysisPointId
(
idxBizPvHealthIndices
.
get
(
0
).
getAnalysisObjSeq
());
idxBizPvWarningRecord
.
setDisposotionState
(
"未处置"
);
idxBizPvWarningRecord
.
setStatus
(
"0"
);
idxBizPvWarningRecord
.
setWarningName
(
level
);
idxBizPvWarningRecord
.
setCONTENT
(
"连续"
+
content
+
"健康指数<"
+
num
);
}
}
}
}
/***
* 每三天取一次最大粒度内的指数异常数据
* 判断三天内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
*
*/
@Scheduled
(
cron
=
"0 0 0 */3 * ? "
)
private
void
healthWarningDayGF
()
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
)-
3
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
LambdaQueryWrapper
<
IdxBizPvHealthIndex
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IdxBizPvHealthIndex:
:
getAnalysisType
,
"按天"
);
wrapper
.
le
(
IdxBizPvHealthIndex:
:
getHealthIndex
,
healthValueNotice
);
wrapper
.
ge
(
IdxBizPvHealthIndex:
:
getRecDate
,
df
.
format
(
calendar
.
getTime
()));
wrapper
.
orderByDesc
(
IdxBizPvHealthIndex:
:
getRecDate
);
List
<
IdxBizPvHealthIndex
>
healthIndices
=
idxBizPvHealthIndexMapper
.
selectList
(
wrapper
);
Map
<
String
,
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizPvHealthIndex:
:
getIndexAddress
)));
for
(
String
gateWayId
:
gateWayMaps
.
keySet
())
{
Map
<
String
,
List
<
IdxBizPvHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizPvHealthIndex
>
idxBizPvHealthIndices
=
healthDataMaps
.
get
(
address
);
List
<
Double
>
healthIndex
=
idxBizPvHealthIndices
.
stream
().
map
(
IdxBizPvHealthIndex:
:
getHealthIndex
).
collect
(
Collectors
.
toList
());
long
riskNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueRisk
).
count
();
long
warnNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueWarn
).
count
();
long
noticeNum
=
healthIndex
.
stream
().
filter
(
e
->
e
<=
healthValueNotice
).
count
();
String
level
=
""
;
String
content
=
""
;
String
num
=
""
;
content
=
healthValueDayCount
+
"天"
;
if
(
riskNum
>=
healthValueDayCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_risk_day"
)){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_risk_day"
,
"risk"
);
level
=
"危险"
;
num
=
""
+
healthValueRisk
;
}
else
if
(
warnNum
>=
healthValueDayCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_warn_day"
)
){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_warn_day"
,
"warn"
);
level
=
"警告"
;
num
=
""
+
healthValueWarn
;
}
else
if
(
noticeNum
>=
healthValueDayCount
&&
!
redisUtils
.
hasKey
(
gateWayId
+
"_"
+
address
+
"_health_notice_day"
)){
redisUtils
.
set
(
gateWayId
+
"_"
+
address
+
"_health_notice_day"
,
"notice"
);
level
=
"注意"
;
num
=
""
+
healthValueNotice
;
}
if
(!
level
.
equals
(
""
)){
IdxBizPvWarningRecord
idxBizPvWarningRecord
=
new
IdxBizPvWarningRecord
();
idxBizPvWarningRecord
.
setRecord
(
idxBizPvHealthIndices
.
get
(
0
).
getRecord
());
idxBizPvWarningRecord
.
setArae
(
idxBizPvHealthIndices
.
get
(
0
).
getArae
());
idxBizPvWarningRecord
.
setStation
(
idxBizPvHealthIndices
.
get
(
0
).
getStation
());
idxBizPvWarningRecord
.
setSubarray
(
idxBizPvHealthIndices
.
get
(
0
).
getSubarray
());
idxBizPvWarningRecord
.
setGatewayId
(
gateWayId
);
idxBizPvWarningRecord
.
setIndexAddress
(
address
);
idxBizPvWarningRecord
.
setEquipmentName
(
idxBizPvHealthIndices
.
get
(
0
).
getEquipmentName
());
idxBizPvWarningRecord
.
setAnalysisPointId
(
idxBizPvHealthIndices
.
get
(
0
).
getAnalysisObjSeq
());
idxBizPvWarningRecord
.
setDisposotionState
(
"未处置"
);
idxBizPvWarningRecord
.
setStatus
(
"0"
);
idxBizPvWarningRecord
.
setWarningName
(
level
);
idxBizPvWarningRecord
.
setCONTENT
(
"连续"
+
content
+
"健康指数<"
+
num
);
idxBizPvWarningRecordMapper
.
insert
(
idxBizPvWarningRecord
);
}
}
}
}
@Scheduled
(
cron
=
"0 0 */1 * * ?"
)
private
void
healthWarningMinute
()
{
Calendar
calendar
=
Calendar
.
getInstance
();
...
...
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