package cn.flightfeather.supervision.domain.repository
|
|
import cn.flightfeather.supervision.domain.entity.Evaluation
|
import cn.flightfeather.supervision.domain.entity.Evaluationrule
|
import cn.flightfeather.supervision.domain.enumeration.AssessmentRuleType
|
import cn.flightfeather.supervision.domain.enumeration.SceneType
|
import cn.flightfeather.supervision.domain.mapper.EvaluationMapper
|
import cn.flightfeather.supervision.domain.mapper.EvaluationruleMapper
|
import org.springframework.stereotype.Repository
|
import tk.mybatis.mapper.entity.Example
|
import java.time.LocalDateTime
|
|
/**
|
* 评估相关数据库操作
|
*/
|
@Repository
|
class EvaluationRep(
|
private val evaluationruleMapper: EvaluationruleMapper,
|
private val evaluationMapper: EvaluationMapper,
|
) {
|
|
/**
|
* 获取评估基本规则(非自评)
|
*/
|
fun findRule(sceneType: SceneType, ruleType: AssessmentRuleType = AssessmentRuleType.Total): Evaluationrule? {
|
val list = evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply {
|
createCriteria().andEqualTo("scensetypeid", sceneType.value)
|
.andEqualTo("ruletype", ruleType.value)
|
and(createCriteria().orIsNull("tasktypeid").orNotEqualTo("tasktypeid", 1))
|
})
|
return if (list.isNotEmpty()) {
|
list[0]
|
} else {
|
null
|
}
|
}
|
|
/**
|
* 获取用户评估周期内最新一期评估总分
|
*/
|
fun findLatest(ruleId: String?, userId: String, period: String, st: LocalDateTime, et: LocalDateTime): Evaluation? {
|
val r = evaluationMapper.selectByExample(Example(Evaluation::class.java).apply {
|
createCriteria().andEqualTo("iguid", userId)
|
.andEqualTo("stguid", ruleId)
|
and(
|
createCriteria().orEqualTo("scensename", period)
|
.orBetween("createdate", st, et)
|
)
|
orderBy("createdate").desc()
|
})
|
return if (r.isNotEmpty()) {
|
r[0]
|
} else {
|
null
|
}
|
}
|
}
|