From 0392c333ed3d987cb2ab3dac4e1a972cff405f21 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 25 四月 2024 17:42:08 +0800
Subject: [PATCH] 1. 新增后台任务关联模块 2. 新增自动评分后台任务; 3. 修复部分bug

---
 src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt |   68 ++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
index d334b56..2fd96af 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
@@ -182,19 +182,19 @@
         private var _baseScene: BaseScene? = null
 
         //鍏蜂綋鐨勯棶棰�
-        val problems: MutableList<Problemlist>
+        val problems: List<Problemlist>
             get() {
                 if (noRecord()) return mutableListOf()
 
-                if (_problems.isEmpty()) {
+                if (_problems == null) {
                     val r = dbMapper.problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
                         createCriteria().andEqualTo("stguid", subTask?.stguid)
                     })
-                    _problems.addAll(r)
+                    _problems = r
                 }
-                return _problems
+                return _problems ?: emptyList()
             }
-        private var _problems = mutableListOf<Problemlist>()
+        private var _problems: List<Problemlist>? = null
 
         //璇勪及鎬诲垎
         val evaluation: Evaluation?
@@ -211,38 +211,40 @@
         private var _evaluation: Evaluation? = null
 
         //璇勪及缁嗗垯寰楀垎
-        val itemevaluationList: MutableList<Itemevaluation>
+        val itemevaluationList: List<Itemevaluation>
             get() {
-                if (_itemevaluationList.isEmpty()) {
+                if (_itemevaluationList == null) {
                     val r = dbMapper.itemevaluationMapper.selectByExample(Example(Itemevaluation::class.java).apply {
                         createCriteria().andEqualTo("stguid", subTask?.stguid)
                     })
-                    _itemevaluationList.addAll(r)
+                    _itemevaluationList = r
                     println("-------------------itemevaluationList--------------------------------")
                 }
-                return _itemevaluationList
+                return _itemevaluationList ?: emptyList()
             }
-        private var _itemevaluationList = mutableListOf<Itemevaluation>()
+        private var _itemevaluationList: List<Itemevaluation>? = null
 
         //闂绫诲瀷
-        val problemTypes: MutableList<Problemtype>
+        val problemTypes: List<Problemtype>
             get() {
-                if (_problemTypes.isEmpty()) {
+                if (_problemTypes == null) {
                     val r = dbMapper.problemtypeMapper.selectByExample(Example(Problemtype::class.java).apply {
                         createCriteria().andEqualTo("scensetypeid", scene?.typeid)
                             .andEqualTo("districtcode", scene?.districtcode)
                         orderBy("extension1")
                     })
-                    _problemTypes.addAll(r)
+                    _problemTypes = r
                 }
-                return _problemTypes
+                return _problemTypes ?: emptyList()
             }
-        private var _problemTypes = mutableListOf<Problemtype>()
+        private var _problemTypes: List<Problemtype>? = null
 
         //鑷姩璇勫垎瑙勫垯涓�绾у垎绫�
-        val topItems: MutableList<Evaluationsubrule2>
+        val topItems: List<Evaluationsubrule2>
             get() {
-                if (_topItems.isEmpty()) {
+                if (_topItems == null) {
+                    val tempTopItems = mutableListOf<Evaluationsubrule2>()
+                    val secRules = mutableListOf<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>()
                     val rule = dbMapper.evaluationruleMapper.selectByExample(Example(Evaluationrule::class.java).apply {
                         createCriteria()
                             .andEqualTo("tasktypeid", 99)
@@ -255,13 +257,13 @@
                         })
                         rules.forEach {
                             if (it.ertype == 2) {
-                                _topItems.add(it)
+                                tempTopItems.add(it)
                             }
                         }
-                        _topItems.sortBy { it.displayid }
+                        tempTopItems.sortBy { it.displayid }
 
                         var t = 0
-                        _topItems.forEach {
+                        tempTopItems.forEach {
                             t += it.maxscore ?: 0
                             val tempRules = mutableListOf<Evaluationsubrule2>()
                             for (i in rules) {
@@ -282,24 +284,26 @@
                                     }
                                 }
                                 tempSubRules.sortBy { ts -> ts.displayid }
-                                this._rules.add(Pair(temp, tempSubRules))
+                                secRules.add(Pair(temp, tempSubRules))
                             }
                         }
                     }
+                    this._rules = secRules
+                    _topItems = tempTopItems
                 }
-                return _topItems
+                return _topItems ?: emptyList()
             }
-        private var _topItems = mutableListOf<Evaluationsubrule2>()
+        private var _topItems: List<Evaluationsubrule2>? = null
 
         //鑷姩璇勫垎瑙勫垯浜岀骇鍜屼笁绾у垎绫�
-        val rules: MutableList<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>
+        val rules: List<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>
             get() {
-                if (_rules.isEmpty()) {
+                if (_rules == null) {
                     this.topItems
                 }
-                return _rules
+                return _rules ?: emptyList()
             }
-        private var _rules = mutableListOf<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>()
+        private var _rules: List<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>? = null
 
         //蹇呭~鍙拌处鏁伴噺
         val ledgerCount: Int
@@ -371,14 +375,14 @@
         fun clear() {
             _scene = null
             _baseScene = null
-            _problems.clear()
+            _problems = null
             _evaluation = null
-            _itemevaluationList.clear()
+            _itemevaluationList = null
             _ledgerRecordNum = null
             if (lastScene != null && lastScene?.typeid != scene?.typeid) {
-                _problemTypes.clear()
-                _topItems.clear()
-                _rules.clear()
+                _problemTypes = null
+                _topItems = null
+                _rules = null
                 _ledgerCount = -1
             }
             recordLastScene()

--
Gitblit v1.9.3