From c55c9a51cea46caea88b2bee5cc3c9ddaa9fc468 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期三, 11 十二月 2024 08:44:22 +0800
Subject: [PATCH] 1. 新增 BaseExcel.kt 和 BaseTemplate.kt 的 toObject输出到对象方法 2. 新增 BaseTemplate 是否执行的状态属性 3. 在cn.flightfeather.supervision.business.report.bean包下新增 BaseTemplateResult.kt 结果对象抽象类 以及 ProAnalysisSummaryResult.kt 和 ProDetailSummaryResult.kt 对应实现:问题整改动态跟踪和分街镇问题整改分析的中间结果对象  注:除了问题整改动态跟踪和分街镇问题整改分析其他的汇总表对象中都没有对应中间结果对象,因此这里还有报错信息

---
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt |   51 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
index 688d2e2..1de9b3d 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
@@ -1,14 +1,34 @@
 package cn.flightfeather.supervision.business.report.template
 
 import cn.flightfeather.supervision.business.report.DataSource
+import cn.flightfeather.supervision.common.utils.Constant
 import cn.flightfeather.supervision.common.utils.ExcelUtil
-import kotlin.math.round
 
 class ProTypeRankMainSummary(dataSource: DataSource) : ProTypeRankSummary(dataSource) {
     override val templateName: String = "鏈堝害涓昏鎴栧吀鍨嬮棶棰樺垎鏋愯〃"
 
-    override fun formatTable(summarys: List<Summary>) {
-        summarys.sortedByDescending { it.count }
+    override fun formatTable(summarys: MutableList<Summary>) {
+        //鎺掑悕闈犲墠鐨刴ax涓棶棰樿璁ゅ畾涓轰富瑕佹垨鍏稿瀷闂
+        val max = when (dataSource.config.sceneType.toString()) {
+            Constant.SceneType.TYPE1.value -> 5
+            else -> 4
+        }
+
+        summarys.sortByDescending { it.count }
+
+        var tPros = 0
+        var mainTPros = 0
+        var pDes = ""
+        for (i in summarys.indices) {
+            val it = summarys[i]
+            tPros += it.count
+            if (i < max) {
+                val lr = if (i > 0) "\n" else ""
+                mainTPros += it.count
+                pDes += "${lr}${i+1}銆�${it.proDes}"
+            }
+        }
+        var per = if (tPros == 0) .0 else mainTPros.toDouble() / tPros
 
         head.clear()
         head.add(
@@ -35,14 +55,23 @@
                 ExcelUtil.MyCell("涓昏闂鍗犳瘮"),
             )
         )
-        for (i in summarys.indices) {
-            val s = summarys[i]
-            contents.add(
-                mutableListOf(
-                    i + 1, "", "", dataSource.rowData.scene?.type ?: "", "", s.count,
-                    s.proDes, s.count, "${round(s.countPer * 1000) / 10}%"
-                )
+//        for (i in summarys.indices) {
+//            if (i >= max) break
+//
+//            val s = summarys[i]
+//            contents.add(
+//                mutableListOf(
+//                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, s.count,
+//                    s.proDes, s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true)
+//                )
+//            )
+//        }
+
+        contents.add(
+            mutableListOf(
+                1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, tPros,
+                pDes, mainTPros, ExcelUtil.MyCell(per.toString(), isPercent = true)
             )
-        }
+        )
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3