feiyu02
2025-09-12 dc4f12f66685260ac357997680e5f3fe723c3c4a
src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationVo.kt
@@ -1,55 +1,80 @@
package cn.flightfeather.supervision.lightshare.vo
import cn.flightfeather.supervision.common.utils.UUIDGenerator
import cn.flightfeather.supervision.domain.ds1.entity.*
import java.util.*
/**
 * 评分规则及得分
 * 评估总分
 * @date 2024/9/24
 * @author feiyu02
 */
class EvaluationVo {
    //规则id
    var id: String? = null
    //规则描述
    var title1: String? = null
    //分值
    var score: Int = 0
    //是否选中
    var select: Boolean = false
    //basic_score: 基础分,必选;addition_score:附加分,可选;null:默认基础分
    var scoreMode: String? = "basic_score"
    //minus_mode: 减分模式;add_mode:加分模式;null:不做设定,说明其子项不是具体的评估细则
    var gradeMode: String? = "minus_mode"
    //single_mode: 单选模式;multi_mode:多选模式;null:不做设定,说明其子项不是具体的评估细则
    var selectMode: String? = "single_mode"
    //二级子规则
    var sub1: MutableList<SubEvaluationVo> = mutableListOf()
}
class EvaluationVo : Evaluation() {
class SubEvaluationVo {
    //有时候一级的规则下面直接是三级规则,没有二级规则,因此此时的二级规则只是为了结构完整性而出现的
    var placeholder: Boolean = false
    //规则id
    var id: String? = null
    //规则描述
    var title2: String? = null
    //分值
    var score: Int = 0
    //是否选中
    var select: Boolean = false
    //minus_mode: 减分模式;add_mode:加分模式;
    var gradeMode: String? = "minus_mode"
    //single_mode: 单选模式;multi_mode:多选模式;
    var selectMode: String? = "single_mode"
    //二级规则分组
    var group: Int? = null
    //三级子规则
    var sub2: MutableList<ThirdEvaluationVo> = mutableListOf()
}
    /**
     * 更新得分
     */
    fun updateScore(score: Int) {
class ThirdEvaluationVo {
    //规则id
    var id: String? = null
    //规则描述
    var content: String? = null
    //分值
    var score: Int = 0
    //是否选中
    var select: Boolean = false
    }
    companion object {
        /**
         * 新增一条自动评分的总得分记录
         * @param inspection 巡查记录
         * @param subTask 巡查子任务
         * @param scene 被巡查场景
         * @param rule 使用的评分规则
         * @param totalScore 总得分
         */
        fun newAutoEvaluation(
            inspection: Inspection?, subTask: Subtask?, scene: Scense, rule: Evaluationrule?,
            totalScore: Int,
        ) = newEvaluation(inspection, subTask, scene, rule, totalScore, Userinfo().apply {
            guid = "admin"
            acountname = "admin"
            realname = "admin"
        })
        /**
         * 新增一条评分的总得分记录
         * @param inspection 巡查记录
         * @param subTask 巡查子任务
         * @param scene 被巡查场景
         * @param rule 使用的评分规则
         * @param totalScore 总得分
         * @param userinfo 评估用户
         */
        fun newEvaluation(
            inspection: Inspection?, subTask: Subtask?, scene: Scense,
            rule: Evaluationrule?, totalScore: Int, userinfo: Userinfo,
        ) = Evaluation().apply {
            guid = UUIDGenerator.generate16ShortUUID()
            iguid = inspection?.guid
            stguid = subTask?.stguid
            sguid = subTask?.scenseid
            scensetypeid = scene.typeid
            scensetype = scene.type
            subscensetypeid = scene.scensesubtypeid
            subscensetype = scene.scensesubtype
            ertype = rule?.ruletype?.toByte()
            provincecode = scene.provincecode
            provincename = scene.provincename
            citycode = scene.citycode
            cityname = scene.cityname
            districtcode = scene.districtcode
            districtname = scene.districtname
            towncode = scene.towncode
            townname = scene.townname
            scensename = scene.name
            scenseaddress = scene.location
            evaluatetime = subTask?.planstarttime
            evaluatorguid = userinfo.guid
            evaluatorusername = userinfo.acountname
            evaluatorrealname = userinfo.realname
            resultscorebef = totalScore.toString()
            createdate = subTask?.planstarttime
            updatedate = Date()
        }
    }
}