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
9d33b51c
Commit
9d33b51c
authored
Mar 13, 2024
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复告警不合理问题
parent
4b3aa9a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
45 deletions
+96
-45
HealthStatusIndicatorServiceImpl.java
...op/biz/service/impl/HealthStatusIndicatorServiceImpl.java
+96
-45
No files found.
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 @
9d33b51c
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
java.nio.charset.StandardCharsets
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
javax.annotation.PostConstruct
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jxiop.api.dto.BizMessage
;
import
com.yeejoin.amos.boot.module.jxiop.api.dto.RiskBizInfoVo
;
...
...
@@ -16,31 +37,39 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningNameEnum
;
import
com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRuleSet
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity5.JumpConfig
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRecordMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRuleSetMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthIndexMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWarningRecordMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWarningRuleSetMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper5.JumpConfigMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
java.nio.charset.StandardCharsets
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexDayMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexHourMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMomentMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexDayMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexHourMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMomentMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexHour
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexMoment
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexDay
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexHour
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexMoment
;
import
com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord
;
import
static
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
utils
.
DateUtils
.
DATE_TIME_PATTERN
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.extern.slf4j.Slf4j
;
@EnableScheduling
@Service
...
...
@@ -176,10 +205,12 @@ public class HealthStatusIndicatorServiceImpl {
Date
date
=
DateUtil
.
offsetHour
(
time
,-
8
);
date
=
DateUtil
.
offsetMinute
(
date
,
0
-(
maxWaringCycle
*
10
));
LambdaQueryWrapper
<
PvHealthIndexMoment
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
ne
(
PvHealthIndexMoment:
:
getHealthLevel
,
"安全"
);
//
wrapper.ne(PvHealthIndexMoment::getHealthLevel,"安全");
wrapper
.
ge
(
PvHealthIndexMoment:
:
getTs
,
date
);
wrapper
.
eq
(
PvHealthIndexMoment:
:
getAnalysisObjType
,
"测点"
);
wrapper
.
orderByDesc
(
PvHealthIndexMoment:
:
getTs
);
Date
dateMax
=
DateUtil
.
offsetHour
(
time
,-
8
);
wrapper
.
le
(
PvHealthIndexMoment:
:
getTs
,
dateMax
);
wrapper
.
orderByAsc
(
PvHealthIndexMoment:
:
getTs
);
List
<
PvHealthIndexMoment
>
healthIndices
=
pvHealthIndexMomentMapper
.
selectList
(
wrapper
);
List
<
String
>
collect
=
healthIndices
.
stream
().
map
(
PvHealthIndexMoment:
:
getAnalysisObjSeq
).
collect
(
Collectors
.
toList
());
if
(
null
==
healthIndices
){
...
...
@@ -543,10 +574,12 @@ public class HealthStatusIndicatorServiceImpl {
date
=
DateUtil
.
offsetHour
(
date
,
0
-
maxWaringCycle
);
LambdaQueryWrapper
<
PvHealthIndexHour
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
ne
(
PvHealthIndexHour:
:
getHealthLevel
,
"安全"
);
//
wrapper.ne(PvHealthIndexHour::getHealthLevel,"安全");
wrapper
.
eq
(
PvHealthIndexHour:
:
getAnalysisObjType
,
"测点"
);
wrapper
.
ge
(
PvHealthIndexHour:
:
getTs
,
date
);
wrapper
.
orderByDesc
(
PvHealthIndexHour:
:
getTs
);
Date
dateMax
=
DateUtil
.
offsetHour
(
time
,-
8
);
wrapper
.
le
(
PvHealthIndexHour:
:
getTs
,
dateMax
);
wrapper
.
orderByAsc
(
PvHealthIndexHour:
:
getTs
);
List
<
PvHealthIndexHour
>
healthIndices
=
pvHealthIndexHourMapper
.
selectList
(
wrapper
);
List
<
String
>
collect
=
healthIndices
.
stream
().
map
(
PvHealthIndexHour:
:
getAnalysisObjSeq
).
collect
(
Collectors
.
toList
());
if
(
null
==
healthIndices
){
...
...
@@ -628,7 +661,7 @@ public class HealthStatusIndicatorServiceImpl {
}
Double
finalHealthValueNotice
=
healthValueNotice
;
if
(
healthIndex
.
size
()>=
healthValueNoticeCount
){
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Warn
Count
,
healthIndex
.
size
());
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Notice
Count
,
healthIndex
.
size
());
noticeNum
=
(
int
)
healthIndexList
.
stream
().
filter
(
e
->
e
<=
finalHealthValueNotice
).
count
();
}
String
level
=
""
;
...
...
@@ -730,10 +763,12 @@ public class HealthStatusIndicatorServiceImpl {
Date
date
=
DateUtil
.
offsetHour
(
time
,-
8
);
date
=
DateUtil
.
offsetDay
(
date
,
0
-
maxWaringCycle
);
LambdaQueryWrapper
<
PvHealthIndexDay
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
ne
(
PvHealthIndexDay:
:
getHealthLevel
,
"安全"
);
//
wrapper.ne(PvHealthIndexDay::getHealthLevel, "安全");
wrapper
.
eq
(
PvHealthIndexDay:
:
getAnalysisObjType
,
"测点"
);
wrapper
.
ge
(
PvHealthIndexDay:
:
getRecDate
,
date
);
wrapper
.
orderByDesc
(
PvHealthIndexDay:
:
getTs
);
wrapper
.
ge
(
PvHealthIndexDay:
:
getTs
,
date
);
Date
dateMax
=
DateUtil
.
offsetHour
(
time
,-
8
);
wrapper
.
le
(
PvHealthIndexDay:
:
getTs
,
dateMax
);
wrapper
.
orderByAsc
(
PvHealthIndexDay:
:
getTs
);
List
<
PvHealthIndexDay
>
healthIndices
=
pvHealthIndexDayMapper
.
selectList
(
wrapper
);
if
(
null
==
healthIndices
){
...
...
@@ -813,7 +848,7 @@ public class HealthStatusIndicatorServiceImpl {
}
Double
finalHealthValueNotice
=
healthValueNotice
;
if
(
healthIndex
.
size
()>=
healthValueNoticeCount
){
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Warn
Count
,
healthIndex
.
size
());
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Notice
Count
,
healthIndex
.
size
());
noticeNum
=
(
int
)
healthIndexList
.
stream
().
filter
(
e
->
e
<=
finalHealthValueNotice
).
count
();
}
String
level
=
""
;
...
...
@@ -899,10 +934,19 @@ public class HealthStatusIndicatorServiceImpl {
// @Scheduled(cron = "0 0 */1 * * ?")
@Async
(
"async"
)
@PostConstruct
public
void
healthWarningMinute
(
Date
time
)
{
if
(!
openHealth
){
return
;
}
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Date time=null;
// try {
// time = simpleDateFormat.parse("2024-03-13 13:30:00");
// } catch (ParseException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
// Calendar calendar = Calendar.getInstance();
log
.
info
(
"风机---------------------预警时间----"
+
time
);
String
format
=
DateUtil
.
format
(
time
,
"yyyy-MM-dd HH:mm:00"
);
...
...
@@ -914,10 +958,13 @@ public class HealthStatusIndicatorServiceImpl {
Date
date
=
DateUtil
.
offsetHour
(
time
,-
8
);
date
=
DateUtil
.
offsetMinute
(
date
,
0
-(
maxWaringCycle
*
10
));
LambdaQueryWrapper
<
FanHealthIndexMoment
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
ne
(
FanHealthIndexMoment:
:
getHealthLevel
,
"安全"
);
//
wrapper.ne(FanHealthIndexMoment::getHealthLevel,"安全");
wrapper
.
eq
(
FanHealthIndexMoment:
:
getAnalysisObjType
,
"测点"
);
wrapper
.
ge
(
FanHealthIndexMoment:
:
getTs
,
date
);
wrapper
.
orderByDesc
(
FanHealthIndexMoment:
:
getTs
);
Date
dateMax
=
DateUtil
.
offsetHour
(
time
,-
8
);
wrapper
.
le
(
FanHealthIndexMoment:
:
getTs
,
dateMax
);
// wrapper.eq(FanHealthIndexMoment::getIndexAddress, "18545");
wrapper
.
orderByAsc
(
FanHealthIndexMoment:
:
getTs
);
//查询最大连续时间规则的测点对象
List
<
FanHealthIndexMoment
>
healthIndices
=
fanHealthIndexMomentMapper
.
selectList
(
wrapper
);
...
...
@@ -1110,14 +1157,16 @@ public class HealthStatusIndicatorServiceImpl {
// 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");
Integer
maxWaringCycle
=
idxBizFanWarningRuleSetMapper
.
getMaxWaringCycleOfHour
()
+
AnalyseOffset
;
Integer
maxWaringCycle
=
idxBizFanWarningRuleSetMapper
.
getMaxWaringCycleOfHour
();
Date
date
=
DateUtil
.
offsetHour
(
time
,-
8
);
date
=
DateUtil
.
offsetHour
(
date
,
0
-(
maxWaringCycle
));
LambdaQueryWrapper
<
FanHealthIndexHour
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
FanHealthIndexHour:
:
getAnalysisObjType
,
"测点"
);
wrapper
.
ne
(
FanHealthIndexHour:
:
getHealthLevel
,
"安全"
);
//
wrapper.ne(FanHealthIndexHour::getHealthLevel, "安全");
wrapper
.
ge
(
FanHealthIndexHour:
:
getTs
,
date
);
wrapper
.
orderByDesc
(
FanHealthIndexHour:
:
getTs
);
Date
dateMax
=
DateUtil
.
offsetHour
(
time
,-
8
);
wrapper
.
le
(
FanHealthIndexHour:
:
getTs
,
dateMax
);
wrapper
.
orderByAsc
(
FanHealthIndexHour:
:
getTs
);
List
<
FanHealthIndexHour
>
healthIndices
=
fanHealthIndexHourMapper
.
selectList
(
wrapper
);
if
(
ObjectUtils
.
isEmpty
(
healthIndices
)){
return
;
...
...
@@ -1203,7 +1252,7 @@ public class HealthStatusIndicatorServiceImpl {
}
Double
finalHealthValueNotice
=
healthValueNotice
;
if
(
healthIndex
.
size
()>=
healthValueNoticeCount
){
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Warn
Count
,
healthIndex
.
size
());
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Notice
Count
,
healthIndex
.
size
());
noticeNum
=
(
int
)
healthIndexList
.
stream
().
filter
(
e
->
e
<=
finalHealthValueNotice
).
count
();
}
String
level
=
""
;
...
...
@@ -1300,15 +1349,17 @@ public class HealthStatusIndicatorServiceImpl {
// Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Integer
maxWaringCycle
=
idxBizFanWarningRuleSetMapper
.
getMaxWaringCycleOf
Hour
()+
AnalyseOffset
;
Integer
maxWaringCycle
=
idxBizFanWarningRuleSetMapper
.
getMaxWaringCycleOf
Day
()
;
Date
date
=
DateUtil
.
offsetHour
(
time
,-
8
);
date
=
DateUtil
.
offsetDay
(
date
,
0
-(
maxWaringCycle
));
LambdaQueryWrapper
<
FanHealthIndexDay
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
ne
(
FanHealthIndexDay:
:
getHealthLevel
,
"安全"
);
//
wrapper.ne(FanHealthIndexDay::getHealthLevel,"安全");
wrapper
.
ge
(
FanHealthIndexDay:
:
getRecDate
,
date
);
wrapper
.
eq
(
FanHealthIndexDay:
:
getAnalysisObjType
,
"测点"
);
wrapper
.
orderByDesc
(
FanHealthIndexDay:
:
getTs
);
Date
dateMax
=
DateUtil
.
offsetHour
(
time
,-
8
);
wrapper
.
le
(
FanHealthIndexDay:
:
getRecDate
,
dateMax
);
wrapper
.
orderByAsc
(
FanHealthIndexDay:
:
getTs
);
List
<
FanHealthIndexDay
>
healthIndices
=
fanHealthIndexDayMapper
.
selectList
(
wrapper
);
if
(
ObjectUtils
.
isEmpty
(
healthIndices
)){
return
;
...
...
@@ -1396,7 +1447,7 @@ public class HealthStatusIndicatorServiceImpl {
}
Double
finalHealthValueNotice
=
healthValueNotice
;
if
(
healthIndex
.
size
()>=
healthValueNoticeCount
){
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Warn
Count
,
healthIndex
.
size
());
List
<
Double
>
healthIndexList
=
healthIndex
.
subList
(
healthIndex
.
size
()-
healthValue
Notice
Count
,
healthIndex
.
size
());
noticeNum
=
(
int
)
healthIndexList
.
stream
().
filter
(
e
->
e
<=
finalHealthValueNotice
).
count
();
}
String
level
=
""
;
...
...
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