From b8cc591541b88dd2bb93f111f8e8075842dce7ca Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 13 八月 2024 17:21:06 +0800
Subject: [PATCH] 1. 新增设备信息相关功能 2. 修正自评估中数据自动评分的部分逻辑

---
 src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt |   53 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
index 20fcc11..a19472f 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/datasource/AopDataSource.kt
@@ -1,5 +1,6 @@
 package cn.flightfeather.supervision.business.autooutput.datasource
 
+import cn.flightfeather.supervision.common.exception.BizException
 import cn.flightfeather.supervision.common.utils.Constant
 import cn.flightfeather.supervision.domain.ds1.entity.*
 import cn.flightfeather.supervision.domain.ds2.entity.LedgerRecord
@@ -69,7 +70,9 @@
                     evaluationScene.clear()
                     evaluationScene.index = i
                     evaluationScene.setDefaultScene(scene)
-                    callback(i, evaluationScene)
+                    do {
+                        callback(i, evaluationScene)
+                    } while (evaluationScene.gotoNextSubTask())
                 }
             }
             1 -> {
@@ -85,12 +88,15 @@
 
     // 浠庣洃绠$郴缁熻幏鍙栧満鏅�
     private fun initSceneSource(config: AopDataConfig) {
-        config.topTaskGuid ?: throw IllegalStateException("椤跺眰浠诲姟id涓嶈兘涓簄ull")
+        config.topTaskGuid ?: throw BizException("椤跺眰浠诲姟id涓嶈兘涓簄ull")
         this.config = config
         this.mode = 0
         sceneSourceList.clear()
         val taskSceneIdList =
             aopDbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType, config.townCode)
+        taskSceneIdList.forEach {
+            println(it.name)
+        }
         sceneSourceList.addAll(taskSceneIdList)
     }
 
@@ -149,12 +155,21 @@
             })
         }
         //宸℃煡浠诲姟淇℃伅
+        var subTaskIndex = 0
         val subTask = InfoProxy<Subtask> {_,_ ->
+            return@InfoProxy if (subTaskList.value?.isNotEmpty() == true) {
+                subTaskList.value?.get(subTaskIndex)
+            } else {
+                null
+            }
+        }
+
+        val subTaskList = InfoProxy<List<Subtask>> {_,_ ->
             return@InfoProxy aopDbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                 createCriteria().andEqualTo("scenseid", scene.value?.guid)
 //                    .andBetween("planstarttime", config?.startTime, config?.endTime)
                     .andEqualTo("tguid", config?.topTaskGuid)
-            })?.takeIf { it.isNotEmpty() }?.get(0)
+            })
         }
 
         //鐜板満宸℃煡淇℃伅
@@ -340,21 +355,43 @@
          */
         fun clear() {
             scene.clear()
+            subTaskIndex = 0
+            subTaskList.clear()
             userInfo.clear()
             userInfoTZ.clear()
+            baseScene.clear()
+            problemTypes.clear()
+            ledgerCount.clear()
+            ledgerRecords.clear()
+
+            clearSubtask()
+        }
+
+        fun clearSubtask() {
             subTask.clear()
             inspection.clear()
-            baseScene.clear()
             problems.clear()
             evaluation.clear()
             itemevaluationList.clear()
-            problemTypes.clear()
-            baseRule.clear()
             totalScore.clear()
             topItems.clear()
+            baseRule.clear()
             rules.clear()
-            ledgerCount.clear()
-            ledgerRecords.clear()
+        }
+
+        /**
+         * 鍒囨崲鑷充笅涓�涓贰鏌ヤ换鍔�
+         * 涓�涓満鏅彲鑳藉悓鏃跺瓨鍦ㄥ涓贰鏌ヤ换鍔subTaskList]锛岄渶瑕佸姣忎釜宸℃煡浠诲姟鍒嗗埆杩涜璇勫垎
+         * @return 鏄惁鏈変笅涓�涓贰鏌ヤ换鍔�
+         */
+        fun gotoNextSubTask(): Boolean {
+            return if (subTaskIndex + 1 < (subTaskList.value?.size ?: 0)) {
+                clearSubtask()
+                subTaskIndex++
+                true
+            } else {
+                false
+            }
         }
 
         /**

--
Gitblit v1.9.3