package cn.flightfeather.supervision.lightshare.vo
|
|
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2
|
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
|
import com.fasterxml.jackson.annotation.JsonInclude
|
import java.util.*
|
|
/**
|
* 评分规则及得分
|
*/
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
class ScoreDetail {
|
// 工地状态(在建或完工)
|
var status: String? = null
|
|
// 总分
|
var totalScore: Int = 0
|
|
// 得分
|
var score: Int = 0
|
|
// 规范性等级
|
var grade: String? = null
|
|
// 更新时间
|
var updateTime: Date? = null
|
|
// 得分细则
|
var details = mutableListOf<ScoreItem>()
|
|
/**
|
* 新增一条评估规则记录
|
* 评估规则的传入有顺序要求,必须是按照浅层级至深层级的顺序传入,评估层级 @see [Evaluationsubrule2.ertype]
|
* @param details 结果
|
* @param rule 评估规则
|
* @param level 评估规则对应的层级深度,从1开始递增,1为最顶层
|
* @param resList 各条规则对应的评估结果
|
* @param onlyShowSelected 只添加选中的选项
|
*/
|
fun addDetail(
|
details: MutableList<ScoreItem>,
|
rule: Evaluationsubrule2,
|
level: Int,
|
resList: List<Itemevaluation>,
|
onlyShowSelected: Boolean = false,
|
) {
|
if (level == 1) {
|
val scoreItem = ScoreItem.fromRule(rule, resList)
|
if (onlyShowSelected) {
|
if (scoreItem.select) details.add(scoreItem)
|
} else {
|
details.add(scoreItem)
|
}
|
} else if (level > 1) {
|
var isFind = false
|
// 判断插入规则是否是当前层级评估集合中某一项的子评估
|
for (d in details) {
|
if (rule.fatherid == d.id) {
|
if (d.subList == null) d.subList = mutableListOf()
|
addDetail(d.subList!!, rule, 1, resList, onlyShowSelected)
|
isFind = true
|
break
|
}
|
}
|
// 若未找到,则往下一层级继续查找
|
if (!isFind && (level - 1 > 1)) {
|
details.forEach { d ->
|
d.subList?.let {
|
addDetail(it, rule, level - 1, resList, onlyShowSelected)
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* 计算总分和得分
|
*/
|
fun calScore() {
|
details.forEach {
|
totalScore += it.maxScore
|
score += when (it.gradeMode) {
|
"minus_mode" -> {
|
(it.score + it.maxScore)
|
}
|
"add_mode" -> {
|
it.score
|
}
|
else -> {
|
(it.score + it.maxScore)
|
}
|
}
|
}
|
grade = when {
|
score >= 95 -> "规范"
|
// 基本规范(90..94)和规范(>=95)
|
score >= 90 -> "基本规范"
|
// 不规范
|
score >= 50 -> "不规范"
|
// 严重不规范
|
else -> "严重不规范"
|
}
|
}
|
}
|
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
class ScoreItem {
|
//排序索引
|
var index: Int? = null
|
|
//评估规则级别(2,3,4),值越大级别越低
|
var level: Int? = null
|
|
//规则id
|
var id: String? = null
|
|
//规则描述
|
var title: String? = null
|
|
//总分值
|
var maxScore: Int = 0
|
|
//实际得分
|
var score: Int = 0
|
|
//是否选中
|
var select: Boolean = false
|
|
//basic_score: 基础分,必选;addition_score:附加分,可选;null:默认基础分
|
var scoreMode: String? = null
|
|
//minus_mode: 减分模式;add_mode:加分模式;null:不做设定,说明其子项不是具体的评估细则
|
var gradeMode: String? = null
|
|
//single_mode: 单选模式;multi_mode:多选模式;null:不做设定,说明其子项不是具体的评估细则
|
var selectMode: String? = null
|
|
//二级子规则
|
var subList: MutableList<ScoreItem>? = null
|
|
companion object {
|
/**
|
* 根据规则和得分结果生成得分项
|
* @param rule
|
* @param resList
|
*/
|
fun fromRule(rule: Evaluationsubrule2, resList: List<Itemevaluation>): ScoreItem {
|
return ScoreItem().apply {
|
index = rule.displayid?.toInt()
|
level = rule.ertype
|
id = rule.guid
|
title = rule.itemname
|
scoreMode = rule.extension1
|
gradeMode = rule.extension2
|
maxScore = rule.maxscore ?: 0
|
selectMode = rule.extension3
|
|
//如果有得分记录,则改变状态为选中
|
for (s in resList) {
|
if (rule.guid == s.esrguid) {
|
score = s.value?.toInt() ?: 0
|
select = s.extension1 == "true"
|
break
|
}
|
}
|
}
|
}
|
}
|
}
|
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
class EvaluationVo {
|
//规则id
|
var id: String? = null
|
|
//规则描述
|
var title: String? = null
|
|
//总分值
|
var maxScore: Int = 0
|
|
//实际得分
|
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 subList: MutableList<SubEvaluationVo> = mutableListOf()
|
}
|
|
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()
|
}
|
|
class ThirdEvaluationVo {
|
//规则id
|
var id: String? = null
|
|
//规则描述
|
var content: String? = null
|
|
//分值
|
var score: Int = 0
|
|
//是否选中
|
var select: Boolean = false
|
}
|