Skip to content

Commit

Permalink
feat: 红线支持指定到具体的步骤插件 TencentBlueKing#5405. 根据指定step名筛选红线指标值
Browse files Browse the repository at this point in the history
  • Loading branch information
JamiKX1 committed Nov 16, 2021
1 parent 520a046 commit 136a96c
Showing 1 changed file with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,24 @@ class QualityRuleCheckService @Autowired constructor(
): Pair<Boolean, MutableList<QualityRuleInterceptRecord>> {
var allCheckResult = true
val interceptList = mutableListOf<QualityRuleInterceptRecord>()
val metadataMap = metadataList.map { it.enName to it }.toMap()
val checkMetaList = mutableListOf<QualityHisMetadata>()

logger.info("QUALITY|metadataList is|$metadataList")

metadataList.forEach {
val ruleTask = QualityRule.RuleTask(it.taskName, it.enName)
if (!ruleTaskSteps.isNullOrEmpty()) {
if (ruleTaskSteps.contains(ruleTask)) {
checkMetaList.add(it)
}
} else {
checkMetaList.add(it)
}
}
val metadataMap = checkMetaList.map { it.enName to it }.toMap()

logger.info("QUALITY|checkMetaList is|$checkMetaList, metadataMap is|$metadataMap")

// 遍历每个指标
indicators.forEach { indicator ->
val thresholdType = indicator.thresholdType
Expand All @@ -436,27 +453,13 @@ class QualityRuleCheckService @Autowired constructor(
indicator.metadataList.map { metadataMap[it.enName] }
}

logger.info("QUALITY|filterMetadataList is|$filterMetadataList")

val checkMetaList = mutableListOf<QualityHisMetadata>()
if (!ruleTaskSteps.isNullOrEmpty() && filterMetadataList.isNotEmpty()) {
filterMetadataList.forEach { metadata ->
val ruleTask = QualityRule.RuleTask(metadata?.taskName, metadata?.enName)
if (ruleTask in ruleTaskSteps) {
checkMetaList.add(metadata!!)
}
}
}

logger.info("QUALITY|checkMetaList is|$checkMetaList")

// 遍历所有基础数据
var elementDetail = ""
val result: String? = when (thresholdType) {
// int类型把所有基础数据累加
QualityDataType.INT -> {
var result: Int? = null
for (it in checkMetaList) {
for (it in filterMetadataList) {
// -1表示直接失败
if (DETAIL_NOT_RUN_VALUE == it?.value) {
result = null
Expand All @@ -479,7 +482,7 @@ class QualityRuleCheckService @Autowired constructor(
// float类型把所有基础数据累加
QualityDataType.FLOAT -> {
var result: BigDecimal? = null
for (it in checkMetaList) {
for (it in filterMetadataList) {

if (it?.value != null && NumberUtils.isCreatable(it.value)) {
val value = BigDecimal(it.value)
Expand Down Expand Up @@ -512,7 +515,7 @@ class QualityRuleCheckService @Autowired constructor(
var result: Boolean? = null
val threshold = indicator.threshold.toBoolean()
logger.info("boolean threshold: $threshold")
for (it in checkMetaList) {
for (it in filterMetadataList) {
logger.info("each value: ${it?.value}")
if (it?.value != null &&
(it.value.toLowerCase() == "true" || it.value.toLowerCase() == "false")
Expand Down

0 comments on commit 136a96c

Please sign in to comment.