From 0516cba27e632f20efac2752787f38f0c87baafa Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 25 九月 2024 09:24:05 +0800 Subject: [PATCH] 1. 新增自动评估添加和更新接口 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationVo.kt | 286 ++++++++++++-------------------------------------------- 1 files changed, 62 insertions(+), 224 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationVo.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationVo.kt index ca80a1d..8dbc046 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationVo.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/vo/EvaluationVo.kt @@ -1,242 +1,80 @@ 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 cn.flightfeather.supervision.common.utils.UUIDGenerator +import cn.flightfeather.supervision.domain.ds1.entity.* import java.util.* /** - * 璇勫垎瑙勫垯鍙婂緱鍒� + * 璇勪及鎬诲垎 + * @date 2024/9/24 + * @author feiyu02 */ -@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>() +class EvaluationVo : Evaluation() { /** - * 鏂板涓�鏉¤瘎浼拌鍒欒褰� - * 璇勪及瑙勫垯鐨勪紶鍏ユ湁椤哄簭瑕佹眰锛屽繀椤绘槸鎸夌収娴呭眰绾ц嚦娣卞眰绾х殑椤哄簭浼犲叆锛岃瘎浼板眰绾� @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 updateScore(score: Int) { + } - - /** - * 璁$畻鎬诲垎鍜屽緱鍒� - */ - 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: 鍑忓垎妯″紡锛沘dd_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 + * 鏂板涓�鏉¤嚜鍔ㄨ瘎鍒嗙殑鎬诲緱鍒嗚褰� + * @param inspection 宸℃煡璁板綍 + * @param subTask 宸℃煡瀛愪换鍔� + * @param scene 琚贰鏌ュ満鏅� + * @param rule 浣跨敤鐨勮瘎鍒嗚鍒� + * @param totalScore 鎬诲緱鍒� */ - 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 + 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" + }) - //濡傛灉鏈夊緱鍒嗚褰曪紝鍒欐敼鍙樼姸鎬佷负閫変腑 - for (s in resList) { - if (rule.guid == s.esrguid) { - score = s.value?.toInt() ?: 0 - select = s.extension1 == "true" - break - } - } - } + /** + * 鏂板涓�鏉¤瘎鍒嗙殑鎬诲緱鍒嗚褰� + * @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() } } -} - -@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: 鍑忓垎妯″紡锛沘dd_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: 鍑忓垎妯″紡锛沘dd_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 } \ No newline at end of file -- Gitblit v1.9.3