feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
src/main/kotlin/cn/flightfeather/supervision/common/risk/RiskAssessment.kt
@@ -2,6 +2,7 @@
import cn.flightfeather.supervision.common.score.EvaluationUtil
import cn.flightfeather.supervision.domain.entity.Evaluation
import cn.flightfeather.supervision.domain.entity.Evaluationrule
import cn.flightfeather.supervision.domain.entity.Userinfo
import cn.flightfeather.supervision.infrastructure.utils.DateUtil
import com.github.pagehelper.PageHelper
@@ -33,24 +34,33 @@
    fun getResult(user: Userinfo, config: DataSource.Config, dbMapper: DbMapper): Triple<Boolean, Int?, String> {
        reset()
        val sTime = LocalDateTime.of(config.year, config.month, 1, 0, 0, 0, 0)
        val eTime = sTime.plusMonths(1)
        val rule = dbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply {
            createCriteria().andEqualTo("scensetypeid", config.sceneType)
                .andEqualTo("ruletype", 0)
        }).takeIf { it.isNotEmpty() }?.get(0)
        // 根据评估的提交周期(单位:月),计算对应的月份范围
        val period = rule?.scensesubtypeid?.toInt() ?: 1
        // 提交周期下的起止月份
        val startM = DateUtil.getStartMonthByPeriod(config.month, period)
        val endM = startM?.plus(period)?.minus(1)
        // 查询开始时间为周期下的首个月份
        val sTime = LocalDateTime.of(config.year, startM ?: config.month, 1, 0, 0, 0, 0)
        // 查询结束时间为统计的月份
        val eTime = LocalDateTime.of(config.year, config.month, 1, 0, 0, 0, 0)
            .plusMonths(1).minusSeconds(1)
        PageHelper.startPage<Evaluation>(1, 1)
        val result = dbMapper.evaluationMapper.selectByExample((Example(Evaluation::class.java).apply {
            createCriteria().andEqualTo("evaluatorguid", user.guid)
                .andEqualTo("ertype", 0)
//                .andBetween("createdate", sTime, eTime)
                .andBetween("createdate", sTime, eTime)
            orderBy("createdate").desc()
        }))
        if (result.isEmpty()) {
            return Triple(false, null, "/")
        } else {
            val rule = dbMapper.evaluationruleMapper.selectByPrimaryKey(result[0].stguid)
            totalScore = rule.resultrange?.toInt() ?: 0
            // 根据评估的提交周期(单位:月),计算对应的月份范围
            val period = rule.scensesubtypeid?.toInt() ?: 1
            val startM = DateUtil.getStartMonthByPeriod(config.month, period)
            val endM = startM?.plus(period)?.minus(1)
            totalScore = rule?.resultrange?.toInt() ?: 0
            // 计算评估记录对应的周期(哪年的几月到几月)
            val list1 = result[0].scensename?.split("/") ?: return Triple(false, null, "/")