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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package cn.flightfeather.supervision.business.autooutput.score
 
import cn.flightfeather.supervision.business.autooutput.datasource.AopDataSource
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2
import cn.flightfeather.supervision.domain.ds1.mapper.ProblemlistMapper
import cn.flightfeather.supervision.lightshare.vo.EvaluationSubRuleVo
import org.springframework.beans.factory.annotation.Autowired
 
/**
 * 自动评分条目
 */
abstract class ScoreItem() {
 
    //自动评分条目id
    abstract var id: String
    //自动评分条目名称
    abstract var name:String
    //最大分值
    var maxScore: Int = 0
    //最小分值(默认0分)
    var minScore: Int = 0
 
    // 评分项是否豁免不扣分
    var exemption = false
 
    lateinit var evaluationScene: AopDataSource.EvaluationScene
 
    private var rulePair: Pair<EvaluationSubRuleVo, MutableList<EvaluationSubRuleVo>>? = null
 
    @Autowired
    lateinit var problemlistMapper: ProblemlistMapper
 
    /**
     * 只执行特殊扣分逻辑
     */
    fun execute(evaluationScene: AopDataSource.EvaluationScene) {
        this.evaluationScene = evaluationScene
        if (!exemption && !evaluationScene.noRecord()) {
            val a = evaluationScene.topRules.value
            getRule(evaluationScene.rules.value)
            calScore()
        }
    }
 
    /**
     * 获取评分规则
     */
    private fun getRule(eList: MutableList<Pair<EvaluationSubRuleVo, MutableList<EvaluationSubRuleVo>>>?) {
        if (eList == null) return
        for (e in eList) {
            if (e.first.guid == id) {
                rulePair = e
                e.first.maxscore?.let { maxScore = it }
                e.first.minscore?.let { minScore = it }
                e.second.sortBy { it.displayid }
                break
            }
        }
    }
 
    /**
     * 根据系统外获取的信息,进行扣分判定。返回需要扣分的条目序号
     * @param size 传入评分条目的数量,评分条目按照一定规则进行排序
     * @return 返回需要扣分的评分条目的序号
     */
    abstract fun otherProblem(size: Int): List<Int>?
 
    /**
     * 自动评分计算逻辑
     */
    fun calScore() {
        if (rulePair?.second == null || rulePair?.second?.isEmpty() == true) {
            println("${name}: 评分条目为空,不做评分")
            return
        }
 
        otherProblem(rulePair?.second!!.size)?.let { it.forEach {i ->
            rulePair?.second!![i].setMaxScore()
        } }
 
        ScoreUtil.subRuleCal(rulePair)
    }
}