package cn.flightfeather.supervision.common.score
|
|
import cn.flightfeather.supervision.domain.entity.Evaluationrule
|
|
object EvaluationUtil {
|
|
class EvaluationLevel {
|
var color: String = ""
|
var creditText: String = ""
|
var evaluateLevel: String = ""
|
}
|
|
fun getEvaluationLevel(totalPoint: Int, rule: Evaluationrule?): EvaluationLevel {
|
val pointLevel = mutableListOf<Pair<Int, Int>>()
|
rule?.extension1?.split("#")?.forEach {
|
val pStr = it.split(",")
|
pointLevel.add(Pair(pStr[0].toInt(), pStr[1].toInt()))
|
}
|
val evaluateLevel = rule?.extension2?.split("#") ?: emptyList()
|
val creditTexts = rule?.extension3?.split("#") ?: emptyList()
|
val levelColors = rule?.remark?.split(";") ?: emptyList()
|
|
val result = EvaluationLevel()
|
if (pointLevel.isEmpty() || evaluateLevel.isEmpty() || creditTexts.isEmpty() || levelColors.isEmpty()) {
|
result.evaluateLevel = when (totalPoint) {
|
in 0..40 -> "极差"
|
in 41..64 -> "较差"
|
in 65..79 -> "一般"
|
in 80..94 -> "良好"
|
in 95..Int.MAX_VALUE -> "优秀"
|
else -> "极差"
|
}
|
} else {
|
for (i in pointLevel.indices) {
|
if (totalPoint in pointLevel[i].first..pointLevel[i].second ||
|
(i == pointLevel.size - 1 && totalPoint > pointLevel[i].second)
|
) {
|
result.color = levelColors[i % levelColors.size]
|
result.creditText = creditTexts[i % creditTexts.size]
|
result.evaluateLevel = evaluateLevel[i % evaluateLevel.size]
|
}
|
}
|
}
|
return result
|
}
|
}
|