hcong
2024-12-17 09c8120288ea7df454c10d67911ab8643f2f4235
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cn.flightfeather.supervision.business.report.template
 
import cn.flightfeather.supervision.business.report.DataSource
import cn.flightfeather.supervision.business.report.bean.BaseTemplateResult
import cn.flightfeather.supervision.business.report.bean.ProTypeRankMainSummaryResult
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.common.utils.ExcelUtil
 
class ProTypeRankMainSummary(dataSource: DataSource) : ProTypeRankSummary(dataSource) {
    override val templateName: String = "月度主要或典型问题分析表"
    override var resultObjects: MutableList<BaseTemplateResult> = mutableListOf(ProTypeRankMainSummaryResult())
    override fun formatTable(summarys: MutableList<Summary>) {
        //排名靠前的max个问题被认定为主要或典型问题
        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(
            mutableListOf(
                ExcelUtil.MyCell("序号", rowSpan = 2),
                ExcelUtil.MyCell("年度", rowSpan = 2),
                ExcelUtil.MyCell("月份", rowSpan = 2),
                ExcelUtil.MyCell("场景类别", rowSpan = 2),
                ExcelUtil.MyCell("区域", rowSpan = 2),
                ExcelUtil.MyCell("问题数", rowSpan = 2),
                ExcelUtil.MyCell("主要或典型问题分析", colSpan = 3),
            )
        )
        head.add(
            mutableListOf(
                ExcelUtil.MyCell(""),
                ExcelUtil.MyCell(""),
                ExcelUtil.MyCell(""),
                ExcelUtil.MyCell(""),
                ExcelUtil.MyCell(""),
                ExcelUtil.MyCell(""),
                ExcelUtil.MyCell("主要问题类别(三级指标)"),
                ExcelUtil.MyCell("主要问题合计数"),
                ExcelUtil.MyCell("主要问题占比"),
            )
        )
//        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)
            )
        )
    }
}