feiyu02
2024-04-25 0392c333ed3d987cb2ab3dac4e1a972cff405f21
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/EvaluationRuleRep.kt
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.domain.ds1.repository
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationrule
import cn.flightfeather.supervision.domain.ds1.mapper.EvaluationruleMapper
import cn.flightfeather.supervision.lightshare.vo.AreaEvaVo
@@ -10,7 +11,10 @@
 * 评估规则数据库相关操作
 */
@Repository
class EvaluationRuleRep(private val evaluationruleMapper: EvaluationruleMapper) {
class EvaluationRuleRep(
    private val evaluationruleMapper: EvaluationruleMapper,
    private val sceneRep: SceneRep,
) {
    /**
     * 根据参数查询总规则
@@ -20,11 +24,24 @@
        return evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply {
            createCriteria().andEqualTo("tasktypeid", areaEvaVo.taskTypeId)
                .andEqualTo("scensetypeid", areaEvaVo.scensetypeid)
                .andEqualTo("provincecode", areaEvaVo.provincecode)
                .andEqualTo("citycode", areaEvaVo.citycode)
                .andEqualTo("districtcode", areaEvaVo.districtcode)
                .andEqualTo("towncode", areaEvaVo.towncode)
                .andEqualTo("isuse", true)
            and(createCriteria().orEqualTo("provincecode", areaEvaVo.provincecode).orIsNull("provincecode"))
            and(createCriteria().orEqualTo("citycode", areaEvaVo.citycode).orIsNull("citycode"))
            and(createCriteria().orEqualTo("districtcode", areaEvaVo.districtcode).orIsNull("districtcode"))
            and(createCriteria().orEqualTo("towncode", areaEvaVo.towncode).orIsNull("towncode"))
        })
    }
    fun findAutoEvaluationRule(subTaskId:String): Evaluationrule? {
        val scene = sceneRep.findBySubTask(subTaskId)
        return findAutoEvaluationRule(Constant.SceneType.getByValue(scene?.typeid.toString()))
    }
    fun findAutoEvaluationRule(sceneType: Constant.SceneType): Evaluationrule? {
        return evaluationruleMapper.selectOne(Evaluationrule().apply {
            scensetypeid = sceneType.value.toByteOrNull()
            tasktypeid = 99
        })
    }
}