feiyu02
2025-09-12 dc4f12f66685260ac357997680e5f3fe723c3c4a
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
package cn.flightfeather.supervision.business.bgtask
 
import cn.flightfeather.supervision.business.autooutput.score.AopEvaluation
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep
import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep
import org.springframework.stereotype.Component
import java.util.*
 
/**
 * 结束所有正在执行的巡查任务,并且对未评分的任务进行自动评分
 */
@Component
class TaskFinishSubtask(
    private val subTaskRep: SubTaskRep,
    private val evaluationRep: EvaluationRep,
    private val aopEvaluation: AopEvaluation,
) {
 
    fun handle() {
        val list = subTaskRep.findByStatus(Constant.TaskProgress.RUNINGSTATUS2)
        list.forEach {
            it ?: return@forEach
            evaluationRep.findBySubtask(it.stguid) ?: aopEvaluation.executeBySubTask(it)
            it.status = Constant.TaskProgress.RUNINGSTATUS3.text
            it.executionendtime = Date()
            subTaskRep.update(it)
        }
    }
}