Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-dj-strategy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 73933f5a
authored
Jun 04, 2026
by
杨卫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:预警引擎自测条
1 parent
b5cdd068
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
15 deletions
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/warning/WarningEngineService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/warning/threshold/EcoMetricValueTransformStrategy.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/warning/threshold/MetricValueTransformStrategy.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/warning/WarningEngineService.java
View file @
73933f5
...
...
@@ -45,9 +45,6 @@ public class WarningEngineService {
private
BiMetricQueryService
biMetricQueryService
;
@Resource
private
EcoCoefficientQueryService
ecoCoefficientQueryService
;
@Resource
private
ThresholdStrategyFactory
thresholdFactory
;
@Resource
...
...
@@ -798,25 +795,16 @@ public class WarningEngineService {
Integer
warningType
,
PgWarningMetricDict
dict
,
Map
<
Integer
,
Map
<
String
,
ThresholdValue
>>
preloadedThresholds
,
String
merchantNo
)
{
if
(
triggeredCond
.
getMetricId
()
!=
null
&&
triggeredValue
!=
null
)
{
// 生态系数查询使用 record 中已设置的 metricCode
if
(
record
.
getMetricCode
()
!=
null
)
{
BigDecimal
eco
=
ecoCoefficientQueryService
.
getCoefficient
(
record
.
getMetricCode
(),
triggeredValue
);
record
.
setEcoCoefficient
(
eco
);
}
}
MetricValueTransformStrategy
matchedStrategy
=
findMatchingStrategy
(
warningType
);
BigDecimal
warnValue
=
matchedStrategy
.
resolveDisplayValue
(
triggeredValue
,
record
);
record
.
setOperator
(
triggeredCond
.
getOperator
());
WarningOperatorEnum
operator
=
WarningOperatorEnum
.
fromSymbol
(
triggeredCond
.
getOperator
());
ThresholdValue
threshold
=
resolveThresholdForCond
(
triggeredCond
,
preloadedThresholds
,
merchantNo
);
// 通过策略构建 label 和获取 unit
MetricValueTransformStrategy
matchedStrategy
=
findMatchingStrategy
(
warningType
);
String
metricName
=
triggeredCond
.
getMetricId
()
!=
null
?
triggeredCond
.
getMetricName
()
:
""
;
String
label
=
matchedStrategy
.
buildWarningLabel
(
metricName
,
categoryExtension
);
String
unit
=
matchedStrategy
.
getWarningUnit
(
dict
);
record
.
setWarningText
(
operator
.
buildWarningText
(
label
,
unit
,
record
.
getMetricDisplay
(),
label
,
unit
,
warnValue
,
threshold
!=
null
?
threshold
.
getDisplay
()
:
null
,
threshold
!=
null
?
threshold
.
getMinDisplay
()
:
null
,
threshold
!=
null
?
threshold
.
getMaxDisplay
()
:
null
));
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/warning/threshold/EcoMetricValueTransformStrategy.java
View file @
73933f5
...
...
@@ -3,6 +3,7 @@ package cn.com.glsx.dj.strategy.service.warning.threshold;
import
cn.com.glsx.dj.strategy.enums.MetricDataTypeEnum
;
import
cn.com.glsx.dj.strategy.enums.WarningTypeEnum
;
import
cn.com.glsx.dj.strategy.model.projectgroup.PgWarningMetricDict
;
import
cn.com.glsx.dj.strategy.model.projectgroup.PgWarningRecord
;
import
cn.com.glsx.dj.strategy.service.warning.EcoCoefficientQueryService
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -49,6 +50,23 @@ public class EcoMetricValueTransformStrategy implements MetricValueTransformStra
}
@Override
public
BigDecimal
resolveDisplayValue
(
BigDecimal
triggeredValue
,
PgWarningRecord
record
)
{
if
(
triggeredValue
==
null
||
record
.
getMetricCode
()
==
null
)
{
return
record
.
getMetricDisplay
();
}
try
{
BigDecimal
eco
=
ecoCoefficientQueryService
.
getCoefficient
(
record
.
getMetricCode
(),
triggeredValue
);
if
(
eco
!=
null
)
{
record
.
setEcoCoefficient
(
eco
);
return
eco
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"生态系数查询失败,metricCode={}"
,
record
.
getMetricCode
(),
e
);
}
return
record
.
getMetricDisplay
();
}
@Override
public
BigDecimal
transform
(
BigDecimal
scaledValue
,
TransformContext
ctx
)
{
if
(
scaledValue
==
null
)
{
return
null
;
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/warning/threshold/MetricValueTransformStrategy.java
View file @
73933f5
...
...
@@ -2,6 +2,7 @@ package cn.com.glsx.dj.strategy.service.warning.threshold;
import
cn.com.glsx.dj.strategy.enums.WarningTypeEnum
;
import
cn.com.glsx.dj.strategy.model.projectgroup.PgWarningMetricDict
;
import
cn.com.glsx.dj.strategy.model.projectgroup.PgWarningRecord
;
import
cn.hutool.core.util.StrUtil
;
import
java.math.BigDecimal
;
...
...
@@ -56,4 +57,15 @@ public interface MetricValueTransformStrategy {
default
String
getWarningUnit
(
PgWarningMetricDict
dict
)
{
return
dict
!=
null
&&
dict
.
getUnit
()
!=
null
?
dict
.
getUnit
()
:
StrUtil
.
EMPTY
;
}
/**
* 解析告警文案展示值并设置生态系数——生态预警查系数表,其余不做操作。
*
* @param triggeredValue BI 原值
* @param record 预警记录(生态策略会设置 ecoCoefficient)
* @return 告警文案展示值
*/
default
BigDecimal
resolveDisplayValue
(
BigDecimal
triggeredValue
,
PgWarningRecord
record
)
{
return
record
.
getMetricDisplay
();
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment