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/business/autooutput/score/AopEvaluation.kt | 133 +++++++++++++++++++++++++++++++++----------- 1 files changed, 100 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopEvaluation.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopEvaluation.kt index a2c9c8c..ccfac49 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopEvaluation.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopEvaluation.kt @@ -15,6 +15,7 @@ import cn.flightfeather.supervision.common.utils.UUIDGenerator import cn.flightfeather.supervision.domain.ds1.entity.Evaluation import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation +import cn.flightfeather.supervision.domain.ds1.entity.Subtask import org.springframework.stereotype.Component import java.util.* import kotlin.math.abs @@ -24,9 +25,9 @@ */ @Component class AopEvaluation( + private val aopOutput: AopOutput, private val aopDbMapper: AopDbMapper, private val aopSceneTypeCheck: AopSceneTypeCheck, - private val aopOutput: AopOutput, csScoreItem1: CsScoreItem1, csScoreItem2: CsScoreItem2, mpScoreItem1: MpScoreItem1, @@ -35,15 +36,17 @@ whScoreItem1: WhScoreItem1, whScoreItem2: WhScoreItem2, reScoreItem5: ReScoreItem5, - reScoreItem7: ReScoreItem7, reScoreItem8: ReScoreItem8, reScoreItem9: ReScoreItem9, reScoreItem10: ReScoreItem10, reScoreItem11: ReScoreItem11, ) { + //姝e湪杩涜璇勪及鐨勫贰鏌ヤ换鍔� + private val runningSubtask = mutableListOf<String>() - //鏁版嵁婧� - private var source: AopDataSource? = null + //姝e湪杩涜璇勪及鐨勬�诲贰鏌ヤ换鍔� + private val runningTopTask = mutableListOf<String>() + //鐗瑰畾璇勫垎椤癸紙闄や簡缁熶竴鐨勬牴鎹贰鏌ラ棶棰樼洿鎺ユ墸鍒嗗锛屾湁鐗瑰畾鐨勬墸鍒嗛�昏緫鐨勮瘎浼伴」锛� private val itemList = mutableListOf<ScoreItem>() @@ -57,7 +60,6 @@ add(whScoreItem1) add(whScoreItem2) add(reScoreItem5) - add(reScoreItem7) add(reScoreItem8) add(reScoreItem9) add(reScoreItem10) @@ -65,26 +67,85 @@ } } - fun setResource(topTaskGuid: String?, sceneType: Int, districtName: String? = null, townCode: String? = null) { - source = AopDataSource(aopDbMapper, aopSceneTypeCheck) - source?.setResource(topTaskGuid, sceneType, districtName, townCode) + fun executeByTopTask(topTaskGuid: String?, sceneType: Int, districtName: String? = null, townCode: String? = null) { + val source = setResource(topTaskGuid, sceneType, districtName, townCode) + execute(source) + } + + /** + * 瀵圭壒瀹氱殑宸℃煡浠诲姟杩涜鍗曠嫭璇勫垎 + */ + fun executeBySubTask(subTask: Subtask) { + if (checkSubtaskExist(subTask)) return + val source = setResource(subTask) + execute(source) + runningSubtask.remove(subTask.stguid) + } + + @Synchronized + private fun checkTopTaskExist(topTaskGuid: String?): Boolean { + return if (runningTopTask.contains(topTaskGuid)) { + true + } else { + topTaskGuid?.let { runningTopTask.add(it) } + false + } + } + + @Synchronized + private fun checkSubtaskExist(subTask: Subtask): Boolean { + return if (subTask.stguid == null || runningSubtask.contains(subTask.stguid)) { + true + } else { + runningSubtask.add(subTask.stguid!!) + false + } + } + + private fun setResource(subTask: Subtask): AopDataSource { + val source = AopDataSource(aopDbMapper, aopSceneTypeCheck) + source.setResource(subTask) + return source + } + + private fun setResource( + topTaskGuid: String?, + sceneType: Int, + districtName: String?, + townCode: String?, + ): AopDataSource { + val source = AopDataSource(aopDbMapper, aopSceneTypeCheck) + source.setResource(topTaskGuid, sceneType, districtName, townCode) + return source } /** * 鎵ц璇勫垎閫昏緫 */ - fun execute() { - //鑾峰彇鏁版嵁婧愶紙寰呰瘎浼扮殑鍦烘櫙锛� - //寰幆澶勭悊姣忎釜鍦烘櫙 - source?.loop {index, evaluationScene -> - if (evaluationScene.noRecord()) return@loop + private fun execute(source: AopDataSource, isBySubtask: Boolean = false) { + // 褰撻渶瑕佸彧閽堝鍗曡瘝宸℃煡浠诲姟杩涜璇勪及鏃� + if (isBySubtask) { + source.runBySubTask { index, evaluationScene -> + if (evaluationScene.noRecord()) return@runBySubTask - itemGrade(index, evaluationScene) - totalGrade(index, evaluationScene)?.run { - aopOutput.toDbEvaluation(evaluationScene, this) + itemGrade(index, evaluationScene) + totalGrade(index, evaluationScene)?.run { + aopOutput.toDbEvaluation(evaluationScene, this) + } } } + // 褰撻拡瀵瑰満鏅繘琛岃瘎浼版椂锛岃鍖呮嫭璇ュ満鏅綋鏈堝彲鑳藉瓨鍦ㄧ殑澶嶆牳宸℃煡鎯呭喌 + else { + //寰幆澶勭悊姣忎釜鍦烘櫙 + source.loop { index, evaluationScene -> + if (evaluationScene.noRecord()) return@loop + itemGrade(index, evaluationScene) + totalGrade(index, evaluationScene)?.run { + aopOutput.toDbEvaluation(evaluationScene, this) + } + } + } } /** @@ -92,10 +153,10 @@ */ private fun itemGrade(index: Int, evaluationScene: AopDataSource.EvaluationScene) { // 瑙勫垯鏉$洰寰楀垎鍒濆鍖� - evaluationScene.topItems.value?.forEach { s -> s.extension1 = null } + evaluationScene.topRules.value?.forEach { s -> s.clear() } evaluationScene.rules.value?.forEach { p -> - p.first.extension1 = null - p.second.forEach { e -> e.extension1 = null } + p.first.clear() + p.second.forEach { e -> e.clear() } } /** 1. 鏍规嵁璇勫垎瑙勫垯瀵瑰簲鐨勯棶棰樿嚜鍔ㄥ垽鏂槸鍚︽墸鍒�***************************************************************/ @@ -111,7 +172,7 @@ // 瀛樺湪澶氫釜璇勫垎椤瑰拰鍚屼竴涓棶棰樺叧鑱旓紝鍥犳蹇呴』鍏ㄩ儴璇勫垎椤归兘鍒ゅ畾涓�閬� sr.problemlist?.split(",")?.forEach { pId -> if (pList.contains(pId)) { - sr.extension1 = (0 - (sr.maxscore ?: 0)).toString() + sr.setMaxScore() } } } @@ -121,18 +182,21 @@ /** 2.閮ㄥ垎鏈夌壒娈婅瘎鍒嗛�昏緫鐨勮鍒欒繘琛岃绠�*************************************************************************/ itemList.forEach { item -> item.execute(evaluationScene) } - /** 3. 琛ュ叏鍚勪笂绾ц瘎鍒嗛」鐨勮鍒�*************************************************************************/ + /** 3. 琛ュ厖鍚勪笂绾ц瘎鍒嗛」鐨勮鍒�*************************************************************************/ evaluationScene.rules.value?.forEach { r -> val fatherId = r.first.fatherid - for (t in (evaluationScene.topItems.value ?: emptyList())) { + for (t in (evaluationScene.topRules.value ?: emptyList())) { if (t.guid == fatherId) { - var s = t.extension1?.toIntOrNull() ?: 0 - s += r.first.extension1?.toIntOrNull() ?: 0 + var s = t.score + s += r.first.score // 闄愬埗鏈�楂樻墸鍒� - if (abs(s) > (t.maxscore ?: 0)) { - s = 0 - (t.maxscore ?: 0) - } - t.extension1 = s.toString() +// if (abs(s) > (t.maxscore ?: 0)) { +//// s = 0 - (t.maxscore ?: 0) +// t.setMaxScore() +// } else { +// t.score = s +// } + t.score = s break } } @@ -142,20 +206,23 @@ /** * 璁$畻鎬诲垎 */ - private fun totalGrade(index: Int, evaluationScene: AopDataSource.EvaluationScene): Pair<Evaluation, List<Itemevaluation>>? { + private fun totalGrade( + index: Int, + evaluationScene: AopDataSource.EvaluationScene, + ): Pair<Evaluation, List<Itemevaluation>>? { val scene = evaluationScene.scene.value ?: return null - val topItems = evaluationScene.topItems.value ?: return null + val topItems = evaluationScene.topRules.value ?: return null val rules = evaluationScene.rules.value ?: return null val subTask = evaluationScene.subTask.value val inspection = evaluationScene.inspection.value val totalScore = evaluationScene.totalScore.value ?: return null var total = 0//鎬绘墸闄ょ殑鍒嗘暟 - evaluationScene.topItems.value?.forEach top@{ top -> - total += top.extension1?.toIntOrNull() ?: 0 + evaluationScene.topRules.value?.forEach top@{ top -> + total += top.score } val evaluation = Evaluation().apply { - evaluationScene.baseRule.value?.let { + evaluationScene.baseRule.value?.let { guid = UUIDGenerator.generate16ShortUUID() iguid = inspection?.guid stguid = subTask?.stguid -- Gitblit v1.9.3