From dc4f12f66685260ac357997680e5f3fe723c3c4a Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 12 九月 2025 17:22:40 +0800 Subject: [PATCH] 2025.9.12 1. 新增监测设备和巡查场景信息的匹配功能 --- src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt | 78 +++++++++++++++++++-------------------- 1 files changed, 38 insertions(+), 40 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 2fd96af..96f71fa 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt @@ -23,8 +23,6 @@ */ class DataSource(val config: ExcelConfigVo, val dbMapper: DbMapper){ - private val dateUtil = DateUtil() - private val sourceList = mutableListOf<Subtask>() var year = 0 @@ -61,7 +59,7 @@ */ fun reset() { rowData.index = 0 - rowData.subTask = sourceList.first() + rowData.subTask = if (sourceList.isEmpty()) null else sourceList.first() rowData.clear() } @@ -70,7 +68,7 @@ */ fun areaName(): String { val t = dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid) - return "${dateUtil.DateToString(t.starttime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${if (area != t.districtname) area else ""}${Constant.SceneType.getDes(config.sceneType)}" + return "${DateUtil.DateToString(config.startTime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${if (area != t.districtname) area else ""}${Constant.SceneType.getDes(config.sceneType)}" } /** @@ -87,52 +85,52 @@ })?.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 if (area.isBlank()) area = it.districtname ?: "" } - //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟 - var taskSceneIdList = listOf<String>() - val subTaskList = if (config.subTaskIdList?.isNotEmpty() == true || - (config.startTime != null || config.endTime != null) - ) { - 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) - } - }) - } else { - taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config - .sceneType, config.townCode).map { it.guid ?: "" } - dbMapper.subtaskMapper.selectByExample(Example(Subtask::class.java).apply { - createCriteria().andIn("scenseid", taskSceneIdList) - .andEqualTo("tguid", config.topTaskGuid) - }) - } + // 缁熻鎬讳换鍔′笅鎵�鏈夊満鏅� + if (config.allScene) { + //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟 + val taskSceneIdList = dbMapper.scenseMapper.getSceneByType(config.topTaskGuid, config.sceneType, + config.townCode).map { it.guid ?: "" } - if (taskSceneIdList.isNotEmpty()) { - taskSceneIdList.forEach { - var subtask: Subtask? = null - for (s in subTaskList) { - if (s.scenseid == it) { - subtask = s - result.add(s) + 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 (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