feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
    }
}