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
cba395e6
Commit
cba395e6
authored
Aug 17, 2023
by
chenzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
c2ea1be8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
351 additions
and
125 deletions
+351
-125
IdxBizFanPointVarCentralValueDto.java
...odule/jxiop/biz/dto/IdxBizFanPointVarCentralValueDto.java
+3
-0
IdxBizFanPointVarCentralValue.java
...odule/jxiop/biz/entity/IdxBizFanPointVarCentralValue.java
+4
-3
IdxBizFanWarningRecord.java
.../boot/module/jxiop/biz/entity/IdxBizFanWarningRecord.java
+5
-0
IdxBizFanPointProcessVariableClassificationMapper.java
...r2/IdxBizFanPointProcessVariableClassificationMapper.java
+2
-1
CommonServiceImpl.java
...boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
+116
-0
HealthStatusIndicatorServiceImpl.java
...op/biz/service/impl/HealthStatusIndicatorServiceImpl.java
+212
-121
application.properties
...iop-analyse-biz/src/main/resources/application.properties
+9
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/dto/IdxBizFanPointVarCentralValueDto.java
View file @
cba395e6
...
@@ -114,4 +114,7 @@ public class IdxBizFanPointVarCentralValueDto {
...
@@ -114,4 +114,7 @@ public class IdxBizFanPointVarCentralValueDto {
@TableField
(
"PROCESS_POINT2_ID"
)
@TableField
(
"PROCESS_POINT2_ID"
)
private
Double
processPoint2Id
;
private
Double
processPoint2Id
;
@ApiModelProperty
(
value
=
"预警内容"
)
@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/entity/IdxBizFanPointVarCentralValue.java
View file @
cba395e6
...
@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
...
@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
/**
/**
*
*
...
@@ -39,7 +40,7 @@ public class IdxBizFanPointVarCentralValue{
...
@@ -39,7 +40,7 @@ public class IdxBizFanPointVarCentralValue{
*
*
*/
*/
@TableField
(
"REC_DATE"
)
@TableField
(
"REC_DATE"
)
private
LocalDateTim
e
recDate
;
private
Dat
e
recDate
;
/**
/**
*
*
...
@@ -81,7 +82,7 @@ public class IdxBizFanPointVarCentralValue{
...
@@ -81,7 +82,7 @@ public class IdxBizFanPointVarCentralValue{
*
*
*/
*/
@TableField
(
"ANALYSIS_POINT_ID"
)
@TableField
(
"ANALYSIS_POINT_ID"
)
private
Integer
analysisPointId
;
private
String
analysisPointId
;
/**
/**
* 片区
* 片区
...
@@ -171,6 +172,6 @@ public class IdxBizFanPointVarCentralValue{
...
@@ -171,6 +172,6 @@ public class IdxBizFanPointVarCentralValue{
* 工况变量2ID
* 工况变量2ID
*/
*/
@TableField
(
"PROCESS_POINT2_ID"
)
@TableField
(
"PROCESS_POINT2_ID"
)
private
Double
processPoint2Id
;
private
String
processPoint2Id
;
}
}
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 @
cba395e6
...
@@ -125,4 +125,9 @@ public class IdxBizFanWarningRecord{
...
@@ -125,4 +125,9 @@ public class IdxBizFanWarningRecord{
@TableField
(
"EQUIPMENT_NAME"
)
@TableField
(
"EQUIPMENT_NAME"
)
private
String
equipmentName
;
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/mapper2/IdxBizFanPointProcessVariableClassificationMapper.java
View file @
cba395e6
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
mapper2
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
mapper2
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification
;
import
java.util.List
;
import
java.util.List
;
...
@@ -12,7 +13,7 @@ import java.util.List;
...
@@ -12,7 +13,7 @@ import java.util.List;
* @date 2023-08-15
* @date 2023-08-15
*/
*/
public
interface
IdxBizFanPointProcessVariableClassificationMapper
extends
BaseMapper
<
IdxBizFanPointProcessVariableClassification
>
{
public
interface
IdxBizFanPointProcessVariableClassificationMapper
extends
BaseMapper
<
IdxBizFanPointProcessVariableClassification
>
{
List
<
IdxBizFanPointProcessVariableClassification
>
getInfluxDBData
();
List
<
IdxBizFanPointProcessVariableClassification
Dto
>
getInfluxDBData
();
List
<
String
>
gateWayIdListFan
();
List
<
String
>
gateWayIdListFan
();
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
View file @
cba395e6
...
@@ -2,15 +2,27 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
...
@@ -2,15 +2,27 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*
;
import
com.yeejoin.amos.component.influxdb.InfluxdbUtil
;
import
com.yeejoin.amos.component.influxdb.InfluxdbUtil
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.SearchHit
;
import
org.springframework.data.elasticsearch.core.SearchHits
;
import
org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -48,6 +60,11 @@ public class CommonServiceImpl {
...
@@ -48,6 +60,11 @@ public class CommonServiceImpl {
@Value
(
"${gkzxzjs.key:input 2}"
)
@Value
(
"${gkzxzjs.key:input 2}"
)
String
gkzxzjskey2
;
String
gkzxzjskey2
;
//----------------健康指数值计算相关请求属性配置------------------------
@Value
(
"${gkzxzjs.url:8804dc58-508b-4e73-8346-5aa8d808746f}"
)
String
jkzsjsurl
;
// {"tableName": "idx_biz_fan_point_process_variable_classification"} 风机工况变量划分
// {"tableName": "idx_biz_fan_point_process_variable_classification"} 风机工况变量划分
// {"tableName": "idx_biz_pv_point_process_variable_classification"} 光伏工况变量画分
// {"tableName": "idx_biz_pv_point_process_variable_classification"} 光伏工况变量画分
// {"tableName": "idx_biz_fan_point_var_correlation"} 风机相关性
// {"tableName": "idx_biz_fan_point_var_correlation"} 风机相关性
...
@@ -63,6 +80,13 @@ public class CommonServiceImpl {
...
@@ -63,6 +80,13 @@ public class CommonServiceImpl {
@Autowired
@Autowired
private
InfluxdbUtil
influxdbUtil
;
private
InfluxdbUtil
influxdbUtil
;
@Autowired
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
@Autowired
IdxBizFanPointVarCentralValueMapper
idxBizFanPointVarCentralValueMapper
;
/**
/**
* @return
* @return
...
@@ -638,4 +662,96 @@ public class CommonServiceImpl {
...
@@ -638,4 +662,96 @@ public class CommonServiceImpl {
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
FORMAT_UTC
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
FORMAT_UTC
);
return
dateFormat
.
format
(
timeStr
);
return
dateFormat
.
format
(
timeStr
);
}
}
@Scheduled
(
cron
=
"0/10 * * * * ?"
)
private
void
healthWarningMinute
()
{
List
<
IdxBizFanPointProcessVariableClassificationDto
>
data
=
idxBizFanPointProcessVariableClassificationMapper
.
getInfluxDBData
();
Map
<
String
,
List
<
IdxBizFanPointProcessVariableClassificationDto
>>
maps
=
data
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanPointProcessVariableClassificationDto:
:
getGatewayId
));
BoolQueryBuilder
boolMustAll
=
QueryBuilders
.
boolQuery
();
List
<
QueryBuilder
>
should
=
boolMustAll
.
should
();
for
(
String
s
:
maps
.
keySet
())
{
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
List
<
String
>
address
=
maps
.
get
(
s
).
stream
().
map
(
IdxBizFanPointProcessVariableClassificationDto:
:
getIndexAddress
).
collect
(
Collectors
.
toList
());
boolQueryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
"address.keyword"
,
address
)).
must
(
QueryBuilders
.
matchQuery
(
"gatewayId.keyword"
,
s
));
should
.
add
(
boolQueryBuilder
);
}
// 创建查询构造器
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
//过滤条件
.
withQuery
(
boolMustAll
);
List
<
ESEquipments
>
equipments
=
new
LinkedList
<>();
long
totle
=
0
;
try
{
SearchHits
<
ESEquipments
>
searchHits
=
elasticsearchTemplate
.
search
(
queryBuilder
.
build
(),
ESEquipments
.
class
);
for
(
SearchHit
searchHit
:
searchHits
.
getSearchHits
())
{
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
searchHit
.
getContent
());
ESEquipments
eSAlertCalled
=
JSONObject
.
toJavaObject
(
jsonObject
,
ESEquipments
.
class
);
equipments
.
add
(
eSAlertCalled
);
}
totle
=
searchHits
.
getTotalHits
();
}
catch
(
Exception
e
)
{
// TODO: handle exception
}
for
(
IdxBizFanPointProcessVariableClassificationDto
datum
:
data
)
{
for
(
ESEquipments
equipment
:
equipments
)
{
if
(
equipment
.
getAddress
().
equals
(
datum
.
getIndexAddress
())
&&
equipment
.
getGatewayId
().
equals
(
datum
.
getGatewayId
())){
datum
.
setCurrentValue
(
equipment
.
getValueDouble
());
}
}
}
LambdaQueryWrapper
<
IdxBizFanPointVarCentralValue
>
wrapper
=
new
LambdaQueryWrapper
<>();
List
<
IdxBizFanPointVarCentralValue
>
idxBizUhefs
=
idxBizFanPointVarCentralValueMapper
.
selectList
(
wrapper
);
List
<
Map
<
String
,
Object
>>
datas
=
new
ArrayList
<>();
for
(
IdxBizFanPointVarCentralValue
idxBizUhef
:
idxBizUhefs
)
{
double
value1
=
0.00
;
double
value2
=
0.00
;
double
value3
=
0.00
;
double
value4
=
0.00
;
for
(
IdxBizFanPointProcessVariableClassificationDto
datum
:
data
)
{
if
(
idxBizUhef
.
getProcessPoint1Id
().
equals
(
datum
.
getSequenceNbr
())){
value1
=
datum
.
getCurrentValue
();
}
if
(
idxBizUhef
.
getProcessPoint2Id
().
equals
(
datum
.
getSequenceNbr
()))
{
value2
=
datum
.
getCurrentValue
();
}
if
(
idxBizUhef
.
getProcessPoint3Id
().
equals
(
datum
.
getSequenceNbr
()))
{
value3
=
datum
.
getCurrentValue
();
}
if
(
idxBizUhef
.
getAnalysisPointId
().
equals
(
datum
.
getSequenceNbr
()))
{
value4
=
datum
.
getCurrentValue
();
}
}
if
(
idxBizUhef
.
getProcess1Min
()
<
value1
&&
value1
<
idxBizUhef
.
getProcess1Max
()
&&
idxBizUhef
.
getProcess2Min
()
<
value2
&&
value2
<
idxBizUhef
.
getPorcess2Max
()
&&
idxBizUhef
.
getProcess3Min
()
<
value3
&&
value3
<
idxBizUhef
.
getProcess3Max
()){
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"analysVariable"
,
value4
);
map
.
put
(
"stdDev"
,
idxBizUhef
.
getAnalysisStdDev
());
map
.
put
(
"centerValue"
,
idxBizUhef
.
getAnalysisCenterValue
());
map
.
put
(
"analysVariableId"
,
idxBizUhef
.
getAnalysisPointId
());
datas
.
add
(
map
);
}
}
if
(!
datas
.
isEmpty
())
{
logger
.
info
(
"------------------------------------------开始调用健康指数计算算法开始----------------------------------------"
);
HashMap
<
String
,
Object
>
realParams
=
new
HashMap
<>();
realParams
.
put
(
gkzxzjskey1
,
datas
);
String
response
=
HttpUtil
.
createPost
(
baseUrl
+
jkzsjsurl
).
body
(
JSON
.
toJSONString
(
realParams
)).
execute
().
body
();
try
{
logger
.
info
(
"--------------------repsonse: "
+
response
);
TimeUnit
.
SECONDS
.
sleep
(
sleepTime
);
logger
.
info
(
"------------------------------------------调用健康指数计算算法结束----------------------------------------"
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
}
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 @
cba395e6
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizUhefDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizUxfvDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPldo
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizUhef
;
import
com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizUxfv
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPldoMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizUhefMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizUxfvMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
;
import
org.springframework.data.elasticsearch.core.SearchHit
;
import
org.springframework.data.elasticsearch.core.SearchHits
;
import
org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
public
class
HealthStatusIndicatorServiceImpl
{
public
class
HealthStatusIndicatorServiceImpl
{
@Autowired
@Value
(
"${healthValue_Warn}"
)
private
IdxBizUhefMapper
idxBizUhefMapper
;
Double
healthValueWarn
;
@Autowired
@Value
(
"${healthValue_Risk}"
)
private
IdxBizUxfvMapper
idxBizUxfvMapper
;
Double
healthValueRisk
;
@Autowired
@Value
(
"${healthValue_Notice}"
)
private
IdxBizPldoMapper
idxBizPldoMapper
;
Double
healthValueNotice
;
@Autowired
private
InfluxDButils
influxDButils
;
@Autowired
private
ElasticsearchRestTemplate
elasticsearchTemplate
;
@Scheduled
(
cron
=
"0/10 * * * * ? "
)
@Value
(
"${healthValue_DayCount}"
)
private
void
mother
()
{
long
healthValueDayCount
;
List
<
IdxBizUxfvDto
>
data
=
idxBizUxfvMapper
.
getInfluxDBData
();
@Value
(
"${healthValue_HourCount}"
)
long
healthValueHourCount
;
@Value
(
"${healthValue_MinCount}"
)
long
healthValueMinCount
;
Map
<
String
,
List
<
IdxBizUxfvDto
>>
maps
=
data
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizUxfvDto:
:
getGatewayId
));
@Autowired
BoolQueryBuilder
boolMustAll
=
QueryBuilders
.
boolQuery
()
;
private
RedisUtils
redisUtils
;
@Autowired
IdxBizFanHealthIndexMapper
idxBizFanHealthIndexMapper
;
List
<
QueryBuilder
>
should
=
boolMustAll
.
should
();
@Autowired
for
(
String
s
:
maps
.
keySet
())
{
IdxBizFanWarningRecordMapper
idxBizFanWarningRecordMapper
;
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
List
<
String
>
address
=
maps
.
get
(
s
).
stream
().
map
(
IdxBizUxfvDto:
:
getIndexAddress
).
collect
(
Collectors
.
toList
());
/***
boolQueryBuilder
.
must
(
QueryBuilders
.
termsQuery
(
"address.keyword"
,
address
)).
must
(
QueryBuilders
.
matchQuery
(
"gatewayId.keyword"
,
s
));
* 每一小时获取一次最大粒度内的指数异常数据
should
.
add
(
boolQueryBuilder
);
* 判断一小时内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
}
*
*/
@Scheduled
(
cron
=
"0 0 */1 * * ?"
)
private
void
healthWarningMinute
()
{
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
<
IdxBizFanHealthIndex
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IdxBizFanHealthIndex:
:
getAnalysisType
,
"按时刻"
);
wrapper
.
le
(
IdxBizFanHealthIndex:
:
getHealthIndex
,
healthValueNotice
);
wrapper
.
ge
(
IdxBizFanHealthIndex:
:
getRecDate
,
df
.
format
(
calendar
.
getTime
()));
wrapper
.
orderByDesc
(
IdxBizFanHealthIndex:
:
getRecDate
);
List
<
IdxBizFanHealthIndex
>
healthIndices
=
idxBizFanHealthIndexMapper
.
selectList
(
wrapper
);
Map
<
Integer
,
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getIndexAddress
)));
for
(
Integer
gateWayId
:
gateWayMaps
.
keySet
())
{
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndices
=
healthDataMaps
.
get
(
address
);
List
<
Double
>
healthIndex
=
idxBizFanHealthIndices
.
stream
().
map
(
IdxBizFanHealthIndex:
:
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
(
""
)){
NativeSearchQueryBuilder
queryBuilder
=
new
NativeSearchQueryBuilder
()
IdxBizFanWarningRecord
idxBizFanWarningRecord
=
new
IdxBizFanWarningRecord
();
//过滤条件
idxBizFanWarningRecord
.
setRecord
(
idxBizFanHealthIndices
.
get
(
0
).
getRecord
());
.
withQuery
(
boolMustAll
);
idxBizFanWarningRecord
.
setArae
(
idxBizFanHealthIndices
.
get
(
0
).
getArae
());
List
<
ESEquipments
>
equipments
=
new
LinkedList
<>();
idxBizFanWarningRecord
.
setStation
(
idxBizFanHealthIndices
.
get
(
0
).
getStation
());
long
totle
=
0
;
idxBizFanWarningRecord
.
setSubSystem
(
idxBizFanHealthIndices
.
get
(
0
).
getSubSystem
());
try
{
idxBizFanWarningRecord
.
setGatewayId
(
gateWayId
);
SearchHits
<
ESEquipments
>
searchHits
=
elasticsearchTemplate
.
search
(
queryBuilder
.
build
(),
ESEquipments
.
class
);
idxBizFanWarningRecord
.
setIndexAddress
(
address
);
idxBizFanWarningRecord
.
setEquipmentName
(
idxBizFanHealthIndices
.
get
(
0
).
getEquipmentName
());
for
(
SearchHit
searchHit
:
searchHits
.
getSearchHits
())
{
idxBizFanWarningRecord
.
setAnalysisPointId
(
idxBizFanHealthIndices
.
get
(
0
).
getAnalysisObjSeq
());
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
searchHit
.
getContent
());
idxBizFanWarningRecord
.
setDisposotionState
(
"未处置"
);
ESEquipments
eSAlertCalled
=
JSONObject
.
toJavaObject
(
jsonObject
,
ESEquipments
.
class
);
idxBizFanWarningRecord
.
setStatus
(
"0"
);
equipments
.
add
(
eSAlertCalled
);
idxBizFanWarningRecord
.
setWarningName
(
level
);
idxBizFanWarningRecord
.
setCONTENT
(
"连续"
+
content
+
"健康指数<"
+
num
);
}
}
}
totle
=
searchHits
.
getTotalHits
();
}
catch
(
Exception
e
)
{
// TODO: handle exception
}
}
}
/***
* 每五小时获取一次最大粒度内的指数异常数据
* 判断五小时内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
*
*/
@Scheduled
(
cron
=
"0 0 */5 * * ?"
)
private
void
healthWarningHour
()
{
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
<
IdxBizFanHealthIndex
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IdxBizFanHealthIndex:
:
getAnalysisType
,
"按小时"
);
wrapper
.
le
(
IdxBizFanHealthIndex:
:
getHealthIndex
,
healthValueNotice
);
wrapper
.
ge
(
IdxBizFanHealthIndex:
:
getRecDate
,
df
.
format
(
calendar
.
getTime
()));
wrapper
.
orderByDesc
(
IdxBizFanHealthIndex:
:
getRecDate
);
List
<
IdxBizFanHealthIndex
>
healthIndices
=
idxBizFanHealthIndexMapper
.
selectList
(
wrapper
);
Map
<
Integer
,
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getIndexAddress
)));
for
(
Integer
gateWayId
:
gateWayMaps
.
keySet
())
{
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndices
=
healthDataMaps
.
get
(
address
);
List
<
Double
>
healthIndex
=
idxBizFanHealthIndices
.
stream
().
map
(
IdxBizFanHealthIndex:
:
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
;
for
(
IdxBizUxfvDto
datum
:
data
)
{
for
(
ESEquipments
equipment
:
equipments
)
{
if
(
equipment
.
getAddress
().
equals
(
datum
.
getIndexAddress
())
&&
equipment
.
getGatewayId
().
equals
(
datum
.
getGatewayId
())){
datum
.
setCurrentValue
(
equipment
.
getValueDouble
());
}
}
}
}
LambdaQueryWrapper
<
IdxBizUhef
>
wrapper
=
new
LambdaQueryWrapper
<>();
if
(!
level
.
equals
(
""
)){
List
<
IdxBizUhef
>
idxBizUhefs
=
idxBizUhefMapper
.
selectList
(
wrapper
);
IdxBizFanWarningRecord
idxBizFanWarningRecord
=
new
IdxBizFanWarningRecord
();
List
<
Map
<
String
,
Object
>>
datas
=
new
ArrayList
<>();
idxBizFanWarningRecord
.
setRecord
(
idxBizFanHealthIndices
.
get
(
0
).
getRecord
());
for
(
IdxBizUhef
idxBizUhef
:
idxBizUhefs
)
{
idxBizFanWarningRecord
.
setArae
(
idxBizFanHealthIndices
.
get
(
0
).
getArae
());
double
value1
=
0.00
;
idxBizFanWarningRecord
.
setStation
(
idxBizFanHealthIndices
.
get
(
0
).
getStation
());
double
value2
=
0.00
;
idxBizFanWarningRecord
.
setSubSystem
(
idxBizFanHealthIndices
.
get
(
0
).
getSubSystem
());
double
value3
=
0.00
;
idxBizFanWarningRecord
.
setGatewayId
(
gateWayId
);
double
value4
=
0.00
;
idxBizFanWarningRecord
.
setIndexAddress
(
address
);
idxBizFanWarningRecord
.
setEquipmentName
(
idxBizFanHealthIndices
.
get
(
0
).
getEquipmentName
());
for
(
IdxBizUxfvDto
datum
:
data
)
{
idxBizFanWarningRecord
.
setAnalysisPointId
(
idxBizFanHealthIndices
.
get
(
0
).
getAnalysisObjSeq
());
if
(
idxBizUhef
.
getPointOneId
().
equals
(
datum
.
getSequenceNbr
())){
idxBizFanWarningRecord
.
setDisposotionState
(
"未处置"
);
value1
=
datum
.
getCurrentValue
();
idxBizFanWarningRecord
.
setStatus
(
"0"
);
}
idxBizFanWarningRecord
.
setWarningName
(
level
);
if
(
idxBizUhef
.
getPointTwoId
().
equals
(
datum
.
getSequenceNbr
()))
{
idxBizFanWarningRecord
.
setCONTENT
(
"连续"
+
content
+
"健康指数<"
+
num
);
value2
=
datum
.
getCurrentValue
();
}
if
(
idxBizUhef
.
getPointThreeId
().
equals
(
datum
.
getSequenceNbr
()))
{
value3
=
datum
.
getCurrentValue
();
}
}
if
(
idxBizUhef
.
getAnalysisPointId
().
equals
(
datum
.
getSequenceNbr
()))
{
value4
=
datum
.
getCurrentValue
();
}
}
}
if
(
idxBizUhef
.
getProcess1Min
()
<
value1
&&
value1
<
idxBizUhef
.
getProcess1Max
()
&&
}
idxBizUhef
.
getProcess2Min
()
<
value2
&&
value2
<
idxBizUhef
.
getProcess2Max
()
&&
}
idxBizUhef
.
getProcess3Min
()
<
value3
&&
value3
<
idxBizUhef
.
getProcess3Max
()){
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"analysVariable"
,
value4
);
map
.
put
(
"stdDev"
,
idxBizUhef
.
getAnalysisStdDev
());
map
.
put
(
"centerValue"
,
idxBizUhef
.
getAnalysisCenterValue
());
map
.
put
(
"analysVariableId"
,
idxBizUhef
.
getAnalysisPointId
());
datas
.
add
(
map
);
//算法接口 获取健康指数
double
healthExponent
=
0.00
;
LambdaQueryWrapper
<
IdxBizPldo
>
healthQerry
=
new
LambdaQueryWrapper
<>();
healthQerry
.
ge
(
IdxBizPldo:
:
getGroupLowerLimit
,
healthExponent
);
healthQerry
.
le
(
IdxBizPldo:
:
getGroupUpperLimit
,
healthExponent
);
healthQerry
.
eq
(
IdxBizPldo:
:
getAnalysisObjType
,
"设备"
);
IdxBizPldo
idxBizPldo
=
idxBizPldoMapper
.
selectOne
(
healthQerry
);
IdxBizFanHealthIndex
idxBizFanHealthIndex
=
new
IdxBizFanHealthIndex
();
/***
* 每三天取一次最大粒度内的指数异常数据
* 判断三天内数据是否符合预警规则 符合则报警并在redis中缓存 同一级别的预警记录下次不生成
*
*/
@Scheduled
(
cron
=
"0 0 0 */3 * ? "
)
private
void
healthWarningDay
()
{
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
<
IdxBizFanHealthIndex
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IdxBizFanHealthIndex:
:
getAnalysisType
,
"按天"
);
wrapper
.
le
(
IdxBizFanHealthIndex:
:
getHealthIndex
,
healthValueNotice
);
wrapper
.
ge
(
IdxBizFanHealthIndex:
:
getRecDate
,
df
.
format
(
calendar
.
getTime
()));
wrapper
.
orderByDesc
(
IdxBizFanHealthIndex:
:
getRecDate
);
List
<
IdxBizFanHealthIndex
>
healthIndices
=
idxBizFanHealthIndexMapper
.
selectList
(
wrapper
);
Map
<
Integer
,
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>>
gateWayMaps
=
healthIndices
.
stream
().
collect
(
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getGatewayId
,
Collectors
.
groupingBy
(
IdxBizFanHealthIndex:
:
getIndexAddress
)));
for
(
Integer
gateWayId
:
gateWayMaps
.
keySet
())
{
Map
<
String
,
List
<
IdxBizFanHealthIndex
>>
healthDataMaps
=
gateWayMaps
.
get
(
gateWayId
);
for
(
String
address
:
healthDataMaps
.
keySet
())
{
List
<
IdxBizFanHealthIndex
>
idxBizFanHealthIndices
=
healthDataMaps
.
get
(
address
);
List
<
Double
>
healthIndex
=
idxBizFanHealthIndices
.
stream
().
map
(
IdxBizFanHealthIndex:
:
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
(
""
)){
IdxBizFanWarningRecord
idxBizFanWarningRecord
=
new
IdxBizFanWarningRecord
();
idxBizFanWarningRecord
.
setRecord
(
idxBizFanHealthIndices
.
get
(
0
).
getRecord
());
idxBizFanWarningRecord
.
setArae
(
idxBizFanHealthIndices
.
get
(
0
).
getArae
());
idxBizFanWarningRecord
.
setStation
(
idxBizFanHealthIndices
.
get
(
0
).
getStation
());
idxBizFanWarningRecord
.
setSubSystem
(
idxBizFanHealthIndices
.
get
(
0
).
getSubSystem
());
idxBizFanWarningRecord
.
setGatewayId
(
gateWayId
);
idxBizFanWarningRecord
.
setIndexAddress
(
address
);
idxBizFanWarningRecord
.
setEquipmentName
(
idxBizFanHealthIndices
.
get
(
0
).
getEquipmentName
());
idxBizFanWarningRecord
.
setAnalysisPointId
(
idxBizFanHealthIndices
.
get
(
0
).
getAnalysisObjSeq
());
idxBizFanWarningRecord
.
setDisposotionState
(
"未处置"
);
idxBizFanWarningRecord
.
setStatus
(
"0"
);
idxBizFanWarningRecord
.
setWarningName
(
level
);
idxBizFanWarningRecord
.
setCONTENT
(
"连续"
+
content
+
"健康指数<"
+
num
);
idxBizFanWarningRecordMapper
.
insert
(
idxBizFanWarningRecord
);
}
}
}
}
}
// TODO: data
}
}
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/application.properties
View file @
cba395e6
...
@@ -80,3 +80,11 @@ spring.elasticsearch.rest.connection-timeout=30000
...
@@ -80,3 +80,11 @@ spring.elasticsearch.rest.connection-timeout=30000
spring.elasticsearch.rest.username
=
elastic
spring.elasticsearch.rest.username
=
elastic
spring.elasticsearch.rest.password
=
123456
spring.elasticsearch.rest.password
=
123456
spring.elasticsearch.rest.read-timeout
=
30000
spring.elasticsearch.rest.read-timeout
=
30000
healthValue_Warn
=
39
healthValue_Risk
=
59
healthValue_Notice
=
79
healthValue_DayCount
=
3
healthValue_HourCount
=
6
healthValue_MinCount
=
5
\ No newline at end of file
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