feiyu02
2024-01-09 c1becf4cbd2e99601ce011c14b8742427249cfb4
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
package cn.flightfeather.supervision.business.report.cols
 
import cn.flightfeather.supervision.business.report.BaseCols
import cn.flightfeather.supervision.business.report.DataSource
import cn.flightfeather.supervision.common.utils.ExcelUtil
 
//问题整改分布
class ColProblemDistribution(chooseIndexList: List<Int> = emptyList()) : BaseCols(chooseIndexList) {
    private var h2 = mutableListOf<ExcelUtil.MyCell>()
    private val currentProblemType = mutableMapOf<String, String>()
    private val currentProblemHead = mutableListOf<String>()
 
    override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
        val h1 = mutableListOf<ExcelUtil.MyCell>()
 
        dataSource.rowData.problemTypes.forEach {
            if (!currentProblemHead.contains(it.typename)) {
                currentProblemHead.add(it.typename ?: "")
                h1.add(ExcelUtil.MyCell(it.typename ?: "", colSpan = 0))
            }
            currentProblemType[it.guid ?: ""] = it.description ?: ""
            if (currentProblemHead.contains(it.typename)) {
                h2.add(ExcelUtil.MyCell(it.description ?: ""))
                h1.last().colSpan++
 
                h2.add(ExcelUtil.MyCell("是否整改"))
                h1.last().colSpan++
            }
        }
 
        return mutableListOf(h1, h2)
    }
 
    override fun onOneRow(rowData: DataSource.RowData): List<Any> {
        val pDis = mutableListOf<Any>()//具体问题分布及整改情况
        repeat(h2.size) { pDis.add("")}
        rowData.problems.forEach {p ->
            val des = currentProblemType[p.ptguid]
 
            //具体问题分布
            for (t in h2.indices) {
                if (des == h2[t].text) {
                    //具体问题这一列添加文本,表示问题存在
                    pDis[t] = 1
                    //问题列的下一列是该问题的整改情况
                    pDis[t + 1] = if (p.ischanged == true) 1 else 0
                    break
                }
            }
        }
 
        return pDis
    }
}