package cn.flightfeather.supervision.business.autooutput.score
|
|
import cn.flightfeather.supervision.business.Info
|
import cn.flightfeather.supervision.business.autooutput.datasource.AopDataSource
|
import cn.flightfeather.supervision.common.utils.UUIDGenerator
|
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationrule
|
import cn.flightfeather.supervision.domain.ds1.entity.Evaluationsubrule2
|
import cn.flightfeather.supervision.domain.ds1.entity.Inspection
|
import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
|
import kotlin.math.abs
|
|
/**
|
* 得分计算工具
|
* 评分表格分为三个层级
|
* 第一层为大分类,第二层为评估标准,第三层为标准对应的不同程度的评估结果
|
*/
|
object ScoreUtil {
|
|
/**
|
* 计算某一具体评分标准的得分
|
* 针对减分模式
|
*/
|
fun subRuleCal(rulePair: Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>?) {
|
val rule = rulePair?.first
|
val itemList = rulePair?.second
|
var total: Int? = null
|
itemList?.forEach {
|
if (!it.extension1.isNullOrBlank()) {
|
total = (total ?: 0) + it.extension1!!.toInt()
|
}
|
}
|
if (total == null) {
|
rule?.extension1 = "0"
|
} else {
|
val s = if (abs(total!!) > rule?.maxscore!!) {
|
0 - rule.maxscore!!
|
} else {
|
total
|
}
|
rule.extension1 = s.toString()
|
}
|
}
|
|
/**
|
* 生成新的一条评分记录
|
*/
|
fun newItemEvaluation(evaluationScene: AopDataSource.EvaluationScene, itemRule: Evaluationsubrule2) =
|
Itemevaluation().apply {
|
val rule = evaluationScene.baseRule.value
|
val subTask = evaluationScene.subTask.value
|
val inspection = evaluationScene.inspection.value
|
ieguid = UUIDGenerator.generate16ShortUUID()
|
iguid = inspection?.guid
|
stguid = subTask?.stguid
|
sguid = subTask?.scenseid
|
sensename = subTask?.scensename
|
erguid = rule?.guid
|
rulename = rule?.rulename
|
ruletype = rule?.ruletype?.toInt()
|
ertype = itemRule.ertype
|
esrguid = itemRule.guid
|
name = itemRule.itemname
|
value = itemRule.extension1 ?: "0"
|
extension1 = (itemRule.extension1 != null).toString()
|
}
|
}
|