From f75ff7a0fc566dc18b60987b3fa2e65cae4665da Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 30 七月 2025 16:01:41 +0800 Subject: [PATCH] 2025.7.30 1. 新增基础数据产品相关接口(待完成) --- src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt | 62 ++++++++++++++++++++++++++----- 1 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt index c12a5cc..61a1cb8 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt @@ -5,28 +5,58 @@ /** * 缁熻鏁版嵁鍒楀熀绫� + * @param chooseIndexList 閫夋嫨闇�瑕佽緭鍑虹殑鍒楀簭鍙凤紝涓嶅~鍐欐椂琛ㄧず榛樿杈撳嚭鎵�鏈夊垪 */ -abstract class BaseCols(){ +abstract class BaseCols(private val chooseIndexList: List<Int>){ protected var heads = mutableListOf<MutableList<ExcelUtil.MyCell>>() //鐢熸垚琛ㄥご fun getHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> { heads = onHeads(dataSource) - return heads + val _heads = if (chooseIndexList.isNotEmpty()) { + val __heads = mutableListOf<MutableList<ExcelUtil.MyCell>>() + heads.forEach {head -> + val h = mutableListOf<ExcelUtil.MyCell>() + chooseIndexList.forEach {i -> + if (i < head.size) { + h.add(head[i]) + } + } + __heads.add(h) + } + __heads + } else { + heads + } + return _heads } abstract fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> //鐢熸垚涓�琛屽唴瀹� fun getOneRow(rowData: DataSource.RowData): List<Any> { - return if (rowData.noRecord()) { - val r = mutableListOf<String>() - repeat(heads.last().size) { r.add(("")) } +// return if (rowData.noRecord()) { +// val r = mutableListOf<String>() +// repeat(heads.last().size) { r.add(("")) } +// r +// } else { +// onOneRow(rowData) +// } + val row = onOneRow(rowData) + val _row = if (chooseIndexList.isNotEmpty()) { + val r = mutableListOf<Any>() + chooseIndexList.forEach {i -> + if (i < row.size) { + r.add(row[i]) + } + } r } else { - onOneRow(rowData) + row } + + return _row } abstract fun onOneRow(rowData: DataSource.RowData): List<Any> @@ -39,7 +69,7 @@ * 鏂拌�佽〃澶村悎骞� */ fun combineHead(oldHeads: MutableList<MutableList<ExcelUtil.MyCell>>, dataSource: DataSource) { - //鍚堝苟琛ㄥご锛岄噰鍙栫畝鍖栭�昏緫锛屽彧鏈夌涓�琛岀殑琛ㄥご浼氳繘琛屽崟鍏冩牸鐨勮法琛屽悎骞� + // FIXME: 2023/1/31 鍚堝苟琛ㄥご锛岄噰鍙栫畝鍖栭�昏緫锛屽彧鏈夌涓�琛岀殑琛ㄥご浼氳繘琛屽崟鍏冩牸鐨勮法琛屽悎骞� val newHeads = getHeads(dataSource) if (oldHeads.isEmpty()) { newHeads.forEach { oldHeads.add(it) } @@ -57,7 +87,12 @@ oldHeads.first().forEach { it.rowSpan++ } } val h = mutableListOf<ExcelUtil.MyCell>() - repeat(oldHeads.size) { h.add(ExcelUtil.MyCell("")) } + + var cols = 0 + oldHeads.last().forEach { + cols += it.colSpan + } + repeat(cols) { h.add(ExcelUtil.MyCell("")) } oldHeads.add(h) h } @@ -70,12 +105,19 @@ newHeads.first().forEach { it.rowSpan++ } } val h = mutableListOf<ExcelUtil.MyCell>() - repeat(newHeads.size) { h.add(ExcelUtil.MyCell("")) } + + var cols = 0 + newHeads.last().forEach { + cols += it.colSpan + } + repeat(cols) { h.add(ExcelUtil.MyCell("")) } newHeads.add(h) h } + } - oH.addAll(nH) + for (i in oldHeads.indices) { + oldHeads[i].addAll(newHeads[i]) } } } -- Gitblit v1.9.3