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
|
}
|
}
|