From d2727f231319a48019bc3b87439136ab49b97b9b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 08 十一月 2024 09:49:57 +0800
Subject: [PATCH] 1. 2024.11.08 修复部分bug

---
 src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt |   63 ++++++++++++++++---------------
 1 files changed, 33 insertions(+), 30 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 f91d3f6..575041e 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
@@ -59,7 +59,7 @@
      */
     fun reset() {
         rowData.index = 0
-        rowData.subTask = sourceList.first()
+        rowData.subTask = if (sourceList.isEmpty()) null else sourceList.first()
         rowData.clear()
     }
 
@@ -85,7 +85,7 @@
             })?.takeIf { it.isNotEmpty() }?.get(0)?.let { area = it.townname ?: "" }
         }
 
-        dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid).let {
+        dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid)?.let {
             val time = LocalDateTime.ofInstant(it.starttime?.toInstant(), ZoneId.systemDefault())
             this.year = time.year
             this.month = time.monthValue
@@ -93,41 +93,44 @@
         }
 
         //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟
-        var taskSceneIdList = listOf<String>()
-        val subTaskList = if (config.subTaskIdList?.isNotEmpty() == true) {
-            dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
-                createCriteria().apply {
-                    andIn("stguid", config.subTaskIdList)
-                    config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) }
-                    config.endTime?.let { andLessThanOrEqualTo("planendtime", it) }
-                    config.districtCode?.let { andEqualTo("districtcode", it) }
-//                    andEqualTo("tguid", config.topTaskGuid)
-                }
-            })
-        } else {
-            taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config
-                .sceneType, config.townCode).map { it.guid ?: "" }
-            dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
+        val taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType,
+            config.townCode).map { it.guid ?: "" }
+
+        // 缁熻鎬讳换鍔′笅鎵�鏈夊満鏅�
+        if (config.allScene) {
+            val subTaskList = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
                 createCriteria().apply {
                     if (taskSceneIdList.isNotEmpty()) andIn("scenseid", taskSceneIdList)
                 }.andEqualTo("tguid", config.topTaskGuid)
             })
-        }
-
-        if (taskSceneIdList.isNotEmpty()) {
-            taskSceneIdList.forEach {
-                var subtask: Subtask? = null
-                for (s in subTaskList) {
-                    if (s.scenseid == it) {
-                        subtask = s
-                        result.add(s)
+            // 缁欒繕鏈贰鏌ョ殑鍦烘櫙鐢熸垚绌虹殑瀛愪换鍔″璞�
+            if (taskSceneIdList.isNotEmpty()) {
+                taskSceneIdList.forEach {
+                    var subtask: Subtask? = null
+                    for (s in subTaskList) {
+                        if (s.scenseid == it) {
+                            subtask = s
+                            result.add(s)
+                        }
+                    }
+                    if (subtask == null) {
+                        result.add(Subtask().apply { scenseid = it })
                     }
                 }
-                if (subtask == null) {
-                    result.add(Subtask().apply { scenseid = it })
-                }
+            } else {
+                result.addAll(subTaskList)
             }
-        } else {
+        }
+        else {
+            val subTaskList = dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
+                    createCriteria().apply {
+                        if (config.subTaskIdList?.isNotEmpty() == true) andIn("stguid", config.subTaskIdList)
+                        config.startTime?.let { andGreaterThanOrEqualTo("planstarttime", it) }
+                        config.endTime?.let { andLessThanOrEqualTo("planendtime", it) }
+                        config.districtCode?.let { andEqualTo("districtcode", it) }
+                        andEqualTo("tguid", config.topTaskGuid)
+                    }
+                })
             result.addAll(subTaskList)
         }
 

--
Gitblit v1.9.3