From 909fd8929d7906f1dca68acc05e36e29b0b9192c Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 15 十一月 2022 10:57:30 +0800
Subject: [PATCH] 2022.11.15

---
 src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt |   25 ++++++++++---------------
 1 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt
index f10a5be..fefb508 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseTemplate.kt
@@ -12,9 +12,10 @@
 
 /**
  * excel鎶ュ憡妯℃澘鍩虹被
+ * 鍗曚釜鏁版嵁婧�
  */
 // FIXME: 2022/7/15 妯℃澘绠�鍖栵細鍙湁琛ㄥご浼氭秹鍙婂崟鍏冩牸鍚堝苟锛岄粯璁よ〃鍐呭涓病鏈夊悎骞�
-abstract class BaseTemplate(val dataSource: DataSource){
+abstract class BaseTemplate(val dataSource: DataSource) : BaseOutputInterface {
 
     //鍒楃粍鍚�
     abstract val cols: List<BaseCols>
@@ -24,6 +25,7 @@
 
     //琛ㄥご
     val head = mutableListOf<MutableList<ExcelUtil.MyCell>>()
+
     //鍐呭
     val contents = mutableListOf<MutableList<Any>>()
 
@@ -33,11 +35,11 @@
         dataSource.reset()
         //鍚堟垚琛ㄥご
         cols.forEach {
-            it.combineHead(head,dataSource)
+            it.combineHead(head, dataSource)
         }
         //鍚堟垚鏁版嵁
         dataSource.loop { index, rowData ->
-            cols.forEach {col ->
+            cols.forEach { col ->
                 val r = col.getOneRow(rowData)
                 if (index >= contents.size) {
                     contents.add(mutableListOf())
@@ -47,12 +49,12 @@
         }
     }
 
-    fun toWorkBook(wb: HSSFWorkbook) {
+    override fun toWorkBook(wb: HSSFWorkbook) {
         val f = tableFormat()
         ExcelUtil.write(f.first, f.second, wb, templateName)
     }
 
-    fun toOutputStream(out: OutputStream, sheetName: String? = null) {
+    override fun toOutputStream(out: OutputStream, sheetName: String?) {
         val f = tableFormat()
         ExcelUtil.write2(out, f.first, f.second, sheetName ?: templateName)
     }
@@ -60,7 +62,7 @@
     /**
      * 杈撳嚭涓烘枃妗�
      */
-    fun toFile(path: String) {
+    override fun toFile(path: String) {
         val fileName = "${dataSource.areaName()}-${templateName}-${Date().time}.xls"
         val out = FileOutputStream(path + fileName)
         toOutputStream(out)
@@ -69,12 +71,13 @@
     /**
      * 琛ㄥご鍜岃〃鍐呭鏍煎紡杞寲
      */
-    private fun tableFormat(): Pair<MutableList<Array<Any>>, MutableList<Array<Any>>> {
+    fun tableFormat(): Pair<MutableList<Array<Any>>, MutableList<Array<Any>>> {
         val h = mutableListOf<Array<Any>>()
         val c = mutableListOf<Array<Any>>()
         head.forEach { h.add(it.toTypedArray()) }
         contents.forEach { c.add(it.toTypedArray()) }
         val index = c[0][0]
+        //鎸夌収绗竴鍒楄繘琛屾帓搴�
         if (index is Int) {
             c.sortBy {
                 if (it[0] is Int) {
@@ -91,11 +94,3 @@
         return Pair(h, c)
     }
 }
-
-//鍥哄畾鍒楃粍鍚�
-
-
-//鍩烘湰淇℃伅
-//闂鎵e垎鍒嗗竷
-
-

--
Gitblit v1.9.3