Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
my-flink-project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
AI算法平台
my-flink-project
Commits
c5979387
Commit
c5979387
authored
Nov 08, 2023
by
周昊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、开发算法阈值算法块
parent
ed92ab30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
src/main/java/com/censoft/flink/transform/AlarmThresholdFunction.java
...a/com/censoft/flink/transform/AlarmThresholdFunction.java
+62
-0
No files found.
src/main/java/com/censoft/flink/transform/AlarmThresholdFunction.java
0 → 100644
View file @
c5979387
package
com
.
censoft
.
flink
.
transform
;
import
com.censoft.flink.domain.AlgorithmPushDto
;
import
com.censoft.flink.domain.AlgorithmSceneBasePo
;
import
com.censoft.flink.domain.AlgorithmScenePiecePo
;
import
com.censoft.flink.domain.AlgorithmScenePieceVariablePo
;
import
com.censoft.flink.exception.ParameterTransformException
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
/**
* @author 周昊
* @desc 报警阈值筛选
*/
public
class
AlarmThresholdFunction
implements
AlgorithmBaseFilterFunction
{
//threshold 阈值百分比(整数)
private
final
Integer
threshold
;
//对应报警间隔 参数KEY
private
static
String
thresholdKey
=
"threshold"
;
public
AlarmThresholdFunction
(
Integer
threshold
)
{
this
.
threshold
=
threshold
;
}
public
static
AlarmThresholdFunction
getFilterFunction
(
AlgorithmSceneBasePo
algorithmSceneBasePo
,
AlgorithmScenePiecePo
algorithmScenePiecePo
)
{
//参数准备
Optional
<
AlgorithmScenePieceVariablePo
>
variablePo
=
algorithmScenePiecePo
.
getVariablePos
()
.
stream
()
.
filter
(
po
->
thresholdKey
.
equals
(
po
.
getVariableKey
()))
.
findFirst
();
//判断参数是否存在,如果不存在抛出异常
if
(!
variablePo
.
isPresent
())
{
throw
new
ParameterTransformException
();
}
Integer
threshold
=
Integer
.
valueOf
(
variablePo
.
get
().
getVariableValue
());
return
new
AlarmThresholdFunction
(
threshold
);
}
@Override
public
boolean
filter
(
AlgorithmPushDto
algorithmPushDto
)
{
return
algorithmPushDto
.
getResult
()
.
stream
()
.
map
(
po
->
{
String
label
=
po
.
getLabel
();
if
(
label
.
contains
(
"_"
))
{
String
thresholdString
=
label
.
substring
(
label
.
indexOf
(
"_"
)
+
1
);
return
Integer
.
valueOf
(
thresholdString
);
}
else
{
return
null
;
}
}).
filter
(
str
->
str
!=
null
)
.
filter
(
value
->
value
>=
threshold
)
.
findFirst
().
isPresent
();
}
}
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